diff --git a/abi/IEthBlocklistErc20Vault.json b/abi/IEthBlocklistErc20Vault.json index 4df347e..674a6bb 100644 --- a/abi/IEthBlocklistErc20Vault.json +++ b/abi/IEthBlocklistErc20Vault.json @@ -866,6 +866,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -876,7 +881,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1570,6 +1575,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1607,7 +1617,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthBlocklistVault.json b/abi/IEthBlocklistVault.json index 3cad0e6..b539776 100644 --- a/abi/IEthBlocklistVault.json +++ b/abi/IEthBlocklistVault.json @@ -723,6 +723,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -733,7 +738,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1273,6 +1278,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1310,7 +1320,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthErc20Vault.json b/abi/IEthErc20Vault.json index d41ef6a..45d7ca9 100644 --- a/abi/IEthErc20Vault.json +++ b/abi/IEthErc20Vault.json @@ -790,6 +790,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -800,7 +805,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1463,6 +1468,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1500,7 +1510,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthGenesisVault.json b/abi/IEthGenesisVault.json index e8832b9..c4bdb2a 100644 --- a/abi/IEthGenesisVault.json +++ b/abi/IEthGenesisVault.json @@ -710,6 +710,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -720,7 +725,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1253,6 +1258,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1290,7 +1300,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthPrivErc20Vault.json b/abi/IEthPrivErc20Vault.json index fb7abe9..8777378 100644 --- a/abi/IEthPrivErc20Vault.json +++ b/abi/IEthPrivErc20Vault.json @@ -834,6 +834,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -844,7 +849,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1520,6 +1525,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1557,7 +1567,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthPrivVault.json b/abi/IEthPrivVault.json index 2d63d4e..b621ebd 100644 --- a/abi/IEthPrivVault.json +++ b/abi/IEthPrivVault.json @@ -691,6 +691,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -701,7 +706,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1223,6 +1228,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1260,7 +1270,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/abi/IEthVault.json b/abi/IEthVault.json index f063a11..b0a3ea1 100644 --- a/abi/IEthVault.json +++ b/abi/IEthVault.json @@ -647,6 +647,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -657,7 +662,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], @@ -1166,6 +1171,11 @@ "name": "receiver", "type": "address" }, + { + "internalType": "uint256", + "name": "osTokenShares", + "type": "uint256" + }, { "internalType": "address", "name": "referrer", @@ -1203,7 +1213,7 @@ "outputs": [ { "internalType": "uint256", - "name": "osTokenShares", + "name": "", "type": "uint256" } ], diff --git a/contracts/interfaces/IEthErc20Vault.sol b/contracts/interfaces/IEthErc20Vault.sol index 55e1735..b9bdf59 100644 --- a/contracts/interfaces/IEthErc20Vault.sol +++ b/contracts/interfaces/IEthErc20Vault.sol @@ -58,24 +58,30 @@ interface IEthErc20Vault is /** * @notice Deposits assets to the vault and mints OsToken shares to the receiver * @param receiver The address to receive the OsToken + * @param osTokenShares The amount of OsToken shares to mint. + * If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount. * @param referrer The address of the referrer - * @return osTokenShares The amount of OsToken shares minted + * @return The amount of OsToken shares minted */ function depositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer - ) external payable returns (uint256 osTokenShares); + ) external payable returns (uint256); /** * @notice Updates the state, deposits assets to the vault and mints OsToken shares to the receiver * @param receiver The address to receive the OsToken + * @param osTokenShares The amount of OsToken shares to mint. + * If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount. * @param referrer The address of the referrer * @param harvestParams The parameters for the harvest - * @return osTokenShares The amount of OsToken shares minted + * @return The amount of OsToken shares minted */ function updateStateAndDepositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer, IKeeperRewards.HarvestParams calldata harvestParams - ) external payable returns (uint256 osTokenShares); + ) external payable returns (uint256); } diff --git a/contracts/interfaces/IEthVault.sol b/contracts/interfaces/IEthVault.sol index 74319f1..3b20189 100644 --- a/contracts/interfaces/IEthVault.sol +++ b/contracts/interfaces/IEthVault.sol @@ -52,24 +52,30 @@ interface IEthVault is /** * @notice Deposits assets to the vault and mints OsToken shares to the receiver * @param receiver The address to receive the OsToken + * @param osTokenShares The amount of OsToken shares to mint. + * If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount. * @param referrer The address of the referrer - * @return osTokenShares The amount of OsToken shares minted + * @return The amount of OsToken shares minted */ function depositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer - ) external payable returns (uint256 osTokenShares); + ) external payable returns (uint256); /** * @notice Updates the state, deposits assets to the vault and mints OsToken shares to the receiver * @param receiver The address to receive the OsToken + * @param osTokenShares The amount of OsToken shares to mint. + * If set to type(uint256).max, max OsToken shares will be minted based on the deposited amount. * @param referrer The address of the referrer * @param harvestParams The parameters for the harvest - * @return osTokenShares The amount of OsToken shares minted + * @return The amount of OsToken shares minted */ function updateStateAndDepositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer, IKeeperRewards.HarvestParams calldata harvestParams - ) external payable returns (uint256 osTokenShares); + ) external payable returns (uint256); } diff --git a/contracts/vaults/ethereum/EthErc20Vault.sol b/contracts/vaults/ethereum/EthErc20Vault.sol index b23c602..dfddfa9 100644 --- a/contracts/vaults/ethereum/EthErc20Vault.sol +++ b/contracts/vaults/ethereum/EthErc20Vault.sol @@ -97,21 +97,27 @@ contract EthErc20Vault is /// @inheritdoc IEthErc20Vault function depositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer - ) public payable override returns (uint256 osTokenShares) { + ) public payable override returns (uint256) { deposit(msg.sender, referrer); - osTokenShares = _calcMaxOsTokenShares(msg.value); + if (osTokenShares == type(uint256).max) { + // mint max OsToken shares based on the deposited amount + osTokenShares = _calcMaxOsTokenShares(msg.value); + } mintOsToken(receiver, osTokenShares, referrer); + return osTokenShares; } /// @inheritdoc IEthErc20Vault function updateStateAndDepositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer, IKeeperRewards.HarvestParams calldata harvestParams - ) external payable override returns (uint256 osTokenShares) { + ) external payable override returns (uint256) { updateState(harvestParams); - return depositAndMintOsToken(receiver, referrer); + return depositAndMintOsToken(receiver, osTokenShares, referrer); } /// @inheritdoc IERC20 diff --git a/contracts/vaults/ethereum/EthVault.sol b/contracts/vaults/ethereum/EthVault.sol index eee0e71..dc65a43 100644 --- a/contracts/vaults/ethereum/EthVault.sol +++ b/contracts/vaults/ethereum/EthVault.sol @@ -93,21 +93,27 @@ contract EthVault is /// @inheritdoc IEthVault function depositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer - ) public payable override returns (uint256 osTokenShares) { + ) public payable override returns (uint256) { deposit(msg.sender, referrer); - osTokenShares = _calcMaxOsTokenShares(msg.value); + if (osTokenShares == type(uint256).max) { + // mint max OsToken shares based on the deposited amount + osTokenShares = _calcMaxOsTokenShares(msg.value); + } mintOsToken(receiver, osTokenShares, referrer); + return osTokenShares; } /// @inheritdoc IEthVault function updateStateAndDepositAndMintOsToken( address receiver, + uint256 osTokenShares, address referrer, IKeeperRewards.HarvestParams calldata harvestParams - ) external payable override returns (uint256 osTokenShares) { + ) external payable override returns (uint256) { updateState(harvestParams); - return depositAndMintOsToken(receiver, referrer); + return depositAndMintOsToken(receiver, osTokenShares, referrer); } /// @inheritdoc IVaultEnterExit diff --git a/test/EthErc20Vault.spec.ts b/test/EthErc20Vault.spec.ts index 8ea5624..6efd2b1 100644 --- a/test/EthErc20Vault.spec.ts +++ b/test/EthErc20Vault.spec.ts @@ -20,7 +20,7 @@ import { ethVaultFixture, } from './shared/fixtures' import { expect } from './shared/expect' -import { ZERO_ADDRESS } from './shared/constants' +import { MAX_UINT256, ZERO_ADDRESS } from './shared/constants' import { collateralizeEthVault, getHarvestParams, @@ -41,7 +41,7 @@ describe('EthErc20Vault', () => { const feePercent = 1000 const metadataIpfsHash = 'bafkreidivzimqfqtoqxkrpge6bjyhlvxqs3rhe73owtmdulaxr5do5in7u' const referrer = '0x' + '1'.repeat(40) - let sender: Wallet, receiver: Wallet, admin: Signer, dao: Wallet + let sender: Wallet, receiver: Wallet, admin: Signer, dao: Wallet, other: Wallet let vault: EthErc20Vault, keeper: Keeper, validatorsRegistry: Contract, @@ -53,7 +53,7 @@ describe('EthErc20Vault', () => { osToken: OsToken beforeEach('deploy fixtures', async () => { - ;[dao, sender, receiver, admin] = await (ethers as any).getSigners() + ;[dao, sender, receiver, admin, other] = await (ethers as any).getSigners() const fixture = await loadFixture(ethVaultFixture) vault = await fixture.createEthErc20Vault(admin, { capacity, @@ -267,12 +267,13 @@ describe('EthErc20Vault', () => { expect(await vault.osTokenPositions(sender.address)).to.eq(0n) expect(await vault.getShares(sender.address)).to.eq(0n) + // max shares const config = await osTokenConfig.getConfig(await vault.getAddress()) let osTokenAssets = (assets * config.ltvPercent) / ethers.parseEther('1') - const osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) - const receipt = await vault + let osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) + let receipt = await vault .connect(sender) - .depositAndMintOsToken(receiver.address, ZERO_ADDRESS, { value: assets }) + .depositAndMintOsToken(receiver.address, MAX_UINT256, ZERO_ADDRESS, { value: assets }) if (MAINNET_FORK.enabled) { shares += 1n // rounding error @@ -290,6 +291,31 @@ describe('EthErc20Vault', () => { .to.emit(vault, 'OsTokenMinted') .withArgs(sender.address, receiver.address, osTokenAssets, osTokenShares, ZERO_ADDRESS) await snapshotGasCost(receipt) + + // mint osToken with half shares + osTokenAssets = assets / 2n + osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) + receipt = await vault + .connect(receiver) + .depositAndMintOsToken(other.address, osTokenShares, ZERO_ADDRESS, { value: assets }) + + if (MAINNET_FORK.enabled) { + osTokenAssets -= 1n // rounding error + } + + expect(await osToken.balanceOf(other.address)).to.eq(osTokenShares) + expect(await vault.osTokenPositions(receiver.address)).to.eq(osTokenShares) + expect(await vault.getShares(receiver.address)).to.eq(shares) + await expect(receipt) + .to.emit(vault, 'Deposited') + .withArgs(receiver.address, receiver.address, assets, shares, ZERO_ADDRESS) + await expect(receipt) + .to.emit(vault, 'Transfer') + .withArgs(ZERO_ADDRESS, receiver.address, shares) + await expect(receipt) + .to.emit(vault, 'OsTokenMinted') + .withArgs(receiver.address, other.address, osTokenAssets, osTokenShares, ZERO_ADDRESS) + await snapshotGasCost(receipt) }) it('can update state, deposit, and mint osToken in one transaction', async () => { @@ -328,9 +354,15 @@ describe('EthErc20Vault', () => { const osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) const receipt = await vault .connect(sender) - .updateStateAndDepositAndMintOsToken(receiver.address, ZERO_ADDRESS, harvestParams, { - value: assets, - }) + .updateStateAndDepositAndMintOsToken( + receiver.address, + MAX_UINT256, + ZERO_ADDRESS, + harvestParams, + { + value: assets, + } + ) let sharesAfter = await vault.convertToShares(assets) sharesAfter += 1n // rounding error diff --git a/test/EthVault.mint.spec.ts b/test/EthVault.mint.spec.ts index ca4e9ed..8ec8476 100644 --- a/test/EthVault.mint.spec.ts +++ b/test/EthVault.mint.spec.ts @@ -15,7 +15,7 @@ import { ThenArg } from '../helpers/types' import snapshotGasCost from './shared/snapshotGasCost' import { createUnknownVaultMock, ethVaultFixture } from './shared/fixtures' import { expect } from './shared/expect' -import { ONE_DAY, ZERO_ADDRESS } from './shared/constants' +import { MAX_UINT256, ONE_DAY, ZERO_ADDRESS } from './shared/constants' import { collateralizeEthVault, getHarvestParams, @@ -211,10 +211,12 @@ describe('EthVault - mint', () => { const config = await osTokenConfig.getConfig(await vault.getAddress()) let osTokenAssets = (assets * config.ltvPercent) / ethers.parseEther('1') - const osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) - const receipt = await vault + let osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) + + // mint max shares + let receipt = await vault .connect(other) - .depositAndMintOsToken(receiver.address, ZERO_ADDRESS, { value: assets }) + .depositAndMintOsToken(receiver.address, MAX_UINT256, ZERO_ADDRESS, { value: assets }) if (MAINNET_FORK.enabled) { osTokenAssets -= 1n // rounding error @@ -230,6 +232,28 @@ describe('EthVault - mint', () => { .to.emit(vault, 'OsTokenMinted') .withArgs(other.address, receiver.address, osTokenAssets, osTokenShares, ZERO_ADDRESS) await snapshotGasCost(receipt) + + // mint half shares + osTokenAssets = assets / 2n + osTokenShares = await osTokenVaultController.convertToShares(osTokenAssets) + receipt = await vault + .connect(sender) + .depositAndMintOsToken(other.address, osTokenShares, ZERO_ADDRESS, { value: assets }) + + if (MAINNET_FORK.enabled) { + osTokenAssets -= 1n // rounding error + } + + expect(await osToken.balanceOf(other.address)).to.eq(osTokenShares) + expect(await vault.osTokenPositions(sender.address)).to.eq(osTokenShares) + expect(await vault.getShares(sender.address)).to.eq(shares * 2n) + await expect(receipt) + .to.emit(vault, 'Deposited') + .withArgs(sender.address, sender.address, assets, shares, ZERO_ADDRESS) + await expect(receipt) + .to.emit(vault, 'OsTokenMinted') + .withArgs(sender.address, other.address, osTokenAssets, osTokenShares, ZERO_ADDRESS) + await snapshotGasCost(receipt) }) it('can update state, deposit, and mint osToken in one transaction', async () => { @@ -269,9 +293,15 @@ describe('EthVault - mint', () => { const receipt = await vault .connect(other) - .updateStateAndDepositAndMintOsToken(receiver.address, ZERO_ADDRESS, harvestParams, { - value: assets, - }) + .updateStateAndDepositAndMintOsToken( + receiver.address, + MAX_UINT256, + ZERO_ADDRESS, + harvestParams, + { + value: assets, + } + ) let sharesAfter = await vault.convertToShares(assets) sharesAfter += 1n // rounding error diff --git a/test/__snapshots__/DepositDataRegistry.spec.ts.snap b/test/__snapshots__/DepositDataRegistry.spec.ts.snap index 9876ff4..431e577 100644 --- a/test/__snapshots__/DepositDataRegistry.spec.ts.snap +++ b/test/__snapshots__/DepositDataRegistry.spec.ts.snap @@ -3,41 +3,41 @@ exports[`DepositDataRegistry deposit data manager update succeeds 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 63787, + "gasUsed": 63809, } `; exports[`DepositDataRegistry deposit data root update success 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 64551, + "gasUsed": 64573, } `; exports[`DepositDataRegistry migrate succeeds 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 164940, + "gasUsed": 165072, } `; exports[`DepositDataRegistry multiple validators succeeds 1`] = ` Object { "calldataByteLength": 3364, - "gasUsed": 688195, + "gasUsed": 688239, } `; exports[`DepositDataRegistry single validator can update state and register validator 1`] = ` Object { "calldataByteLength": 1636, - "gasUsed": 407205, + "gasUsed": 407293, } `; exports[`DepositDataRegistry single validator succeeds 1`] = ` Object { "calldataByteLength": 1156, - "gasUsed": 333821, + "gasUsed": 333865, } `; diff --git a/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap b/test/__snapshots__/EthBlocklistErc20Vault.spec.ts.snap index e633695..17a1435 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": 177634, + "gasUsed": 177711, } `; diff --git a/test/__snapshots__/EthBlocklistVault.spec.ts.snap b/test/__snapshots__/EthBlocklistVault.spec.ts.snap index 98abb51..6700a56 100644 --- a/test/__snapshots__/EthBlocklistVault.spec.ts.snap +++ b/test/__snapshots__/EthBlocklistVault.spec.ts.snap @@ -3,7 +3,7 @@ exports[`EthBlocklistVault deposit can be called by not blocked user 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 69045, + "gasUsed": 69012, } `; @@ -17,6 +17,6 @@ Object { exports[`EthBlocklistVault mint osToken can mint from not blocked user 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 177451, + "gasUsed": 177528, } `; diff --git a/test/__snapshots__/EthErc20Vault.spec.ts.snap b/test/__snapshots__/EthErc20Vault.spec.ts.snap index 87fc173..11d924a 100644 --- a/test/__snapshots__/EthErc20Vault.spec.ts.snap +++ b/test/__snapshots__/EthErc20Vault.spec.ts.snap @@ -2,15 +2,22 @@ exports[`EthErc20Vault can deposit and mint osToken in one transaction 1`] = ` Object { - "calldataByteLength": 68, - "gasUsed": 212573, + "calldataByteLength": 100, + "gasUsed": 212666, +} +`; + +exports[`EthErc20Vault can deposit and mint osToken in one transaction 2`] = ` +Object { + "calldataByteLength": 100, + "gasUsed": 174079, } `; exports[`EthErc20Vault can update state, deposit, and mint osToken in one transaction 1`] = ` Object { - "calldataByteLength": 260, - "gasUsed": 266104, + "calldataByteLength": 292, + "gasUsed": 266292, } `; @@ -31,7 +38,7 @@ Object { exports[`EthErc20Vault enter exit queue emits transfer event 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 96214, + "gasUsed": 96236, } `; diff --git a/test/__snapshots__/EthGenesisVault.spec.ts.snap b/test/__snapshots__/EthGenesisVault.spec.ts.snap index bcf1cbe..64dee6c 100644 --- a/test/__snapshots__/EthGenesisVault.spec.ts.snap +++ b/test/__snapshots__/EthGenesisVault.spec.ts.snap @@ -17,48 +17,48 @@ Object { exports[`EthGenesisVault pulls withdrawals on claim exited assets 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 77228, + "gasUsed": 77250, } `; exports[`EthGenesisVault pulls withdrawals on multiple validators registration 1`] = ` Object { "calldataByteLength": 3748, - "gasUsed": 652713, + "gasUsed": 652757, } `; exports[`EthGenesisVault pulls withdrawals on single validator registration 1`] = ` Object { "calldataByteLength": 1188, - "gasUsed": 312904, + "gasUsed": 312948, } `; exports[`EthGenesisVault update state deducts rewards on first state update 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 150235, + "gasUsed": 150279, } `; exports[`EthGenesisVault update state skips updating legacy with zero total assets 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 145804, + "gasUsed": 145848, } `; exports[`EthGenesisVault update state splits penalty between rewardEthToken and vault 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 119615, + "gasUsed": 119659, } `; exports[`EthGenesisVault update state splits reward between rewardEthToken and vault 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 167335, + "gasUsed": 167379, } `; diff --git a/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap b/test/__snapshots__/EthPrivErc20Vault.spec.ts.snap index c35725b..9d61942 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": 177659, + "gasUsed": 177736, } `; diff --git a/test/__snapshots__/EthPrivVault.spec.ts.snap b/test/__snapshots__/EthPrivVault.spec.ts.snap index ec940bf..2443017 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": 177476, + "gasUsed": 177553, } `; diff --git a/test/__snapshots__/EthVault.deposit.spec.ts.snap b/test/__snapshots__/EthVault.deposit.spec.ts.snap index 630f1d0..dc946fc 100644 --- a/test/__snapshots__/EthVault.deposit.spec.ts.snap +++ b/test/__snapshots__/EthVault.deposit.spec.ts.snap @@ -3,14 +3,14 @@ exports[`EthVault - deposit empty vault: no assets & no shares deposit 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 66728, + "gasUsed": 66695, } `; exports[`EthVault - deposit full vault: assets & shares deposit 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 66728, + "gasUsed": 66695, } `; @@ -24,6 +24,6 @@ Object { exports[`EthVault - deposit full vault: assets & shares update state and deposit 1`] = ` Object { "calldataByteLength": 260, - "gasUsed": 155301, + "gasUsed": 155330, } `; diff --git a/test/__snapshots__/EthVault.liquidate.spec.ts.snap b/test/__snapshots__/EthVault.liquidate.spec.ts.snap index 25845be..ce89ab9 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": 112425, + "gasUsed": 112447, } `; exports[`EthVault - liquidate can liquidate 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 112425, + "gasUsed": 112447, } `; diff --git a/test/__snapshots__/EthVault.mint.spec.ts.snap b/test/__snapshots__/EthVault.mint.spec.ts.snap index a1df8a3..66e515f 100644 --- a/test/__snapshots__/EthVault.mint.spec.ts.snap +++ b/test/__snapshots__/EthVault.mint.spec.ts.snap @@ -2,28 +2,35 @@ exports[`EthVault - mint can deposit and mint osToken in one transaction 1`] = ` Object { - "calldataByteLength": 68, - "gasUsed": 210457, + "calldataByteLength": 100, + "gasUsed": 210616, +} +`; + +exports[`EthVault - mint can deposit and mint osToken in one transaction 2`] = ` +Object { + "calldataByteLength": 100, + "gasUsed": 154902, } `; exports[`EthVault - mint can update state, deposit, and mint osToken in one transaction 1`] = ` Object { - "calldataByteLength": 260, - "gasUsed": 262099, + "calldataByteLength": 292, + "gasUsed": 262419, } `; exports[`EthVault - mint mints osTokens to the receiver 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 175230, + "gasUsed": 175307, } `; exports[`EthVault - mint updates position accumulated fee 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 120345, + "gasUsed": 120422, } `; diff --git a/test/__snapshots__/EthVault.multicall.spec.ts.snap b/test/__snapshots__/EthVault.multicall.spec.ts.snap index aaddd1d..ff805ce 100644 --- a/test/__snapshots__/EthVault.multicall.spec.ts.snap +++ b/test/__snapshots__/EthVault.multicall.spec.ts.snap @@ -3,13 +3,13 @@ exports[`EthVault - multicall can update state and queue for exit 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 168266, + "gasUsed": 168354, } `; exports[`EthVault - multicall can update state and queue for exit 2`] = ` Object { "calldataByteLength": 548, - "gasUsed": 109702, + "gasUsed": 109768, } `; diff --git a/test/__snapshots__/EthVault.redeem.spec.ts.snap b/test/__snapshots__/EthVault.redeem.spec.ts.snap index 32ac9a3..0985201 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": 126764, + "gasUsed": 126808, } `; exports[`EthVault - redeem osToken can redeem 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 126764, + "gasUsed": 126808, } `; diff --git a/test/__snapshots__/EthVault.register.spec.ts.snap b/test/__snapshots__/EthVault.register.spec.ts.snap index ea9ad39..ca55b8b 100644 --- a/test/__snapshots__/EthVault.register.spec.ts.snap +++ b/test/__snapshots__/EthVault.register.spec.ts.snap @@ -3,13 +3,13 @@ exports[`EthVault - register multiple validators succeeds from validators manager 1`] = ` Object { "calldataByteLength": 2596, - "gasUsed": 631228, + "gasUsed": 631250, } `; exports[`EthVault - register single validator succeeds from validators manager 1`] = ` Object { "calldataByteLength": 1028, - "gasUsed": 298416, + "gasUsed": 298438, } `; diff --git a/test/__snapshots__/EthVault.settings.spec.ts.snap b/test/__snapshots__/EthVault.settings.spec.ts.snap index 3bc2250..1537147 100644 --- a/test/__snapshots__/EthVault.settings.spec.ts.snap +++ b/test/__snapshots__/EthVault.settings.spec.ts.snap @@ -10,13 +10,13 @@ Object { exports[`EthVault - settings metadata IPFS hash only admin can update 1`] = ` Object { "calldataByteLength": 132, - "gasUsed": 32623, + "gasUsed": 32645, } `; exports[`EthVault - settings validators manager can be updated by admin 1`] = ` Object { "calldataByteLength": 36, - "gasUsed": 52775, + "gasUsed": 52797, } `; diff --git a/test/__snapshots__/EthVault.state.spec.ts.snap b/test/__snapshots__/EthVault.state.spec.ts.snap index d7e4a7e..2a58723 100644 --- a/test/__snapshots__/EthVault.state.spec.ts.snap +++ b/test/__snapshots__/EthVault.state.spec.ts.snap @@ -3,21 +3,21 @@ exports[`EthVault - state allocates fee to recipient when delta is above zero 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 117478, + "gasUsed": 117544, } `; exports[`EthVault - state applies penalty when delta is below zero 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 117275, + "gasUsed": 117341, } `; exports[`EthVault - state splits penalty between exiting assets and staking assets 1`] = ` Object { "calldataByteLength": 196, - "gasUsed": 107076, + "gasUsed": 107120, } `; diff --git a/test/__snapshots__/EthVault.token.spec.ts.snap b/test/__snapshots__/EthVault.token.spec.ts.snap index 688acb4..2343d80 100644 --- a/test/__snapshots__/EthVault.token.spec.ts.snap +++ b/test/__snapshots__/EthVault.token.spec.ts.snap @@ -3,14 +3,14 @@ exports[`EthVault - token approve when the sender has enough balance when the spender had an approved amount approves the requested amount and replaces the previous one 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 33688, + "gasUsed": 33710, } `; exports[`EthVault - token approve when the sender has enough balance when there was no approved amount before approves the requested amount 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 50788, + "gasUsed": 50810, } `; @@ -24,14 +24,14 @@ Object { exports[`EthVault - token transfer from when the spender has enough allowance when the token owner has enough balance transfers the requested amount 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 54703, + "gasUsed": 54725, } `; exports[`EthVault - token transfer from when the spender has unlimited allowance does not decrease the spender allowance 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 61179, + "gasUsed": 61201, } `; diff --git a/test/__snapshots__/EthVault.upgrade.spec.ts.snap b/test/__snapshots__/EthVault.upgrade.spec.ts.snap index d76e3bd..6138e74 100644 --- a/test/__snapshots__/EthVault.upgrade.spec.ts.snap +++ b/test/__snapshots__/EthVault.upgrade.spec.ts.snap @@ -3,41 +3,41 @@ exports[`EthVault - upgrade does not modify the state variables 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 186999, + "gasUsed": 187131, } `; exports[`EthVault - upgrade does not modify the state variables 2`] = ` Object { "calldataByteLength": 100, - "gasUsed": 187795, + "gasUsed": 187927, } `; exports[`EthVault - upgrade does not modify the state variables 3`] = ` Object { "calldataByteLength": 100, - "gasUsed": 187263, + "gasUsed": 187395, } `; exports[`EthVault - upgrade does not modify the state variables 4`] = ` Object { "calldataByteLength": 100, - "gasUsed": 188047, + "gasUsed": 188179, } `; exports[`EthVault - upgrade does not modify the state variables 5`] = ` Object { "calldataByteLength": 100, - "gasUsed": 187089, + "gasUsed": 187221, } `; exports[`EthVault - upgrade works with valid call data 1`] = ` Object { "calldataByteLength": 132, - "gasUsed": 76089, + "gasUsed": 76221, } `; diff --git a/test/__snapshots__/EthVault.whitelist.spec.ts.snap b/test/__snapshots__/EthVault.whitelist.spec.ts.snap index 1c38af0..809d2fe 100644 --- a/test/__snapshots__/EthVault.whitelist.spec.ts.snap +++ b/test/__snapshots__/EthVault.whitelist.spec.ts.snap @@ -3,7 +3,7 @@ exports[`EthVault - whitelist deposit can be called by whitelisted user 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 69033, + "gasUsed": 69000, } `; @@ -24,13 +24,13 @@ Object { exports[`EthVault - whitelist whitelist can be updated by whitelister 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 53105, + "gasUsed": 53127, } `; exports[`EthVault - whitelist whitelist can be updated by whitelister 2`] = ` Object { "calldataByteLength": 68, - "gasUsed": 31193, + "gasUsed": 31215, } `; diff --git a/test/__snapshots__/EthVault.withdraw.spec.ts.snap b/test/__snapshots__/EthVault.withdraw.spec.ts.snap index 990791d..06fc083 100644 --- a/test/__snapshots__/EthVault.withdraw.spec.ts.snap +++ b/test/__snapshots__/EthVault.withdraw.spec.ts.snap @@ -3,35 +3,35 @@ exports[`EthVault - withdraw claim exited assets for single user in multiple checkpoints in multiple transactions 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 75958, + "gasUsed": 75980, } `; exports[`EthVault - withdraw claim exited assets for single user in multiple checkpoints in multiple transactions 2`] = ` Object { "calldataByteLength": 100, - "gasUsed": 48789, + "gasUsed": 48807, } `; exports[`EthVault - withdraw claim exited assets for single user in multiple checkpoints in single transaction 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 51394, + "gasUsed": 51416, } `; exports[`EthVault - withdraw claim exited assets for single user in single checkpoint 1`] = ` Object { "calldataByteLength": 100, - "gasUsed": 48789, + "gasUsed": 48807, } `; exports[`EthVault - withdraw enter exit queue locks assets for the time of exit 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 77311, + "gasUsed": 77333, } `; diff --git a/test/__snapshots__/EthVaultFactory.spec.ts.snap b/test/__snapshots__/EthVaultFactory.spec.ts.snap index 4e61202..363e14e 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": 599715, + "gasUsed": 599759, } `; exports[`EthVaultFactory EthErc20Vault private vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 450896, + "gasUsed": 450940, } `; exports[`EthVaultFactory EthErc20Vault public vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 575795, + "gasUsed": 575839, } `; exports[`EthVaultFactory EthErc20Vault public vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 516, - "gasUsed": 426976, + "gasUsed": 427020, } `; exports[`EthVaultFactory EthVault private vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 525593, + "gasUsed": 525637, } `; exports[`EthVaultFactory EthVault private vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 376774, + "gasUsed": 376818, } `; exports[`EthVaultFactory EthVault public vault deployment with own escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 501673, + "gasUsed": 501717, } `; exports[`EthVaultFactory EthVault public vault deployment with shared escrow gas 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 352854, + "gasUsed": 352898, } `; diff --git a/test/__snapshots__/KeeperRewards.spec.ts.snap b/test/__snapshots__/KeeperRewards.spec.ts.snap index 547a7cc..32dec20 100644 --- a/test/__snapshots__/KeeperRewards.spec.ts.snap +++ b/test/__snapshots__/KeeperRewards.spec.ts.snap @@ -3,42 +3,42 @@ exports[`KeeperRewards harvest (own escrow) succeeds for latest rewards root 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 111324, + "gasUsed": 111368, } `; exports[`KeeperRewards harvest (own escrow) succeeds for previous rewards root 1`] = ` Object { "calldataByteLength": 324, - "gasUsed": 113478, + "gasUsed": 113522, } `; exports[`KeeperRewards harvest (own escrow) succeeds for previous rewards root 2`] = ` Object { "calldataByteLength": 196, - "gasUsed": 74254, + "gasUsed": 74298, } `; exports[`KeeperRewards harvest (shared escrow) succeeds for latest rewards root 1`] = ` Object { "calldataByteLength": 292, - "gasUsed": 143880, + "gasUsed": 143946, } `; exports[`KeeperRewards harvest (shared escrow) succeeds for previous rewards root 1`] = ` Object { "calldataByteLength": 292, - "gasUsed": 146034, + "gasUsed": 146100, } `; exports[`KeeperRewards harvest (shared escrow) succeeds for previous rewards root 2`] = ` Object { "calldataByteLength": 196, - "gasUsed": 90399, + "gasUsed": 90465, } `; diff --git a/test/__snapshots__/KeeperValidators.spec.ts.snap b/test/__snapshots__/KeeperValidators.spec.ts.snap index e5f8401..cf0588f 100644 --- a/test/__snapshots__/KeeperValidators.spec.ts.snap +++ b/test/__snapshots__/KeeperValidators.spec.ts.snap @@ -3,28 +3,28 @@ exports[`KeeperValidators register multiple validators succeeds 1`] = ` Object { "calldataByteLength": 3748, - "gasUsed": 694600, + "gasUsed": 694644, } `; exports[`KeeperValidators register multiple validators succeeds 2`] = ` Object { "calldataByteLength": 3748, - "gasUsed": 602832, + "gasUsed": 602876, } `; exports[`KeeperValidators register single validator succeeds 1`] = ` Object { "calldataByteLength": 1540, - "gasUsed": 340247, + "gasUsed": 340291, } `; exports[`KeeperValidators register single validator succeeds 2`] = ` Object { "calldataByteLength": 1540, - "gasUsed": 286590, + "gasUsed": 286634, } `; diff --git a/test/__snapshots__/RewardSplitter.spec.ts.snap b/test/__snapshots__/RewardSplitter.spec.ts.snap index 254e5b1..7a0ee45 100644 --- a/test/__snapshots__/RewardSplitter.spec.ts.snap +++ b/test/__snapshots__/RewardSplitter.spec.ts.snap @@ -3,7 +3,7 @@ exports[`RewardSplitter decrease shares owner can decrease shares 1`] = ` Object { "calldataByteLength": 68, - "gasUsed": 67063, + "gasUsed": 67085, } `; @@ -17,7 +17,7 @@ Object { exports[`RewardSplitter sync rewards anyone can sync rewards 1`] = ` Object { "calldataByteLength": 4, - "gasUsed": 73088, + "gasUsed": 73110, } `; @@ -31,6 +31,6 @@ Object { exports[`RewardSplitter withdraw rewards can enter exit queue with multicall 1`] = ` Object { "calldataByteLength": 612, - "gasUsed": 170800, + "gasUsed": 170888, } `; diff --git a/test/__snapshots__/VaultsRegistry.spec.ts.snap b/test/__snapshots__/VaultsRegistry.spec.ts.snap index d47fa85..bd00db7 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": 352854, + "gasUsed": 352898, } `;