Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/stableswap.clar
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@
)
;; Assert that tx-sender is an admin using is-some & index-of with the admins var
(asserts! (is-some (index-of current-admins tx-sender)) (err "err-not-admin"))
(asserts! (> new-convergence-threshold u0) (err "err-invalid-convergence-threshold"))

(ok (var-set convergence-threshold new-convergence-threshold))
)
Expand Down Expand Up @@ -1032,4 +1033,3 @@
(ok staking-contract)
)
)

34 changes: 33 additions & 1 deletion tests/stableswap_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,4 +1675,36 @@ Clarinet.test({
block.receipts[0].result.expectErr()
console.log(JSON.stringify(block.receipts));
},
});
});

// Test convergence threshold admin controls
Clarinet.test({
name: "Ensure admins cannot set convergence threshold to zero",
async fn(chain: Chain, accounts: Map<string, Account>) {
const deployer = accounts.get("deployer")!;
const wallet_1 = accounts.get("wallet_1")!;

const block = chain.mineBlock([
Tx.contractCall("stableswap", "change-convergence-threshold", [types.uint(0)], deployer.address)
]);

block.receipts[0].result.expectErr()
console.log(JSON.stringify(block.receipts));
},
});

// Test convergence threshold admin controls
Clarinet.test({
name: "Ensure admins can set convergence threshold above zero",
async fn(chain: Chain, accounts: Map<string, Account>) {
const deployer = accounts.get("deployer")!;
const wallet_1 = accounts.get("wallet_1")!;

const block = chain.mineBlock([
Tx.contractCall("stableswap", "change-convergence-threshold", [types.uint(1)], deployer.address)
]);

block.receipts[0].result.expectOk()
console.log(JSON.stringify(block.receipts));
},
});