Skip to content

Commit

Permalink
fixing for #324
Browse files Browse the repository at this point in the history
  • Loading branch information
hyossid committed Nov 1, 2021
1 parent ab202be commit 76d1333
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 11 deletions.
10 changes: 5 additions & 5 deletions clarity/contracts/token/token-usda.clar
Original file line number Diff line number Diff line change
Expand Up @@ -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
;; )
8 changes: 4 additions & 4 deletions clarity/contracts/token/token-wbtc.clar
Original file line number Diff line number Diff line change
Expand Up @@ -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
;; )
43 changes: 41 additions & 2 deletions clarity/tests/fixed-weight-pool_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -41,8 +42,15 @@ Clarinet.test({

async fn(chain: Chain, accounts: Map<string, Account>) {
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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -151,6 +166,7 @@ Clarinet.test({

async fn(chain: Chain, accounts: Map<string, Account>) {
let deployer = accounts.get("deployer")!;
let wallet_1 = accounts.get("wallet_1")!;
let contractOwner = deployer

let FWPTest = new FWPTestAgent1(chain, deployer);
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -347,9 +377,18 @@ Clarinet.test({

async fn(chain: Chain, accounts: Map<string, Account>) {
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()
Expand Down
48 changes: 48 additions & 0 deletions clarity/tests/models/alex-tests-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down

0 comments on commit 76d1333

Please sign in to comment.