mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-02-12 08:26:46 +00:00
vault: do not delete lock when burning
This commit is contained in:
parent
b09f742944
commit
25d9c15ca7
@ -179,7 +179,7 @@ abstract contract VaultBase {
|
||||
Fund fund,
|
||||
Recipient recipient
|
||||
) internal {
|
||||
Lock memory lock = _locks[controller][fund];
|
||||
Lock storage lock = _locks[controller][fund];
|
||||
require(lock.isLocked(), LockRequired());
|
||||
|
||||
Account memory account = _getAccount(controller, fund, recipient);
|
||||
@ -189,13 +189,8 @@ abstract contract VaultBase {
|
||||
);
|
||||
|
||||
uint128 amount = account.available + account.designated;
|
||||
lock.value -= amount;
|
||||
|
||||
if (lock.value == 0) {
|
||||
delete _locks[controller][fund];
|
||||
} else {
|
||||
_locks[controller][fund] = lock;
|
||||
}
|
||||
lock.value -= amount;
|
||||
|
||||
delete _accounts[controller][fund][recipient];
|
||||
|
||||
|
@ -129,6 +129,14 @@ describe("Vault", function () {
|
||||
const extending = vault.extendLock(fund, expiry - 1)
|
||||
await expect(extending).to.be.revertedWith("InvalidExpiry")
|
||||
})
|
||||
|
||||
it("does not delete lock when no tokens remain", async function () {
|
||||
await token.connect(account).approve(vault.address, 30)
|
||||
await vault.deposit(fund, account.address, 30)
|
||||
await vault.burn(fund, account.address)
|
||||
expect((await vault.getLock(fund))[0]).to.not.equal(0)
|
||||
expect((await vault.getLock(fund))[1]).to.not.equal(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe("depositing", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user