Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTG-001 Add December Instruments #355

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 8 additions & 20 deletions addresses/arb_mainnet/assets.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
{
"dataType": "Map",
"value": [
[
"0x303000000000",
"0x82af49447d8a07e3bd95bd0d56f35241523fbab1"
],
[
"0x303100000000",
"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"
],
[
"0x303200000000",
"0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
],
[
"0x30A000000000",
"0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"
]
]
}
"dataType": "Map",
"value": [
["0x303000000000", "0x82af49447d8a07e3bd95bd0d56f35241523fbab1"],
["0x303100000000", "0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"],
["0x303200000000", "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"],
["0x30A000000000", "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"]
]
}
16 changes: 16 additions & 0 deletions addresses/arb_mainnet/deployers.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,22 @@
[
"0xA73ba15B76a165a4dB56ef71B46D695A751334b6",
"0xC7aE076086623ecEA2450e364C838916a043F9a8"
],
[
"0x394C7ACEEbbD5F6CDf5b4DC7315933eA6CBCcb5C",
"0x05950b4e68f103d5aBEf20364dE219a247e59C23"
],
[
"0x01FE7dDE6688C92DDAcAB33bb2df7c20cf8C1702",
"0x05950b4e68f103d5aBEf20364dE219a247e59C23"
],
[
"0x54A0FDAff2A691e623065D79B2534105748C0C3F",
"0x05950b4e68f103d5aBEf20364dE219a247e59C23"
],
[
"0x40EcBf16Ea85FF6edF62896EcF45536fC5121430",
"0x05950b4e68f103d5aBEf20364dE219a247e59C23"
]
]
}
16 changes: 16 additions & 0 deletions addresses/arb_mainnet/joins.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@
[
"0x00A0FF00028B",
"0xACEe99762457023925E535dB1f52364cBEBe6A71"
],
[
"0x0030FF000291",
"0x394C7ACEEbbD5F6CDf5b4DC7315933eA6CBCcb5C"
],
[
"0x0031FF000291",
"0x01FE7dDE6688C92DDAcAB33bb2df7c20cf8C1702"
],
[
"0x0032FF000291",
"0x54A0FDAff2A691e623065D79B2534105748C0C3F"
],
[
"0x00A0FF000291",
"0x40EcBf16Ea85FF6edF62896EcF45536fC5121430"
]
]
}
2 changes: 0 additions & 2 deletions contracts/Importer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import "@yield-protocol/utils-v2/src/utils/Timelock.sol";
import "@yield-protocol/utils-v2/src/utils/EmergencyBrake.sol";
import "@yield-protocol/utils-v2/src/utils/Assert.sol";
import "@yield-protocol/utils-v2/src/token/ERC20RewardsWrapper.sol";
import "@yield-protocol/utils-v2/src/token/TokenUpgrade.sol";
import "@yield-protocol/strategy-v2/src/Strategy.sol";
import "@yield-protocol/yvarb/contracts/YieldStEthLever.sol";
import "@yield-protocol/yvarb/contracts/YieldNotionalLever.sol";
import "erc3156-wrappers/contracts/uniswap/UniswapERC3156.sol";
69 changes: 36 additions & 33 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs'
import * as fs from 'fs'
import * as path from 'path'

import '@nomiclabs/hardhat-waffle'
Expand All @@ -11,10 +11,10 @@ import 'hardhat-gas-reporter'
import 'solidity-coverage'

// uncomment this to verify Tenderly contracts
import * as tdly from "@tenderly/hardhat-tenderly";
tdly.setup();
import * as tdly from '@tenderly/hardhat-tenderly'
tdly.setup()

import "./augmentations"
import './augmentations'

