diff --git a/abi/Errors.json b/abi/Errors.json index 8874ad9f..e2f2620a 100644 --- a/abi/Errors.json +++ b/abi/Errors.json @@ -24,11 +24,6 @@ "name": "DeadlineExpired", "type": "error" }, - { - "inputs": [], - "name": "EigenInvalidReallocations", - "type": "error" - }, { "inputs": [], "name": "EigenInvalidWithdrawal", diff --git a/chiado-config.json b/chiado-config.json deleted file mode 100644 index 069b56c3..00000000 --- a/chiado-config.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "public_key": "0x123..", - "exit_signature": "0x456..." - } -] diff --git a/contracts/interfaces/IGnoPoolEscrow.sol b/contracts/interfaces/IGnoPoolEscrow.sol index 88b8954c..c9a2acd9 100644 --- a/contracts/interfaces/IGnoPoolEscrow.sol +++ b/contracts/interfaces/IGnoPoolEscrow.sol @@ -3,10 +3,10 @@ pragma solidity 0.8.22; /** - * @title IPoolEscrow + * @title IGnoPoolEscrow * @author StakeWise * @dev Copied from https://github.com/stakewise/contracts/blob/gnosis-chain/contracts/interfaces/IPoolEscrow.sol - * @notice Defines the interface for the PoolEscrow contract + * @notice Defines the interface for the PoolEscrow contract on Gnosis */ interface IGnoPoolEscrow { /** diff --git a/contracts/interfaces/IVaultOsToken.sol b/contracts/interfaces/IVaultOsToken.sol index 1d0af95c..1fbf7be0 100644 --- a/contracts/interfaces/IVaultOsToken.sol +++ b/contracts/interfaces/IVaultOsToken.sol @@ -110,7 +110,7 @@ interface IVaultOsToken is IVaultState, IVaultEnterExit { /** * @notice Liquidates a user position and returns the number of received assets. - * Can only be called when health factor is below 1. + * Can only be called when health factor is below 1 by the liquidator. * @param osTokenShares The number of shares to cover * @param owner The address of the position owner to liquidate * @param receiver The address of the receiver of the liquidated assets @@ -118,7 +118,7 @@ interface IVaultOsToken is IVaultState, IVaultEnterExit { function liquidateOsToken(uint256 osTokenShares, address owner, address receiver) external; /** - * @notice Redeems osToken shares for assets. Can only be called when health factor is above redeemFromHealthFactor. + * @notice Redeems osToken shares for assets. Can only be called when health factor is above redeemFromHealthFactor by the redeemer. * @param osTokenShares The number of osToken shares to redeem * @param owner The address of the position owner to redeem from * @param receiver The address of the receiver of the redeemed assets diff --git a/contracts/libraries/Errors.sol b/contracts/libraries/Errors.sol index 0a49bb98..b1b696b1 100644 --- a/contracts/libraries/Errors.sol +++ b/contracts/libraries/Errors.sol @@ -53,7 +53,6 @@ library Errors { error ExitRequestNotProcessed(); error ValueNotChanged(); error EigenInvalidWithdrawal(); - error EigenInvalidReallocations(); error InvalidEigenQueuedWithdrawals(); error InvalidWithdrawalCredentials(); error EigenPodNotFound(); diff --git a/test/EthVault.liquidate.spec.ts b/test/EthVault.liquidate.spec.ts index 0c7e2390..31a1432d 100644 --- a/test/EthVault.liquidate.spec.ts +++ b/test/EthVault.liquidate.spec.ts @@ -87,6 +87,14 @@ describe('EthVault - liquidate', () => { } await vault.connect(dao).updateState(harvestParams) await osToken.connect(owner).transfer(liquidator.address, osTokenShares) + await osTokenConfig.connect(dao).setLiquidator(liquidator.address) + }) + + it('cannot liquidate osTokens from not liquidator', async () => { + await osTokenConfig.connect(dao).setLiquidator(dao.address) + await expect( + vault.connect(liquidator).liquidateOsToken(osTokenShares, owner.address, ZERO_ADDRESS) + ).to.be.revertedWithCustomError(vault, 'AccessDenied') }) it('cannot liquidate osTokens to zero receiver', async () => { diff --git a/test/EthVault.redeem.spec.ts b/test/EthVault.redeem.spec.ts index 444b1f95..accce480 100644 --- a/test/EthVault.redeem.spec.ts +++ b/test/EthVault.redeem.spec.ts @@ -102,6 +102,14 @@ describe('EthVault - redeem osToken', () => { } await vault.connect(dao).updateState(harvestParams) await osToken.connect(owner).transfer(redeemer.address, osTokenShares) + await osTokenConfig.connect(dao).setRedeemer(redeemer.address) + }) + + it('cannot redeem osTokens from not redeemer', async () => { + await osTokenConfig.connect(dao).setRedeemer(dao.address) + await expect( + vault.connect(redeemer).redeemOsToken(redeemedShares, owner.address, ZERO_ADDRESS) + ).to.be.revertedWithCustomError(vault, 'AccessDenied') }) it('cannot redeem osTokens to zero receiver', async () => { diff --git a/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap b/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap index c90ab2e7..2440c095 100644 --- a/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap +++ b/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap @@ -17,7 +17,7 @@ Object { exports[`EthBlocklistErc20Vault mint osToken can mint from not blocked user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 174049, + "gasUsed": 176332, } `; diff --git a/test/__snapshots__/EthBlocklistVault.spec.ts.snap b/test/__snapshots__/EthBlocklistVault.spec.ts.snap index 7f5e8ce5..cc1e1243 100644 --- a/test/__snapshots__/EthBlocklistVault.spec.ts.snap +++ b/test/__snapshots__/EthBlocklistVault.spec.ts.snap @@ -17,6 +17,6 @@ Object { exports[`EthBlocklistVault mint osToken can mint from not blocked user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 173839, + "gasUsed": 176122, } `; diff --git a/test/__snapshots__/EthGenesisVault.spec.ts.snap b/test/__snapshots__/EthGenesisVault.spec.ts.snap index 84fc01dd..b0502f58 100644 --- a/test/__snapshots__/EthGenesisVault.spec.ts.snap +++ b/test/__snapshots__/EthGenesisVault.spec.ts.snap @@ -10,7 +10,7 @@ Object { exports[`EthGenesisVault migrate migrates from rewardEthToken 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 79584, + "gasUsed": 79583, } `; diff --git a/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap b/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap index 0a21bcd2..263e9a21 100644 --- a/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap +++ b/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap @@ -17,7 +17,7 @@ Object { exports[`EthPrivErc20Vault mint osToken can mint from whitelisted user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 174074, + "gasUsed": 176357, } `; diff --git a/test/__snapshots__/EthPrivVault.spec.ts.snap b/test/__snapshots__/EthPrivVault.spec.ts.snap index 60554a49..353c6387 100644 --- a/test/__snapshots__/EthPrivVault.spec.ts.snap +++ b/test/__snapshots__/EthPrivVault.spec.ts.snap @@ -3,6 +3,6 @@ exports[`EthPrivVault mint osToken can mint from not whitelisted user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 173864, + "gasUsed": 176147, } `; diff --git a/test/__snapshots__/EthVault.liquidate.spec.ts.snap b/test/__snapshots__/EthVault.liquidate.spec.ts.snap index bc58a4e7..98381e78 100644 --- a/test/__snapshots__/EthVault.liquidate.spec.ts.snap +++ b/test/__snapshots__/EthVault.liquidate.spec.ts.snap @@ -3,13 +3,13 @@ exports[`EthVault - liquidate calculates liquidation correctly 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 109388, + "gasUsed": 114958, } `; exports[`EthVault - liquidate can liquidate 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 109388, + "gasUsed": 114958, } `; diff --git a/test/__snapshots__/EthVault.mint.spec.ts.snap b/test/__snapshots__/EthVault.mint.spec.ts.snap index a2151efe..433648de 100644 --- a/test/__snapshots__/EthVault.mint.spec.ts.snap +++ b/test/__snapshots__/EthVault.mint.spec.ts.snap @@ -3,13 +3,13 @@ exports[`EthVault - mint mints osTokens to the receiver 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 171564, + "gasUsed": 173847, } `; exports[`EthVault - mint updates position accumulated fee 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 116676, + "gasUsed": 118959, } `; diff --git a/test/__snapshots__/EthVault.redeem.spec.ts.snap b/test/__snapshots__/EthVault.redeem.spec.ts.snap index 7c7e5c0f..fa035ce0 100644 --- a/test/__snapshots__/EthVault.redeem.spec.ts.snap +++ b/test/__snapshots__/EthVault.redeem.spec.ts.snap @@ -3,13 +3,13 @@ exports[`EthVault - redeem osToken calculates redeem correctly 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 125549, + "gasUsed": 130874, } `; exports[`EthVault - redeem osToken can redeem 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 125549, + "gasUsed": 130874, } `; diff --git a/test/__snapshots__/EthVaultFactory.spec.ts.snap b/test/__snapshots__/EthVaultFactory.spec.ts.snap index 68bd70d0..1e05ccd5 100644 --- a/test/__snapshots__/EthVaultFactory.spec.ts.snap +++ b/test/__snapshots__/EthVaultFactory.spec.ts.snap @@ -3,55 +3,55 @@ exports[`EthVaultFactory EthErc20Vault private vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 577199, + "gasUsed": 577198, } `; exports[`EthVaultFactory EthErc20Vault private vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 428380, + "gasUsed": 428379, } `; exports[`EthVaultFactory EthErc20Vault public vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 553279, + "gasUsed": 553278, } `; exports[`EthVaultFactory EthErc20Vault public vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 404460, + "gasUsed": 404459, } `; exports[`EthVaultFactory EthVault private vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 503077, + "gasUsed": 503076, } `; exports[`EthVaultFactory EthVault private vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 354258, + "gasUsed": 354257, } `; exports[`EthVaultFactory EthVault public vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 479157, + "gasUsed": 479156, } `; exports[`EthVaultFactory EthVault public vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 330338, + "gasUsed": 330337, } `; diff --git a/test/__snapshots__/OsTokenConfig.spec.ts.snap b/test/__snapshots__/OsTokenConfig.spec.ts.snap index a2b0ad90..74b1ef79 100644 --- a/test/__snapshots__/OsTokenConfig.spec.ts.snap +++ b/test/__snapshots__/OsTokenConfig.spec.ts.snap @@ -3,6 +3,6 @@ exports[`OsTokenConfig owner can update config 1`] = ` Object { "calldataByteLength": 164, - "gasUsed": 32418, + "gasUsed": 32520, } `; diff --git a/test/__snapshots__/VaultsRegistry.spec.ts.snap b/test/__snapshots__/VaultsRegistry.spec.ts.snap index ab82aafd..e0800540 100644 --- a/test/__snapshots__/VaultsRegistry.spec.ts.snap +++ b/test/__snapshots__/VaultsRegistry.spec.ts.snap @@ -3,7 +3,7 @@ exports[`VaultsRegistry factory can add vault 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 330338, + "gasUsed": 330337, } `; diff --git a/test/gnosis/__snapshots__/GnoBlocklistErc20Vault.spec.ts.snap b/test/gnosis/__snapshots__/GnoBlocklistErc20Vault.spec.ts.snap index 091a76de..89b1d8d7 100644 --- a/test/gnosis/__snapshots__/GnoBlocklistErc20Vault.spec.ts.snap +++ b/test/gnosis/__snapshots__/GnoBlocklistErc20Vault.spec.ts.snap @@ -10,7 +10,7 @@ Object { exports[`GnoBlocklistErc20Vault mint osToken can mint from not blocked user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 174005, + "gasUsed": 176288, } `; diff --git a/test/gnosis/__snapshots__/GnoBlocklistVault.spec.ts.snap b/test/gnosis/__snapshots__/GnoBlocklistVault.spec.ts.snap index 81efd92b..5c5da5ac 100644 --- a/test/gnosis/__snapshots__/GnoBlocklistVault.spec.ts.snap +++ b/test/gnosis/__snapshots__/GnoBlocklistVault.spec.ts.snap @@ -10,6 +10,6 @@ Object { exports[`GnoBlocklistVault mint osToken can mint from not blocked user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 173795, + "gasUsed": 176078, } `; diff --git a/test/gnosis/__snapshots__/GnoOwnMevEscrow.spec.ts.snap b/test/gnosis/__snapshots__/GnoOwnMevEscrow.spec.ts.snap index f406459c..83e41998 100644 --- a/test/gnosis/__snapshots__/GnoOwnMevEscrow.spec.ts.snap +++ b/test/gnosis/__snapshots__/GnoOwnMevEscrow.spec.ts.snap @@ -3,6 +3,6 @@ exports[`GnoOwnMevEscrow vault deployment gas 1`] = ` Object { "calldataByteLength": 719, - "gasUsed": 173612, + "gasUsed": 173636, } `; diff --git a/test/gnosis/__snapshots__/GnoPrivErc20Vault.spec.ts.snap b/test/gnosis/__snapshots__/GnoPrivErc20Vault.spec.ts.snap index 7a91bee1..a4d762ac 100644 --- a/test/gnosis/__snapshots__/GnoPrivErc20Vault.spec.ts.snap +++ b/test/gnosis/__snapshots__/GnoPrivErc20Vault.spec.ts.snap @@ -10,7 +10,7 @@ Object { exports[`GnoPrivErc20Vault mint osToken can mint from not whitelisted user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 174030, + "gasUsed": 176313, } `; diff --git a/test/gnosis/__snapshots__/GnoPrivVault.spec.ts.snap b/test/gnosis/__snapshots__/GnoPrivVault.spec.ts.snap index f34bcec9..1f65c799 100644 --- a/test/gnosis/__snapshots__/GnoPrivVault.spec.ts.snap +++ b/test/gnosis/__snapshots__/GnoPrivVault.spec.ts.snap @@ -10,6 +10,6 @@ Object { exports[`GnoPrivVault mint osToken can mint from not whitelisted user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 173820, + "gasUsed": 176103, } `; diff --git a/test/shared/fixtures.ts b/test/shared/fixtures.ts index f85aa8d0..b57fbe23 100644 --- a/test/shared/fixtures.ts +++ b/test/shared/fixtures.ts @@ -315,22 +315,23 @@ export const createOsTokenConfig = async function ( liqThresholdPercent: BigNumberish, liqBonusPercent: BigNumberish, ltvPercent: BigNumberish, - skipFork: boolean = false + liquidator: Wallet, + redeemer: Wallet ): Promise { const signer = await ethers.provider.getSigner() - if (MAINNET_FORK.enabled && !skipFork) { - const contract = OsTokenConfig__factory.connect(mainnetDeployment.OsTokenConfig, signer) - await transferOwnership(contract, owner) - return contract - } const factory = await ethers.getContractFactory('OsTokenConfig') - const contract = await factory.deploy(owner.address, { - redeemFromLtvPercent, - redeemToLtvPercent, - liqThresholdPercent, - liqBonusPercent, - ltvPercent, - }) + const contract = await factory.deploy( + owner.address, + { + redeemFromLtvPercent, + redeemToLtvPercent, + liqThresholdPercent, + liqBonusPercent, + ltvPercent, + }, + await liquidator.getAddress(), + await redeemer.getAddress() + ) return OsTokenConfig__factory.connect(await contract.getAddress(), signer) } @@ -691,7 +692,9 @@ export const ethVaultFixture = async function (): Promise { OSTOKEN_REDEEM_TO_LTV, OSTOKEN_LIQ_THRESHOLD, OSTOKEN_LIQ_BONUS, - OSTOKEN_LTV + OSTOKEN_LTV, + dao, + dao ) // 7. deploy depositDataRegistry diff --git a/test/shared/gnoFixtures.ts b/test/shared/gnoFixtures.ts index 50e28b20..d6cec307 100644 --- a/test/shared/gnoFixtures.ts +++ b/test/shared/gnoFixtures.ts @@ -483,7 +483,8 @@ export const gnoVaultFixture = async function (): Promise { OSTOKEN_LIQ_THRESHOLD, OSTOKEN_LIQ_BONUS, OSTOKEN_LTV, - true + dao, + dao ) // 7. deploy Balancer vault