From b055bc47214c3eb03ce2a4bee3cdcaaffd2fd1b0 Mon Sep 17 00:00:00 2001 From: Omar Date: Thu, 8 Feb 2024 19:30:06 -0800 Subject: [PATCH] [Misc]: Add version of DEX package to name --- Cargo.toml | 4 +- .../Cargo.toml | 2 +- .../README.md | 0 .../src/bin_selector.rs | 0 .../src/blueprint_interface.rs | 2 +- .../src/lib.rs | 6 +- .../src/tick_math.rs | 0 .../Cargo.toml | 2 +- .../src/blueprint_interface.rs | 2 +- .../src/lib.rs | 6 +- tests/Cargo.toml | 4 +- tests/src/environment.rs | 201 +++++++++--------- tests/src/prelude.rs | 8 +- .../tests/{caviarnine.rs => caviarnine_v1.rs} | 112 +++++----- tests/tests/{ociswap.rs => ociswap_v1.rs} | 56 ++--- tests/tests/protocol.rs | 58 ++--- tools/bootstrap/Cargo.toml | 4 +- tools/bootstrap/src/mainnet_testing.rs | 88 ++++---- tools/bootstrap/src/stokenet_production.rs | 86 ++++---- .../src/types/name_indexed_dex_information.rs | 12 +- 20 files changed, 335 insertions(+), 318 deletions(-) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/Cargo.toml (94%) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/README.md (100%) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/src/bin_selector.rs (100%) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/src/blueprint_interface.rs (98%) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/src/lib.rs (99%) rename packages/{caviarnine-adapter-v1 => caviarnine-v1-adapter-v1}/src/tick_math.rs (100%) rename packages/{ociswap-adapter-v1 => ociswap-v1-adapter-v1}/Cargo.toml (94%) rename packages/{ociswap-adapter-v1 => ociswap-v1-adapter-v1}/src/blueprint_interface.rs (98%) rename packages/{ociswap-adapter-v1 => ociswap-v1-adapter-v1}/src/lib.rs (98%) rename tests/tests/{caviarnine.rs => caviarnine_v1.rs} (88%) rename tests/tests/{ociswap.rs => ociswap_v1.rs} (92%) diff --git a/Cargo.toml b/Cargo.toml index 33f7c695..d9a7d4ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,8 @@ members = [ # Packages "packages/ignition", "packages/simple-oracle", - "packages/ociswap-adapter-v1", - "packages/caviarnine-adapter-v1", + "packages/ociswap-v1-adapter-v1", + "packages/caviarnine-v1-adapter-v1", # Libraries "libraries/package-loader", "libraries/gateway-client", diff --git a/packages/caviarnine-adapter-v1/Cargo.toml b/packages/caviarnine-v1-adapter-v1/Cargo.toml similarity index 94% rename from packages/caviarnine-adapter-v1/Cargo.toml rename to packages/caviarnine-v1-adapter-v1/Cargo.toml index 12dfa3e7..0ac1191d 100644 --- a/packages/caviarnine-adapter-v1/Cargo.toml +++ b/packages/caviarnine-v1-adapter-v1/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "caviarnine-adapter-v1" +name = "caviarnine-v1-adapter-v1" version.workspace = true edition.workspace = true description = "Defines the adapter for Caviarnine" diff --git a/packages/caviarnine-adapter-v1/README.md b/packages/caviarnine-v1-adapter-v1/README.md similarity index 100% rename from packages/caviarnine-adapter-v1/README.md rename to packages/caviarnine-v1-adapter-v1/README.md diff --git a/packages/caviarnine-adapter-v1/src/bin_selector.rs b/packages/caviarnine-v1-adapter-v1/src/bin_selector.rs similarity index 100% rename from packages/caviarnine-adapter-v1/src/bin_selector.rs rename to packages/caviarnine-v1-adapter-v1/src/bin_selector.rs diff --git a/packages/caviarnine-adapter-v1/src/blueprint_interface.rs b/packages/caviarnine-v1-adapter-v1/src/blueprint_interface.rs similarity index 98% rename from packages/caviarnine-adapter-v1/src/blueprint_interface.rs rename to packages/caviarnine-v1-adapter-v1/src/blueprint_interface.rs index 6a5ff398..b84a58d8 100644 --- a/packages/caviarnine-adapter-v1/src/blueprint_interface.rs +++ b/packages/caviarnine-v1-adapter-v1/src/blueprint_interface.rs @@ -2,7 +2,7 @@ use scrypto::prelude::*; use scrypto_interface::*; define_interface! { - QuantaSwap as CaviarninePool impl [ + QuantaSwap as CaviarnineV1Pool impl [ ScryptoStub, ScryptoTestStub, #[cfg(feature = "manifest-builder-stubs")] diff --git a/packages/caviarnine-adapter-v1/src/lib.rs b/packages/caviarnine-v1-adapter-v1/src/lib.rs similarity index 99% rename from packages/caviarnine-adapter-v1/src/lib.rs rename to packages/caviarnine-v1-adapter-v1/src/lib.rs index 927753f5..bb63d1b6 100644 --- a/packages/caviarnine-adapter-v1/src/lib.rs +++ b/packages/caviarnine-v1-adapter-v1/src/lib.rs @@ -23,7 +23,7 @@ macro_rules! define_error { )* ) => { $( - const $name: &'static str = concat!("[Caviarnine Adapter]", " ", $item); + const $name: &'static str = concat!("[Caviarnine v1 Adapter v1]", " ", $item); )* }; } @@ -104,8 +104,8 @@ pub mod adapter { fn pool( component_address: ComponentAddress, - ) -> CaviarninePoolInterfaceScryptoStub { - CaviarninePoolInterfaceScryptoStub::from(component_address) + ) -> CaviarnineV1PoolInterfaceScryptoStub { + CaviarnineV1PoolInterfaceScryptoStub::from(component_address) } fn get_pool_information( diff --git a/packages/caviarnine-adapter-v1/src/tick_math.rs b/packages/caviarnine-v1-adapter-v1/src/tick_math.rs similarity index 100% rename from packages/caviarnine-adapter-v1/src/tick_math.rs rename to packages/caviarnine-v1-adapter-v1/src/tick_math.rs diff --git a/packages/ociswap-adapter-v1/Cargo.toml b/packages/ociswap-v1-adapter-v1/Cargo.toml similarity index 94% rename from packages/ociswap-adapter-v1/Cargo.toml rename to packages/ociswap-v1-adapter-v1/Cargo.toml index 197bd0fb..f1854eaf 100644 --- a/packages/ociswap-adapter-v1/Cargo.toml +++ b/packages/ociswap-v1-adapter-v1/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "ociswap-adapter-v1" +name = "ociswap-v1-adapter-v1" version.workspace = true edition.workspace = true description = "Defines the adapter for Ociswap" diff --git a/packages/ociswap-adapter-v1/src/blueprint_interface.rs b/packages/ociswap-v1-adapter-v1/src/blueprint_interface.rs similarity index 98% rename from packages/ociswap-adapter-v1/src/blueprint_interface.rs rename to packages/ociswap-v1-adapter-v1/src/blueprint_interface.rs index 5529fac7..66f323b5 100644 --- a/packages/ociswap-adapter-v1/src/blueprint_interface.rs +++ b/packages/ociswap-v1-adapter-v1/src/blueprint_interface.rs @@ -2,7 +2,7 @@ use scrypto::prelude::*; use scrypto_interface::*; define_interface! { - BasicPool as OciswapPool impl [ + BasicPool as OciswapV1Pool impl [ ScryptoStub, ScryptoTestStub, #[cfg(feature = "manifest-builder-stubs")] diff --git a/packages/ociswap-adapter-v1/src/lib.rs b/packages/ociswap-v1-adapter-v1/src/lib.rs similarity index 98% rename from packages/ociswap-adapter-v1/src/lib.rs rename to packages/ociswap-v1-adapter-v1/src/lib.rs index b5e9185b..65a9c691 100644 --- a/packages/ociswap-adapter-v1/src/lib.rs +++ b/packages/ociswap-v1-adapter-v1/src/lib.rs @@ -16,7 +16,7 @@ macro_rules! define_error { )* ) => { $( - pub const $name: &'static str = concat!("[Ociswap Adapter]", " ", $item); + pub const $name: &'static str = concat!("[Ociswap v1 Adapter v1]", " ", $item); )* }; } @@ -64,8 +64,8 @@ pub mod adapter { fn pool( component_address: ComponentAddress, - ) -> OciswapPoolInterfaceScryptoStub { - OciswapPoolInterfaceScryptoStub::from(component_address) + ) -> OciswapV1PoolInterfaceScryptoStub { + OciswapV1PoolInterfaceScryptoStub::from(component_address) } } diff --git a/tests/Cargo.toml b/tests/Cargo.toml index c0bb8f92..80512850 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -15,11 +15,11 @@ radix-engine-interface = { workspace = true } ignition = { path = "../packages/ignition", features = ["test"] } simple-oracle = { path = "../packages/simple-oracle", features = ["test"] } -ociswap-adapter-v1 = { path = "../packages/ociswap-adapter-v1", features = [ +ociswap-v1-adapter-v1 = { path = "../packages/ociswap-v1-adapter-v1", features = [ "test", "manifest-builder-stubs" ] } -caviarnine-adapter-v1 = { path = "../packages/caviarnine-adapter-v1", features = [ +caviarnine-v1-adapter-v1 = { path = "../packages/caviarnine-v1-adapter-v1", features = [ "test", "manifest-builder-stubs" ] } diff --git a/tests/src/environment.rs b/tests/src/environment.rs index a8064529..bfe1a786 100644 --- a/tests/src/environment.rs +++ b/tests/src/environment.rs @@ -10,8 +10,8 @@ pub trait EnvironmentSpecifier { // Components type Ignition; type SimpleOracle; - type OciswapPool; - type CaviarninePool; + type OciswapV1Pool; + type CaviarnineV1Pool; type OciswapAdapter; type CaviarnineAdapter; @@ -29,8 +29,8 @@ impl EnvironmentSpecifier for ScryptoTestEnvironmentSpecifier { // Components type Ignition = Ignition; type SimpleOracle = SimpleOracle; - type OciswapPool = OciswapPoolInterfaceScryptoTestStub; - type CaviarninePool = CaviarninePoolInterfaceScryptoTestStub; + type OciswapV1Pool = OciswapV1PoolInterfaceScryptoTestStub; + type CaviarnineV1Pool = CaviarnineV1PoolInterfaceScryptoTestStub; type OciswapAdapter = OciswapAdapter; type CaviarnineAdapter = CaviarnineAdapter; @@ -48,8 +48,8 @@ impl EnvironmentSpecifier for ScryptoUnitEnvironmentSpecifier { // Components type Ignition = ComponentAddress; type SimpleOracle = ComponentAddress; - type OciswapPool = ComponentAddress; - type CaviarninePool = ComponentAddress; + type OciswapV1Pool = ComponentAddress; + type CaviarnineV1Pool = ComponentAddress; type OciswapAdapter = ComponentAddress; type CaviarnineAdapter = ComponentAddress; @@ -82,8 +82,8 @@ where pub resources: ResourceInformation, pub protocol: ProtocolEntities, /* Supported Dexes */ - pub ociswap: DexEntities, - pub caviarnine: DexEntities, + pub ociswap_v1: DexEntities, + pub caviarnine_v1: DexEntities, } impl Environment @@ -96,8 +96,8 @@ where const PACKAGE_NAMES: [&'static str; 4] = [ "ignition", "simple-oracle", - "ociswap-adapter-v1", - "caviarnine-adapter-v1", + "ociswap-v1-adapter-v1", + "caviarnine-v1-adapter-v1", ]; const RESOURCE_DIVISIBILITIES: ResourceInformation = @@ -122,9 +122,10 @@ impl ScryptoTestEnv { scrypto_decode::<(Vec, DbFlash)>(Self::PACKAGES_BINARY) .expect("Can't fail!"); - let caviarnine_package = + let caviarnine_v1_package = PackageAddress::try_from(addresses[0]).unwrap(); - let ociswap_package = PackageAddress::try_from(addresses[1]).unwrap(); + let ociswap_v1_package = + PackageAddress::try_from(addresses[1]).unwrap(); let mut env = TestEnvironmentBuilder::new().flash(db_flash).build(); @@ -153,7 +154,7 @@ impl ScryptoTestEnv { .map(|address| rule!(require(address)))?; // Publishing the various packages to the testing environment - let [ignition_package, simple_oracle_package, ociswap_adapter_v1_package, caviarnine_adapter_v1_package] = + let [ignition_package, simple_oracle_package, ociswap_v1_adapter_v1_package, caviarnine_v1_adapter_v1_package] = Self::PACKAGE_NAMES .map(|name| Self::publish_package(name, &mut env).unwrap()); @@ -178,7 +179,7 @@ impl ScryptoTestEnv { // Creating the liquidity receipt resource that each of the exchanges // will use. - let [ociswap_liquidity_receipt_resource, caviarnine_liquidity_receipt_resource] = + let [ociswap_v1_liquidity_receipt_resource, caviarnine_v1_liquidity_receipt_resource] = [(), ()].map(|_| { ResourceBuilder::new_ruid_non_fungible::( OwnerRole::None, @@ -198,40 +199,41 @@ impl ScryptoTestEnv { }); // Creating the Ociswap pools of the resources. - let ociswap_pools = resource_addresses.try_map(|resource_address| { - let mut ociswap_pool = - OciswapPoolInterfaceScryptoTestStub::instantiate( - *resource_address, - XRD, - configuration.fees, - FAUCET, - ociswap_package, - &mut env, - )?; + let ociswap_v1_pools = + resource_addresses.try_map(|resource_address| { + let mut ociswap_pool = + OciswapV1PoolInterfaceScryptoTestStub::instantiate( + *resource_address, + XRD, + configuration.fees, + FAUCET, + ociswap_v1_package, + &mut env, + )?; - let resource_x = ResourceManager(*resource_address) - .mint_fungible(dec!(100_000_000), &mut env)?; - let resource_y = ResourceManager(XRD) - .mint_fungible(dec!(100_000_000), &mut env)?; - let _ = - ociswap_pool.add_liquidity(resource_x, resource_y, &mut env)?; + let resource_x = ResourceManager(*resource_address) + .mint_fungible(dec!(100_000_000), &mut env)?; + let resource_y = ResourceManager(XRD) + .mint_fungible(dec!(100_000_000), &mut env)?; + let _ = ociswap_pool + .add_liquidity(resource_x, resource_y, &mut env)?; - Ok::<_, RuntimeError>(ociswap_pool) - })?; + Ok::<_, RuntimeError>(ociswap_pool) + })?; // Creating the Caviarnine pools of the resources. let bin_span = 100; - let caviarnine_pools = + let caviarnine_v1_pools = resource_addresses.try_map(|resource_address| { let mut caviarnine_pool = - CaviarninePoolInterfaceScryptoTestStub::new( + CaviarnineV1PoolInterfaceScryptoTestStub::new( rule!(allow_all), rule!(allow_all), *resource_address, XRD, bin_span, None, - caviarnine_package, + caviarnine_v1_package, &mut env, )?; @@ -289,18 +291,18 @@ impl ScryptoTestEnv { ignition_package, &mut env, )?; - let ociswap_adapter_v1 = OciswapAdapter::instantiate( + let ociswap_v1_adapter_v1 = OciswapAdapter::instantiate( Default::default(), OwnerRole::None, None, - ociswap_adapter_v1_package, + ociswap_v1_adapter_v1_package, &mut env, )?; - let caviarnine_adapter_v1 = CaviarnineAdapter::instantiate( + let caviarnine_v1_adapter_v1 = CaviarnineAdapter::instantiate( Default::default(), OwnerRole::None, None, - caviarnine_adapter_v1_package, + caviarnine_v1_adapter_v1_package, &mut env, )?; @@ -371,31 +373,31 @@ impl ScryptoTestEnv { } ignition.insert_pool_information( - OciswapPoolInterfaceScryptoTestStub::blueprint_id( - ociswap_package, + OciswapV1PoolInterfaceScryptoTestStub::blueprint_id( + ociswap_v1_package, ), PoolBlueprintInformation { - adapter: ociswap_adapter_v1.into(), - allowed_pools: ociswap_pools + adapter: ociswap_v1_adapter_v1.into(), + allowed_pools: ociswap_v1_pools .iter() .map(|pool| pool.try_into().unwrap()) .collect(), - liquidity_receipt: ociswap_liquidity_receipt_resource, + liquidity_receipt: ociswap_v1_liquidity_receipt_resource, }, &mut env, )?; ignition.insert_pool_information( - CaviarninePoolInterfaceScryptoTestStub::blueprint_id( - caviarnine_package, + CaviarnineV1PoolInterfaceScryptoTestStub::blueprint_id( + caviarnine_v1_package, ), PoolBlueprintInformation { - adapter: caviarnine_adapter_v1.into(), - allowed_pools: caviarnine_pools + adapter: caviarnine_v1_adapter_v1.into(), + allowed_pools: caviarnine_v1_pools .iter() .map(|pool| pool.try_into().unwrap()) .collect(), - liquidity_receipt: caviarnine_liquidity_receipt_resource, + liquidity_receipt: caviarnine_v1_liquidity_receipt_resource, }, &mut env, )?; @@ -412,19 +414,19 @@ impl ScryptoTestEnv { protocol_owner_badge, protocol_manager_badge, }, - ociswap: DexEntities { - package: ociswap_package, - pools: ociswap_pools, - adapter_package: ociswap_adapter_v1_package, - adapter: ociswap_adapter_v1, - liquidity_receipt: ociswap_liquidity_receipt_resource, + ociswap_v1: DexEntities { + package: ociswap_v1_package, + pools: ociswap_v1_pools, + adapter_package: ociswap_v1_adapter_v1_package, + adapter: ociswap_v1_adapter_v1, + liquidity_receipt: ociswap_v1_liquidity_receipt_resource, }, - caviarnine: DexEntities { - package: caviarnine_package, - pools: caviarnine_pools, - adapter_package: caviarnine_adapter_v1_package, - adapter: caviarnine_adapter_v1, - liquidity_receipt: caviarnine_liquidity_receipt_resource, + caviarnine_v1: DexEntities { + package: caviarnine_v1_package, + pools: caviarnine_v1_pools, + adapter_package: caviarnine_v1_adapter_v1_package, + adapter: caviarnine_v1_adapter_v1, + liquidity_receipt: caviarnine_v1_liquidity_receipt_resource, }, }) } @@ -450,9 +452,10 @@ impl ScryptoUnitEnv { scrypto_decode::<(Vec, DbFlash)>(Self::PACKAGES_BINARY) .expect("Can't fail!"); - let caviarnine_package = + let caviarnine_v1_package = PackageAddress::try_from(addresses[0]).unwrap(); - let ociswap_package = PackageAddress::try_from(addresses[1]).unwrap(); + let ociswap_v1_package = + PackageAddress::try_from(addresses[1]).unwrap(); let mut test_runner = { let mut in_memory_substate_database = @@ -501,7 +504,7 @@ impl ScryptoUnitEnv { let protocol_manager_rule = rule!(require(protocol_manager_badge)); let protocol_owner_rule = rule!(require(protocol_owner_badge)); - let [ignition_package, simple_oracle_package, ociswap_adapter_v1_package, caviarnine_adapter_v1_package] = + let [ignition_package, simple_oracle_package, ociswap_v1_adapter_v1_package, caviarnine_v1_adapter_v1_package] = Self::PACKAGE_NAMES.map(|package_name| { let (code, definition) = package_loader::PackageLoader::get(package_name); @@ -522,7 +525,7 @@ impl ScryptoUnitEnv { ) }); - let [ociswap_liquidity_receipt_resource, caviarnine_liquidity_receipt_resource] = [(), ()].map(|_| { + let [ociswap_v1_liquidity_receipt_resource, caviarnine_v1_liquidity_receipt_resource] = [(), ()].map(|_| { test_runner .execute_manifest( ManifestBuilder::new() @@ -561,11 +564,11 @@ impl ScryptoUnitEnv { .unwrap() }); - let ociswap_pools = resource_addresses.map(|resource_address| { + let ociswap_v1_pools = resource_addresses.map(|resource_address| { let manifest = ManifestBuilder::new() .lock_fee_from_faucet() - .ociswap_pool_instantiate( - ociswap_package, + .ociswap_v1_pool_instantiate( + ociswap_v1_package, *resource_address, XRD, configuration.fees, @@ -588,7 +591,7 @@ impl ScryptoUnitEnv { .with_name_lookup(|builder, _| { let xrd_bucket = builder.bucket("xrd_bucket"); let other_bucket = builder.bucket("other_bucket"); - builder.ociswap_pool_add_liquidity( + builder.ociswap_v1_pool_add_liquidity( component_address, xrd_bucket, other_bucket, @@ -603,11 +606,11 @@ impl ScryptoUnitEnv { component_address }); - let caviarnine_pools = resource_addresses.map(|resource_address| { + let caviarnine_v1_pools = resource_addresses.map(|resource_address| { let manifest = ManifestBuilder::new() .lock_fee_from_faucet() .allocate_global_address( - caviarnine_package, + caviarnine_v1_package, "QuantaSwap", "reservation", "address", @@ -625,8 +628,8 @@ impl ScryptoUnitEnv { let other_bucket = builder.bucket("other_bucket"); builder - .caviarnine_pool_new( - caviarnine_package, + .caviarnine_v1_pool_new( + caviarnine_v1_package, rule!(allow_all), rule!(allow_all), *resource_address, @@ -634,7 +637,7 @@ impl ScryptoUnitEnv { 50, Some(reservation), ) - .caviarnine_pool_add_liquidity( + .caviarnine_v1_pool_add_liquidity( address, other_bucket, xrd_bucket, @@ -724,9 +727,9 @@ impl ScryptoUnitEnv { .copied() .unwrap(); - let [ociswap_adapter_v1, caviarnine_adapter_v1] = [ - (ociswap_adapter_v1_package, "OciswapAdapter"), - (caviarnine_adapter_v1_package, "CaviarnineAdapter"), + let [ociswap_v1_adapter_v1, caviarnine_v1_adapter_v1] = [ + (ociswap_v1_adapter_v1_package, "OciswapAdapter"), + (caviarnine_v1_adapter_v1_package, "CaviarnineAdapter"), ] .map(|(package_address, blueprint_name)| { test_runner @@ -757,10 +760,10 @@ impl ScryptoUnitEnv { test_runner .execute_manifest_ignoring_fee( TransactionManifestV1 { - instructions: caviarnine_pools + instructions: caviarnine_v1_pools .iter() .map(|address| InstructionV1::CallMethod { - address: caviarnine_adapter_v1.into(), + address: caviarnine_v1_adapter_v1.into(), method_name: "cache_pool_information".to_owned(), args: manifest_args!(address).into(), }) @@ -841,17 +844,17 @@ impl ScryptoUnitEnv { blueprint_name, ) in [ ( - ociswap_adapter_v1, - ociswap_pools, - ociswap_liquidity_receipt_resource, - ociswap_package, + ociswap_v1_adapter_v1, + ociswap_v1_pools, + ociswap_v1_liquidity_receipt_resource, + ociswap_v1_package, "BasicPool", ), ( - caviarnine_adapter_v1, - caviarnine_pools, - caviarnine_liquidity_receipt_resource, - caviarnine_package, + caviarnine_v1_adapter_v1, + caviarnine_v1_pools, + caviarnine_v1_liquidity_receipt_resource, + caviarnine_v1_package, "QuantaSwap", ), ] { @@ -904,19 +907,19 @@ impl ScryptoUnitEnv { protocol_manager_badge, ), }, - ociswap: DexEntities { - package: ociswap_package, - pools: ociswap_pools, - adapter_package: ociswap_adapter_v1_package, - adapter: ociswap_adapter_v1, - liquidity_receipt: ociswap_liquidity_receipt_resource, + ociswap_v1: DexEntities { + package: ociswap_v1_package, + pools: ociswap_v1_pools, + adapter_package: ociswap_v1_adapter_v1_package, + adapter: ociswap_v1_adapter_v1, + liquidity_receipt: ociswap_v1_liquidity_receipt_resource, }, - caviarnine: DexEntities { - package: caviarnine_package, - pools: caviarnine_pools, - adapter_package: caviarnine_adapter_v1_package, - adapter: caviarnine_adapter_v1, - liquidity_receipt: caviarnine_liquidity_receipt_resource, + caviarnine_v1: DexEntities { + package: caviarnine_v1_package, + pools: caviarnine_v1_pools, + adapter_package: caviarnine_v1_adapter_v1_package, + adapter: caviarnine_v1_adapter_v1, + liquidity_receipt: caviarnine_v1_liquidity_receipt_resource, }, } } diff --git a/tests/src/prelude.rs b/tests/src/prelude.rs index f6c4e69f..24f4b989 100644 --- a/tests/src/prelude.rs +++ b/tests/src/prelude.rs @@ -12,13 +12,13 @@ pub use radix_engine_interface::prelude::*; pub use scrypto_test::prelude::*; pub use scrypto_unit::*; -pub use ::caviarnine_adapter_v1::test_bindings::*; +pub use ::caviarnine_v1_adapter_v1::test_bindings::*; pub use ::ignition::test_bindings::*; pub use ::ignition::*; -pub use ::ociswap_adapter_v1::test_bindings::*; +pub use ::ociswap_v1_adapter_v1::test_bindings::*; pub use ::simple_oracle::test_bindings::*; -pub use ::caviarnine_adapter_v1::*; -pub use ::ociswap_adapter_v1::*; +pub use ::caviarnine_v1_adapter_v1::*; +pub use ::ociswap_v1_adapter_v1::*; pub use ::sbor; diff --git a/tests/tests/caviarnine.rs b/tests/tests/caviarnine_v1.rs similarity index 88% rename from tests/tests/caviarnine.rs rename to tests/tests/caviarnine_v1.rs index 272d5edb..988abdef 100644 --- a/tests/tests/caviarnine.rs +++ b/tests/tests/caviarnine_v1.rs @@ -7,7 +7,7 @@ pub fn can_open_a_simple_position_against_a_caviarnine_pool( let Environment { environment: ref mut env, mut protocol, - caviarnine, + caviarnine_v1, resources, .. } = ScryptoTestEnv::new()?; @@ -21,7 +21,7 @@ pub fn can_open_a_simple_position_against_a_caviarnine_pool( // Act let rtn = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, ); @@ -39,7 +39,7 @@ fn can_open_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { environment: mut test_runner, resources, protocol, - caviarnine, + caviarnine_v1, .. } = ScryptoUnitEnv::new_with_configuration(Configuration { maximum_allowed_relative_price_difference: dec!(0.03), @@ -74,7 +74,7 @@ fn can_open_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { "open_liquidity_position", ( bucket, - caviarnine.pools.bitcoin, + caviarnine_v1.pools.bitcoin, LockupPeriod::from_months(6).unwrap(), ), ) @@ -103,7 +103,7 @@ fn can_open_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { "open_liquidity_position", ( bucket, - caviarnine.pools.bitcoin, + caviarnine_v1.pools.bitcoin, LockupPeriod::from_months(6).unwrap(), ), ) @@ -131,7 +131,7 @@ fn can_close_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { environment: mut test_runner, resources, protocol, - caviarnine, + caviarnine_v1, .. } = ScryptoUnitEnv::new_with_configuration(Configuration { maximum_allowed_relative_price_difference: dec!(0.03), @@ -167,7 +167,7 @@ fn can_close_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { "open_liquidity_position", ( bucket, - caviarnine.pools.bitcoin, + caviarnine_v1.pools.bitcoin, LockupPeriod::from_months(6).unwrap(), ), ) @@ -233,10 +233,10 @@ fn can_close_a_liquidity_position_in_caviarnine_that_fits_into_fee_limits() { .lock_fee_from_faucet() .withdraw_from_account( account_address, - caviarnine.liquidity_receipt, + caviarnine_v1.liquidity_receipt, dec!(1), ) - .take_all_from_worktop(caviarnine.liquidity_receipt, "receipt") + .take_all_from_worktop(caviarnine_v1.liquidity_receipt, "receipt") .with_bucket("receipt", |builder, bucket| { builder.call_method( protocol.ignition, @@ -270,7 +270,7 @@ fn contributions_directly_to_caviarnine_could_fail_due_to_bucket_order( let Environment { environment: ref mut env, resources, - mut caviarnine, + mut caviarnine_v1, .. } = ScryptoTestEnv::new()?; @@ -284,7 +284,7 @@ fn contributions_directly_to_caviarnine_could_fail_due_to_bucket_order( }; // Act - let result = caviarnine.pools.bitcoin.add_liquidity( + let result = caviarnine_v1.pools.bitcoin.add_liquidity( buckets.0, buckets.1, vec![(27000, dec!(1), dec!(1))], @@ -311,7 +311,7 @@ fn contributions_to_caviarnine_through_adapter_dont_fail_due_to_bucket_ordering( let Environment { environment: ref mut env, resources, - mut caviarnine, + mut caviarnine_v1, .. } = ScryptoTestEnv::new()?; @@ -325,8 +325,8 @@ fn contributions_to_caviarnine_through_adapter_dont_fail_due_to_bucket_ordering( }; // Act - let result = caviarnine.adapter.open_liquidity_position( - caviarnine.pools.bitcoin.try_into().unwrap(), + let result = caviarnine_v1.adapter.open_liquidity_position( + caviarnine_v1.pools.bitcoin.try_into().unwrap(), buckets, env, ); @@ -348,7 +348,7 @@ fn liquidity_receipt_includes_the_amount_of_liquidity_positions_we_expect_to_see environment: ref mut env, mut protocol, resources, - caviarnine, + caviarnine_v1, .. } = ScryptoTestEnv::new()?; protocol @@ -360,22 +360,23 @@ fn liquidity_receipt_includes_the_amount_of_liquidity_positions_we_expect_to_see let (liquidity_receipt, _, _) = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, )?; // Act - let liquidity_receipt_data = ResourceManager(caviarnine.liquidity_receipt) - .get_non_fungible_data::<_, _, LiquidityReceipt>( - liquidity_receipt - .0 - .non_fungible_local_ids(env)? - .first() - .unwrap() - .clone(), - env, - )?; + let liquidity_receipt_data = + ResourceManager(caviarnine_v1.liquidity_receipt) + .get_non_fungible_data::<_, _, LiquidityReceipt>( + liquidity_receipt + .0 + .non_fungible_local_ids(env)? + .first() + .unwrap() + .clone(), + env, + )?; // Assert let adapter_information = liquidity_receipt_data @@ -397,7 +398,7 @@ pub fn contribution_amount_reported_in_receipt_nft_matches_caviarnine_state( let Environment { environment: ref mut env, mut protocol, - caviarnine, + caviarnine_v1, resources, .. } = ScryptoTestEnv::new()?; @@ -411,7 +412,7 @@ pub fn contribution_amount_reported_in_receipt_nft_matches_caviarnine_state( // Act let (ignition_receipt, ..) = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, )?; @@ -424,25 +425,26 @@ pub fn contribution_amount_reported_in_receipt_nft_matches_caviarnine_state( .first() .unwrap() .clone(); - NonFungibleGlobalId::new(caviarnine.liquidity_receipt, local_id) + NonFungibleGlobalId::new(caviarnine_v1.liquidity_receipt, local_id) }; - let ignition_receipt_data = ResourceManager(caviarnine.liquidity_receipt) - .get_non_fungible_data::<_, _, LiquidityReceipt>( - ignition_receipt - .0 - .non_fungible_local_ids(env)? - .first() - .unwrap() - .clone(), - env, - )?; + let ignition_receipt_data = + ResourceManager(caviarnine_v1.liquidity_receipt) + .get_non_fungible_data::<_, _, LiquidityReceipt>( + ignition_receipt + .0 + .non_fungible_local_ids(env)? + .first() + .unwrap() + .clone(), + env, + )?; let caviarnine_receipt = protocol .ignition .withdraw_pool_units(ignition_receipt_global_id, env)?; let mut caviarnine_reported_contributions = - caviarnine.pools.bitcoin.get_redemption_bin_values( + caviarnine_v1.pools.bitcoin.get_redemption_bin_values( caviarnine_receipt .non_fungible_local_ids(env)? .first() @@ -572,14 +574,14 @@ fn non_strict_testing_of_fees( let Environment { environment: ref mut env, mut protocol, - mut caviarnine, + mut caviarnine_v1, resources, .. } = ScryptoTestEnv::new()?; - let pool_reported_price = caviarnine + let pool_reported_price = caviarnine_v1 .adapter - .price(caviarnine.pools.bitcoin.try_into().unwrap(), env)?; + .price(caviarnine_v1.pools.bitcoin.try_into().unwrap(), env)?; protocol.oracle.set_price( pool_reported_price.base, pool_reported_price.quote, @@ -593,15 +595,15 @@ fn non_strict_testing_of_fees( .mint_fungible(bitcoin_amount_in, env)?; let (receipt, _, _) = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, )?; - let pool_units = caviarnine + let pool_units = caviarnine_v1 .adapter .open_liquidity_position( - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), ( ResourceManager(resources.bitcoin) .mint_fungible(dec!(100_000), env)?, @@ -616,7 +618,7 @@ fn non_strict_testing_of_fees( Movement::Down => { let bitcoin_bucket = ResourceManager(resources.bitcoin) .mint_fungible(dec!(450_000_000), env)?; - let _ = caviarnine.pools.bitcoin.swap(bitcoin_bucket, env)?; + let _ = caviarnine_v1.pools.bitcoin.swap(bitcoin_bucket, env)?; } // The user asset price stays the same. We do not do anything. Movement::Same => {} @@ -624,24 +626,26 @@ fn non_strict_testing_of_fees( Movement::Up => { let xrd_bucket = ResourceManager(XRD).mint_fungible(dec!(450_000_000), env)?; - let _ = caviarnine.pools.bitcoin.swap(xrd_bucket, env)?; + let _ = caviarnine_v1.pools.bitcoin.swap(xrd_bucket, env)?; } } match protocol_coefficient { // Somebody claimed some portion of the pool Movement::Down => { - let _ = - caviarnine.pools.bitcoin.remove_liquidity(pool_units, env)?; + let _ = caviarnine_v1 + .pools + .bitcoin + .remove_liquidity(pool_units, env)?; } // Nothing Movement::Same => {} // Somebody contributed to the pool some amount Movement::Up => { - let _ = caviarnine + let _ = caviarnine_v1 .adapter .open_liquidity_position( - caviarnine.pools.bitcoin.try_into().unwrap(), + caviarnine_v1.pools.bitcoin.try_into().unwrap(), ( ResourceManager(resources.bitcoin) .mint_fungible(dec!(100_000), env)?, @@ -657,9 +661,9 @@ fn non_strict_testing_of_fees( env.set_current_time(Instant::new( *LockupPeriod::from_months(12).unwrap().seconds() as i64, )); - let pool_reported_price = caviarnine + let pool_reported_price = caviarnine_v1 .adapter - .price(caviarnine.pools.bitcoin.try_into().unwrap(), env)?; + .price(caviarnine_v1.pools.bitcoin.try_into().unwrap(), env)?; protocol.oracle.set_price( pool_reported_price.base, pool_reported_price.quote, diff --git a/tests/tests/ociswap.rs b/tests/tests/ociswap_v1.rs similarity index 92% rename from tests/tests/ociswap.rs rename to tests/tests/ociswap_v1.rs index 699a9e32..091a9b76 100644 --- a/tests/tests/ociswap.rs +++ b/tests/tests/ociswap_v1.rs @@ -7,7 +7,7 @@ pub fn can_open_a_simple_position_against_an_ociswap_pool( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1, resources, .. } = ScryptoTestEnv::new()?; @@ -18,7 +18,7 @@ pub fn can_open_a_simple_position_against_an_ociswap_pool( // Act let rtn = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - ociswap.pools.bitcoin.try_into().unwrap(), + ociswap_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, ); @@ -35,17 +35,17 @@ pub fn price_reported_by_pool_is_equal_to_price_reported_by_adapter( // Arrange let Environment { environment: ref mut env, - mut ociswap, + mut ociswap_v1, resources, .. } = ScryptoTestEnv::new()?; let bitcoin_bucket = ResourceManager(resources.bitcoin) .mint_fungible(dec!(10_000_000), env)?; - let _ = ociswap.pools.bitcoin.swap(bitcoin_bucket, env)?; + let _ = ociswap_v1.pools.bitcoin.swap(bitcoin_bucket, env)?; // Act - let pool_reported_price = ociswap + let pool_reported_price = ociswap_v1 .pools .bitcoin .price_sqrt(env)? @@ -54,9 +54,9 @@ pub fn price_reported_by_pool_is_equal_to_price_reported_by_adapter( .unwrap() .checked_truncate(RoundingMode::ToZero) .unwrap(); - let adapter_reported_price = ociswap + let adapter_reported_price = ociswap_v1 .adapter - .price(ociswap.pools.bitcoin.try_into().unwrap(), env)? + .price(ociswap_v1.pools.bitcoin.try_into().unwrap(), env)? .price; // Assert @@ -72,7 +72,7 @@ fn can_open_a_liquidity_position_in_ociswap_that_fits_into_fee_limits() { environment: mut test_runner, resources, protocol, - ociswap, + ociswap_v1, .. } = ScryptoUnitEnv::new_with_configuration(Configuration { maximum_allowed_relative_price_difference: dec!(0.03), @@ -107,7 +107,7 @@ fn can_open_a_liquidity_position_in_ociswap_that_fits_into_fee_limits() { "open_liquidity_position", ( bucket, - ociswap.pools.bitcoin, + ociswap_v1.pools.bitcoin, LockupPeriod::from_months(6).unwrap(), ), ) @@ -147,7 +147,7 @@ fn can_close_a_liquidity_position_in_ociswap_that_fits_into_fee_limits() { environment: mut test_runner, resources, protocol, - ociswap, + ociswap_v1, .. } = ScryptoUnitEnv::new_with_configuration(Configuration { maximum_allowed_relative_price_difference: dec!(0.03), @@ -182,7 +182,7 @@ fn can_close_a_liquidity_position_in_ociswap_that_fits_into_fee_limits() { "open_liquidity_position", ( bucket, - ociswap.pools.bitcoin, + ociswap_v1.pools.bitcoin, LockupPeriod::from_months(6).unwrap(), ), ) @@ -245,10 +245,10 @@ fn can_close_a_liquidity_position_in_ociswap_that_fits_into_fee_limits() { .lock_fee_from_faucet() .withdraw_from_account( account_address, - ociswap.liquidity_receipt, + ociswap_v1.liquidity_receipt, dec!(1), ) - .take_all_from_worktop(ociswap.liquidity_receipt, "receipt") + .take_all_from_worktop(ociswap_v1.liquidity_receipt, "receipt") .with_bucket("receipt", |builder, bucket| { builder.call_method( protocol.ignition, @@ -294,7 +294,7 @@ fn contributions_directly_to_ociswap_dont_fail_due_to_bucket_order( let Environment { environment: ref mut env, resources, - mut ociswap, + mut ociswap_v1, .. } = ScryptoTestEnv::new()?; @@ -308,7 +308,7 @@ fn contributions_directly_to_ociswap_dont_fail_due_to_bucket_order( }; // Act - let result = ociswap + let result = ociswap_v1 .pools .bitcoin .add_liquidity(buckets.0, buckets.1, env); @@ -332,7 +332,7 @@ fn contributions_to_ociswap_through_adapter_dont_fail_due_to_bucket_ordering( let Environment { environment: ref mut env, resources, - mut ociswap, + mut ociswap_v1, .. } = ScryptoTestEnv::new()?; @@ -346,8 +346,8 @@ fn contributions_to_ociswap_through_adapter_dont_fail_due_to_bucket_ordering( }; // Act - let result = ociswap.adapter.open_liquidity_position( - ociswap.pools.bitcoin.try_into().unwrap(), + let result = ociswap_v1.adapter.open_liquidity_position( + ociswap_v1.pools.bitcoin.try_into().unwrap(), buckets, env, ); @@ -459,7 +459,7 @@ fn non_strict_testing_of_fees( let Environment { environment: ref mut env, mut protocol, - mut ociswap, + mut ociswap_v1, resources, .. } = ScryptoTestEnv::new()?; @@ -470,7 +470,7 @@ fn non_strict_testing_of_fees( .mint_fungible(bitcoin_amount_in, env)?; let (receipt, _, _) = protocol.ignition.open_liquidity_position( FungibleBucket(bitcoin_bucket), - ociswap.pools.bitcoin.try_into().unwrap(), + ociswap_v1.pools.bitcoin.try_into().unwrap(), LockupPeriod::from_months(6).unwrap(), env, )?; @@ -480,7 +480,7 @@ fn non_strict_testing_of_fees( Movement::Down => { let bitcoin_bucket = ResourceManager(resources.bitcoin) .mint_fungible(dec!(100_000_000), env)?; - let _ = ociswap.pools.bitcoin.swap(bitcoin_bucket, env)?; + let _ = ociswap_v1.pools.bitcoin.swap(bitcoin_bucket, env)?; } // The user asset price stays the same. We do not do anything. Movement::Same => {} @@ -488,12 +488,12 @@ fn non_strict_testing_of_fees( Movement::Up => { let xrd_bucket = ResourceManager(XRD).mint_fungible(dec!(100_000_000), env)?; - let _ = ociswap.pools.bitcoin.swap(xrd_bucket, env)?; + let _ = ociswap_v1.pools.bitcoin.swap(xrd_bucket, env)?; } } let pool_unit = { - let pool = ociswap.pools.bitcoin.liquidity_pool(env)?; + let pool = ociswap_v1.pools.bitcoin.liquidity_pool(env)?; let output = env .call_module_method_typed::<_, _, MetadataGetOutput>( pool, @@ -524,7 +524,8 @@ fn non_strict_testing_of_fees( CreationStrategy::Mock, env, )?; - let _ = ociswap.pools.bitcoin.remove_liquidity(pool_units, env)?; + let _ = + ociswap_v1.pools.bitcoin.remove_liquidity(pool_units, env)?; } // Nothing Movement::Same => {} @@ -533,16 +534,17 @@ fn non_strict_testing_of_fees( let xrd = ResourceManager(XRD).mint_fungible(dec!(10_000), env)?; let bitcoin = ResourceManager(resources.bitcoin) .mint_fungible(dec!(10_000), env)?; - let _ = ociswap.pools.bitcoin.add_liquidity(xrd, bitcoin, env)?; + let _ = + ociswap_v1.pools.bitcoin.add_liquidity(xrd, bitcoin, env)?; } } env.set_current_time(Instant::new( *LockupPeriod::from_months(12).unwrap().seconds() as i64, )); - let pool_reported_price = ociswap + let pool_reported_price = ociswap_v1 .adapter - .price(ociswap.pools.bitcoin.try_into().unwrap(), env)?; + .price(ociswap_v1.pools.bitcoin.try_into().unwrap(), env)?; protocol.oracle.set_price( pool_reported_price.base, pool_reported_price.quote, diff --git a/tests/tests/protocol.rs b/tests/tests/protocol.rs index 1e07e43d..a170da2b 100644 --- a/tests/tests/protocol.rs +++ b/tests/tests/protocol.rs @@ -14,7 +14,7 @@ fn cant_open_a_liquidity_position_when_opening_is_disabled( environment: ref mut env, resources, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -72,11 +72,11 @@ fn cant_open_liquidity_position_against_a_pool_outside_of_the_allow_list( environment: ref mut env, resources, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; - let new_pool = OciswapPoolInterfaceScryptoTestStub::instantiate( + let new_pool = OciswapV1PoolInterfaceScryptoTestStub::instantiate( resources.bitcoin, XRD, dec!(0), @@ -109,7 +109,7 @@ fn cant_open_a_liquidity_position_in_a_pool_after_it_has_been_removed_from_allow environment: ref mut env, resources, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -140,7 +140,7 @@ fn cant_open_a_liquidity_position_with_some_random_resource( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -168,7 +168,7 @@ fn cant_open_a_liquidity_position_by_providing_the_protocol_resource( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -201,7 +201,7 @@ pub fn can_open_a_liquidity_position_before_the_price_is_stale( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new_with_configuration(Configuration { @@ -234,7 +234,7 @@ pub fn can_open_a_liquidity_position_right_before_price_goes_stale( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new_with_configuration(Configuration { @@ -270,7 +270,7 @@ pub fn cant_open_a_liquidity_position_right_after_price_goes_stale( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new_with_configuration(Configuration { @@ -306,7 +306,7 @@ pub fn can_open_liquidity_position_when_oracle_price_is_lower_than_pool_but_with let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new_with_configuration(Configuration { @@ -378,7 +378,7 @@ fn test_open_position_oracle_price_cutoffs( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new_with_configuration(Configuration { @@ -409,7 +409,7 @@ fn cant_open_a_liquidity_position_with_an_invalid_lockup_period( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -485,7 +485,7 @@ fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resou let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -493,7 +493,7 @@ fn cant_add_an_allowed_pool_where_neither_of_the_resources_is_the_protocol_resou .mint_initial_supply(100, env)?; let fungible2 = ResourceBuilder::new_fungible(OwnerRole::None) .mint_initial_supply(100, env)?; - let pool = OciswapPoolInterfaceScryptoTestStub::instantiate( + let pool = OciswapV1PoolInterfaceScryptoTestStub::instantiate( fungible1.resource_address(env)?, fungible2.resource_address(env)?, dec!(0), @@ -566,7 +566,7 @@ fn cant_open_a_liquidity_position_with_volatile_user_resource_when_volatile_vaul environment: ref mut env, mut protocol, resources, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -600,7 +600,7 @@ fn cant_open_a_liquidity_position_with_non_volatile_user_resource_when_non_volat environment: ref mut env, mut protocol, resources, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -639,7 +639,7 @@ fn can_open_a_liquidity_position_with_no_protocol_resources_in_user_resources_va let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -675,7 +675,7 @@ fn opening_a_liquidity_position_of_a_volatile_resource_consumes_protocol_assets_ let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -745,7 +745,7 @@ fn liquidity_receipt_data_matches_component_state() -> Result<(), RuntimeError> let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -867,7 +867,7 @@ fn cant_close_a_liquidity_position_using_a_fake_nft() -> Result<(), RuntimeError environment: ref mut env, mut protocol, resources, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -910,7 +910,7 @@ fn cant_close_a_liquidity_position_when_closing_is_closed( environment: ref mut env, mut protocol, resources, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; protocol @@ -946,7 +946,7 @@ fn cant_close_a_liquidity_position_with_more_than_one_nft( environment: ref mut env, mut protocol, resources, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; @@ -988,7 +988,7 @@ fn cant_close_a_liquidity_position_before_its_maturity_date( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -1023,7 +1023,7 @@ fn can_close_a_liquidity_position_the_minute_it_matures( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -1070,7 +1070,7 @@ fn cant_close_a_liquidity_position_of_a_pool_with_no_adapter( let Environment { environment: ref mut env, mut protocol, - ociswap, + ociswap_v1: ociswap, .. } = ScryptoTestEnv::new()?; let (bucket, _) = ResourceManager(ociswap.liquidity_receipt) @@ -1099,7 +1099,7 @@ fn user_gets_back_the_same_amount_they_put_in_when_user_resource_price_goes_down let Environment { environment: ref mut env, mut protocol, - mut ociswap, + ociswap_v1: mut ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -1170,7 +1170,7 @@ fn user_gets_enough_protocol_resource_to_purchase_back_user_assets_lost_due_to_i let Environment { environment: ref mut env, mut protocol, - mut ociswap, + ociswap_v1: mut ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -1241,7 +1241,7 @@ fn user_gets_enough_protocol_resource_to_purchase_back_user_assets_lost_due_to_i let Environment { environment: ref mut env, mut protocol, - mut ociswap, + ociswap_v1: mut ociswap, resources, .. } = ScryptoTestEnv::new()?; @@ -1312,7 +1312,7 @@ fn amount_of_protocol_resources_returned_to_user_has_an_upper_bound_of_the_amoun let Environment { environment: ref mut env, mut protocol, - mut ociswap, + ociswap_v1: mut ociswap, resources, .. } = ScryptoTestEnv::new()?; diff --git a/tools/bootstrap/Cargo.toml b/tools/bootstrap/Cargo.toml index ebc3c85e..365e6fff 100644 --- a/tools/bootstrap/Cargo.toml +++ b/tools/bootstrap/Cargo.toml @@ -15,10 +15,10 @@ gateway-client = { path = "../../libraries/gateway-client" } package-loader = { path = "../../libraries/package-loader", features = [ "build-time-blueprints", ] } -ociswap-adapter-v1 = { path = "../../packages/ociswap-adapter-v1", features = [ +ociswap-v1-adapter-v1 = { path = "../../packages/ociswap-v1-adapter-v1", features = [ "manifest-builder-stubs", ] } -caviarnine-adapter-v1 = { path = "../../packages/caviarnine-adapter-v1", features = [ +caviarnine-v1-adapter-v1 = { path = "../../packages/caviarnine-v1-adapter-v1", features = [ "manifest-builder-stubs", ] } diff --git a/tools/bootstrap/src/mainnet_testing.rs b/tools/bootstrap/src/mainnet_testing.rs index 47e83ffc..36fb961c 100644 --- a/tools/bootstrap/src/mainnet_testing.rs +++ b/tools/bootstrap/src/mainnet_testing.rs @@ -67,7 +67,7 @@ impl MainnetTesting { usdt: resource_address!("resource_rdx1tkafx32lu72mcxr85gjx0rh3rx9q89zqffg4phmv5rxdqg5fnd0w7s"), }; let exchanges = NameIndexedDexInformation { - caviarnine: DexInformation { + caviarnine_v1: DexInformation { package: package_address!("package_rdx1p4r9rkp0cq67wmlve544zgy0l45mswn6h798qdqm47x4762h383wa3"), pools: NameIndexedResourceInformation { bitcoin: component_address!("component_rdx1crzl2c39m83lpe6fv62epgp3phqunxhc264ys23qz8xeemjcu8lln3"), @@ -78,7 +78,7 @@ impl MainnetTesting { }, // TODO: Ths following is INCORRECT INFORMATION! There is no Ociswap // package on mainnet. - ociswap: DexInformation { + ociswap_v1: DexInformation { package: package_address!("package_rdx1p5l6dp3slnh9ycd7gk700czwlck9tujn0zpdnd0efw09n2zdnn0lzx"), pools: NameIndexedResourceInformation { bitcoin: component_address!("component_rdx1cr5uxxjq4a0r3gfn6yd62lk96fqca34tnmyqdxkwefhckcjea4t3am"), @@ -208,21 +208,21 @@ impl MainnetTesting { let ( ignition_package_address, simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) = { let (ignition_code, ignition_package_definition) = PackageLoader::get("ignition"); let (simple_oracle_code, simple_oracle_package_definition) = PackageLoader::get("simple-oracle"); let ( - ociswap_adapter_v1_code, - ociswap_adapter_v1_package_definition, - ) = PackageLoader::get("ociswap-adapter-v1"); + ociswap_v1_adapter_v1_code, + ociswap_v1_adapter_v1_package_definition, + ) = PackageLoader::get("ociswap-v1-adapter-v1"); let ( - caviarnine_adapter_v1_code, - caviarnine_adapter_v1_package_definition, - ) = PackageLoader::get("caviarnine-adapter-v1"); + caviarnine_v1_adapter_v1_code, + caviarnine_v1_adapter_v1_package_definition, + ) = PackageLoader::get("caviarnine-v1-adapter-v1"); // We can publish the simple oracle, ociswap adapter v1, and // caviarnine adapter v1 all in a single transaction since they @@ -242,8 +242,8 @@ impl MainnetTesting { ) .publish_package_advanced( None, - ociswap_adapter_v1_code, - ociswap_adapter_v1_package_definition, + ociswap_v1_adapter_v1_code, + ociswap_v1_adapter_v1_package_definition, metadata_init! { "name" => "Ociswap Adapter v1 Package", updatable; "description" => "The implementation of an adapter for Ociswap for the Ignition protocol.", updatable; @@ -254,8 +254,8 @@ impl MainnetTesting { ) .publish_package_advanced( None, - caviarnine_adapter_v1_code, - caviarnine_adapter_v1_package_definition, + caviarnine_v1_adapter_v1_code, + caviarnine_v1_adapter_v1_package_definition, metadata_init! { "name" => "Caviarnine Adapter v1 Package", updatable; "description" => "The implementation of an adapter for Caviarnine for the Ignition protocol.", updatable; @@ -272,8 +272,8 @@ impl MainnetTesting { let ( simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) = ( *package_addresses.first().unwrap(), *package_addresses.get(1).unwrap(), @@ -305,8 +305,8 @@ impl MainnetTesting { ( ignition_package_address, simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) }; @@ -316,8 +316,8 @@ impl MainnetTesting { let ignition_package_global_caller_rule = rule!(require(package_of_direct_caller(ignition_package_address))); let ( - ociswap_liquidity_receipt_resource, - caviarnine_liquidity_receipt_resource, + ociswap_v1_liquidity_receipt_resource, + caviarnine_v1_liquidity_receipt_resource, ) = { let roles = NonFungibleResourceRoles { // Mintable and burnable by the Ignition package and @@ -442,8 +442,8 @@ impl MainnetTesting { let ( ignition_component, simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) = { let manifest = ManifestBuilder::new() // Creating the oracle component @@ -465,7 +465,7 @@ impl MainnetTesting { ) // Creating the ociswap adapter v1 component .call_function( - ociswap_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, "OciswapAdapter", "instantiate", ( @@ -480,7 +480,7 @@ impl MainnetTesting { ) // Creating the ociswap adapter v1 component .call_function( - caviarnine_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, "CaviarnineAdapter", "instantiate", ( @@ -502,8 +502,8 @@ impl MainnetTesting { let ( simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) = ( *component_addresses.first().unwrap(), *component_addresses.get(1).unwrap(), @@ -533,20 +533,20 @@ impl MainnetTesting { InitializationParametersManifest { initial_pool_information: Some(indexmap! { BlueprintId { - package_address: exchanges.caviarnine.package, + package_address: exchanges.caviarnine_v1.package, blueprint_name: "QuantaSwap".to_owned() } => PoolBlueprintInformationManifest { - adapter: caviarnine_adapter_v1_component, - allowed_pools: exchanges.caviarnine.pools.into_iter().collect(), - liquidity_receipt: caviarnine_liquidity_receipt_resource + adapter: caviarnine_v1_adapter_v1_component, + allowed_pools: exchanges.caviarnine_v1.pools.into_iter().collect(), + liquidity_receipt: caviarnine_v1_liquidity_receipt_resource }, BlueprintId { - package_address: exchanges.ociswap.package, + package_address: exchanges.ociswap_v1.package, blueprint_name: "BasicPool".to_owned() } => PoolBlueprintInformationManifest { - adapter: ociswap_adapter_v1_component, - allowed_pools: exchanges.ociswap.pools.into_iter().collect(), - liquidity_receipt: ociswap_liquidity_receipt_resource + adapter: ociswap_v1_adapter_v1_component, + allowed_pools: exchanges.ociswap_v1.pools.into_iter().collect(), + liquidity_receipt: ociswap_v1_liquidity_receipt_resource } }), initial_user_resource_volatility: Some( @@ -583,8 +583,8 @@ impl MainnetTesting { ( ignition_component_address, simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) }; @@ -616,18 +616,22 @@ impl MainnetTesting { GlobalAddress::from(protocol_owner_badge), GlobalAddress::from(ignition_package_address), GlobalAddress::from(simple_oracle_package_address), - GlobalAddress::from(ociswap_adapter_v1_package_address), GlobalAddress::from( - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, ), - GlobalAddress::from(ociswap_liquidity_receipt_resource), GlobalAddress::from( - caviarnine_liquidity_receipt_resource, + caviarnine_v1_adapter_v1_package_address, + ), + GlobalAddress::from( + ociswap_v1_liquidity_receipt_resource, + ), + GlobalAddress::from( + caviarnine_v1_liquidity_receipt_resource, ), GlobalAddress::from(ignition_component), GlobalAddress::from(simple_oracle_component), - GlobalAddress::from(ociswap_adapter_v1_component), - GlobalAddress::from(caviarnine_adapter_v1_component), + GlobalAddress::from(ociswap_v1_adapter_v1_component), + GlobalAddress::from(caviarnine_v1_adapter_v1_component), ], ) .call_role_assignment_method( diff --git a/tools/bootstrap/src/stokenet_production.rs b/tools/bootstrap/src/stokenet_production.rs index d8f9fc17..541548a3 100644 --- a/tools/bootstrap/src/stokenet_production.rs +++ b/tools/bootstrap/src/stokenet_production.rs @@ -66,7 +66,7 @@ impl StokenetProduction { usdt: resource_address!("resource_tdx_2_1t4p3ytx933n576pdps4ua7jkjh36zrh36a543u0tfcsu2vthavlqg8"), }; let exchanges = NameIndexedDexInformation { - caviarnine: DexInformation { + caviarnine_v1: DexInformation { package: package_address!("package_tdx_2_1p57g523zj736u370z6g4ynrytn7t6r2hledvzkhl6tzpg3urn0707e"), pools: NameIndexedResourceInformation { bitcoin: component_address!("component_tdx_2_1czt59vxdqg7q4l0gzphmt5ev6lagl2cu6sm2hsaz9y8ypcf0aukf8r"), @@ -77,7 +77,7 @@ impl StokenetProduction { }, // TODO: Ths following is INCORRECT INFORMATION! There is no Ociswap // package on Stokenet. - ociswap: DexInformation { + ociswap_v1: DexInformation { package: package_address!("package_tdx_2_1p40dekel26tp2a2srma4sc3lj2ukr6y8k4amr7x8yav86lyyeg7ta7"), pools: NameIndexedResourceInformation { bitcoin: component_address!("component_tdx_2_1czt59vxdqg7q4l0gzphmt5ev6lagl2cu6sm2hsaz9y8ypcf0aukf8r"), @@ -209,21 +209,21 @@ impl StokenetProduction { let ( ignition_package_address, simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) = { let (ignition_code, ignition_package_definition) = PackageLoader::get("ignition"); let (simple_oracle_code, simple_oracle_package_definition) = PackageLoader::get("simple-oracle"); let ( - ociswap_adapter_v1_code, - ociswap_adapter_v1_package_definition, - ) = PackageLoader::get("ociswap-adapter-v1"); + ociswap_v1_adapter_v1_code, + ociswap_v1_adapter_v1_package_definition, + ) = PackageLoader::get("ociswap-v1-adapter-v1"); let ( - caviarnine_adapter_v1_code, - caviarnine_adapter_v1_package_definition, - ) = PackageLoader::get("caviarnine-adapter-v1"); + caviarnine_v1_adapter_v1_code, + caviarnine_v1_adapter_v1_package_definition, + ) = PackageLoader::get("caviarnine-v1-adapter-v1"); // We can publish the simple oracle, ociswap adapter v1, and // caviarnine adapter v1 all in a single transaction since they @@ -243,8 +243,8 @@ impl StokenetProduction { ) .publish_package_advanced( None, - ociswap_adapter_v1_code, - ociswap_adapter_v1_package_definition, + ociswap_v1_adapter_v1_code, + ociswap_v1_adapter_v1_package_definition, metadata_init! { "name" => "Ociswap Adapter v1 Package", updatable; "description" => "The implementation of an adapter for Ociswap for the Ignition protocol.", updatable; @@ -255,8 +255,8 @@ impl StokenetProduction { ) .publish_package_advanced( None, - caviarnine_adapter_v1_code, - caviarnine_adapter_v1_package_definition, + caviarnine_v1_adapter_v1_code, + caviarnine_v1_adapter_v1_package_definition, metadata_init! { "name" => "Caviarnine Adapter v1 Package", updatable; "description" => "The implementation of an adapter for Caviarnine for the Ignition protocol.", updatable; @@ -273,8 +273,8 @@ impl StokenetProduction { let ( simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) = ( *package_addresses.first().unwrap(), *package_addresses.get(1).unwrap(), @@ -306,8 +306,8 @@ impl StokenetProduction { ( ignition_package_address, simple_oracle_package_address, - ociswap_adapter_v1_package_address, - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, ) }; @@ -317,8 +317,8 @@ impl StokenetProduction { let ignition_package_global_caller_rule = rule!(require(package_of_direct_caller(ignition_package_address))); let ( - ociswap_liquidity_receipt_resource, - caviarnine_liquidity_receipt_resource, + ociswap_v1_liquidity_receipt_resource, + caviarnine_v1_liquidity_receipt_resource, ) = { let roles = NonFungibleResourceRoles { // Mintable and burnable by the Ignition package and @@ -443,8 +443,8 @@ impl StokenetProduction { let ( ignition_component, simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) = { let manifest = ManifestBuilder::new() // Creating the oracle component @@ -466,7 +466,7 @@ impl StokenetProduction { ) // Creating the ociswap adapter v1 component .call_function( - ociswap_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, "OciswapAdapter", "instantiate", ( @@ -481,7 +481,7 @@ impl StokenetProduction { ) // Creating the ociswap adapter v1 component .call_function( - caviarnine_adapter_v1_package_address, + caviarnine_v1_adapter_v1_package_address, "CaviarnineAdapter", "instantiate", ( @@ -503,8 +503,8 @@ impl StokenetProduction { let ( simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) = ( *component_addresses.first().unwrap(), *component_addresses.get(1).unwrap(), @@ -534,23 +534,23 @@ impl StokenetProduction { InitializationParametersManifest { initial_pool_information: Some(indexmap! { BlueprintId { - package_address: exchanges.caviarnine.package, + package_address: exchanges.caviarnine_v1.package, blueprint_name: "QuantaSwap".to_owned() } => PoolBlueprintInformationManifest { - adapter: caviarnine_adapter_v1_component, - allowed_pools: exchanges.caviarnine.pools.into_iter().collect(), - liquidity_receipt: caviarnine_liquidity_receipt_resource + adapter: caviarnine_v1_adapter_v1_component, + allowed_pools: exchanges.caviarnine_v1.pools.into_iter().collect(), + liquidity_receipt: caviarnine_v1_liquidity_receipt_resource }, BlueprintId { - package_address: exchanges.ociswap.package, + package_address: exchanges.ociswap_v1.package, blueprint_name: "BasicPool".to_owned() } => PoolBlueprintInformationManifest { - adapter: ociswap_adapter_v1_component, + adapter: ociswap_v1_adapter_v1_component, // TODO: Fix this when we have actual // ociswap pools. allowed_pools: Default::default(), // allowed_pools: exchanges.ociswap.pools.into_iter().collect(), - liquidity_receipt: ociswap_liquidity_receipt_resource + liquidity_receipt: ociswap_v1_liquidity_receipt_resource } }), initial_user_resource_volatility: Some( @@ -587,8 +587,8 @@ impl StokenetProduction { ( ignition_component_address, simple_oracle_component, - ociswap_adapter_v1_component, - caviarnine_adapter_v1_component, + ociswap_v1_adapter_v1_component, + caviarnine_v1_adapter_v1_component, ) }; @@ -619,18 +619,22 @@ impl StokenetProduction { GlobalAddress::from(protocol_owner_badge), GlobalAddress::from(ignition_package_address), GlobalAddress::from(simple_oracle_package_address), - GlobalAddress::from(ociswap_adapter_v1_package_address), GlobalAddress::from( - caviarnine_adapter_v1_package_address, + ociswap_v1_adapter_v1_package_address, ), - GlobalAddress::from(ociswap_liquidity_receipt_resource), GlobalAddress::from( - caviarnine_liquidity_receipt_resource, + caviarnine_v1_adapter_v1_package_address, + ), + GlobalAddress::from( + ociswap_v1_liquidity_receipt_resource, + ), + GlobalAddress::from( + caviarnine_v1_liquidity_receipt_resource, ), GlobalAddress::from(ignition_component), GlobalAddress::from(simple_oracle_component), - GlobalAddress::from(ociswap_adapter_v1_component), - GlobalAddress::from(caviarnine_adapter_v1_component), + GlobalAddress::from(ociswap_v1_adapter_v1_component), + GlobalAddress::from(caviarnine_v1_adapter_v1_component), ], ) .call_role_assignment_method( diff --git a/tools/bootstrap/src/types/name_indexed_dex_information.rs b/tools/bootstrap/src/types/name_indexed_dex_information.rs index 0031fa4b..91302a39 100644 --- a/tools/bootstrap/src/types/name_indexed_dex_information.rs +++ b/tools/bootstrap/src/types/name_indexed_dex_information.rs @@ -1,7 +1,7 @@ #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct NameIndexedDexInformation { - pub ociswap: T, - pub caviarnine: T, + pub ociswap_v1: T, + pub caviarnine_v1: T, } impl NameIndexedDexInformation { @@ -10,8 +10,8 @@ impl NameIndexedDexInformation { F: FnMut(&T) -> O, { NameIndexedDexInformation:: { - ociswap: map(&self.ociswap), - caviarnine: map(&self.caviarnine), + ociswap_v1: map(&self.ociswap_v1), + caviarnine_v1: map(&self.caviarnine_v1), } } @@ -23,8 +23,8 @@ impl NameIndexedDexInformation { F: FnMut(&T) -> Result, { Ok(NameIndexedDexInformation:: { - ociswap: map(&self.ociswap)?, - caviarnine: map(&self.caviarnine)?, + ociswap_v1: map(&self.ociswap_v1)?, + caviarnine_v1: map(&self.caviarnine_v1)?, }) } }