function infuraNodeUrl(network: any) {
let infuraKey
Expand All @@ -36,37 +36,39 @@ function alchemyNodeUrl(network: any) {
return `https://eth-${network}.alchemyapi.io/v2/${alchemyKey}`
}


function arbNodeUrl(network: string) {
switch (network) {
// case "rinkeby": return "https://rinkeby.arbitrum.io/rpc";
case "mainnet": return "https://arb1.arbitrum.io/rpc";
case 'mainnet':
return 'https://arb1.arbitrum.io/rpc'
}
throw new Error(`Unknown arbitrum network ${network}`);
throw new Error(`Unknown arbitrum network ${network}`)
}

let mnemonic = process.env.MNEMONIC
if (!mnemonic) {
try {
mnemonic = fs.readFileSync(path.resolve(__dirname, '.secret')).toString().trim()
} catch (e) { }
} catch (e) {}
}
const accounts = mnemonic ? {
mnemonic,
} : undefined
const accounts = mnemonic
? {
mnemonic,
}
: undefined

let etherscanKey = process.env.ETHERSCANKEY
if (!etherscanKey) {
try {
etherscanKey = fs.readFileSync(path.resolve(__dirname, '.etherscanKey')).toString().trim()
} catch (e) { }
} catch (e) {}
}

let arbiscanKey = process.env.ARBISCANKEY
if (!arbiscanKey) {
try {
arbiscanKey = fs.readFileSync(path.resolve(__dirname, '.arbiscanKey')).toString().trim()
} catch (e) { }
} catch (e) {}
}

