Skip to content
Merged
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: 2 additions & 0 deletions contracts/contracts/adapters/zest-protocol-adapter.clar
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@

(define-public (collect-zest-fee (amount uint) (treasury principal))
(begin
(try! (assert-configured))
(try! (assert-not-paused))
(try! (assert-authorized-caller))
(asserts! (> amount u0) err-invalid-amount)
Expand All @@ -252,6 +253,7 @@

(define-public (emergency-exit-zest (vault-id uint))
(begin
(try! (assert-configured))
(try! (assert-not-paused))
(try! (assert-authorized-caller))
(let ((current (get-vault-position vault-id)))
Expand Down
21 changes: 17 additions & 4 deletions contracts/tests/security.adapter-treasury-guard_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ Clarinet.test({
const attackerTreasury = accounts.get('wallet_8')!;

const block = chain.mineBlock([
Tx.contractCall(
'zest-protocol-adapter',
'set-zest-config',
[
types.principal(`${deployer.address}.mock-zest-protocol`),
types.principal(`${deployer.address}.mock-zest-protocol`),
types.principal(`${deployer.address}.mock-zest-protocol`),
types.principal(`${deployer.address}.mock-zest-protocol`),
types.principal(`${deployer.address}.mock-zest-protocol`),
],
deployer.address,
),
Tx.contractCall('zest-protocol-adapter', 'collect-zest-fee', [types.uint(10_000), types.principal(attackerTreasury.address)], deployer.address),
Tx.contractCall('alex-liquidity-adapter', 'collect-alex-fee', [types.uint(10_000), types.principal(attackerTreasury.address)], deployer.address),
Tx.contractCall('stackingdao-adapter', 'collect-stackingdao-fee', [types.uint(10_000), types.principal(attackerTreasury.address)], deployer.address),
Tx.contractCall('hermetica-adapter', 'collect-hermetica-fee', [types.uint(10_000), types.principal(attackerTreasury.address)], deployer.address),
]);

block.receipts[0].result.expectErr().expectUint(3405);
block.receipts[1].result.expectErr().expectUint(3505);
block.receipts[2].result.expectErr().expectUint(3605);
block.receipts[3].result.expectErr().expectUint(3705);
block.receipts[0].result.expectOk().expectBool(true);
block.receipts[1].result.expectErr().expectUint(3405);
block.receipts[2].result.expectErr().expectUint(3505);
block.receipts[3].result.expectErr().expectUint(3605);
block.receipts[4].result.expectErr().expectUint(3705);
},
});
15 changes: 15 additions & 0 deletions contracts/tests/zest-protocol-adapter_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,18 @@ Clarinet.test({
balance.result.expectErr().expectUint(3403);
},
});

Clarinet.test({
name: 'zest-adapter: rejects production calls before configuration',
async fn(chain: Chain, accounts: Map<string, Account>) {
const deployer = accounts.get('deployer')!;

const block = chain.mineBlock([
Tx.contractCall('zest-protocol-adapter', 'collect-zest-fee', [types.uint(10_000), types.principal(deployer.address)], deployer.address),
Tx.contractCall('zest-protocol-adapter', 'emergency-exit-zest', [types.uint(1)], deployer.address),
]);

block.receipts[0].result.expectErr().expectUint(3408);
block.receipts[1].result.expectErr().expectUint(3408);
},
});
Loading