Skip to content

Commit

Permalink
deployed prod abis (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
akwritescode authored Jan 12, 2022
1 parent 01b4d4f commit 399da4e
Show file tree
Hide file tree
Showing 13 changed files with 720 additions and 162 deletions.
4 changes: 2 additions & 2 deletions packages/hardhat/contracts/core/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract Controller is Ownable, ReentrancyGuard, IERC721Receiver {

//80% of index
uint256 internal constant LOWER_MARK_RATIO = 8e17;
//125% of index
//140% of index
uint256 internal constant UPPER_MARK_RATIO = 140e16;
// 10%
uint256 internal constant LIQUIDATION_BOUNTY = 1e17;
Expand Down Expand Up @@ -476,7 +476,7 @@ contract Controller is Ownable, ReentrancyGuard, IERC721Receiver {
return 0;
}

// add back the bounty amount, liquidators only get reward from liquidation
// add back the bounty amount, liquidators onlly get reward from liquidation
cachedVault.addEthCollateral(bounty);

// if the vault is still not safe after saving, liquidate it
Expand Down
26 changes: 15 additions & 11 deletions packages/hardhat/deploy/01_deploy_uniswapv3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

console.log(`Start deploying with ${deployer}`)

const {deploy} = deployments;
const { deploy } = deployments;

if (hasUniswapDeployments(network.name)) {
console.log(`Already have Uniswap Deployment on network ${network.name}. Skipping this step. 🍹\n`)
} else {
console.log(`\nDeploying whole Uniswap 🦄 on network ${network.name} again...`)


// get WETH9
const weth9 = await getWETH(ethers, deployer, network.name)

// Deploy Uniswap Factory
await deploy("UniswapV3Factory", {
from: deployer,
Expand All @@ -51,7 +51,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
});
console.log(`UniswapV3Factory Deployed 🍹`)
const uniswapFactory = await ethers.getContract("UniswapV3Factory", deployer);

await deploy("SwapRouter", {
from: deployer,
log: true,
Expand All @@ -62,10 +62,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [uniswapFactory.address, weth9.address]
});
console.log(`SwapRouter Deployed 🍍`)

// tokenDescriptor is only used to query tokenURI() on NFT. Don't need that in our deployment
const tokenDescriptorAddress = ethers.constants.AddressZero

await deploy("NonfungiblePositionManager", {
from: deployer,
log: true,
Expand All @@ -75,14 +75,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
},
args: [uniswapFactory.address, weth9.address, tokenDescriptorAddress]
});
console.log(`NonfungiblePositionManager Deployed 🥑\n`)

console.log(`NonfungiblePositionManager Deployed 🥑\n`)
}

// deploy quoter separately.
const { uniswapFactory } = await getUniswapDeployments(ethers, deployer, network.name)
const weth = await getWETH(ethers, deployer, network.name)


if (network.name === "mainnet") {
return
}

await deploy("Quoter", {
from: deployer,
log: true,
Expand All @@ -93,7 +97,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
args: [uniswapFactory.address, weth.address]
});

console.log(`Quoter Deployed 🥦\n`)
console.log(`Quoter Deployed 🥦\n`)
}

export default func;
12 changes: 6 additions & 6 deletions packages/hardhat/deploy/03_deploy_pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployer } = await getNamedAccounts();

const { positionManager, uniswapFactory } = await getUniswapDeployments(ethers, deployer, network.name)

// Get Tokens
const weth9 = await getWETH(ethers, deployer, network.name)
const usdc = await getUSDC(ethers, deployer, network.name);

// Create ETH/SQUEETH Pool with positionManager
const squeeth = await ethers.getContract("WPowerPerp", deployer);

// update this number to initial price we want to start the pool with.
const squeethPriceInEth = 3350 / oracleScaleFactor.toNumber();

const squeethPriceInEth = 3290 / oracleScaleFactor.toNumber();
const squeethWethPool = await createUniPool(squeethPriceInEth, weth9, squeeth, positionManager, uniswapFactory)
const tx1 = await squeethWethPool.increaseObservationCardinalityNext(128)
const tx1 = await squeethWethPool.increaseObservationCardinalityNext(128)
await ethers.provider.waitForTransaction(tx1.hash, 1)