module.exports = {
Expand All @@ -76,15 +78,15 @@ module.exports = {
optimizer: {
enabled: true,
runs: 100,
}
}
},
},
},
abiExporter: {
path: './abis',
clear: true,
flat: true,
// only: [':ERC20$'],
spacing: 2
spacing: 2,
},
typechain: {
outDir: 'typechain',
Expand Down Expand Up @@ -113,46 +115,47 @@ module.exports = {
},
localhost: {
timeout: 600000,
chainId: 42161, // hardhat node used 31337 for local host but anvil uses the actual chainid
chainId: 42161, // hardhat node used 31337 for local host but anvil uses the actual chainid
loggingEnabled: true,
},
tenderly: {
// update url of fork
url: "https://rpc.tenderly.co/fork/08a8b5cd-268d-45a3-9a3c-c5174db794f3",
url: 'https://rpc.tenderly.co/fork/1f7ebecb-407d-422e-a2d9-86c0f59011e0',
blockGasLimit: 300_000_000_000,
// update chainId if necessary
forkNetwork: "1",
username: "Yield",
project: "v2",
timeout: 60_000_000,
gasPrice: 1_000_000_000
// forkNetwork: '',
// username: 'Yield',
// project: 'v2',
// timeout: 60_000_000,
gasPrice: 1_000_000_000,
},
mainnet: {
accounts,
blockGasLimit: 300_000_000_000,
gasPrice: 20_000_000_000,
timeout: 60_000_000,
gasMultiplier: 1.2,
url: infuraNodeUrl('mainnet')
url: infuraNodeUrl('mainnet'),
},
arb_mainnet: {
accounts,
url: arbNodeUrl('mainnet'),
chainId: 42161,
timeout: 60000
timeout: 60000,
},
coverage: {
url: 'http://127.0.0.1:8555',
},
},
tenderly: {
username: "Yield",
project: "v2",
forkNetwork: "1",
},
username: 'Yield',
project: 'v2',
forkNetwork: '1',
},
etherscan: {
apiKey: {
mainnet: etherscanKey,
arbitrumOne: arbiscanKey
}
}
}
arbitrumOne: arbiscanKey,
},
},
}
13 changes: 8 additions & 5 deletions scripts/fragments/assetsAndSeries/makeIlk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ export const makeIlk = async (

proposal = proposal.concat(await updateCollateralization(cauldron, ilk.collateralization, nesting + 1))
proposal = proposal.concat(await updateDebtLimits(cauldron, ilk, nesting + 1))

// We add ETH as a collateral type for all ilks, with a fixed collateralization of 200%, just so that all assets can be priced in ETH terms
let priceInEth = { baseId: ilk.collateralization.ilkId, ilkId: ETH, oracle: ilk.collateralization.oracle, ratio: 2000000 }
proposal = proposal.concat(await updateCollateralization(cauldron, priceInEth, nesting + 1))


// Doing this for ETH ilks would override the legit values
if (ilk.collateralization.ilkId !== ETH) {
// We add ETH as a collateral type for all ilks, with a fixed collateralization of 200%, just so that all assets can be priced in ETH terms
let priceInEth = { baseId: ilk.collateralization.ilkId, ilkId: ETH, oracle: ilk.collateralization.oracle, ratio: 2000000 }
proposal = proposal.concat(await updateCollateralization(cauldron, priceInEth, nesting + 1))
}

// Some ilks are not liquidable
if (ilk.auctionLineAndLimit !== undefined) {
proposal = proposal.concat(await addIlkToWitch(cloak, witch, ilk, join, nesting + 1))
Expand Down
36 changes: 35 additions & 1 deletion scripts/fragments/oracles/updateYieldSpaceMultiOracleSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* These data sources are IOracle contracts that will be used either directly or as part of paths.
*/

import { ethers } from 'hardhat'
import { getName, indent } from '../../../shared/helpers'
import { YieldSpaceMultiOracle } from '../../../typechain'
import { OracleSource } from '../../governance/confTypes'
Expand All @@ -28,3 +27,38 @@ export const updateYieldSpaceMultiOracleSource = async (

return proposal
}

export const updateYieldSpaceMultiOracleSources = async (
yieldSpaceMultiOracle: YieldSpaceMultiOracle,
sources: OracleSource[],
pools: Map<string, string>,
nesting: number = 0
): Promise<Array<{ target: string; data: string }>> => {
console.log()
console.log(indent(nesting, `UPDATE_YIELD_SPACE_MULTI_ORACLE_SOURCES`))
const proposal: Array<{ target: string; data: string }> = []

const added = new Set<string>()

for (let source of sources) {
const pair = `${getName(source.baseId)}/${getName(source.quoteId)}`

if (added.has(pair) || added.has(`${getName(source.quoteId)}/${getName(source.baseId)}`)) {
console.log(indent(nesting, `YieldSpaceMultiOracle: ${pair} already dealt with, skipping`))
continue
}
added.add(pair)

const proposalArray = await updateYieldSpaceMultiOracleSource(
yieldSpaceMultiOracle,
source.baseId,
source.quoteId,
pools.getOrThrow(source.baseId),
nesting + 1
)

proposalArray.forEach((arr) => proposal.push(arr))
}

return proposal
}
33 changes: 21 additions & 12 deletions scripts/fragments/witch/addIlkToWitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,28 @@ export const addIlkToWitch = async (
})
console.log(indent(nesting, `join(${getName(ilk.ilkId)}).grantRole(exit, witch)`))

proposal.push({
target: cloak.address,
data: cloak.interface.encodeFunctionData('add', [
witch.address,
[
{
host: join.address,
signature: id(join.interface, 'exit(address,uint128)'),
},
],
]),
const hasPermissions = await cloak.contains(witch.address, {
host: join.address,
signature: id(join.interface, 'exit(address,uint128)'),
})
console.log(indent(nesting, `cloak.add(witch exit ${getName(ilk.ilkId)})`))

if (!hasPermissions) {
proposal.push({
target: cloak.address,
data: cloak.interface.encodeFunctionData('add', [
witch.address,
[
{
host: join.address,
signature: id(join.interface, 'exit(address,uint128)'),
},
],
]),
})
console.log(indent(nesting, `cloak.add(witch exit ${getName(ilk.ilkId)})`))
} else {
console.log(indent(nesting, `Cloak already has permissions on the witch exit (${getName(ilk.ilkId)})`))
}
} else {
console.log(indent(nesting, `Witch already has an exit role on join(${getName(ilk.ilkId)})`))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -eux
export HERE=$(dirname $0)
RUN="npx hardhat run --network tenderly"

# Phase 1: Deploy Joins
# export CONF=$PWD/$HERE/contango.deployments
# $RUN $HERE/../../../../../shared/deploy.ts

# Phase 2: Orchestrate
export CONF=$PWD/$HERE/contango.config
$RUN $HERE/orchestrate.ts
# $RUN $HERE/../../../../../shared/approve.ts
# $RUN $HERE/../../../../../shared/execute.ts

Loading