Skip to content

Commit

Permalink
feat: usdt market on mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaShWoof committed Jun 6, 2024
1 parent 6612e4e commit 9cc487b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 34 deletions.
16 changes: 8 additions & 8 deletions deployments/mainnet/usdt/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion deployments/mainnet/usdt/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
{
Expand Down
5 changes: 4 additions & 1 deletion deployments/mainnet/usdt/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 3 additions & 11 deletions scenario/ApproveThisScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()');
});
});
12 changes: 8 additions & 4 deletions scenario/BulkerScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 },
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion scenario/LiquidationBotScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
};

Expand Down
7 changes: 6 additions & 1 deletion scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const addresses = {
WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
WETH9: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
CB_ETH: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704',
WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0'
WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
USDT: '0xdAC17F958D2ee523a2206206994597C13D831ec7'
},
goerli: {
WETH: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d'
Expand Down Expand Up @@ -87,6 +88,10 @@ export const flashLoanPools = {
weth: {
tokenAddress: addresses.mainnet.USDC,
poolFee: 500
},
usdt: {
tokenAddress: addresses.mainnet.DAI,
poolFee: 100
}
},
goerli: {
Expand Down

0 comments on commit 9cc487b

Please sign in to comment.