Skip to content

Commit

Permalink
Merge pull request #349 from arcxmoney/feat/deploy-vaults-pools-b-c
Browse files Browse the repository at this point in the history
Deploy WETH vaults B and C along with their pools
  • Loading branch information
gtupak authored Jul 12, 2022
2 parents 593b362 + 13f2e22 commit e7a0e44
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 20 deletions.
1 change: 0 additions & 1 deletion deployments/mumbai/collateral-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const collateralConfig: CollateralConfigMap = {
WMATIC: {
collateralAddress: '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889',
borrowPool: '0xb1fB649039F829Aa588bAc07411bb2D25A21E446',
mintLimit: utils.parseEther('500000'),
oracle: {
source: 'MockSapphireOracle',
getDeployTx: (signer: Signer) =>
Expand Down
45 changes: 44 additions & 1 deletion deployments/polygon/collateral-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const collateralConfig: CollateralConfigMap = {
WETH: {
collateralAddress: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
borrowPool: '0x59b8a21A0B0cE87E308082Af6fFC4205b5dC932C',
mintLimit: utils.parseEther('500000'),
oracle: {
source: 'ChainLinkOracle',
getDeployTx: (signer: Signer) =>
Expand All @@ -33,6 +32,50 @@ const collateralConfig: CollateralConfigMap = {
interestRate: '1547125957',
},
},
'WETH-B': {
collateralAddress: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
borrowPool: '0x1321f1f1aa541A56C31682c57b80ECfCCd9bB288',
oracle: '0x45e3875E434043670f8760e5e27cF170BE3BAFdf',
borrowRatios: {
highCRatio: utils.parseEther('1.4285714285'), // 70%
lowCRatio: utils.parseEther('1.0526315789'), // 95% LTV
},
fees: {
liquidatorDiscount: utils.parseEther('0.1'),
poolInterestFee: utils.parseEther('0.5'),
liquidationArcFee: utils.parseEther('0.5'),
borrowFee: utils.parseEther('0.0005'),
},
limits: {
vaultBorrowMax: utils.parseEther('100000'),
defaultBorrowLimit: 0,
},
interestSettings: {
interestRate: '937303470', // 3%
},
},
'WETH-C': {
collateralAddress: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
borrowPool: '0x69b37541d1C00c949B530ccd3d23437188767160',
oracle: '0x45e3875E434043670f8760e5e27cF170BE3BAFdf',
borrowRatios: {
highCRatio: utils.parseEther('1.4285714285'), // 70%
lowCRatio: utils.parseEther('1'), // 100% LTV
},
fees: {
liquidatorDiscount: utils.parseEther('0.1'),
poolInterestFee: utils.parseEther('0.5'),
liquidationArcFee: utils.parseEther('0.5'),
borrowFee: utils.parseEther('0.0005'),
},
limits: {
vaultBorrowMax: utils.parseEther('100000'),
defaultBorrowLimit: 0,
},
interestSettings: {
interestRate: '315522921', // 1%
},
},
};

export default collateralConfig;
42 changes: 41 additions & 1 deletion deployments/polygon/deployed.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,45 @@
"version": 3,
"type": "borrowing",
"group": ""
},
{
"name": "SapphirePoolProxy",
"source": "ArcProxy",
"address": "0x1321f1f1aa541A56C31682c57b80ECfCCd9bB288",
"txn": "0x86d66869ef489ac79389c3e734b030ed89e836f8f18b6823e02e0348810400c7",
"network": "polygon",
"version": 1,
"type": "borrowing",
"group": "B"
},
{
"name": "SapphireCoreProxy",
"source": "ArcProxy",
"address": "0xE106dDE30B538a0F86146862d131FC6733C6EEe4",
"txn": "0xf8377dd7c5550090185fa42fb8d56de9aba499979a9b379abb89c04baf709a32",
"network": "polygon",
"version": 1,
"type": "borrowing",
"group": "WETH-B"
},
{
"name": "SapphirePoolProxy",
"source": "ArcProxy",
"address": "0x69b37541d1C00c949B530ccd3d23437188767160",
"txn": "0xcde13415a2351ae894ddc52058e3a9e55f12ecf77b2465147e32e1fdec6a7899",
"network": "polygon",
"version": 1,
"type": "borrowing",
"group": "C"
},
{
"name": "SapphireCoreProxy",
"source": "ArcProxy",
"address": "0x1990BAbB67C1d297Fde4b3e540e6a32148654F44",
"txn": "0x64fb169bc729185cb3f2bfbcff4d3b7ca796decda632f0caaef8be57f148174f",
"network": "polygon",
"version": 1,
"type": "borrowing",
"group": "WETH-C"
}
]
]
13 changes: 7 additions & 6 deletions deployments/types/deploymentTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ export enum DeploymentType {
export interface CoreConfig {
collateralAddress: string;
borrowPool: string;
mintLimit: BigNumberish;
oracle: {
source: string;
getDeployTx: (signer: Signer) => TransactionRequest;
constructorArguments: unknown[];
};
oracle:
| string
| {
source: string;
getDeployTx: (signer: Signer) => TransactionRequest;
constructorArguments: unknown[];
};
borrowRatios: {
highCRatio: BigNumberish;
lowCRatio: BigNumberish;
Expand Down
38 changes: 30 additions & 8 deletions tasks/sapphire-tasks/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,10 @@ task('deploy-sapphire', 'Deploy a Sapphire core')

const { collateralAddress } = collatConfig;

const oracleAddress = await _deployOracle(
networkConfig,
signer,
hre,
collatConfig.oracle,
);
const oracleAddress =
typeof collatConfig.oracle === 'string'
? collatConfig.oracle
: await _deployOracle(networkConfig, signer, hre, collatConfig.oracle);

if (!oracleAddress) {
throw red(`The oracle was not deployed!`);
Expand Down Expand Up @@ -362,10 +360,12 @@ task('deploy-sapphire', 'Deploy a Sapphire core')
}

console.log(yellow(`Calling core.init() ...\n`));
// Setting interest rate setter as the deployer, to set it to the ultimate owner or prescribed interest setter later

const tx = await core.init(
collateralAddress,
oracleAddress,
collatConfig.interestSettings.interestSetter || ultimateOwner,
signer.address,
collatConfig.pauseOperator || ultimateOwner,
assessorAddress,
collatConfig.feeCollector || ultimateOwner,
Expand Down Expand Up @@ -430,6 +430,20 @@ task('deploy-sapphire', 'Deploy a Sapphire core')
await core.setInterestRate(collatConfig.interestSettings.interestRate);
console.log(green(`Interest rate successfully set\n`));
}

if (collatConfig.interestSettings.interestSetter !== signer.address) {
console.log(
yellow(
`Setting interest setter to ${
collatConfig.interestSettings.interestSetter || ultimateOwner
}\n`,
),
);
await core.setInterestSetter(
collatConfig.interestSettings.interestSetter || ultimateOwner,
);
console.log(green(`Interest setter successfully set\n`));
}
});

task('deploy-borrow-pool')
Expand All @@ -441,10 +455,17 @@ task('deploy-borrow-pool')
1,
types.int,
)
.addOptionalParam('group', 'Group name for the deployment registration')
.addFlag('implementationOnly', 'Only deploy the implementation contract')
.setAction(async (taskArgs, hre) => {
const { network, signer, networkConfig } = await loadDetails(hre);
const { name, symbol, contractVersion, implementationOnly } = taskArgs;
const {
name,
symbol,
contractVersion,
implementationOnly,
group,
} = taskArgs;

await pruneDeployments(network, signer.provider);

Expand Down Expand Up @@ -479,6 +500,7 @@ task('deploy-borrow-pool')
),
version: 1,
type: DeploymentType.borrowing,
group,
},
networkConfig,
);
Expand Down
6 changes: 3 additions & 3 deletions tasks/staking-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,12 @@ task(
'Prints the amount in wei to be created in the sablier stream',
)
.addParam('amount', 'Amount of ARCx to top up in ether')
.addParam('duration', 'Duration of the stream in seconds')
.setAction(async (taskArgs) => {
const { amount } = taskArgs;
const { amount, duration } = taskArgs;

const targetAmount = utils.parseEther(amount);
const streamDuration = 30 * 24 * 60 * 60;
const streamAmount = targetAmount.div(streamDuration).mul(streamDuration);
const streamAmount = targetAmount.div(duration).mul(duration);

console.log(green(`${streamAmount} wei`));
});
1 change: 1 addition & 0 deletions test/mainnet_fork/flashLiquidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('FlashLiquidator', () => {
const coreProxyAddress = loadContract({
network: 'polygon',
name: 'SapphireCoreProxy',
group: 'WETH',
}).address;
arc = SapphireArc.new(signer);
await arc.addCores({
Expand Down

0 comments on commit e7a0e44

Please sign in to comment.