mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-01-30 18:25:41 +00:00
vault: disallow designating of flowing tokens
This commit is contained in:
parent
b988db9bd3
commit
28ad5ced18
@ -150,10 +150,17 @@ abstract contract VaultBase {
|
||||
Recipient recipient,
|
||||
uint128 amount
|
||||
) internal {
|
||||
Balance storage balance = _balances[controller][context][recipient];
|
||||
Balance memory balance = _balances[controller][context][recipient];
|
||||
require(amount <= balance.available, InsufficientBalance());
|
||||
|
||||
balance.available -= amount;
|
||||
balance.designated += amount;
|
||||
|
||||
Flow memory flow = _flows[controller][context][recipient];
|
||||
Lock memory lock = _locks[controller][context];
|
||||
_checkFlowInvariant(balance, lock, flow);
|
||||
|
||||
_balances[controller][context][recipient] = balance;
|
||||
}
|
||||
|
||||
function _lockup(
|
||||
|
@ -600,6 +600,15 @@ describe("Vault", function () {
|
||||
).to.be.revertedWith("InsufficientBalance")
|
||||
})
|
||||
|
||||
it("cannot designate tokens that are flowing", async function () {
|
||||
await vault.flow(context, sender, receiver, 5)
|
||||
setAutomine(true)
|
||||
await vault.designate(context, sender, 500)
|
||||
await expect(vault.designate(context, sender, 1)).to.be.revertedWith(
|
||||
"InsufficientBalance"
|
||||
)
|
||||
})
|
||||
|
||||
it("cannot burn tokens that are flowing", async function () {
|
||||
await vault.flow(context, sender, receiver, 5)
|
||||
setAutomine(true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user