Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tsudmi committed Apr 29, 2024
1 parent a631190 commit 919b273
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 57 deletions.
5 changes: 0 additions & 5 deletions abi/Errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
"name": "DeadlineExpired",
"type": "error"
},
{
"inputs": [],
"name": "EigenInvalidReallocations",
"type": "error"
},
{
"inputs": [],
"name": "EigenInvalidWithdrawal",
Expand Down
6 changes: 0 additions & 6 deletions chiado-config.json

This file was deleted.

4 changes: 2 additions & 2 deletions contracts/interfaces/IGnoPoolEscrow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/interfaces/IVaultOsToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ 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
*/
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
Expand Down
1 change: 0 additions & 1 deletion contracts/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ library Errors {
error ExitRequestNotProcessed();
error ValueNotChanged();
error EigenInvalidWithdrawal();
error EigenInvalidReallocations();
error InvalidEigenQueuedWithdrawals();
error InvalidWithdrawalCredentials();
error EigenPodNotFound();
Expand Down
8 changes: 8 additions & 0 deletions test/EthVault.liquidate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
8 changes: 8 additions & 0 deletions test/EthVault.redeem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object {
exports[`EthBlocklistErc20Vault mint osToken can mint from not blocked user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 174049,
"gasUsed": 176332,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/EthBlocklistVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Object {
exports[`EthBlocklistVault mint osToken can mint from not blocked user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 173839,
"gasUsed": 176122,
}
`;
2 changes: 1 addition & 1 deletion test/__snapshots__/EthGenesisVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
exports[`EthGenesisVault migrate migrates from rewardEthToken 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 79584,
"gasUsed": 79583,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/EthPrivErc20Vault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object {
exports[`EthPrivErc20Vault mint osToken can mint from whitelisted user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 174074,
"gasUsed": 176357,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/EthPrivVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
exports[`EthPrivVault mint osToken can mint from not whitelisted user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 173864,
"gasUsed": 176147,
}
`;
4 changes: 2 additions & 2 deletions test/__snapshots__/EthVault.liquidate.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
`;
4 changes: 2 additions & 2 deletions test/__snapshots__/EthVault.mint.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
`;
4 changes: 2 additions & 2 deletions test/__snapshots__/EthVault.redeem.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
`;
16 changes: 8 additions & 8 deletions test/__snapshots__/EthVaultFactory.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
`;
2 changes: 1 addition & 1 deletion test/__snapshots__/OsTokenConfig.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
exports[`OsTokenConfig owner can update config 1`] = `
Object {
"calldataByteLength": 164,
"gasUsed": 32418,
"gasUsed": 32520,
}
`;
2 changes: 1 addition & 1 deletion test/__snapshots__/VaultsRegistry.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`VaultsRegistry factory can add vault 1`] = `
Object {
"calldataByteLength": 324,
"gasUsed": 330338,
"gasUsed": 330337,
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
exports[`GnoBlocklistErc20Vault mint osToken can mint from not blocked user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 174005,
"gasUsed": 176288,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/gnosis/__snapshots__/GnoBlocklistVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Object {
exports[`GnoBlocklistVault mint osToken can mint from not blocked user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 173795,
"gasUsed": 176078,
}
`;
2 changes: 1 addition & 1 deletion test/gnosis/__snapshots__/GnoOwnMevEscrow.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
exports[`GnoOwnMevEscrow vault deployment gas 1`] = `
Object {
"calldataByteLength": 719,
"gasUsed": 173612,
"gasUsed": 173636,
}
`;
2 changes: 1 addition & 1 deletion test/gnosis/__snapshots__/GnoPrivErc20Vault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object {
exports[`GnoPrivErc20Vault mint osToken can mint from not whitelisted user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 174030,
"gasUsed": 176313,
}
`;

Expand Down
2 changes: 1 addition & 1 deletion test/gnosis/__snapshots__/GnoPrivVault.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Object {
exports[`GnoPrivVault mint osToken can mint from not whitelisted user 1`] = `
Object {
"calldataByteLength": 100,
"gasUsed": 173820,
"gasUsed": 176103,
}
`;
31 changes: 17 additions & 14 deletions test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,23 @@ export const createOsTokenConfig = async function (
liqThresholdPercent: BigNumberish,
liqBonusPercent: BigNumberish,
ltvPercent: BigNumberish,
skipFork: boolean = false
liquidator: Wallet,
redeemer: Wallet
): Promise<OsTokenConfig> {
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)
}

Expand Down Expand Up @@ -691,7 +692,9 @@ export const ethVaultFixture = async function (): Promise<EthVaultFixture> {
OSTOKEN_REDEEM_TO_LTV,
OSTOKEN_LIQ_THRESHOLD,
OSTOKEN_LIQ_BONUS,
OSTOKEN_LTV
OSTOKEN_LTV,
dao,
dao
)

// 7. deploy depositDataRegistry
Expand Down
3 changes: 2 additions & 1 deletion test/shared/gnoFixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ export const gnoVaultFixture = async function (): Promise<GnoVaultFixture> {
OSTOKEN_LIQ_THRESHOLD,
OSTOKEN_LIQ_BONUS,
OSTOKEN_LTV,
true
dao,
dao
)

// 7. deploy Balancer vault
Expand Down

0 comments on commit 919b273

Please sign in to comment.