diff --git a/clarity/contracts/token/token-usda.clar b/clarity/contracts/token/token-usda.clar index 2f675f40..193b7c72 100644 --- a/clarity/contracts/token/token-usda.clar +++ b/clarity/contracts/token/token-usda.clar @@ -97,8 +97,8 @@ ) ;; Initialize the contract for Testing. -(begin - (try! (ft-mint? usda u1000000000 tx-sender)) - (try! (ft-mint? usda u10000000 'ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.alex-reserve-pool)) - (try! (ft-mint? usda u200000 'ST1J4G6RR643BCG8G8SR6M2D9Z9KXT2NJDRK3FBTK)) ;;wallet_1 -) +;; (begin +;; (try! (ft-mint? usda u1000000000 tx-sender)) +;; (try! (ft-mint? usda u10000000 'ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.alex-reserve-pool)) +;; (try! (ft-mint? usda u200000 'ST1J4G6RR643BCG8G8SR6M2D9Z9KXT2NJDRK3FBTK)) ;;wallet_1 +;; ) diff --git a/clarity/contracts/token/token-wbtc.clar b/clarity/contracts/token/token-wbtc.clar index 4d7ac7b4..bfd9b66e 100644 --- a/clarity/contracts/token/token-wbtc.clar +++ b/clarity/contracts/token/token-wbtc.clar @@ -97,7 +97,7 @@ ) ;; Initialize the contract for Testing. -(begin - (try! (ft-mint? wbtc u2000000000000 tx-sender)) - (try! (ft-mint? wbtc u2000000000000 'ST1J4G6RR643BCG8G8SR6M2D9Z9KXT2NJDRK3FBTK)) ;;wallet_1 -) +;; (begin +;; (try! (ft-mint? wbtc u2000000000000 tx-sender)) +;; (try! (ft-mint? wbtc u2000000000000 'ST1J4G6RR643BCG8G8SR6M2D9Z9KXT2NJDRK3FBTK)) ;;wallet_1 +;; ) diff --git a/clarity/tests/fixed-weight-pool_test.ts b/clarity/tests/fixed-weight-pool_test.ts index 3661211b..3fccdd5b 100644 --- a/clarity/tests/fixed-weight-pool_test.ts +++ b/clarity/tests/fixed-weight-pool_test.ts @@ -24,6 +24,7 @@ const fwpwbtcusdaAddress = "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.fwp-wbtc-u const multisigAddress = "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.multisig-fwp-wbtc-usda-50-50" const fwpAddress = "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.fixed-weight-pool" const wrongPooltokenAddress = "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.ytp-yield-usda-23040-usda" +const alexreservepoolAddress = "ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.alex-reserve-pool" const ONE_8 = 100000000 @@ -41,8 +42,15 @@ Clarinet.test({ async fn(chain: Chain, accounts: Map) { let deployer = accounts.get("deployer")!; + let wallet_1 = accounts.get("wallet_1")!; let FWPTest = new FWPTestAgent1(chain, deployer); - + let usdaToken = new USDAToken(chain, deployer); + let wbtcToken = new WBTCToken(chain, deployer); + let mint = usdaToken.mint(deployer.address, 10*ONE_8); + mint = usdaToken.mint(alexreservepoolAddress, 10*ONE_8); + mint = usdaToken.mint(wallet_1.address, 200000); + mint = wbtcToken.mint(deployer.address, 20000*ONE_8); + mint = wbtcToken.mint(wallet_1.address, 20000*ONE_8); // Deployer creating a pool, initial tokens injected to the pool let result = FWPTest.createPool(deployer, wbtcAddress, usdaAddress, weightX, weightY, fwpwbtcusdaAddress, multisigAddress, wbtcQ, wbtcQ*wbtcPrice); result.expectOk().expectBool(true); @@ -112,7 +120,14 @@ Clarinet.test({ let deployer = accounts.get("deployer")!; let wallet_1 = accounts.get("wallet_1")!; let FWPTest = new FWPTestAgent1(chain, deployer); - + + let usdaToken = new USDAToken(chain, deployer); + let wbtcToken = new WBTCToken(chain, deployer); + let mint = usdaToken.mint(deployer.address, 10*ONE_8); + mint = usdaToken.mint(alexreservepoolAddress, 10*ONE_8); + mint = usdaToken.mint(wallet_1.address, 200000); + mint = wbtcToken.mint(deployer.address, 20000*ONE_8); + mint = wbtcToken.mint(wallet_1.address, 20000*ONE_8); // non-deployer attempting to create a pool will throw an error let result = FWPTest.createPool(wallet_1, wbtcAddress, usdaAddress, weightX, weightY, fwpwbtcusdaAddress, multisigAddress, wbtcQ, wbtcQ*wbtcPrice); result.expectErr().expectUint(1000); @@ -151,6 +166,7 @@ Clarinet.test({ async fn(chain: Chain, accounts: Map) { let deployer = accounts.get("deployer")!; + let wallet_1 = accounts.get("wallet_1")!; let contractOwner = deployer let FWPTest = new FWPTestAgent1(chain, deployer); @@ -159,6 +175,11 @@ Clarinet.test({ let wbtcToken = new WBTCToken(chain, deployer); let fwpPoolToken = new POOLTOKEN_FWP_WBTC_USDA_5050(chain, deployer); + let mint = usdaToken.mint(deployer.address, 10*ONE_8); + mint = usdaToken.mint(alexreservepoolAddress, 10*ONE_8); + mint = usdaToken.mint(wallet_1.address, 200000); + mint = wbtcToken.mint(deployer.address, 20000*ONE_8); + mint = wbtcToken.mint(wallet_1.address, 20000*ONE_8); const feeRateX = 0.1*ONE_8; // 10% const feeRateY = 0.1*ONE_8; const feeRebate = 0.5*ONE_8; @@ -259,6 +280,15 @@ Clarinet.test({ let wallet_1 = accounts.get("wallet_1")!; let FWPTest = new FWPTestAgent1(chain, deployer); let MultiSigTest = new MS_FWP_WBTC_USDA_5050(chain, deployer); + + let usdaToken = new USDAToken(chain, deployer); + let wbtcToken = new WBTCToken(chain, deployer); + let mint = usdaToken.mint(deployer.address, 10*ONE_8); + mint = usdaToken.mint(alexreservepoolAddress, 10*ONE_8); + mint = usdaToken.mint(wallet_1.address, 200000); + mint = wbtcToken.mint(deployer.address, 20000*ONE_8); + mint = wbtcToken.mint(wallet_1.address, 20000*ONE_8); + const feeRateX = 5000000; // 5% const feeRateY = 5000000; @@ -347,9 +377,18 @@ Clarinet.test({ async fn(chain: Chain, accounts: Map) { let deployer = accounts.get("deployer")!; + let wallet_1 = accounts.get("wallet_1")!; let FWPTest = new FWPTestAgent1(chain, deployer); let Oracle = new OracleManager(chain, deployer); + let usdaToken = new USDAToken(chain, deployer); + let wbtcToken = new WBTCToken(chain, deployer); + let mint = usdaToken.mint(deployer.address, 10*ONE_8); + mint = usdaToken.mint(alexreservepoolAddress, 10*ONE_8); + mint = usdaToken.mint(wallet_1.address, 200000); + mint = wbtcToken.mint(deployer.address, 20000*ONE_8); + mint = wbtcToken.mint(wallet_1.address, 20000*ONE_8); + // initialise prices let oracleresult = Oracle.updatePrice(deployer,"WBTC", "coingecko" ,wbtcPrice * ONE_8); oracleresult.expectOk() diff --git a/clarity/tests/models/alex-tests-tokens.ts b/clarity/tests/models/alex-tests-tokens.ts index 05981538..1115778d 100644 --- a/clarity/tests/models/alex-tests-tokens.ts +++ b/clarity/tests/models/alex-tests-tokens.ts @@ -16,6 +16,14 @@ class USDAToken { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("token-usda", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("token-usda", "get-balance", [ types.principal(wallet), @@ -51,6 +59,14 @@ class WBTCToken { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("token-wbtc", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("token-wbtc", "get-balance", [ types.principal(wallet), @@ -86,6 +102,14 @@ class POOLTOKEN_FWP_WBTC_USDA_5050 { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("fwp-wbtc-usda-50-50", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("fwp-wbtc-usda-50-50", "get-balance", [ types.principal(wallet), @@ -107,6 +131,14 @@ class POOLTOKEN_YTP_WBTC_WBTC_59760 { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("ytp-yield-wbtc-59760-wbtc", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("ytp-yield-wbtc-59760-wbtc", "get-balance", [ types.principal(wallet), @@ -128,6 +160,14 @@ class YIELD_WBTC_59760 { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("yield-wbtc-59760", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("yield-wbtc-59760", "get-balance", [ types.principal(wallet), @@ -150,6 +190,14 @@ class KEY_WBTC_59760_USDA { this.deployer = deployer; } + // Always need to called by deployer + mint(recipient: string, amount : number) { + return this.chain.callReadOnlyFn("key-wbtc-59760-usda", "mint", [ + types.principal(recipient), + types.uint(amount), + ], this.deployer.address); + } + balanceOf(wallet: string) { return this.chain.callReadOnlyFn("key-wbtc-59760-usda", "get-balance", [ types.principal(wallet),