From fccf5de5f6d5ac3074cd379cb62852f14ece79ad Mon Sep 17 00:00:00 2001 From: pmckelvy1 Date: Sat, 7 Oct 2023 11:58:30 -0400 Subject: [PATCH] get gas measurements, fix ftoken/ctoken vault gas. (#960) Co-authored-by: Taylor Brent --- .../assets/compoundv2/CTokenWrapper.sol | 4 +- .../plugins/assets/compoundv2/ICToken.sol | 2 +- contracts/plugins/mocks/CTokenWrapperMock.sol | 4 +- contracts/plugins/mocks/ComptrollerMock.sol | 2 +- .../1-tmp-assets-collateral.json | 24 +- scripts/deploy.ts | 1 + .../phase2-assets/2_deploy_collateral.ts | 236 -------------- .../deploy_compound_v2_collateral.ts | 293 ++++++++++++++++++ test/integration/CTokenVaultGas.test.ts | 235 ++++++++++++++ .../__snapshots__/CTokenVaultGas.test.ts.snap | 25 ++ test/integration/fixtures.ts | 2 +- .../AaveV3FiatCollateral.test.ts.snap | 6 +- .../aave/ATokenFiatCollateral.test.ts | 7 + .../ATokenFiatCollateral.test.ts.snap | 14 +- .../AnkrEthCollateralTestSuite.test.ts.snap | 4 + .../CBETHCollateral.test.ts.snap | 4 + .../individual-collateral/collateralTests.ts | 10 + .../compoundv2/CTokenFiatCollateral.test.ts | 7 + .../CTokenFiatCollateral.test.ts.snap | 20 +- .../__snapshots__/CometTestSuite.test.ts.snap | 4 + .../curve/collateralTests.ts | 12 + .../CrvStableMetapoolSuite.test.ts.snap | 4 + ...StableRTokenMetapoolTestSuite.test.ts.snap | 4 + .../CrvStableTestSuite.test.ts.snap | 4 + .../CvxStableMetapoolSuite.test.ts.snap | 4 + ...StableRTokenMetapoolTestSuite.test.ts.snap | 4 + .../CvxStableTestSuite.test.ts.snap | 4 + .../SDaiCollateralTestSuite.test.ts.snap | 8 +- .../FTokenFiatCollateral.test.ts.snap | 84 +++-- .../SFrxEthTestSuite.test.ts.snap | 4 + .../LidoStakedEthTestSuite.test.ts.snap | 4 + .../MorphoAAVEFiatCollateral.test.ts.snap | 12 + .../MorphoAAVENonFiatCollateral.test.ts.snap | 8 + ...AAVESelfReferentialCollateral.test.ts.snap | 4 + .../RethCollateralTestSuite.test.ts.snap | 4 + .../StargateETHTestSuite.test.ts.snap | 8 + 36 files changed, 773 insertions(+), 303 deletions(-) create mode 100644 scripts/deployment/phase2-assets/collaterals/deploy_compound_v2_collateral.ts create mode 100644 test/integration/CTokenVaultGas.test.ts create mode 100644 test/integration/__snapshots__/CTokenVaultGas.test.ts.snap diff --git a/contracts/plugins/assets/compoundv2/CTokenWrapper.sol b/contracts/plugins/assets/compoundv2/CTokenWrapper.sol index 534de316a0..286787d42a 100644 --- a/contracts/plugins/assets/compoundv2/CTokenWrapper.sol +++ b/contracts/plugins/assets/compoundv2/CTokenWrapper.sol @@ -35,7 +35,9 @@ contract CTokenWrapper is RewardableERC20Wrapper { // === Overrides === function _claimAssetRewards() internal virtual override { - comptroller.claimComp(address(this)); + address[] memory cTokens = new address[](1); + cTokens[0] = address(underlying); + comptroller.claimComp(address(this), cTokens); } // No overrides of _deposit()/_withdraw() necessary: no staking required diff --git a/contracts/plugins/assets/compoundv2/ICToken.sol b/contracts/plugins/assets/compoundv2/ICToken.sol index 384ba84980..9dafd86c80 100644 --- a/contracts/plugins/assets/compoundv2/ICToken.sol +++ b/contracts/plugins/assets/compoundv2/ICToken.sol @@ -35,7 +35,7 @@ interface ICToken is IERC20Metadata { interface IComptroller { /// Claim comp for an account, to an account - function claimComp(address account) external; + function claimComp(address account, address[] memory cTokens) external; /// @return The address for COMP token function getCompAddress() external view returns (address); diff --git a/contracts/plugins/mocks/CTokenWrapperMock.sol b/contracts/plugins/mocks/CTokenWrapperMock.sol index 7ada69cb2c..c0cd0922a6 100644 --- a/contracts/plugins/mocks/CTokenWrapperMock.sol +++ b/contracts/plugins/mocks/CTokenWrapperMock.sol @@ -42,7 +42,9 @@ contract CTokenWrapperMock is ERC20Mock, IRewardable { revert("reverting claim rewards"); } uint256 oldBal = comp.balanceOf(msg.sender); - comptroller.claimComp(msg.sender); + address[] memory cTokens = new address[](1); + cTokens[0] = address(underlying); + comptroller.claimComp(msg.sender, cTokens); emit RewardsClaimed(IERC20(address(comp)), comp.balanceOf(msg.sender) - oldBal); } diff --git a/contracts/plugins/mocks/ComptrollerMock.sol b/contracts/plugins/mocks/ComptrollerMock.sol index 8e0d128508..9f95726479 100644 --- a/contracts/plugins/mocks/ComptrollerMock.sol +++ b/contracts/plugins/mocks/ComptrollerMock.sol @@ -19,7 +19,7 @@ contract ComptrollerMock is IComptroller { compBalances[recipient] = amount; } - function claimComp(address holder) external { + function claimComp(address holder, address[] memory) external { // Mint amount and update internal balances if (address(compToken) != address(0)) { uint256 amount = compBalances[holder]; diff --git a/scripts/addresses/mainnet-3.0.0/1-tmp-assets-collateral.json b/scripts/addresses/mainnet-3.0.0/1-tmp-assets-collateral.json index 7cb86310ed..d03e354462 100644 --- a/scripts/addresses/mainnet-3.0.0/1-tmp-assets-collateral.json +++ b/scripts/addresses/mainnet-3.0.0/1-tmp-assets-collateral.json @@ -17,12 +17,12 @@ "aUSDT": "0xe39188ddd4eb27d1d25f5f58cc6a5fd9228eedef", "aBUSD": "0xeB1A036E83aD95f0a28d0c8E2F20bf7f1B299F05", "aUSDP": "0x0d61Ce1801A460eB683b5ed1b6C7965d31b769Fd", - "cDAI": "0x440A634DdcFb890BCF8b0Bf07Ef2AaBB37dd5F8C", - "cUSDC": "0x50a9d529EA175CdE72525Eaa809f5C3c47dAA1bB", - "cUSDT": "0x5757fF814da66a2B4f9D11d48570d742e246CfD9", - "cUSDP": "0x99bD63BF7e2a69822cD73A82d42cF4b5501e5E50", - "cWBTC": "0x688c95461d611Ecfc423A8c87caCE163C6B40384", - "cETH": "0x357d4dB0c2179886334cC33B8528048F7E1D3Fe3", + "cDAI": "0x33A8d92B2BE84755441C2b6e39715c4b8938242c", + "cUSDC": "0x073F98792ef4c00bB5f11B1F64f13cB25Cde0d8D", + "cUSDT": "0x0EEa20c426EcE7D3dA5b73946bb1626697aA7c59", + "cUSDP": "0xA7eCF508CdF5a88ae93b899DE4fcACcB43112Ce8", + "cWBTC": "0xa570BF93FC51406809dBf52aB898913541C91C20", + "cETH": "0xeC12e8412a7AE4598d754f4016D487c269719856", "WBTC": "0x87A959e0377C68A50b08a91ae5ab3aFA7F41ACA4", "WETH": "0x6B87142C7e6cA80aa3E6ead0351673C45c8990e3", "EURT": "0xEBD07CE38e2f46031c982136012472A4D24AE070", @@ -65,12 +65,12 @@ "aUSDT": "0x21fe646D1Ed0733336F2D4d9b2FE67790a6099D9", "aBUSD": "0xe639d53Aa860757D7fe9cD4ebF9C8b92b8DedE7D", "aUSDP": "0x80A574cC2B369dc496af6655f57a16a4f180BfAF", - "cDAI": "0x3043be171e846c33D5f06864Cc045d9Fc799aF52", - "cUSDC": "0xf579F9885f1AEa0d3F8bE0F18AfED28c92a43022", - "cUSDT": "0x4Be33630F92661afD646081BC29079A38b879aA0", - "cUSDP": "0xF69c995129CC16d0F577C303091a400cC1879fFa", - "cWBTC": "0xF2A309bc36A504c772B416a4950d5d0021219745", - "cETH": "0xbF6E8F64547Bdec55bc3FBb0664722465FCC2F0F", + "cDAI": "0xD048934408bb0e39F23c7ff5C1ac5F773D16D2df", + "cUSDC": "0x1c21E28F6cd7C4Be734cb60f9c6451484803924d", + "cUSDT": "0xD971Fd59e90E836eCF2b8adE76374102025084A1", + "cUSDP": "0xbe7B053E820c5FBe70a0f075DA0C931aD8816e4F", + "cWBTC": "0xb120c3429900DDF665b34882d7685e39BB01897B", + "cETH": "0xd0cb758e918ac6973a2959343ECa4F333d8d25B1", "WBTC": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", "WETH": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "EURT": "0xC581b735A1688071A1746c968e0798D642EDE491", diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 12e104aeed..db067c3362 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -47,6 +47,7 @@ async function main() { 'phase2-assets/assets/deploy_crv.ts', 'phase2-assets/assets/deploy_cvx.ts', 'phase2-assets/2_deploy_collateral.ts', + 'phase2-assets/collaterals/deploy_compound_v2_collateral.ts', 'phase2-assets/collaterals/deploy_lido_wsteth_collateral.ts', 'phase2-assets/collaterals/deploy_rocket_pool_reth_collateral.ts', 'phase2-assets/collaterals/deploy_flux_finance_collateral.ts', diff --git a/scripts/deployment/phase2-assets/2_deploy_collateral.ts b/scripts/deployment/phase2-assets/2_deploy_collateral.ts index b232dc5ed1..cd8fdaa334 100644 --- a/scripts/deployment/phase2-assets/2_deploy_collateral.ts +++ b/scripts/deployment/phase2-assets/2_deploy_collateral.ts @@ -445,242 +445,6 @@ async function main() { const btcOracleError = fp('0.005') // 0.5% const combinedBTCWBTCError = combinedError(wbtcOracleError, btcOracleError) - /*** Compound V2 not available in Base L2s */ - if (!baseL2Chains.includes(hre.network.name)) { - /******** Deploy CToken Fiat Collateral - cDAI **************************/ - const CTokenFactory = await ethers.getContractFactory('CTokenWrapper') - const cDai = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cDAI!) - - const cDaiVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cDAI!, - `${await cDai.name()} Vault`, - `${await cDai.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cDaiVault.deployed() - - console.log( - `Deployed Vault for cDAI on ${hre.network.name} (${chainId}): ${cDaiVault.address} ` - ) - - const { collateral: cDaiCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { - priceTimeout: priceTimeout.toString(), - priceFeed: networkConfig[chainId].chainlinkFeeds.DAI, - oracleError: fp('0.0025').toString(), // 0.25% - cToken: cDaiVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr - targetName: hre.ethers.utils.formatBytes32String('USD'), - defaultThreshold: fp('0.0125').toString(), // 1.25% - delayUntilDefault: bn('86400').toString(), // 24h - revenueHiding: revenueHiding.toString(), - }) - collateral = await ethers.getContractAt('ICollateral', cDaiCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cDAI = cDaiCollateral - assetCollDeployments.erc20s.cDAI = cDaiVault.address - deployedCollateral.push(cDaiCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - - /******** Deploy CToken Fiat Collateral - cUSDC **************************/ - const cUsdc = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDC!) - - const cUsdcVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cUSDC!, - `${await cUsdc.name()} Vault`, - `${await cUsdc.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cUsdcVault.deployed() - - console.log( - `Deployed Vault for cUSDC on ${hre.network.name} (${chainId}): ${cUsdcVault.address} ` - ) - - const { collateral: cUsdcCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { - priceTimeout: priceTimeout.toString(), - priceFeed: networkConfig[chainId].chainlinkFeeds.USDC, - oracleError: fp('0.0025').toString(), // 0.25% - cToken: cUsdcVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr - targetName: hre.ethers.utils.formatBytes32String('USD'), - defaultThreshold: fp('0.0125').toString(), // 1.25% - delayUntilDefault: bn('86400').toString(), // 24h - revenueHiding: revenueHiding.toString(), - }) - collateral = await ethers.getContractAt('ICollateral', cUsdcCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cUSDC = cUsdcCollateral - assetCollDeployments.erc20s.cUSDC = cUsdcVault.address - deployedCollateral.push(cUsdcCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - - /******** Deploy CToken Fiat Collateral - cUSDT **************************/ - const cUsdt = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDT!) - - const cUsdtVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cUSDT!, - `${await cUsdt.name()} Vault`, - `${await cUsdt.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cUsdtVault.deployed() - - console.log( - `Deployed Vault for cUSDT on ${hre.network.name} (${chainId}): ${cUsdtVault.address} ` - ) - - const { collateral: cUsdtCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { - priceTimeout: priceTimeout.toString(), - priceFeed: networkConfig[chainId].chainlinkFeeds.USDT, - oracleError: fp('0.0025').toString(), // 0.25% - cToken: cUsdtVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr - targetName: hre.ethers.utils.formatBytes32String('USD'), - defaultThreshold: fp('0.0125').toString(), // 1.25% - delayUntilDefault: bn('86400').toString(), // 24h - revenueHiding: revenueHiding.toString(), - }) - collateral = await ethers.getContractAt('ICollateral', cUsdtCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cUSDT = cUsdtCollateral - assetCollDeployments.erc20s.cUSDT = cUsdtVault.address - deployedCollateral.push(cUsdtCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - - /******** Deploy CToken Fiat Collateral - cUSDP **************************/ - const cUsdp = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDP!) - - const cUsdpVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cUSDP!, - `${await cUsdp.name()} Vault`, - `${await cUsdp.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cUsdpVault.deployed() - - console.log( - `Deployed Vault for cUSDP on ${hre.network.name} (${chainId}): ${cUsdpVault.address} ` - ) - - const { collateral: cUsdpCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { - priceTimeout: priceTimeout.toString(), - priceFeed: networkConfig[chainId].chainlinkFeeds.USDP, - oracleError: fp('0.01').toString(), // 1% - cToken: cUsdpVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr - targetName: hre.ethers.utils.formatBytes32String('USD'), - defaultThreshold: fp('0.02').toString(), // 2% - delayUntilDefault: bn('86400').toString(), // 24h - revenueHiding: revenueHiding.toString(), - }) - collateral = await ethers.getContractAt('ICollateral', cUsdpCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cUSDP = cUsdpCollateral - assetCollDeployments.erc20s.cUSDP = cUsdpVault.address - deployedCollateral.push(cUsdpCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - - /******** Deploy CToken Non-Fiat Collateral - cWBTC **************************/ - const cWBTC = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cWBTC!) - - const cWBTCVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cWBTC!, - `${await cWBTC.name()} Vault`, - `${await cWBTC.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cWBTCVault.deployed() - - console.log( - `Deployed Vault for cWBTC on ${hre.network.name} (${chainId}): ${cWBTCVault.address} ` - ) - - const { collateral: cWBTCCollateral } = await hre.run('deploy-ctoken-nonfiat-collateral', { - priceTimeout: priceTimeout.toString(), - referenceUnitFeed: networkConfig[chainId].chainlinkFeeds.WBTC, - targetUnitFeed: networkConfig[chainId].chainlinkFeeds.BTC, - combinedOracleError: combinedBTCWBTCError.toString(), - cToken: cWBTCVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr - targetUnitOracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr - targetName: hre.ethers.utils.formatBytes32String('BTC'), - defaultThreshold: fp('0.01').add(combinedBTCWBTCError).toString(), // ~3.5% - delayUntilDefault: bn('86400').toString(), // 24h - revenueHiding: revenueHiding.toString(), - }) - collateral = await ethers.getContractAt('ICollateral', cWBTCCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cWBTC = cWBTCCollateral - assetCollDeployments.erc20s.cWBTC = cWBTCVault.address - deployedCollateral.push(cWBTCCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - - /******** Deploy CToken Self-Referential Collateral - cETH **************************/ - const cETH = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cETH!) - - const cETHVault = await CTokenFactory.deploy( - networkConfig[chainId].tokens.cETH!, - `${await cETH.name()} Vault`, - `${await cETH.symbol()}-VAULT`, - networkConfig[chainId].COMPTROLLER! - ) - - await cETHVault.deployed() - - console.log( - `Deployed Vault for cETH on ${hre.network.name} (${chainId}): ${cETHVault.address} ` - ) - - const { collateral: cETHCollateral } = await hre.run( - 'deploy-ctoken-selfreferential-collateral', - { - priceTimeout: priceTimeout.toString(), - priceFeed: networkConfig[chainId].chainlinkFeeds.ETH, - oracleError: fp('0.005').toString(), // 0.5% - cToken: cETHVault.address, - maxTradeVolume: fp('1e6').toString(), // $1m, - oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr - targetName: hre.ethers.utils.formatBytes32String('ETH'), - revenueHiding: revenueHiding.toString(), - referenceERC20Decimals: '18', - } - ) - collateral = await ethers.getContractAt('ICollateral', cETHCollateral) - await (await collateral.refresh()).wait() - expect(await collateral.status()).to.equal(CollateralStatus.SOUND) - - assetCollDeployments.collateral.cETH = cETHCollateral - assetCollDeployments.erc20s.cETH = cETHVault.address - deployedCollateral.push(cETHCollateral.toString()) - - fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) - } - /******** Deploy Non-Fiat Collateral - wBTC **************************/ if ( networkConfig[chainId].tokens.WBTC && diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_compound_v2_collateral.ts b/scripts/deployment/phase2-assets/collaterals/deploy_compound_v2_collateral.ts new file mode 100644 index 0000000000..d328a311dd --- /dev/null +++ b/scripts/deployment/phase2-assets/collaterals/deploy_compound_v2_collateral.ts @@ -0,0 +1,293 @@ +import fs from 'fs' +import hre, { ethers } from 'hardhat' +import { expect } from 'chai' +import { getChainId } from '../../../../common/blockchain-utils' +import { baseL2Chains, networkConfig } from '../../../../common/configuration' +import { bn, fp } from '../../../../common/numbers' +import { CollateralStatus } from '../../../../common/constants' +import { + getDeploymentFile, + getAssetCollDeploymentFilename, + IAssetCollDeployments, + getDeploymentFilename, + fileExists, +} from '../../common' +import { combinedError, priceTimeout, oracleTimeout, revenueHiding } from '../../utils' +import { ICollateral, ATokenMock, StaticATokenLM } from '../../../../typechain' + +async function main() { + // ==== Read Configuration ==== + const [burner] = await hre.ethers.getSigners() + + const chainId = await getChainId(hre) + + console.log(`Deploying Collateral to network ${hre.network.name} (${chainId}) + with burner account: ${burner.address}`) + + if (!networkConfig[chainId]) { + throw new Error(`Missing network configuration for ${hre.network.name}`) + } + + // Get phase1 deployment + const phase1File = getDeploymentFilename(chainId) + if (!fileExists(phase1File)) { + throw new Error(`${phase1File} doesn't exist yet. Run phase 1`) + } + // Check previous step completed + const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) + const assetCollDeployments = getDeploymentFile(assetCollDeploymentFilename) + + // Get Oracle Lib address if previously deployed (can override with arbitrary address) + const deployedCollateral: string[] = [] + + let collateral: ICollateral + + const wbtcOracleError = fp('0.02') // 2% + const btcOracleError = fp('0.005') // 0.5% + const combinedBTCWBTCError = combinedError(wbtcOracleError, btcOracleError) + + /*** Compound V2 not available in Base L2s */ + if (!baseL2Chains.includes(hre.network.name)) { + /******** Deploy CToken Fiat Collateral - cDAI **************************/ + const CTokenFactory = await ethers.getContractFactory('CTokenWrapper') + const cDai = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cDAI!) + + const cDaiVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cDAI!, + `${await cDai.name()} Vault`, + `${await cDai.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cDaiVault.deployed() + + console.log( + `Deployed Vault for cDAI on ${hre.network.name} (${chainId}): ${cDaiVault.address} ` + ) + + const { collateral: cDaiCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { + priceTimeout: priceTimeout.toString(), + priceFeed: networkConfig[chainId].chainlinkFeeds.DAI, + oracleError: fp('0.0025').toString(), // 0.25% + cToken: cDaiVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: fp('0.0125').toString(), // 1.25% + delayUntilDefault: bn('86400').toString(), // 24h + revenueHiding: revenueHiding.toString(), + }) + collateral = await ethers.getContractAt('ICollateral', cDaiCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cDAI = cDaiCollateral + assetCollDeployments.erc20s.cDAI = cDaiVault.address + deployedCollateral.push(cDaiCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + /******** Deploy CToken Fiat Collateral - cUSDC **************************/ + const cUsdc = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDC!) + + const cUsdcVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cUSDC!, + `${await cUsdc.name()} Vault`, + `${await cUsdc.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cUsdcVault.deployed() + + console.log( + `Deployed Vault for cUSDC on ${hre.network.name} (${chainId}): ${cUsdcVault.address} ` + ) + + const { collateral: cUsdcCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { + priceTimeout: priceTimeout.toString(), + priceFeed: networkConfig[chainId].chainlinkFeeds.USDC, + oracleError: fp('0.0025').toString(), // 0.25% + cToken: cUsdcVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: fp('0.0125').toString(), // 1.25% + delayUntilDefault: bn('86400').toString(), // 24h + revenueHiding: revenueHiding.toString(), + }) + collateral = await ethers.getContractAt('ICollateral', cUsdcCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cUSDC = cUsdcCollateral + assetCollDeployments.erc20s.cUSDC = cUsdcVault.address + deployedCollateral.push(cUsdcCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + /******** Deploy CToken Fiat Collateral - cUSDT **************************/ + const cUsdt = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDT!) + + const cUsdtVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cUSDT!, + `${await cUsdt.name()} Vault`, + `${await cUsdt.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cUsdtVault.deployed() + + console.log( + `Deployed Vault for cUSDT on ${hre.network.name} (${chainId}): ${cUsdtVault.address} ` + ) + + const { collateral: cUsdtCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { + priceTimeout: priceTimeout.toString(), + priceFeed: networkConfig[chainId].chainlinkFeeds.USDT, + oracleError: fp('0.0025').toString(), // 0.25% + cToken: cUsdtVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: fp('0.0125').toString(), // 1.25% + delayUntilDefault: bn('86400').toString(), // 24h + revenueHiding: revenueHiding.toString(), + }) + collateral = await ethers.getContractAt('ICollateral', cUsdtCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cUSDT = cUsdtCollateral + assetCollDeployments.erc20s.cUSDT = cUsdtVault.address + deployedCollateral.push(cUsdtCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + /******** Deploy CToken Fiat Collateral - cUSDP **************************/ + const cUsdp = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cUSDP!) + + const cUsdpVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cUSDP!, + `${await cUsdp.name()} Vault`, + `${await cUsdp.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cUsdpVault.deployed() + + console.log( + `Deployed Vault for cUSDP on ${hre.network.name} (${chainId}): ${cUsdpVault.address} ` + ) + + const { collateral: cUsdpCollateral } = await hre.run('deploy-ctoken-fiat-collateral', { + priceTimeout: priceTimeout.toString(), + priceFeed: networkConfig[chainId].chainlinkFeeds.USDP, + oracleError: fp('0.01').toString(), // 1% + cToken: cUsdpVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: fp('0.02').toString(), // 2% + delayUntilDefault: bn('86400').toString(), // 24h + revenueHiding: revenueHiding.toString(), + }) + collateral = await ethers.getContractAt('ICollateral', cUsdpCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cUSDP = cUsdpCollateral + assetCollDeployments.erc20s.cUSDP = cUsdpVault.address + deployedCollateral.push(cUsdpCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + /******** Deploy CToken Non-Fiat Collateral - cWBTC **************************/ + const cWBTC = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cWBTC!) + + const cWBTCVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cWBTC!, + `${await cWBTC.name()} Vault`, + `${await cWBTC.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cWBTCVault.deployed() + + console.log( + `Deployed Vault for cWBTC on ${hre.network.name} (${chainId}): ${cWBTCVault.address} ` + ) + + const { collateral: cWBTCCollateral } = await hre.run('deploy-ctoken-nonfiat-collateral', { + priceTimeout: priceTimeout.toString(), + referenceUnitFeed: networkConfig[chainId].chainlinkFeeds.WBTC, + targetUnitFeed: networkConfig[chainId].chainlinkFeeds.BTC, + combinedOracleError: combinedBTCWBTCError.toString(), + cToken: cWBTCVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr + targetUnitOracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr + targetName: hre.ethers.utils.formatBytes32String('BTC'), + defaultThreshold: fp('0.01').add(combinedBTCWBTCError).toString(), // ~3.5% + delayUntilDefault: bn('86400').toString(), // 24h + revenueHiding: revenueHiding.toString(), + }) + collateral = await ethers.getContractAt('ICollateral', cWBTCCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cWBTC = cWBTCCollateral + assetCollDeployments.erc20s.cWBTC = cWBTCVault.address + deployedCollateral.push(cWBTCCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + + /******** Deploy CToken Self-Referential Collateral - cETH **************************/ + const cETH = await ethers.getContractAt('IERC20Metadata', networkConfig[chainId].tokens.cETH!) + + const cETHVault = await CTokenFactory.deploy( + networkConfig[chainId].tokens.cETH!, + `${await cETH.name()} Vault`, + `${await cETH.symbol()}-VAULT`, + networkConfig[chainId].COMPTROLLER! + ) + + await cETHVault.deployed() + + console.log( + `Deployed Vault for cETH on ${hre.network.name} (${chainId}): ${cETHVault.address} ` + ) + + const { collateral: cETHCollateral } = await hre.run( + 'deploy-ctoken-selfreferential-collateral', + { + priceTimeout: priceTimeout.toString(), + priceFeed: networkConfig[chainId].chainlinkFeeds.ETH, + oracleError: fp('0.005').toString(), // 0.5% + cToken: cETHVault.address, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr + targetName: hre.ethers.utils.formatBytes32String('ETH'), + revenueHiding: revenueHiding.toString(), + referenceERC20Decimals: '18', + } + ) + collateral = await ethers.getContractAt('ICollateral', cETHCollateral) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.cETH = cETHCollateral + assetCollDeployments.erc20s.cETH = cETHVault.address + deployedCollateral.push(cETHCollateral.toString()) + + fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) + } + + console.log(`Deployed collateral to ${hre.network.name} (${chainId}) + New deployments: ${deployedCollateral} + Deployment file: ${assetCollDeploymentFilename}`) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/test/integration/CTokenVaultGas.test.ts b/test/integration/CTokenVaultGas.test.ts new file mode 100644 index 0000000000..9bf568772f --- /dev/null +++ b/test/integration/CTokenVaultGas.test.ts @@ -0,0 +1,235 @@ +import { useEnv } from '#/utils/env' +import { BigNumber } from 'ethers' +import { defaultFixtureNoBasket } from './fixtures' +import { loadFixture } from '@nomicfoundation/hardhat-network-helpers' +import { CTokenFiatCollateral } from '@typechain/CTokenFiatCollateral' +import { IConfig, networkConfig } from '#/common/configuration' +import { TestIRToken } from '@typechain/TestIRToken' +import snapshotGasCost from '../utils/snapshotGasCost' +import { ethers } from 'hardhat' +import { advanceTime, getLatestBlockTimestamp, setNextBlockTimestamp } from '../utils/time' +import { CTokenWrapper } from '@typechain/CTokenWrapper' +import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' +import { ICToken } from '@typechain/ICToken' +import { bn, fp } from '#/common/numbers' +import { + Collateral, + IMPLEMENTATION, + Implementation, + ORACLE_ERROR, + ORACLE_TIMEOUT, + PRICE_TIMEOUT, + REVENUE_HIDING, +} from '../fixtures' +import { IERC20Metadata } from '@typechain/IERC20Metadata' +import { TestIBasketHandler } from '@typechain/TestIBasketHandler' +import { TestIBackingManager } from '@typechain/TestIBackingManager' +import { IAssetRegistry } from '@typechain/IAssetRegistry' +import { whileImpersonating } from '../utils/impersonation' + +const describeGas = + IMPLEMENTATION == Implementation.P1 && useEnv('REPORT_GAS') ? describe.only : describe.skip + +describe(`CTokenVault contract`, () => { + let owner: SignerWithAddress + let addr1: SignerWithAddress + let addr2: SignerWithAddress + + // Tokens and Assets + let initialBal: BigNumber + let cTokenUnwrapped: ICToken + let cTokenWrapped: CTokenWrapper + + let cTokenCollateralUnwrapped: Collateral + let cTokenCollateralWrapped: Collateral + + // Config values + let config: IConfig + + // Main + let rToken: TestIRToken + let assetRegistry: IAssetRegistry + let backingManager: TestIBackingManager + let basketHandler: TestIBasketHandler + + beforeEach(async () => { + ;[owner, addr1, addr2] = await ethers.getSigners() + + // Deploy fixture + ;({ assetRegistry, backingManager, basketHandler, config, rToken } = await loadFixture( + defaultFixtureNoBasket + )) + + const defaultThreshold = fp('0.01') // 1% + const delayUntilDefault = bn('86400') // 24h + const CTokenCollateralFactory = await ethers.getContractFactory('CTokenFiatCollateral') + cTokenCollateralUnwrapped = await CTokenCollateralFactory.deploy( + { + priceTimeout: PRICE_TIMEOUT, + chainlinkFeed: networkConfig['31337'].chainlinkFeeds.DAI!, + oracleError: ORACLE_ERROR, + erc20: networkConfig['31337'].tokens.cDAI!, + maxTradeVolume: config.rTokenMaxTradeVolume, + oracleTimeout: ORACLE_TIMEOUT, + targetName: ethers.utils.formatBytes32String('USD'), + defaultThreshold, + delayUntilDefault, + }, + REVENUE_HIDING + ) + await cTokenCollateralUnwrapped.refresh() + + const CTokenWrapperFactory = await ethers.getContractFactory('CTokenWrapper') + const erc20: IERC20Metadata = ( + await ethers.getContractAt('ICToken', networkConfig['31337'].tokens.cDAI!) + ) + cTokenWrapped = await CTokenWrapperFactory.deploy( + erc20.address, + `${await erc20.name()} Vault`, + `${await erc20.symbol()}-VAULT`, + networkConfig['31337'].COMPTROLLER! + ) + cTokenCollateralWrapped = await CTokenCollateralFactory.deploy( + { + priceTimeout: PRICE_TIMEOUT, + chainlinkFeed: networkConfig['31337'].chainlinkFeeds.DAI!, + oracleError: ORACLE_ERROR, + erc20: cTokenWrapped.address, + maxTradeVolume: config.rTokenMaxTradeVolume, + oracleTimeout: ORACLE_TIMEOUT, + targetName: ethers.utils.formatBytes32String('USD'), + defaultThreshold, + delayUntilDefault, + }, + REVENUE_HIDING + ) + await cTokenCollateralWrapped.refresh() + + // Advance time post warmup period + await advanceTime(Number(config.warmupPeriod) + 1) + + // Mint initial balances + const dai = await ethers.getContractAt('ERC20Mock', networkConfig['31337'].tokens.DAI!) + cTokenUnwrapped = await ethers.getContractAt('ICToken', networkConfig['31337'].tokens.cDAI!) + const holderDAI = '0x16b34ce9a6a6f7fc2dd25ba59bf7308e7b38e186' + initialBal = fp('1e7') // 10x the issuance throttle amount + await whileImpersonating(holderDAI, async (daiSigner) => { + await dai.connect(daiSigner).transfer(addr1.address, initialBal) + }) + await dai.connect(addr1).approve(cTokenUnwrapped.address, initialBal) + await cTokenUnwrapped.connect(addr1).mint(initialBal) + }) + + describeGas('Gas Reporting, cTokens', () => { + const initialBal = fp('1e7') + + describe('Unwrapped', () => { + let tokenBal: BigNumber + + beforeEach(async () => { + await assetRegistry.connect(owner).register(cTokenCollateralUnwrapped.address) + + const basketsNeededAmts = [fp('1.0')] + await basketHandler + .connect(owner) + .setPrimeBasket([cTokenUnwrapped.address], basketsNeededAmts) + await basketHandler.connect(owner).refreshBasket() + + // Set up allowances + await backingManager.grantRTokenAllowance(cTokenUnwrapped.address) + + // Charge throttle + await setNextBlockTimestamp(Number(await getLatestBlockTimestamp()) + 3600) + + tokenBal = await cTokenUnwrapped.balanceOf(addr1.address) + + // Provide approvals + await cTokenUnwrapped.connect(addr1).approve(rToken.address, initialBal) + }) + + it('Transfer', async () => { + // Transfer + await snapshotGasCost( + cTokenUnwrapped.connect(addr1).transfer(addr2.address, tokenBal.div(10)) + ) + + // Transfer again + await snapshotGasCost( + cTokenUnwrapped.connect(addr1).transfer(addr2.address, tokenBal.div(10)) + ) + + // Transfer back + await snapshotGasCost( + cTokenUnwrapped.connect(addr2).transfer(addr1.address, tokenBal.div(10)) + ) + }) + + it('Issue RToken', async () => { + // Issue rTokens twice within block + await snapshotGasCost(rToken.connect(addr1).issue(tokenBal.div(10))) + await snapshotGasCost(rToken.connect(addr1).issue(tokenBal.div(10))) + }) + + it('Redeem RToken', async () => { + await rToken.connect(addr1).issue(tokenBal.div(10)) + await snapshotGasCost(rToken.connect(addr1).redeem(tokenBal.div(10))) + }) + }) + + describe('Wrapped', () => { + let tokenBal: BigNumber + + beforeEach(async () => { + const unwrappedBal = await cTokenUnwrapped.balanceOf(addr1.address) + await cTokenUnwrapped.connect(addr1).approve(cTokenWrapped.address, unwrappedBal) + await cTokenWrapped.connect(addr1).deposit(unwrappedBal, addr1.address) + await assetRegistry.connect(owner).register(cTokenCollateralWrapped.address) + + const basketsNeededAmts = [fp('1.0')] + await basketHandler + .connect(owner) + .setPrimeBasket([cTokenWrapped.address], basketsNeededAmts) + await basketHandler.connect(owner).refreshBasket() + + // Set up allowances + await backingManager.grantRTokenAllowance(cTokenWrapped.address) + + // Charge throttle + await setNextBlockTimestamp(Number(await getLatestBlockTimestamp()) + 3600) + + tokenBal = await cTokenWrapped.balanceOf(addr1.address) + + // Provide approvals + await cTokenWrapped.connect(addr1).approve(rToken.address, initialBal) + }) + + it('Transfer', async () => { + // Transfer + await snapshotGasCost( + cTokenWrapped.connect(addr1).transfer(addr2.address, tokenBal.div(10)) + ) + + // Transfer again + await snapshotGasCost( + cTokenWrapped.connect(addr1).transfer(addr2.address, tokenBal.div(10)) + ) + + // Transfer back + await snapshotGasCost( + cTokenWrapped.connect(addr2).transfer(addr1.address, tokenBal.div(10)) + ) + }) + + it('Issue RToken', async () => { + // Issue rTokens twice within block + await snapshotGasCost(rToken.connect(addr1).issue(tokenBal.div(10))) + await snapshotGasCost(rToken.connect(addr1).issue(tokenBal.div(10))) + }) + + it('Redeem RToken', async () => { + await rToken.connect(addr1).issue(tokenBal.div(10)) + await snapshotGasCost(rToken.connect(addr1).redeem(tokenBal.div(10))) + }) + }) + }) +}) diff --git a/test/integration/__snapshots__/CTokenVaultGas.test.ts.snap b/test/integration/__snapshots__/CTokenVaultGas.test.ts.snap new file mode 100644 index 0000000000..a9ec5a85ce --- /dev/null +++ b/test/integration/__snapshots__/CTokenVaultGas.test.ts.snap @@ -0,0 +1,25 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Issue RToken 1`] = `816857`; + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Issue RToken 2`] = `677455`; + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Redeem RToken 1`] = `679421`; + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Transfer 1`] = `159307`; + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Transfer 2`] = `127937`; + +exports[`CTokenVault contract Gas Reporting, cTokens Unwrapped Transfer 3`] = `110849`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Issue RToken 1`] = `965241`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Issue RToken 2`] = `753143`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Redeem RToken 1`] = `748958`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Transfer 1`] = `310005`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Transfer 2`] = `193085`; + +exports[`CTokenVault contract Gas Reporting, cTokens Wrapped Transfer 3`] = `175997`; diff --git a/test/integration/fixtures.ts b/test/integration/fixtures.ts index fa2a573586..f22f9a1f1e 100644 --- a/test/integration/fixtures.ts +++ b/test/integration/fixtures.ts @@ -146,7 +146,7 @@ interface CollateralFixture { basketsNeededAmts: BigNumber[] // reference amounts } -async function collateralFixture( +export async function collateralFixture( comptroller: ComptrollerMock, aaveLendingPool: AaveLendingPoolMock, config: IConfig diff --git a/test/plugins/individual-collateral/aave-v3/__snapshots__/AaveV3FiatCollateral.test.ts.snap b/test/plugins/individual-collateral/aave-v3/__snapshots__/AaveV3FiatCollateral.test.ts.snap index 607d7bd001..62ee74c7f7 100644 --- a/test/plugins/individual-collateral/aave-v3/__snapshots__/AaveV3FiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/aave-v3/__snapshots__/AaveV3FiatCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting ERC20 transfer 1`] = `53509`; + +exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting ERC20 transfer 2`] = `36409`; + exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() after full price timeout 1`] = `69299`; exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() after full price timeout 2`] = `67631`; @@ -20,6 +24,6 @@ exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() during SOUND 2`] = `87706`; -exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() during soft default 1`] = `89730`; +exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() during soft default 1`] = `89656`; exports[`Collateral: Aave V3 Fiat Collateral (USDC) collateral functionality Gas Reporting refresh() during soft default 2`] = `87988`; diff --git a/test/plugins/individual-collateral/aave/ATokenFiatCollateral.test.ts b/test/plugins/individual-collateral/aave/ATokenFiatCollateral.test.ts index 9dc2c4f7fa..ed84d0b200 100644 --- a/test/plugins/individual-collateral/aave/ATokenFiatCollateral.test.ts +++ b/test/plugins/individual-collateral/aave/ATokenFiatCollateral.test.ts @@ -1012,5 +1012,12 @@ describeFork(`ATokenFiatCollateral - Mainnet Forking P${IMPLEMENTATION}`, functi await snapshotGasCost(newADaiCollateral.refresh()) // 2nd refresh can be different than 1st }) }) + + context('ERC20 Wrapper', () => { + it('transfer', async () => { + await snapshotGasCost(staticAToken.connect(addr1).transfer(aDaiCollateral.address, bn('1'))) + await snapshotGasCost(staticAToken.connect(addr1).transfer(aDaiCollateral.address, bn('1'))) + }) + }) }) }) diff --git a/test/plugins/individual-collateral/aave/__snapshots__/ATokenFiatCollateral.test.ts.snap b/test/plugins/individual-collateral/aave/__snapshots__/ATokenFiatCollateral.test.ts.snap index 79711c5fe3..6cc30614b8 100644 --- a/test/plugins/individual-collateral/aave/__snapshots__/ATokenFiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/aave/__snapshots__/ATokenFiatCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting ERC20 Wrapper transfer 1`] = `66986`; + +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting ERC20 Wrapper transfer 2`] = `53409`; + exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 1`] = `74365`; exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 2`] = `72697`; @@ -12,14 +16,14 @@ exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after oracle timeout 2`] = `72697`; -exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after soft default 1`] = `91095`; +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after soft default 1`] = `91169`; exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after soft default 2`] = `91095`; -exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 1`] = `92307`; +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 1`] = `92233`; -exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 2`] = `92233`; +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 2`] = `92307`; -exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 1`] = `127304`; +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 1`] = `127378`; -exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 2`] = `91510`; +exports[`ATokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 2`] = `91436`; diff --git a/test/plugins/individual-collateral/ankr/__snapshots__/AnkrEthCollateralTestSuite.test.ts.snap b/test/plugins/individual-collateral/ankr/__snapshots__/AnkrEthCollateralTestSuite.test.ts.snap index 37480626fe..513e5ca5b6 100644 --- a/test/plugins/individual-collateral/ankr/__snapshots__/AnkrEthCollateralTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/ankr/__snapshots__/AnkrEthCollateralTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: AnkrStakedETH collateral functionality Gas Reporting ERC20 transfer 1`] = `61094`; + +exports[`Collateral: AnkrStakedETH collateral functionality Gas Reporting ERC20 transfer 2`] = `43994`; + exports[`Collateral: AnkrStakedETH collateral functionality Gas Reporting refresh() after full price timeout 1`] = `60337`; exports[`Collateral: AnkrStakedETH collateral functionality Gas Reporting refresh() after full price timeout 2`] = `55868`; diff --git a/test/plugins/individual-collateral/cbeth/__snapshots__/CBETHCollateral.test.ts.snap b/test/plugins/individual-collateral/cbeth/__snapshots__/CBETHCollateral.test.ts.snap index bf09f1f35e..afb2111ab5 100644 --- a/test/plugins/individual-collateral/cbeth/__snapshots__/CBETHCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/cbeth/__snapshots__/CBETHCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CBEthCollateral collateral functionality Gas Reporting ERC20 transfer 1`] = `65479`; + +exports[`Collateral: CBEthCollateral collateral functionality Gas Reporting ERC20 transfer 2`] = `48379`; + exports[`Collateral: CBEthCollateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `59824`; exports[`Collateral: CBEthCollateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `55355`; diff --git a/test/plugins/individual-collateral/collateralTests.ts b/test/plugins/individual-collateral/collateralTests.ts index 6899a19502..471a39b64e 100644 --- a/test/plugins/individual-collateral/collateralTests.ts +++ b/test/plugins/individual-collateral/collateralTests.ts @@ -552,6 +552,16 @@ export default function fn( await reduceRefPerTok(ctx, 5) }) }) + + context('ERC20', () => { + it('transfer', async () => { + const decimals = await ctx.tok.decimals() + const amount = bn('20').mul(bn(10).pow(decimals)) + await mintCollateralTo(ctx, amount, alice, alice.address) + await snapshotGasCost(ctx.tok.connect(alice).transfer(collateral.address, bn('1e6'))) + await snapshotGasCost(ctx.tok.connect(alice).transfer(collateral.address, bn('1e6'))) + }) + }) }) }) }) diff --git a/test/plugins/individual-collateral/compoundv2/CTokenFiatCollateral.test.ts b/test/plugins/individual-collateral/compoundv2/CTokenFiatCollateral.test.ts index df5264769f..876b6e5e52 100644 --- a/test/plugins/individual-collateral/compoundv2/CTokenFiatCollateral.test.ts +++ b/test/plugins/individual-collateral/compoundv2/CTokenFiatCollateral.test.ts @@ -1106,5 +1106,12 @@ describeFork(`CTokenFiatCollateral - Mainnet Forking P${IMPLEMENTATION}`, functi await snapshotGasCost(newCDaiCollateral.refresh()) // 2nd refresh can be different than 1st }) }) + + context('ERC20', () => { + it('transfer', async () => { + await snapshotGasCost(cDaiVault.connect(addr1).transfer(cDaiCollateral.address, bn('1'))) + await snapshotGasCost(cDaiVault.connect(addr1).transfer(cDaiCollateral.address, bn('1'))) + }) + }) }) }) diff --git a/test/plugins/individual-collateral/compoundv2/__snapshots__/CTokenFiatCollateral.test.ts.snap b/test/plugins/individual-collateral/compoundv2/__snapshots__/CTokenFiatCollateral.test.ts.snap index ed6522b5ce..b0874c79c7 100644 --- a/test/plugins/individual-collateral/compoundv2/__snapshots__/CTokenFiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/compoundv2/__snapshots__/CTokenFiatCollateral.test.ts.snap @@ -1,25 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 1`] = `119347`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting ERC20 transfer 1`] = `309933`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 2`] = `117679`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting ERC20 transfer 2`] = `173113`; + +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 1`] = `119361`; + +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after full price timeout 2`] = `117692`; exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after hard default 1`] = `76242`; exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after hard default 2`] = `68560`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after oracle timeout 1`] = `119347`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after oracle timeout 1`] = `119361`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after oracle timeout 2`] = `117679`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after oracle timeout 2`] = `117692`; exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after soft default 1`] = `138781`; exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() after soft default 2`] = `138707`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 1`] = `139845`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 1`] = `139858`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 2`] = `139845`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during SOUND 2`] = `139858`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 1`] = `174990`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 1`] = `175004`; -exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 2`] = `139048`; +exports[`CTokenFiatCollateral - Mainnet Forking P1 Gas Reporting refresh() during soft default 2`] = `139061`; diff --git a/test/plugins/individual-collateral/compoundv3/__snapshots__/CometTestSuite.test.ts.snap b/test/plugins/individual-collateral/compoundv3/__snapshots__/CometTestSuite.test.ts.snap index be30eecd44..a899da3b86 100644 --- a/test/plugins/individual-collateral/compoundv3/__snapshots__/CometTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/compoundv3/__snapshots__/CometTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CompoundV3USDC collateral functionality Gas Reporting ERC20 transfer 1`] = `107621`; + +exports[`Collateral: CompoundV3USDC collateral functionality Gas Reporting ERC20 transfer 2`] = `90521`; + exports[`Collateral: CompoundV3USDC collateral functionality Gas Reporting refresh() after full price timeout 1`] = `109063`; exports[`Collateral: CompoundV3USDC collateral functionality Gas Reporting refresh() after full price timeout 2`] = `104326`; diff --git a/test/plugins/individual-collateral/curve/collateralTests.ts b/test/plugins/individual-collateral/curve/collateralTests.ts index bb31869a26..a9a939a029 100644 --- a/test/plugins/individual-collateral/curve/collateralTests.ts +++ b/test/plugins/individual-collateral/curve/collateralTests.ts @@ -695,6 +695,18 @@ export default function fn( await ctx.curvePool.setVirtualPrice(currentExchangeRate.sub(1e3)).then((e) => e.wait()) }) }) + + context('ERC20 Wrapper', () => { + it('transfer', async () => { + await mintCollateralTo(ctx, bn('2'), ctx.alice, ctx.alice.address) + await snapshotGasCost( + ctx.wrapper.connect(ctx.alice).transfer(ctx.collateral.address, bn('1')) + ) + await snapshotGasCost( + ctx.wrapper.connect(ctx.alice).transfer(ctx.collateral.address, bn('1')) + ) + }) + }) }) }) }) diff --git a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableMetapoolSuite.test.ts.snap b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableMetapoolSuite.test.ts.snap index adac76df06..ea00035779 100644 --- a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableMetapoolSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableMetapoolSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `382837`; + +exports[`Collateral: CurveStableMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `360937`; + exports[`Collateral: CurveStableMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `52705`; exports[`Collateral: CurveStableMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `48237`; diff --git a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableRTokenMetapoolTestSuite.test.ts.snap b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableRTokenMetapoolTestSuite.test.ts.snap index 74b5d0e51d..7c535da1b7 100644 --- a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableRTokenMetapoolTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableRTokenMetapoolTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableRTokenMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `407643`; + +exports[`Collateral: CurveStableRTokenMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `385743`; + exports[`Collateral: CurveStableRTokenMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `69638`; exports[`Collateral: CurveStableRTokenMetapoolCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `65170`; diff --git a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableTestSuite.test.ts.snap b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableTestSuite.test.ts.snap index d725ca2610..5f891c6870 100644 --- a/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/crv/__snapshots__/CrvStableTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `391352`; + +exports[`Collateral: CurveStableCollateral - CurveGaugeWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `369452`; + exports[`Collateral: CurveStableCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `61895`; exports[`Collateral: CurveStableCollateral - CurveGaugeWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `57427`; diff --git a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableMetapoolSuite.test.ts.snap b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableMetapoolSuite.test.ts.snap index 699536b70f..7ccdd8462f 100644 --- a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableMetapoolSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableMetapoolSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `194451`; + +exports[`Collateral: CurveStableMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `172551`; + exports[`Collateral: CurveStableMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `52705`; exports[`Collateral: CurveStableMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `48237`; diff --git a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableRTokenMetapoolTestSuite.test.ts.snap b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableRTokenMetapoolTestSuite.test.ts.snap index 34a9b7f027..d4975bf94d 100644 --- a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableRTokenMetapoolTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableRTokenMetapoolTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableRTokenMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `197088`; + +exports[`Collateral: CurveStableRTokenMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `175188`; + exports[`Collateral: CurveStableRTokenMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `69638`; exports[`Collateral: CurveStableRTokenMetapoolCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `65170`; diff --git a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableTestSuite.test.ts.snap b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableTestSuite.test.ts.snap index 8b01856f7e..20e9558ee6 100644 --- a/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/curve/cvx/__snapshots__/CvxStableTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: CurveStableCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 1`] = `145605`; + +exports[`Collateral: CurveStableCollateral - ConvexStakingWrapper collateral functionality Gas Reporting ERC20 Wrapper transfer 2`] = `123705`; + exports[`Collateral: CurveStableCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 1`] = `61895`; exports[`Collateral: CurveStableCollateral - ConvexStakingWrapper collateral functionality Gas Reporting refresh() after full price timeout 2`] = `57427`; diff --git a/test/plugins/individual-collateral/dsr/__snapshots__/SDaiCollateralTestSuite.test.ts.snap b/test/plugins/individual-collateral/dsr/__snapshots__/SDaiCollateralTestSuite.test.ts.snap index 178c2fa1e9..00b521e8f7 100644 --- a/test/plugins/individual-collateral/dsr/__snapshots__/SDaiCollateralTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/dsr/__snapshots__/SDaiCollateralTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting ERC20 transfer 1`] = `51359`; + +exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting ERC20 transfer 2`] = `34259`; + exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `116754`; exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `108442`; @@ -20,6 +24,6 @@ exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refre exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `123320`; -exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() during soft default 1`] = `131148`; +exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() during soft default 1`] = `131222`; -exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() during soft default 2`] = `123602`; +exports[`Collateral: SDaiCollateral collateral functionality Gas Reporting refresh() during soft default 2`] = `123676`; diff --git a/test/plugins/individual-collateral/flux-finance/__snapshots__/FTokenFiatCollateral.test.ts.snap b/test/plugins/individual-collateral/flux-finance/__snapshots__/FTokenFiatCollateral.test.ts.snap index 35d0ae91c9..b11dbcda01 100644 --- a/test/plugins/individual-collateral/flux-finance/__snapshots__/FTokenFiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/flux-finance/__snapshots__/FTokenFiatCollateral.test.ts.snap @@ -1,97 +1,113 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `117347`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting ERC20 transfer 1`] = `142854`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `115679`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting ERC20 transfer 2`] = `105831`; + +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `117361`; + +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `115692`; exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after hard default 1`] = `140981`; exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after hard default 2`] = `139167`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `117347`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `117361`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `115679`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `115692`; exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after soft default 1`] = `115338`; exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() after soft default 2`] = `115338`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `139164`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `139177`; + +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `139177`; + +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `141202`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `139164`; +exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `139459`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `141114`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting ERC20 transfer 1`] = `142854`; -exports[`Collateral: fDAI Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `139520`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting ERC20 transfer 2`] = `105831`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `117539`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `117553`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `115871`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `115884`; exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after hard default 1`] = `141237`; exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after hard default 2`] = `139423`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `117539`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `117553`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `115871`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `115884`; exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after soft default 1`] = `115530`; exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() after soft default 2`] = `115530`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `139420`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `139433`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `139420`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `139433`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `141370`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `141458`; -exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `139702`; +exports[`Collateral: fFRAX Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `139789`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `125829`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting ERC20 transfer 1`] = `142854`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `124161`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting ERC20 transfer 2`] = `105831`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after hard default 1`] = `149949`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `125843`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after hard default 2`] = `148205`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `124174`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `125829`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after hard default 1`] = `150019`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `124161`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after hard default 2`] = `148135`; + +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `125843`; + +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `124174`; exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after soft default 1`] = `123820`; exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() after soft default 2`] = `123820`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `148202`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `148215`; + +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `148145`; + +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `150096`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `148202`; +exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `148427`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `150082`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting ERC20 transfer 1`] = `142854`; -exports[`Collateral: fUSDC Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `148484`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting ERC20 transfer 2`] = `105831`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `120477`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `120491`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `118809`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `118822`; exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after hard default 1`] = `144383`; exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after hard default 2`] = `142569`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `120477`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after oracle timeout 1`] = `120491`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `118809`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after oracle timeout 2`] = `118822`; exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after soft default 1`] = `118468`; exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() after soft default 2`] = `118468`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `142496`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during SOUND 1`] = `142579`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `142566`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during SOUND 2`] = `142509`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `144446`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during soft default 1`] = `144530`; -exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `142848`; +exports[`Collateral: fUSDT Collateral collateral functionality Gas Reporting refresh() during soft default 2`] = `142861`; diff --git a/test/plugins/individual-collateral/frax-eth/__snapshots__/SFrxEthTestSuite.test.ts.snap b/test/plugins/individual-collateral/frax-eth/__snapshots__/SFrxEthTestSuite.test.ts.snap index 04d291e85c..30de100fa3 100644 --- a/test/plugins/individual-collateral/frax-eth/__snapshots__/SFrxEthTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/frax-eth/__snapshots__/SFrxEthTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: SFraxEthCollateral collateral functionality Gas Reporting ERC20 transfer 1`] = `51304`; + +exports[`Collateral: SFraxEthCollateral collateral functionality Gas Reporting ERC20 transfer 2`] = `34204`; + exports[`Collateral: SFraxEthCollateral collateral functionality Gas Reporting refresh() after full price timeout 1`] = `58995`; exports[`Collateral: SFraxEthCollateral collateral functionality Gas Reporting refresh() after full price timeout 2`] = `54258`; diff --git a/test/plugins/individual-collateral/lido/__snapshots__/LidoStakedEthTestSuite.test.ts.snap b/test/plugins/individual-collateral/lido/__snapshots__/LidoStakedEthTestSuite.test.ts.snap index 09f0a2c8ad..dab42bfd76 100644 --- a/test/plugins/individual-collateral/lido/__snapshots__/LidoStakedEthTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/lido/__snapshots__/LidoStakedEthTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: LidoStakedETH collateral functionality Gas Reporting ERC20 transfer 1`] = `51664`; + +exports[`Collateral: LidoStakedETH collateral functionality Gas Reporting ERC20 transfer 2`] = `34564`; + exports[`Collateral: LidoStakedETH collateral functionality Gas Reporting refresh() after full price timeout 1`] = `88044`; exports[`Collateral: LidoStakedETH collateral functionality Gas Reporting refresh() after full price timeout 2`] = `83575`; diff --git a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVEFiatCollateral.test.ts.snap b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVEFiatCollateral.test.ts.snap index 97e0228cdb..d55a1ae734 100644 --- a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVEFiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVEFiatCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality Gas Reporting refresh() after full price timeout 1`] = `134222`; exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality Gas Reporting refresh() after full price timeout 2`] = `129753`; @@ -24,6 +28,10 @@ exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality G exports[`Collateral: MorphoAAVEV2FiatCollateral - DAI collateral functionality Gas Reporting refresh() during soft default 2`] = `172430`; +exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality Gas Reporting refresh() after full price timeout 1`] = `134425`; exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality Gas Reporting refresh() after full price timeout 2`] = `129956`; @@ -48,6 +56,10 @@ exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality exports[`Collateral: MorphoAAVEV2FiatCollateral - USDC collateral functionality Gas Reporting refresh() during soft default 2`] = `172836`; +exports[`Collateral: MorphoAAVEV2FiatCollateral - USDT collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2FiatCollateral - USDT collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2FiatCollateral - USDT collateral functionality Gas Reporting refresh() after full price timeout 1`] = `133578`; exports[`Collateral: MorphoAAVEV2FiatCollateral - USDT collateral functionality Gas Reporting refresh() after full price timeout 2`] = `129109`; diff --git a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVENonFiatCollateral.test.ts.snap b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVENonFiatCollateral.test.ts.snap index 2c8af6504a..de69e7ba61 100644 --- a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVENonFiatCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVENonFiatCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionality Gas Reporting refresh() after full price timeout 1`] = `133645`; exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionality Gas Reporting refresh() after full price timeout 2`] = `129176`; @@ -24,6 +28,10 @@ exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionali exports[`Collateral: MorphoAAVEV2NonFiatCollateral - WBTC collateral functionality Gas Reporting refresh() during soft default 2`] = `192439`; +exports[`Collateral: MorphoAAVEV2NonFiatCollateral - stETH collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2NonFiatCollateral - stETH collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2NonFiatCollateral - stETH collateral functionality Gas Reporting refresh() after full price timeout 1`] = `167277`; exports[`Collateral: MorphoAAVEV2NonFiatCollateral - stETH collateral functionality Gas Reporting refresh() after full price timeout 2`] = `162808`; diff --git a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVESelfReferentialCollateral.test.ts.snap b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVESelfReferentialCollateral.test.ts.snap index 8bc1fa5575..9148485dab 100644 --- a/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVESelfReferentialCollateral.test.ts.snap +++ b/test/plugins/individual-collateral/morpho-aave/__snapshots__/MorphoAAVESelfReferentialCollateral.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: MorphoAAVEV2SelfReferentialCollateral - WETH collateral functionality Gas Reporting ERC20 transfer 1`] = `73881`; + +exports[`Collateral: MorphoAAVEV2SelfReferentialCollateral - WETH collateral functionality Gas Reporting ERC20 transfer 2`] = `56781`; + exports[`Collateral: MorphoAAVEV2SelfReferentialCollateral - WETH collateral functionality Gas Reporting refresh() after full price timeout 1`] = `201563`; exports[`Collateral: MorphoAAVEV2SelfReferentialCollateral - WETH collateral functionality Gas Reporting refresh() after full price timeout 2`] = `197094`; diff --git a/test/plugins/individual-collateral/rocket-eth/__snapshots__/RethCollateralTestSuite.test.ts.snap b/test/plugins/individual-collateral/rocket-eth/__snapshots__/RethCollateralTestSuite.test.ts.snap index 4c876c0ecb..3f40d8ff1a 100644 --- a/test/plugins/individual-collateral/rocket-eth/__snapshots__/RethCollateralTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/rocket-eth/__snapshots__/RethCollateralTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: RocketPoolETH collateral functionality Gas Reporting ERC20 transfer 1`] = `59421`; + +exports[`Collateral: RocketPoolETH collateral functionality Gas Reporting ERC20 transfer 2`] = `42321`; + exports[`Collateral: RocketPoolETH collateral functionality Gas Reporting refresh() after full price timeout 1`] = `70887`; exports[`Collateral: RocketPoolETH collateral functionality Gas Reporting refresh() after full price timeout 2`] = `66418`; diff --git a/test/plugins/individual-collateral/stargate/__snapshots__/StargateETHTestSuite.test.ts.snap b/test/plugins/individual-collateral/stargate/__snapshots__/StargateETHTestSuite.test.ts.snap index 3eb6942200..43bd23c66d 100644 --- a/test/plugins/individual-collateral/stargate/__snapshots__/StargateETHTestSuite.test.ts.snap +++ b/test/plugins/individual-collateral/stargate/__snapshots__/StargateETHTestSuite.test.ts.snap @@ -1,5 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting ERC20 transfer 1`] = `114735`; + +exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting ERC20 transfer 2`] = `97635`; + exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting refresh() after full price timeout 1`] = `55263`; exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting refresh() after full price timeout 2`] = `50795`; @@ -24,6 +28,10 @@ exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting re exports[`Collateral: Stargate ETH Pool collateral functionality Gas Reporting refresh() during soft default 2`] = `66542`; +exports[`Collateral: Stargate USDC Pool collateral functionality Gas Reporting ERC20 transfer 1`] = `114735`; + +exports[`Collateral: Stargate USDC Pool collateral functionality Gas Reporting ERC20 transfer 2`] = `97635`; + exports[`Collateral: Stargate USDC Pool collateral functionality Gas Reporting refresh() after full price timeout 1`] = `55263`; exports[`Collateral: Stargate USDC Pool collateral functionality Gas Reporting refresh() after full price timeout 2`] = `50795`;