console.log(`SQU/ETH Pool created 🐑. Address: ${squeethWethPool.address}`)

if (network.name === "mainnet") {
Expand Down
22 changes: 11 additions & 11 deletions packages/hardhat/deploy/04_deploy_controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HardhatRuntimeEnvironment} from 'hardhat/types';
import {DeployFunction} from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from 'hardhat-deploy/types';

import { getPoolAddress } from '../test/setup'
import { getUniswapDeployments, getUSDC, getWETH } from '../tasks/utils'
Expand All @@ -15,7 +15,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const oracle = await ethers.getContract("Oracle", deployer);
const shortSqueeth = await ethers.getContract("ShortPowerPerp", deployer);
const wsqueeth = await ethers.getContract("WPowerPerp", deployer);

const weth9 = await getWETH(ethers, deployer, network.name)

const usdc = await getUSDC(ethers, deployer, network.name)
Expand All @@ -26,17 +26,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const squeethEthPool = await getPoolAddress(weth9, wsqueeth, uniswapFactory)

// deploy abdk library
await deploy("ABDKMath64x64", { from: deployer, log: true})
await deploy("ABDKMath64x64", { from: deployer, log: true })
const abdk = await ethers.getContract("ABDKMath64x64", deployer)

await deploy("TickMathExternal", { from: deployer, log: true})
await deploy("TickMathExternal", { from: deployer, log: true })
const tickMathExternal = await ethers.getContract("TickMathExternal", deployer)

await deploy("SqrtPriceMathPartial", { from: deployer, log: true})
await deploy("SqrtPriceMathPartial", { from: deployer, log: true })
const sqrtPriceMathPartial = await ethers.getContract("SqrtPriceMathPartial", deployer)

// deploy controller
await deploy("Controller", { from: deployer, log: true, libraries: {ABDKMath64x64: abdk.address, SqrtPriceMathPartial: sqrtPriceMathPartial.address, TickMathExternal: tickMathExternal.address}, args:[oracle.address, shortSqueeth.address, wsqueeth.address, weth9.address, usdc.address, ethUSDCPool, squeethEthPool, positionManager.address, feeTier]});
await deploy("Controller", { from: deployer, log: true, libraries: { ABDKMath64x64: abdk.address, SqrtPriceMathPartial: sqrtPriceMathPartial.address, TickMathExternal: tickMathExternal.address }, args: [oracle.address, shortSqueeth.address, wsqueeth.address, weth9.address, usdc.address, ethUSDCPool, squeethEthPool, positionManager.address, feeTier] });
const controller = await ethers.getContract("Controller", deployer);

try {
Expand All @@ -46,7 +46,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
} catch (error) {
console.log(`Squeeth already init or wrong deployer address.`)
}

try {
const tx = await shortSqueeth.init(controller.address, { from: deployer });
await ethers.provider.waitForTransaction(tx.hash, 1)
Expand All @@ -55,18 +55,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
console.log(`ShortPowerPerp already init or wrong deployer address.`)
}

const multisig = "0x609FFF64429e2A275a879e5C50e415cec842c629"
const alsig = "0x0144571202B48d8B3EEE3A95E4140B7144F8b72F"

if (network.name === "mainnet") {
try {
const tx = await controller.transferOwnership(multisig, { from: deployer });
const tx = await controller.transferOwnership(alsig, { from: deployer });
await ethers.provider.waitForTransaction(tx.hash, 1)
console.log(`Ownership transferred! 🥭`);
} catch (error) {
console.log(`Ownership transfer failed`)
}
}

}

export default func;
26 changes: 13 additions & 13 deletions packages/hardhat/deployments/mainnet/ABDKMath64x64.json

Large diffs are not rendered by default.

92 changes: 47 additions & 45 deletions packages/hardhat/deployments/mainnet/Controller.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions packages/hardhat/deployments/mainnet/Oracle.json

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions packages/hardhat/deployments/mainnet/ShortHelper.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions packages/hardhat/deployments/mainnet/ShortPowerPerp.json

Large diffs are not rendered by default.

Loading

1 comment on commit 399da4e

@vercel
Copy link

@vercel vercel bot commented on 399da4e Jan 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.