diff --git a/contracts/contracts/adapters/zest-protocol-adapter.clar b/contracts/contracts/adapters/zest-protocol-adapter.clar index 3fa67bf..9c1387c 100644 --- a/contracts/contracts/adapters/zest-protocol-adapter.clar +++ b/contracts/contracts/adapters/zest-protocol-adapter.clar @@ -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) @@ -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))) diff --git a/contracts/tests/security.adapter-treasury-guard_test.ts b/contracts/tests/security.adapter-treasury-guard_test.ts index 514008a..9147400 100644 --- a/contracts/tests/security.adapter-treasury-guard_test.ts +++ b/contracts/tests/security.adapter-treasury-guard_test.ts @@ -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); }, }); diff --git a/contracts/tests/zest-protocol-adapter_test.ts b/contracts/tests/zest-protocol-adapter_test.ts index f58180e..d647d4a 100644 --- a/contracts/tests/zest-protocol-adapter_test.ts +++ b/contracts/tests/zest-protocol-adapter_test.ts @@ -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) { + 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); + }, +});