Skip to content

Commit

Permalink
feat: new price feed and new collateral
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaShWoof committed Feb 6, 2025
1 parent 6cb9b95 commit cd720ae
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 16 deletions.
10 changes: 9 additions & 1 deletion deployments/base/usds/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@
"assets": {
"sUSDS": {
"address": "0x5875eEE11Cf8398102FdAd704C9E96607675467a",
"priceFeed": "0x2330aaE3bca5F05169d5f4597964D44522F62930",
"decimals": "18",
"borrowCF": 0.93,
"liquidateCF": 0.95,
"liquidationFactor": 0.96,
"supplyCap": "0e18"
},
"cbBTC": {
"address": "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
"priceFeed": "0x07DA0E54543a844a80ABE69c8A12F22B3aA59f9D",
"decimals": "8",
"borrowCF": 0.8,
"liquidateCF": 0.85,
"liquidationFactor": 0.95,
"supplyCap": "0e8"
}
}
}
23 changes: 19 additions & 4 deletions deployments/base/usds/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export default async function deploy(deploymentManager: DeploymentManager, deplo
return deployed;
}

const SUSDS_TO_USDS_PRICE_FEED = '0x026a5B6114431d8F3eF2fA0E1B2EDdDccA9c540E';
const USDS_TO_USD_PRICE_FEED = '0x2330aaE3bca5F05169d5f4597964D44522F62930';

