mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-04 22:33:11 +00:00
vault: disallow designating of flowing tokens
This commit is contained in:
parent
4c6c68f9d9
commit
d0b8f961b2
@ -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(
|
||||
|
||||
@ -599,6 +599,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