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,
|
Fund fund,
|
||||||
Recipient recipient
|
Recipient recipient
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock storage lock = _locks[controller][fund];
|
||||||
require(lock.isLocked(), LockRequired());
|
require(lock.isLocked(), LockRequired());
|
||||||
|
|
||||||
Account memory account = _getAccount(controller, fund, recipient);
|
Account memory account = _getAccount(controller, fund, recipient);
|
||||||
@ -189,13 +189,8 @@ abstract contract VaultBase {
|
|||||||
);
|
);
|
||||||
|
|
||||||
uint128 amount = account.available + account.designated;
|
uint128 amount = account.available + account.designated;
|
||||||
lock.value -= amount;
|
|
||||||
|
|
||||||
if (lock.value == 0) {
|
lock.value -= amount;
|
||||||
delete _locks[controller][fund];
|
|
||||||
} else {
|
|
||||||
_locks[controller][fund] = lock;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete _accounts[controller][fund][recipient];
|
delete _accounts[controller][fund][recipient];
|
||||||
|
|
||||||
|
@ -129,6 +129,14 @@ describe("Vault", function () {
|
|||||||
const extending = vault.extendLock(fund, expiry - 1)
|
const extending = vault.extendLock(fund, expiry - 1)
|
||||||
await expect(extending).to.be.revertedWith("InvalidExpiry")
|
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 () {
|
describe("depositing", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user