Skip to content

Commit

Permalink
feat: wbtc market
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaShWoof committed Jan 21, 2025
1 parent 5fe26a2 commit bccbcaa
Show file tree
Hide file tree
Showing 13 changed files with 454 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
bases: [ development, mainnet, mainnet-weth, mainnet-usdt, mainnet-wsteth, mainnet-usds, sepolia-usdc, sepolia-weth, fuji, polygon, polygon-usdt, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-usdt, base-usdbc, base-weth, base-usdc, base-aero, optimism-usdc, optimism-usdt, optimism-weth, mantle-usde, scroll-usdc]
bases: [ development, mainnet, mainnet-weth, mainnet-wbtc, mainnet-usdt, mainnet-wsteth, mainnet-usds, sepolia-usdc, sepolia-weth, fuji, polygon, polygon-usdt, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-usdt, base-usdbc, base-weth, base-usdc, base-aero, optimism-usdc, optimism-usdt, optimism-weth, mantle-usde, scroll-usdc]
name: Run scenarios
env:
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
Expand Down
56 changes: 56 additions & 0 deletions deployments/mainnet/wbtc/configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "Compound WBTC",
"symbol": "cWBTCv3",
"baseToken": "WBTC",
"baseTokenAddress": "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
"baseTokenPriceFeed": "0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23",
"borrowMin": "0.001e8",
"governor": "0x6d903f6003cca6255d85cca4d3b5e5146dc33925",
"pauseGuardian": "0xbbf3f1421d886e9b2c5d716b5192ac998af2012c",
"storeFrontPriceFactor": 0.7,
"targetReserves": "250e18",
"rates": {
"borrowBase": 0.01,
"borrowSlopeLow": 0.014,
"borrowKink": 0.85,
"borrowSlopeHigh": 1.15,
"supplyBase": 0,
"supplySlopeLow": 0.012,
"supplyKink": 0.85,
"supplySlopeHigh": 1
},
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "0e0",
"baseBorrowSpeed": "0e0",
"baseMinForRewards": "0.1e18"
},
"rewardTokenAddress": "0xc00e94Cb662C3520282E6f5717214004A7f26888",
"assets": {
"SolvBTC.BBN": {
"address": "0xd9D920AA40f578ab794426F5C90F6C731D159DEf",
"decimals": "18",
"borrowCF": 0.81,
"liquidateCF": 0.84,
"liquidationFactor": 0.9,
"supplyCap": "0e18"
},
"LBTC": {
"address": "0x8236a87084f8B84306f72007F36F2618A5634494",
"priceFeed": "0x5c29868C58b6e15e2b962943278969Ab6a7D3212",
"decimals": "8",
"borrowCF": 0.73,
"liquidateCF": 0.75,
"liquidationFactor": 0.95,
"supplyCap": "0e18"
},
"pumpBTC": {
"address": "0xF469fBD2abcd6B9de8E169d128226C0Fc90a012e",
"decimals": "8",
"borrowCF": 0.75,
"liquidateCF": 0.78,
"liquidationFactor": 0.9,
"supplyCap": "0e8"
}
}
}
51 changes: 51 additions & 0 deletions deployments/mainnet/wbtc/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager';
import { DeploySpec, deployComet, exp } from '../../../src/deploy';

