mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-07 15:53:07 +00:00
vault: prefix errors with 'Vault'
This commit is contained in:
parent
0a539fb017
commit
dc3084836f
@ -69,7 +69,7 @@ abstract contract VaultBase {
|
|||||||
Timestamp maximum
|
Timestamp maximum
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.NoLock, FundAlreadyLocked());
|
require(lock.status() == LockStatus.NoLock, VaultFundAlreadyLocked());
|
||||||
lock.expiry = expiry;
|
lock.expiry = expiry;
|
||||||
lock.maximum = maximum;
|
lock.maximum = maximum;
|
||||||
_checkLockInvariant(lock);
|
_checkLockInvariant(lock);
|
||||||
@ -82,8 +82,8 @@ abstract contract VaultBase {
|
|||||||
Timestamp expiry
|
Timestamp expiry
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
require(lock.expiry <= expiry, InvalidExpiry());
|
require(lock.expiry <= expiry, VaultInvalidExpiry());
|
||||||
lock.expiry = expiry;
|
lock.expiry = expiry;
|
||||||
_checkLockInvariant(lock);
|
_checkLockInvariant(lock);
|
||||||
_locks[controller][fund] = lock;
|
_locks[controller][fund] = lock;
|
||||||
@ -96,7 +96,7 @@ abstract contract VaultBase {
|
|||||||
uint128 amount
|
uint128 amount
|
||||||
) internal {
|
) internal {
|
||||||
Lock storage lock = _locks[controller][fund];
|
Lock storage lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account storage account = _accounts[controller][fund][recipient];
|
Account storage account = _accounts[controller][fund][recipient];
|
||||||
|
|
||||||
@ -117,10 +117,10 @@ abstract contract VaultBase {
|
|||||||
uint128 amount
|
uint128 amount
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account memory account = _accounts[controller][fund][recipient];
|
Account memory account = _accounts[controller][fund][recipient];
|
||||||
require(amount <= account.balance.available, InsufficientBalance());
|
require(amount <= account.balance.available, VaultInsufficientBalance());
|
||||||
|
|
||||||
account.balance.available -= amount;
|
account.balance.available -= amount;
|
||||||
account.balance.designated += amount;
|
account.balance.designated += amount;
|
||||||
@ -137,10 +137,10 @@ abstract contract VaultBase {
|
|||||||
uint128 amount
|
uint128 amount
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account memory sender = _accounts[controller][fund][from];
|
Account memory sender = _accounts[controller][fund][from];
|
||||||
require(amount <= sender.balance.available, InsufficientBalance());
|
require(amount <= sender.balance.available, VaultInsufficientBalance());
|
||||||
|
|
||||||
sender.balance.available -= amount;
|
sender.balance.available -= amount;
|
||||||
_checkAccountInvariant(sender, lock);
|
_checkAccountInvariant(sender, lock);
|
||||||
@ -158,7 +158,7 @@ abstract contract VaultBase {
|
|||||||
TokensPerSecond rate
|
TokensPerSecond rate
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account memory sender = _accounts[controller][fund][from];
|
Account memory sender = _accounts[controller][fund][from];
|
||||||
sender.flowOut(rate);
|
sender.flowOut(rate);
|
||||||
@ -177,10 +177,10 @@ abstract contract VaultBase {
|
|||||||
uint128 amount
|
uint128 amount
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account storage account = _accounts[controller][fund][recipient];
|
Account storage account = _accounts[controller][fund][recipient];
|
||||||
require(account.balance.designated >= amount, InsufficientBalance());
|
require(account.balance.designated >= amount, VaultInsufficientBalance());
|
||||||
|
|
||||||
account.balance.designated -= amount;
|
account.balance.designated -= amount;
|
||||||
|
|
||||||
@ -193,10 +193,10 @@ abstract contract VaultBase {
|
|||||||
Recipient recipient
|
Recipient recipient
|
||||||
) internal {
|
) internal {
|
||||||
Lock storage lock = _locks[controller][fund];
|
Lock storage lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
Account memory account = _accounts[controller][fund][recipient];
|
Account memory account = _accounts[controller][fund][recipient];
|
||||||
require(account.flow.incoming == account.flow.outgoing, FlowMustBeZero());
|
require(account.flow.incoming == account.flow.outgoing, VaultFlowNotZero());
|
||||||
uint128 amount = account.balance.available + account.balance.designated;
|
uint128 amount = account.balance.available + account.balance.designated;
|
||||||
|
|
||||||
lock.value -= amount;
|
lock.value -= amount;
|
||||||
@ -208,7 +208,7 @@ abstract contract VaultBase {
|
|||||||
|
|
||||||
function _burnFund(Controller controller, Fund fund) internal {
|
function _burnFund(Controller controller, Fund fund) internal {
|
||||||
Lock storage lock = _locks[controller][fund];
|
Lock storage lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Locked, FundNotLocked());
|
require(lock.status() == LockStatus.Locked, VaultFundNotLocked());
|
||||||
|
|
||||||
lock.burned = true;
|
lock.burned = true;
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ abstract contract VaultBase {
|
|||||||
Recipient recipient
|
Recipient recipient
|
||||||
) internal {
|
) internal {
|
||||||
Lock memory lock = _locks[controller][fund];
|
Lock memory lock = _locks[controller][fund];
|
||||||
require(lock.status() == LockStatus.Unlocked, FundNotUnlocked());
|
require(lock.status() == LockStatus.Unlocked, VaultFundNotUnlocked());
|
||||||
|
|
||||||
Account memory account = _accounts[controller][fund][recipient];
|
Account memory account = _accounts[controller][fund][recipient];
|
||||||
account.update(lock.expiry);
|
account.update(lock.expiry);
|
||||||
@ -241,20 +241,20 @@ abstract contract VaultBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _checkLockInvariant(Lock memory lock) private pure {
|
function _checkLockInvariant(Lock memory lock) private pure {
|
||||||
require(lock.expiry <= lock.maximum, InvalidExpiry());
|
require(lock.expiry <= lock.maximum, VaultInvalidExpiry());
|
||||||
}
|
}
|
||||||
|
|
||||||
function _checkAccountInvariant(
|
function _checkAccountInvariant(
|
||||||
Account memory account,
|
Account memory account,
|
||||||
Lock memory lock
|
Lock memory lock
|
||||||
) private pure {
|
) private pure {
|
||||||
require(account.isSolventAt(lock.maximum), InsufficientBalance());
|
require(account.isSolventAt(lock.maximum), VaultInsufficientBalance());
|
||||||
}
|
}
|
||||||
|
|
||||||
error InsufficientBalance();
|
error VaultInsufficientBalance();
|
||||||
error InvalidExpiry();
|
error VaultInvalidExpiry();
|
||||||
error FundNotLocked();
|
error VaultFundNotLocked();
|
||||||
error FundNotUnlocked();
|
error VaultFundNotUnlocked();
|
||||||
error FundAlreadyLocked();
|
error VaultFundAlreadyLocked();
|
||||||
error FlowMustBeZero();
|
error VaultFlowNotZero();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -533,9 +533,9 @@ describe("Vault", function () {
|
|||||||
it("cannot burn tokens that are flowing", async function () {
|
it("cannot burn tokens that are flowing", async function () {
|
||||||
await vault.flow(fund, account.address, account2.address, 5)
|
await vault.flow(fund, account.address, account2.address, 5)
|
||||||
const burning1 = vault.burnAccount(fund, account.address)
|
const burning1 = vault.burnAccount(fund, account.address)
|
||||||
await expect(burning1).to.be.revertedWith("FlowMustBeZero")
|
await expect(burning1).to.be.revertedWith("FlowNotZero")
|
||||||
const burning2 = vault.burnAccount(fund, account2.address)
|
const burning2 = vault.burnAccount(fund, account2.address)
|
||||||
await expect(burning2).to.be.revertedWith("FlowMustBeZero")
|
await expect(burning2).to.be.revertedWith("FlowNotZero")
|
||||||
})
|
})
|
||||||
|
|
||||||
it("can burn tokens that are no longer flowing", async function () {
|
it("can burn tokens that are no longer flowing", async function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user