async function deployContracts(
deploymentManager: DeploymentManager,
deploySpec: DeploySpec
Expand All @@ -22,6 +25,20 @@ async function deployContracts(
'base'
);

deploySpec.cometMain = true;
// deploySpec.cometExt = true;

const _sUSDSPriceFeed = await deploymentManager.deploy(
'sUSDS:priceFeed',
'pricefeeds/MultiplicativePriceFeed.sol',
[
SUSDS_TO_USDS_PRICE_FEED, // wstETH / stETH price feed
USDS_TO_USD_PRICE_FEED, // stETH / ETH price feed
8, // decimals
'sUSDS / USD price feed' // description
]
);

const COMP = await deploymentManager.existing(
'COMP',
'0x9e1028F5F1D5eDE59748FFceE5532509976840E0',
Expand All @@ -36,10 +53,8 @@ async function deployContracts(

// Import shared contracts from cUSDbCv3
const _cometAdmin = await deploymentManager.fromDep('cometAdmin', 'base', 'usdbc');
const _cometFactory = await deploymentManager.fromDep('cometFactory', 'base', 'usdbc');
const _$configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'base', 'usdbc');
const _configurator = await deploymentManager.fromDep('configurator', 'base', 'usdbc');
const _1rewards = await deploymentManager.fromDep('rewards', 'base', 'usdbc');
const _rewards = await deploymentManager.fromDep('rewards', 'base', 'usdbc');
const bulker = await deploymentManager.fromDep('bulker', 'base', 'usdbc');
const l2CrossDomainMessenger = await deploymentManager.fromDep('l2CrossDomainMessenger', 'base', 'usdbc');
const l2StandardBridge = await deploymentManager.fromDep('l2StandardBridge', 'base', 'usdbc');
Expand All @@ -48,7 +63,7 @@ async function deployContracts(

// Deploy Comet
const deployed = await deployComet(deploymentManager, deploySpec, {}, true);

console.log('deploySpec \n\n\n\n', deploySpec);
// XXX We will need to deploy a new bulker only if need to support wstETH

return {
Expand Down
21 changes: 18 additions & 3 deletions deployments/base/usds/migrations/1689893694_configurate_and_ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { diffState, getCometConfig } from '../../../../plugins/deployment_manage
import { migration } from '../../../../plugins/deployment_manager/Migration';
import { calldata, exp, getConfigurationStruct, proposal } from '../../../../src/deploy';
import { expect } from 'chai';
import { ethers, utils } from 'ethers';
import { ethers, utils, Contract } from 'ethers';

const ENSName = 'compound-community-licenses.eth';
const ENSResolverAddress = '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41';
Expand All @@ -27,15 +27,17 @@ export default migration('1689893694_configurate_and_ens', {
enact: async (deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager) => {
const trace = deploymentManager.tracer();

const cometFactory = await deploymentManager.fromDep('cometFactory', 'base', 'usdbc');
const cometFactory = await deploymentManager.contract('cometFactory');
const {
bridgeReceiver,
comet,
cometAdmin,
configurator,
rewards,
USDS
USDS,
// cometFactory
} = await deploymentManager.getContracts();
console.log('cometFactory', cometFactory?.address);

const {
baseL1CrossDomainMessenger,
Expand Down Expand Up @@ -203,6 +205,19 @@ export default migration('1689893694_configurate_and_ens', {
const officialMarketsJSON = await ENSResolver.text(subdomainHash, ENSTextRecordKey);
const officialMarkets = JSON.parse(officialMarketsJSON);

const cometNew = new Contract(
comet.address,
[
'function assetList() external view returns (address)',
],
await deploymentManager.getSigner()
);

const assetListAddress = await cometNew.assetList();

expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero);


expect(officialMarkets).to.deep.equal({
1: [
{
Expand Down
3 changes: 2 additions & 1 deletion forge/test/Comet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract CometTest is Test {
// XXX
}

function testFailXXX() public {
function test_RevertIf_Condition_XXX() public {
CometConfiguration.AssetConfig[] memory assets = new CometConfiguration.AssetConfig[](0);
CometConfiguration.Configuration memory config =
CometConfiguration.Configuration(address(0),
Expand All @@ -36,6 +36,7 @@ contract CometTest is Test {
0,
0,
assets);
vm.expectRevert();
comet = new Comet(config);
}
}
5 changes: 4 additions & 1 deletion plugins/deployment_manager/Spider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract } from 'ethers';
import { Contract, constants } from 'ethers';
import { HardhatRuntimeEnvironment as HRE } from 'hardhat/types';

import { Cache } from './Cache';
Expand Down Expand Up @@ -42,6 +42,9 @@ function maybeStore(alias: Alias, address: Address, into: Aliases): boolean {
if (maybeExists) {
if (maybeExists === address) {
return false;
} else if (maybeExists === constants.AddressZero && address !== constants.AddressZero) {
into.set(alias, address);
return true;
} else {
throw new Error(`Had ${alias} -> ${maybeExists}, not ${address}`);
}
Expand Down
9 changes: 6 additions & 3 deletions scenario/LiquidationScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { scenario } from './context/CometContext';
import { event, expect } from '../test/helpers';
import { expectRevertCustom, timeUntilUnderwater } from './utils';
import { matchesDeployment } from './utils';
import { getConfigForScenario } from './utils/scenarioHelper';

scenario(
'Comet#liquidation > isLiquidatable=true for underwater position',
Expand All @@ -18,16 +19,17 @@ scenario(
const { albert, betty } = actors;
const baseToken = await comet.baseToken();
const baseBorrowMin = (await comet.baseBorrowMin()).toBigInt();
const baseScale = await comet.baseScale();

await world.increaseTime(
await timeUntilUnderwater({
comet,
actor: albert,
fudgeFactor: 60n * 10n // 10 minutes past when position is underwater
fudgeFactor: 6000n * 6000n // 1 hour past when position is underwater
})
);

await betty.withdrawAsset({ asset: baseToken, amount: baseBorrowMin }); // force accrue
await betty.withdrawAsset({ asset: baseToken, amount: 1000n * baseScale.toBigInt() }); // force accrue

expect(await comet.isLiquidatable(albert.address)).to.be.true;
}
Expand Down Expand Up @@ -193,6 +195,7 @@ scenario(
scenario(
'Comet#liquidation > user can end up with a minted supply',
{
filter: async (ctx) => !matchesDeployment(ctx, [{ network: 'base', deployment: 'usds' }]),
tokenBalances: {
$comet: { $base: 1000 },
},
Expand All @@ -210,7 +213,7 @@ scenario(
Math.round(await timeUntilUnderwater({
comet,
actor: albert,
}) * 1.001) // XXX why is this off? better to use a price constraint?
}) * 1.1) // XXX why is this off? better to use a price constraint?
);

const ab0 = await betty.absorb({ absorber: betty.address, accounts: [albert.address] });
Expand Down
7 changes: 7 additions & 0 deletions scenario/utils/scenarioHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const config = {
bulkerBorrowAsset: 500,
liquidationBase: 100000,
liquidationBase1: 1000,
liquidationBase2: 1000,
liquidationAsset: 200,
liquidationAsset1: 1000,
liquidationDenominator: 90,
liquidationNumerator: 90,
rewardsAsset: 10000,
Expand Down Expand Up @@ -60,6 +62,11 @@ export function getConfigForScenario(ctx: CometContext) {
config.interestSeconds = 110;
}

if (ctx.world.base.network === 'base' && ctx.world.base.deployment === 'usds') {
config.liquidationBase2 = 100;
config.liquidationAsset1 = 99;
}

if (ctx.world.base.network === 'arbitrum' && ctx.world.base.deployment === 'usdc.e') {
config.liquidationDenominator = 84;
config.liquidationBase = 100000;
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,5 @@ export async function deployNetworkComet(
}
);

return { comet, configurator, rewards };
return { comet, configurator, rewards, cometFactory };
}
4 changes: 2 additions & 2 deletions tasks/deployment_manager/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ task('deploy', 'Deploys market')
maybeForkEnv,
{
writeCacheToDisk: !simulate || overwrite, // Don't write to disk when simulating, unless overwrite is set
verificationStrategy: 'lazy',
verificationStrategy: simulate? 'lazy' : 'eager',
}
);

Expand Down Expand Up @@ -261,7 +261,7 @@ task('deploy_and_migrate', 'Runs deploy and migration')
maybeForkEnv,
{
writeCacheToDisk: !simulate || overwrite, // Don't write to disk when simulating, unless overwrite is set
verificationStrategy: 'lazy',
verificationStrategy: simulate? 'lazy' : 'eager',
}
);

Expand Down

0 comments on commit cd720ae

Please sign in to comment.