export default async function deploy(deploymentManager: DeploymentManager, deploySpec: DeploySpec): Promise<Deployed> {
const WBTC = await deploymentManager.existing('WBTC', '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599');
const solvBTC_BBN = await deploymentManager.existing('SolvBTC.BBN', '0xd9D920AA40f578ab794426F5C90F6C731D159DEf');
const LBTC = await deploymentManager.existing('LBTC', '0x8236a87084f8B84306f72007F36F2618A5634494');
const pumpBTC = await deploymentManager.existing('pumpBTC', '0xF469fBD2abcd6B9de8E169d128226C0Fc90a012e');
const COMP = await deploymentManager.existing('COMP', '0xc00e94Cb662C3520282E6f5717214004A7f26888');

const solvBTC_BBNPriceFeed = await deploymentManager.deploy(
'SolvBTC.BBN:priceFeed',
'pricefeeds/MultiplicativePriceFeed.sol',
[
'0x1f34794A16D644b9810477EbF3f0b3870141E2e3', // SolvBTC.BBN / SolvBTC price feed
'0x936B31C428C29713343E05D631e69304f5cF5f49', // SolvBTC / BTC price feed
8, // decimals
'solvBTC.BBN / BTC price feed' // description
],
true
);

// Deploy scaling price feed for pumpBTC
const pumpBTCScalingPriceFeed = await deploymentManager.deploy(
'pumpBTC:priceFeed',
'pricefeeds/ScalingPriceFeed.sol',
[
'0x6CE4Ef3689F26edD40ed3ccbE3Cc29dab62C915f', // pumpBTC / BTC price feed
8 // decimals
],
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');
const bulker = await deploymentManager.fromDep('bulker', 'mainnet', 'weth');

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

return {
...deployed,
bulker,
rewards,
COMP
};
}
264 changes: 264 additions & 0 deletions deployments/mainnet/wbtc/migrations/1737396251_configurate_and_ens.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
import { ethers, utils } from 'ethers';
import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager';
import { migration } from '../../../../plugins/deployment_manager/Migration';
import { exp, getConfigurationStruct, proposal } from '../../../../src/deploy';
import { expect } from 'chai';

const ENSName = 'compound-community-licenses.eth';
const ENSResolverAddress = '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41';
const ENSRegistryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
const ENSSubdomainLabel = 'v3-additional-grants';
const ENSSubdomain = `${ENSSubdomainLabel}.${ENSName}`;
const ENSTextRecordKey = 'v3-official-markets';

const cWBTCAddress = '0xC11b1268C1A384e55C48c2391d8d480264A3A7F4';
const WBTCAmount = ethers.BigNumber.from(exp(2, 8));

export default migration('1737396251_configurate_and_ens', {
async prepare() {
return {};
},

async enact(deploymentManager: DeploymentManager) {
const trace = deploymentManager.tracer();

const {
comet,
cometAdmin,
configurator,
rewards,
COMP,
WBTC,
governor
} = await deploymentManager.getContracts();
const cometFactory = await deploymentManager.fromDep('cometFactory', 'mainnet', 'usdc');

const configuration = await getConfigurationStruct(deploymentManager);

const ENSResolver = await deploymentManager.existing('ENSResolver', ENSResolverAddress);
const subdomainHash = ethers.utils.namehash(ENSSubdomain);
const currentChainId = 1;
const newMarketObject = { baseSymbol: 'WBTC', cometAddress: comet.address };
const officialMarketsJSON = JSON.parse(await ENSResolver.text(subdomainHash, ENSTextRecordKey));

if (officialMarketsJSON[currentChainId]) {
officialMarketsJSON[currentChainId].push(newMarketObject);
} else {
officialMarketsJSON[currentChainId] = [newMarketObject];
}

const _reduceReservesCalldata = utils.defaultAbiCoder.encode(
['uint256'],
[WBTCAmount]
);

const actions = [
// 1. Set the Comet factory in configuration
{
contract: configurator,
signature: 'setFactory(address,address)',
args: [comet.address, cometFactory.address],
},
// 2. Set the Comet configuration
{
contract: configurator,
signature: 'setConfiguration(address,(address,address,address,address,address,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint104,uint104,uint104,(address,address,uint8,uint64,uint64,uint64,uint128)[]))',
args: [comet.address, configuration],
},
// 3. Deploy Comet and upgrade it to the new implementation
{
contract: cometAdmin,
signature: 'deployAndUpgradeTo(address,address)',
args: [configurator.address, comet.address],
},
// 4. Set the reward configuration
{
contract: rewards,
signature: 'setRewardConfig(address,address)',
args: [comet.address, COMP.address],
},
// 5. Get WBTC reserves from cWBTC contract
{
target: cWBTCAddress,
signature: '_reduceReserves(uint256)',
calldata: _reduceReservesCalldata
},
// 6. Transfer WBTC to the Comet contract
{
contract: WBTC,
signature: 'transfer(address,uint256)',
args: [comet.address, WBTCAmount],
},
// 7. Update the list of official markets
{
target: ENSResolverAddress,
signature: 'setText(bytes32,string,string)',
calldata: ethers.utils.defaultAbiCoder.encode(
['bytes32', 'string', 'string'],
[subdomainHash, ENSTextRecordKey, JSON.stringify(officialMarketsJSON)]
)
}
];

const description = 'DESCRIPTION';
const txn = await deploymentManager.retry(
async () => trace((await governor.propose(...await proposal(actions, description))))
);

const event = txn.events.find(event => event.event === 'ProposalCreated');
const [proposalId] = event.args;

trace(`Created proposal ${proposalId}.`);
},

async enacted(): Promise<boolean> {
return false;
},

async verify(deploymentManager: DeploymentManager) {
const {
comet,
rewards,
timelock,
COMP,
pumpBTC,
'SolvBTC.BBN': solvBTC_BBN,
LBTC
} = await deploymentManager.getContracts();

// 1. & 2. & 3.
const solvBTC_BBNInfo = await comet.getAssetInfoByAddress(solvBTC_BBN.address);
const lbtcInfo = await comet.getAssetInfoByAddress(LBTC.address);
const pumpBTCInfo = await comet.getAssetInfoByAddress(pumpBTC.address);

// expect(solvBTC_BBNInfo.supplyCap).to.be.eq(exp(18, 18));
// expect(lbtcInfo.supplyCap).to.be.eq(exp(200, 8));
// expect(pumpBTCInfo.supplyCap).to.be.eq(exp(15, 8));

// expect(await comet.baseTrackingSupplySpeed()).to.be.equal(exp(1 / 86400, 15, 18)); // 11574074074
expect(await comet.baseTrackingBorrowSpeed()).to.be.equal(exp(0));


// 4
const config = await rewards.rewardConfig(comet.address);
expect(config.token).to.be.equal(COMP.address);
expect(config.rescaleFactor).to.be.equal(exp(1, 12));
expect(config.shouldUpscale).to.be.equal(true);

expect((await comet.pauseGuardian()).toLowerCase()).to.be.eq('0xbbf3f1421d886e9b2c5d716b5192ac998af2012c');

// 5. & 6.
expect(await comet.getReserves()).to.be.equal(WBTCAmount);

// 7.
const ENSResolver = await deploymentManager.existing('ENSResolver', ENSResolverAddress);
const ENSRegistry = await deploymentManager.existing('ENSRegistry', ENSRegistryAddress);
const subdomainHash = ethers.utils.namehash(ENSSubdomain);
const officialMarketsJSON = await ENSResolver.text(subdomainHash, ENSTextRecordKey);
const officialMarkets = JSON.parse(officialMarketsJSON);
expect(await ENSRegistry.recordExists(subdomainHash)).to.be.equal(true);
expect(await ENSRegistry.owner(subdomainHash)).to.be.equal(timelock.address);
expect(await ENSRegistry.resolver(subdomainHash)).to.be.equal(ENSResolverAddress);
expect(await ENSRegistry.ttl(subdomainHash)).to.be.equal(0);
expect(officialMarkets).to.deep.equal({
1: [
{
baseSymbol: 'USDC',
cometAddress: '0xc3d688B66703497DAA19211EEdff47f25384cdc3'
},
{
baseSymbol: 'WETH',
cometAddress: '0xA17581A9E3356d9A858b789D68B4d866e593aE94'
},
{
baseSymbol: 'USDT',
cometAddress: '0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840'
},
{
baseSymbol: 'wstETH',
cometAddress: '0x3D0bb1ccaB520A66e607822fC55BC921738fAFE3'
},
{
baseSymbol: 'USDS',
cometAddress: '0x5D409e56D886231aDAf00c8775665AD0f9897b56'
},
{
baseSymbol: 'WBTC',
cometAddress: comet.address
}
],
10: [
{
baseSymbol: 'USDC',
cometAddress: '0x2e44e174f7D53F0212823acC11C01A11d58c5bCB'
},
{
baseSymbol: 'USDT',
cometAddress: '0x995E394b8B2437aC8Ce61Ee0bC610D617962B214'
},
{
baseSymbol: 'WETH',
cometAddress: '0xE36A30D249f7761327fd973001A32010b521b6Fd'
}
],
137: [
{
baseSymbol: 'USDC',
cometAddress: '0xF25212E676D1F7F89Cd72fFEe66158f541246445'
},
{
baseSymbol: 'USDT',
cometAddress: '0xaeB318360f27748Acb200CE616E389A6C9409a07'
}
],
5000: [
{
baseSymbol: 'USDe',
cometAddress: '0x606174f62cd968d8e684c645080fa694c1D7786E'
}
],
8453: [
{
baseSymbol: 'USDbC',
cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf'
},
{
baseSymbol: 'WETH',
cometAddress: '0x46e6b214b524310239732D51387075E0e70970bf'
},
{
baseSymbol: 'USDC',
cometAddress: '0xb125E6687d4313864e53df431d5425969c15Eb2F'
},
{
baseSymbol: 'AERO',
cometAddress: '0x784efeB622244d2348d4F2522f8860B96fbEcE89'
},
],
42161: [
{
baseSymbol: 'USDC.e',
cometAddress: '0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA'
},
{
baseSymbol: 'USDC',
cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf'
},
{
baseSymbol: 'WETH',
cometAddress: '0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486'
},
{
baseSymbol: 'USDT',
cometAddress: '0xd98Be00b5D27fc98112BdE293e487f8D4cA57d07'
}
],
534352: [
{
baseSymbol: 'USDC',
cometAddress: '0xB2f97c1Bd3bf02f5e74d13f02E3e26F93D77CE44'
}
]
});
}
});
Loading

0 comments on commit bccbcaa

Please sign in to comment.