mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-01-30 18:25:41 +00:00
vault: cannot burn flowing tokens
This commit is contained in:
parent
7e1e71d25e
commit
ef51834740
@ -110,9 +110,14 @@ abstract contract VaultBase {
|
||||
Context context,
|
||||
Recipient recipient
|
||||
) internal {
|
||||
Flow memory flow = _flows[controller][context][recipient];
|
||||
require(flow.rate == TokensPerSecond.wrap(0), CannotBurnFlowingTokens());
|
||||
|
||||
Balance memory balance = _getBalance(controller, context, recipient);
|
||||
uint128 amount = balance.available + balance.designated;
|
||||
|
||||
_delete(controller, context, recipient);
|
||||
|
||||
_token.safeTransfer(address(0xdead), amount);
|
||||
}
|
||||
|
||||
@ -230,4 +235,5 @@ abstract contract VaultBase {
|
||||
error InvalidExpiry();
|
||||
error LockRequired();
|
||||
error NegativeFlow();
|
||||
error CannotBurnFlowingTokens();
|
||||
}
|
||||
|
@ -598,6 +598,22 @@ describe("Vault", function () {
|
||||
vault.transfer(context, sender, receiver, 1)
|
||||
).to.be.revertedWith("InsufficientBalance")
|
||||
})
|
||||
|
||||
it("cannot burn tokens that are flowing", async function () {
|
||||
await vault.flow(context, sender, receiver, 5)
|
||||
await expect(
|
||||
vault.burn(context, sender)
|
||||
).to.be.revertedWith("CannotBurnFlowingTokens")
|
||||
await expect(
|
||||
vault.burn(context, receiver)
|
||||
).to.be.revertedWith("CannotBurnFlowingTokens")
|
||||
})
|
||||
|
||||
it("can burn tokens that are no longer flowing", async function () {
|
||||
await vault.flow(context, sender, receiver, 5)
|
||||
await vault.flow(context, receiver, sender, 5)
|
||||
await expect(vault.burn(context, sender)).not.to.be.reverted
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user