From 9cc487b92dd80bdc060975047745ae815118e4eb Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Thu, 6 Jun 2024 18:57:16 +0300 Subject: [PATCH] feat: usdt market on mainnet --- deployments/mainnet/usdt/configuration.json | 16 ++++++++-------- deployments/mainnet/usdt/deploy.ts | 2 +- .../migrations/1717664323_configurate_and_ens.ts | 13 ++++++------- deployments/mainnet/usdt/relations.ts | 5 ++++- scenario/ApproveThisScenario.ts | 14 +++----------- scenario/BulkerScenario.ts | 12 ++++++++---- scenario/LiquidationBotScenario.ts | 4 +++- .../liquidateUnderwaterBorrowers.ts | 7 ++++++- 8 files changed, 39 insertions(+), 34 deletions(-) diff --git a/deployments/mainnet/usdt/configuration.json b/deployments/mainnet/usdt/configuration.json index 8d86a6cd7..e65375ab8 100644 --- a/deployments/mainnet/usdt/configuration.json +++ b/deployments/mainnet/usdt/configuration.json @@ -34,14 +34,6 @@ "liquidationFactor": 0.75, "supplyCap": "0e18" }, - "WBTC": { - "address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", - "decimals": "8", - "borrowCF": 0.80, - "liquidateCF": 0.85, - "liquidationFactor": 0.95, - "supplyCap": "0e8" - }, "WETH": { "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "decimals": "18", @@ -50,6 +42,14 @@ "liquidationFactor": 0.95, "supplyCap": "0e18" }, + "WBTC": { + "address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", + "decimals": "8", + "borrowCF": 0.80, + "liquidateCF": 0.85, + "liquidationFactor": 0.95, + "supplyCap": "0e8" + }, "UNI": { "address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984", "decimals": "18", diff --git a/deployments/mainnet/usdt/deploy.ts b/deployments/mainnet/usdt/deploy.ts index a48250854..bdc3ff96b 100644 --- a/deployments/mainnet/usdt/deploy.ts +++ b/deployments/mainnet/usdt/deploy.ts @@ -77,10 +77,10 @@ export default async function deploy(deploymentManager: DeploymentManager, deplo 8 // decimals ] ); + const cometFactory = await deploymentManager.deploy('USDT:cometFactory', 'CometFactory.sol', [], true); // Import shared contracts from cUSDCv3 const cometAdmin = await deploymentManager.fromDep('cometAdmin', 'mainnet', 'usdc'); - const cometFactory = await deploymentManager.fromDep('cometFactory', 'mainnet', 'usdc'); const $configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'mainnet', 'usdc'); const configurator = await deploymentManager.fromDep('configurator', 'mainnet', 'usdc'); const rewards = await deploymentManager.fromDep('rewards', 'mainnet', 'usdc'); diff --git a/deployments/mainnet/usdt/migrations/1717664323_configurate_and_ens.ts b/deployments/mainnet/usdt/migrations/1717664323_configurate_and_ens.ts index d654baa29..752006a95 100644 --- a/deployments/mainnet/usdt/migrations/1717664323_configurate_and_ens.ts +++ b/deployments/mainnet/usdt/migrations/1717664323_configurate_and_ens.ts @@ -13,17 +13,16 @@ const ENSTextRecordKey = 'v3-official-markets'; const cUSDTAddress = '0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9'; const USDTAmount = ethers.BigNumber.from(exp(500_000, 6)); - export default migration('1713517203_configurate_and_ens', { - prepare: async (_deploymentManager: DeploymentManager) => { - return {}; + async prepare(deploymentManager: DeploymentManager) { + const cometFactory = await deploymentManager.deploy('cometFactory', 'CometFactory.sol', [], true); + return { newFactoryAddress: cometFactory.address }; }, - enact: async (deploymentManager: DeploymentManager) => { + async enact(deploymentManager: DeploymentManager, _, { newFactoryAddress }) { const trace = deploymentManager.tracer(); const ethers = deploymentManager.hre.ethers; - const cometFactory = await deploymentManager.fromDep('cometFactory', 'mainnet', 'usdc'); const { comet, cometAdmin, @@ -52,13 +51,13 @@ export default migration('1713517203_configurate_and_ens', { ['uint256'], [USDTAmount] ); - + console.log('factory', newFactoryAddress); const actions = [ // 1. Set the Comet factory in configuration { contract: configurator, signature: 'setFactory(address,address)', - args: [comet.address, cometFactory.address], + args: [comet.address, newFactoryAddress], }, // 2. Set the Comet configuration { diff --git a/deployments/mainnet/usdt/relations.ts b/deployments/mainnet/usdt/relations.ts index a81e1fd7a..703290b78 100644 --- a/deployments/mainnet/usdt/relations.ts +++ b/deployments/mainnet/usdt/relations.ts @@ -12,7 +12,10 @@ export default { } }, 'USDT': { - artifact: 'contracts/test/NonStandardToken.sol:NonStandardToken', + artifact: 'contracts/test/NonStandardFaucetToken.sol:NonStandardToken', + }, + 'TetherToken': { + artifact: 'contracts/test/NonStandardFaucetToken.sol:NonStandardToken', }, 'AppProxyUpgradeable': { artifact: 'contracts/ERC20.sol:ERC20', diff --git a/scenario/ApproveThisScenario.ts b/scenario/ApproveThisScenario.ts index afc8d895e..c952e2185 100644 --- a/scenario/ApproveThisScenario.ts +++ b/scenario/ApproveThisScenario.ts @@ -17,31 +17,23 @@ scenario('Comet#approveThis > allows governor to authorize and rescind authoriza expect(await comet.isAllowed(comet.address, timelock.address)).to.be.false; }); -scenario.only('Comet#approveThis > allows governor to authorize and rescind authorization for non-Comet ERC20', {}, async ({ comet, timelock, actors }, context) => { +scenario('Comet#approveThis > allows governor to authorize and rescind authorization for non-Comet ERC20', {}, async ({ comet, timelock, actors }, context) => { const { admin } = actors; const baseTokenAddress = await comet.baseToken(); const baseToken = context.getAssetByAddress(baseTokenAddress); - console.log('baseToken', baseTokenAddress); const newAllowance = 999_888n; await context.setNextBaseFeeToZero(); - console.log(admin.address, timelock.address); - console.log('governor', await comet.governor()); - const usdt = context.getAssetByAddress('0xdAC17F958D2ee523a2206206994597C13D831ec7'); - console.log('allowance', await usdt.allowance(comet.address, timelock.address)); - await admin.approveThis(timelock.address, '0xdAC17F958D2ee523a2206206994597C13D831ec7', newAllowance, { gasPrice: 0 }); + await admin.approveThis(timelock.address, baseTokenAddress, newAllowance, { gasPrice: 0 }); - console.log('baseToken', baseToken.address); expect(await baseToken.allowance(comet.address, timelock.address)).to.be.equal(newAllowance); - console.log('baseToken', baseToken.address); await context.setNextBaseFeeToZero(); await admin.approveThis(timelock.address, baseTokenAddress, 0, { gasPrice: 0 }); - console.log('baseToken', baseToken.address); expect(await baseToken.allowance(comet.address, timelock.address)).to.be.equal(0n); }); scenario('Comet#approveThis > reverts if not called by governor', {}, async ({ comet, timelock }) => { await expectRevertCustom(comet.approveThis(timelock.address, comet.address, constants.MaxUint256), 'Unauthorized()'); -}); +}); \ No newline at end of file diff --git a/scenario/BulkerScenario.ts b/scenario/BulkerScenario.ts index 91e2608f8..bfeba4c65 100644 --- a/scenario/BulkerScenario.ts +++ b/scenario/BulkerScenario.ts @@ -24,8 +24,9 @@ scenario( const baseAssetAddress = await comet.baseToken(); const baseAsset = context.getAssetByAddress(baseAssetAddress); const baseScale = (await comet.baseScale()).toBigInt(); - const { asset: collateralAssetAddress, scale: scaleBN } = await comet.getAssetInfo(0); - const collateralAsset = context.getAssetByAddress(collateralAssetAddress); + const { asset: asset0, scale: scale0 } = await comet.getAssetInfo(0); + const { asset: asset1, scale: scale1 } = await comet.getAssetInfo(1); + const { asset: collateralAssetAddress, scale: scaleBN } = asset0 === wrappedNativeToken ? { asset: asset1, scale: scale1 } : { asset: asset0, scale: scale0 }; const collateralAsset = context.getAssetByAddress(collateralAssetAddress); const collateralScale = scaleBN.toBigInt(); const toSupplyCollateral = 3000n * collateralScale; const toBorrowBase = 1000n * baseScale; @@ -165,6 +166,7 @@ scenario( filter: async (ctx) => await isBulkerSupported(ctx) && await isRewardSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, { network: 'linea-goerli' }]), supplyCaps: { $asset0: 3000, + $asset1: 3000, }, tokenBalances: { albert: { $base: '== 1000000', $asset0: 3000 }, @@ -177,8 +179,10 @@ scenario( const baseAssetAddress = await comet.baseToken(); const baseAsset = context.getAssetByAddress(baseAssetAddress); const baseScale = (await comet.baseScale()).toBigInt(); - const { asset: collateralAssetAddress, scale: scaleBN } = await comet.getAssetInfo(0); - const collateralAsset = context.getAssetByAddress(collateralAssetAddress); + const { asset: asset0, scale: scale0 } = await comet.getAssetInfo(0); + const { asset: asset1, scale: scale1 } = await comet.getAssetInfo(1); + const { asset: collateralAssetAddress, scale: scaleBN } = asset0 === wrappedNativeToken ? { asset: asset1, scale: scale1 } : { asset: asset0, scale: scale0 }; const collateralAsset = context.getAssetByAddress(collateralAssetAddress); + console.log('collateralAsset', collateralAssetAddress); const collateralScale = scaleBN.toBigInt(); const [rewardTokenAddress] = await rewards.rewardConfig(comet.address); const toSupplyBase = 1_000_000n * baseScale; diff --git a/scenario/LiquidationBotScenario.ts b/scenario/LiquidationBotScenario.ts index 763468c9e..310ce695e 100644 --- a/scenario/LiquidationBotScenario.ts +++ b/scenario/LiquidationBotScenario.ts @@ -733,13 +733,15 @@ scenario( const baseTokenBalances = { mainnet: { usdc: 2250000, - weth: 20 + weth: 20, + usdt: 2250000 }, }; const assetAmounts = { mainnet: { usdc: ' == 5000', // COMP weth: ' == 10000', // CB_ETH + usdt: ' == 5000', // COMP }, }; diff --git a/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts b/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts index d073fb587..6daa02083 100644 --- a/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts +++ b/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts @@ -38,7 +38,8 @@ const addresses = { WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', WETH9: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', CB_ETH: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704', - WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0' + WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', + USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7' }, goerli: { WETH: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d' @@ -87,6 +88,10 @@ export const flashLoanPools = { weth: { tokenAddress: addresses.mainnet.USDC, poolFee: 500 + }, + usdt: { + tokenAddress: addresses.mainnet.DAI, + poolFee: 100 } }, goerli: {