diff --git a/.openzeppelin/unknown-1337.json b/.openzeppelin/unknown-1337.json index 8f0eb6b..1a00f40 100644 --- a/.openzeppelin/unknown-1337.json +++ b/.openzeppelin/unknown-1337.json @@ -3,24 +3,122 @@ "proxies": [ { "address": "0xAa588d3737B611baFD7bD713445b314BD453a5C8", - "txHash": "0xbff0d19a2b783c142078a6bcb92dfe11daa3e41825b357339fd6af46f9e0cab0", + "txHash": "0xba09ef006b8c13132b90d051eb29f8d37807b9f94535f5faa97d39d294d005de", "kind": "uups" }, { "address": "0xf204a4Ef082f5c04bB89F7D5E6568B796096735a", - "txHash": "0x6a52214d95c8e2ac3fae0f8f24ac302c3c50704983ac34f52bedf4a62e5e7784", + "txHash": "0x84a0c962b459be20c0bd6b641f311facddd17a1dd59bb3792bdef9b73286b0de", "kind": "uups" }, { "address": "0xdDA6327139485221633A1FcD65f4aC932E60A2e1", - "txHash": "0xe16d5c84ecdaa19680581a1a4c98b8f8ef82b6adf22f9e031ed0876899a73d2e", + "txHash": "0xc7425f15aa452f205c9c9b469e78a1ea286cdbc2487fda2dd14f9e66fe52facd", "kind": "uups" } ], "impls": { - "e2f4b79cb79843693558203eb40c54091f9d2c17d5770e75827ce7be7c1d0168": { + "87784a845eba6fa7a50a7a794443408fef1f3145e3f3ed9fe34d8db84b28f31b": { + "address": "0x82D50AD3C1091866E258Fd0f1a7cC9674609D254", + "txHash": "0xe962d153c25e131ddac53e63d84a5a5efdbf58de81caf177de626fa4221b009a", + "layout": { + "storage": [ + { + "contract": "Initializable", + "label": "_initialized", + "type": "t_uint8", + "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", + "retypedFrom": "bool" + }, + { + "contract": "Initializable", + "label": "_initializing", + "type": "t_bool", + "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" + }, + { + "contract": "Interest", + "label": "rate", + "type": "t_uint256", + "src": "../project:/contracts/Interest.sol:19" + }, + { + "contract": "Interest", + "label": "startTime", + "type": "t_uint256", + "src": "../project:/contracts/Interest.sol:23" + }, + { + "contract": "Interest", + "label": "startValue", + "type": "t_uint256", + "src": "../project:/contracts/Interest.sol:27" + }, + { + "contract": "ContextUpgradeable", + "label": "__gap", + "type": "t_array(t_uint256)50_storage", + "src": "../@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" + }, + { + "contract": "OwnableUpgradeable", + "label": "_owner", + "type": "t_address", + "src": "../@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" + }, + { + "contract": "OwnableUpgradeable", + "label": "__gap", + "type": "t_array(t_uint256)49_storage", + "src": "../@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" + }, + { + "contract": "ERC1967UpgradeUpgradeable", + "label": "__gap", + "type": "t_array(t_uint256)50_storage", + "src": "../@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" + }, + { + "contract": "UUPSUpgradeable", + "label": "__gap", + "type": "t_array(t_uint256)50_storage", + "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:107" + }, + { + "contract": "Swap", + "label": "params", + "type": "t_contract(IParameters)9276", + "src": "../project:/contracts/Swap.sol:15" + } + ], + "types": { + "t_contract(IParameters)9276": { + "label": "contract IParameters" + }, + "t_array(t_uint256)50_storage": { + "label": "uint256[50]" + }, + "t_uint256": { + "label": "uint256" + }, + "t_address": { + "label": "address" + }, + "t_array(t_uint256)49_storage": { + "label": "uint256[49]" + }, + "t_uint8": { + "label": "uint8" + }, + "t_bool": { + "label": "bool" + } + } + } + }, + "e230c1904bcdaaf74455a5d5b8dd7626321a7a08358fe8236262a01326433536": { "address": "0xFB88dE099e13c3ED21F80a7a1E49f8CAEcF10df6", - "txHash": "0x4112fc70c86a85173127ece6a2b78fd9262238189a58c8d1c645279195f64293", + "txHash": "0x49e0781c649cdee4644df6cd8893b23d3cc18d0b3de639e42d3c714107ecc9a8", "layout": { "storage": [ { @@ -274,104 +372,6 @@ } } } - }, - "87784a845eba6fa7a50a7a794443408fef1f3145e3f3ed9fe34d8db84b28f31b": { - "address": "0x82D50AD3C1091866E258Fd0f1a7cC9674609D254", - "txHash": "0x15efef1b642f06a1a34fe4d808dbe5fb8493997a47352df56bd63d30301fbb26", - "layout": { - "storage": [ - { - "contract": "Initializable", - "label": "_initialized", - "type": "t_uint8", - "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:62", - "retypedFrom": "bool" - }, - { - "contract": "Initializable", - "label": "_initializing", - "type": "t_bool", - "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol:67" - }, - { - "contract": "Interest", - "label": "rate", - "type": "t_uint256", - "src": "../project:/contracts/Interest.sol:19" - }, - { - "contract": "Interest", - "label": "startTime", - "type": "t_uint256", - "src": "../project:/contracts/Interest.sol:23" - }, - { - "contract": "Interest", - "label": "startValue", - "type": "t_uint256", - "src": "../project:/contracts/Interest.sol:27" - }, - { - "contract": "ContextUpgradeable", - "label": "__gap", - "type": "t_array(t_uint256)50_storage", - "src": "../@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol:36" - }, - { - "contract": "OwnableUpgradeable", - "label": "_owner", - "type": "t_address", - "src": "../@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:22" - }, - { - "contract": "OwnableUpgradeable", - "label": "__gap", - "type": "t_array(t_uint256)49_storage", - "src": "../@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol:94" - }, - { - "contract": "ERC1967UpgradeUpgradeable", - "label": "__gap", - "type": "t_array(t_uint256)50_storage", - "src": "../@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol:211" - }, - { - "contract": "UUPSUpgradeable", - "label": "__gap", - "type": "t_array(t_uint256)50_storage", - "src": "../@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol:107" - }, - { - "contract": "Swap", - "label": "params", - "type": "t_contract(IParameters)9276", - "src": "../project:/contracts/Swap.sol:15" - } - ], - "types": { - "t_contract(IParameters)9276": { - "label": "contract IParameters" - }, - "t_array(t_uint256)50_storage": { - "label": "uint256[50]" - }, - "t_uint256": { - "label": "uint256" - }, - "t_address": { - "label": "address" - }, - "t_array(t_uint256)49_storage": { - "label": "uint256[49]" - }, - "t_uint8": { - "label": "uint8" - }, - "t_bool": { - "label": "bool" - } - } - } } } } diff --git a/deployments-test.json b/deployments-test.json index 24af6e0..413569f 100644 --- a/deployments-test.json +++ b/deployments-test.json @@ -1,6 +1,6 @@ { "hedge": "0xAa588d3737B611baFD7bD713445b314BD453a5C8", "leverage": "0xf204a4Ef082f5c04bB89F7D5E6568B796096735a", - "swap": "0xdDA6327139485221633A1FcD65f4aC932E60A2e1", + "ETH/USD Swap": "0xdDA6327139485221633A1FcD65f4aC932E60A2e1", "timelock": "0x30753E4A8aad7F8597332E813735Def5dD395028" } \ No newline at end of file diff --git a/migrations/2_migrations.js b/migrations/2_migrations.js index d509183..f8603cf 100644 --- a/migrations/2_migrations.js +++ b/migrations/2_migrations.js @@ -13,18 +13,32 @@ const MockPrice = artifacts.require("MockPrice") const MockWETH = artifacts.require("MockWETH") const MockMath = artifacts.require("MockMath") -const addrs = { - dashboard: { // arbitrum - chainlinkFeed: "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612", - underlying: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", - }, - goerli: { - chainlinkFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e", - underlying: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", - }, - 'goerli-fork': { - chainlinkFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e", - underlying: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", +const consts = { + hedgeName: "USD Synth (ETH-backed)", + hedgeSymbol: "USDᵉᵗʰ", + leverageName: "ETHUSD Long", + leverageSymbol: "ETHUSD", + swapName: "ETH/USD Swap", + addrs: { + dashboard: { + name: "arbitrum", + chainlinkFeed: "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612", + underlying: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", + timelock: undefined // deploy a new timelock + }, + goerli: { + name: "goerli", + chainlinkFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e", + underlying: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + }, + 'goerli-fork': { + name: "goerli-fork", + chainlinkFeed: "0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e", + underlying: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + }, + test: { + name: "test", + } } } @@ -41,18 +55,19 @@ module.exports = async function (deployer, network, accounts) { await deployer.deploy(MockModel) await deployer.deploy(MockWETH, accounts) } else { - await deployer.deploy(Price8Decimal, addrs[network].chainlinkFeed) + await deployer.deploy(Price8Decimal, consts.addrs[network].chainlinkFeed) } await deployer.deploy(LinearModel) - const minDelay = (isLocal || isTestnet) ? 0 : (7 * 24 * 60 * 60) - await deployer.deploy(Timelock, minDelay, [accounts[0]], ['0x0000000000000000000000000000000000000000']) + let timelockAddr = consts.addrs[network].timelock + if (!timelockAddr) { + const minDelay = (isLocal || isTestnet) ? 0 : (7 * 24 * 60 * 60) + await deployer.deploy(Timelock, minDelay, [accounts[0]], ['0x0000000000000000000000000000000000000000']) + timelockAddr = Timelock.address + } - //const hedge = await deployer.deploy(Token, "Hedged WETH", "EUSD", accounts[0]) - //const leverage = await deployer.deploy(Token, "Leveraged WETH", "LETH", accounts[0]) - //await deployer.deploy(Swap, MockPrice.address, MockModel.address, hedge.address, leverage.address, MockWETH.address) - const hedge = await deployProxy(Token, ["Hedged WETH", "EUSD", accounts[0]], { deployer, kind: "uups" }); - const leverage = await deployProxy(Token, ["Leveraged WETH", "LETH", accounts[0]], { deployer, kind: "uups" }); + const hedge = await deployProxy(Token, [consts.hedgeName, consts.hedgeSymbol, accounts[0]], { deployer, kind: "uups" }); + const leverage = await deployProxy(Token, [consts.leverageName, consts.leverageSymbol, accounts[0]], { deployer, kind: "uups" }); let priceAddr let modelAddr @@ -64,28 +79,42 @@ module.exports = async function (deployer, network, accounts) { } else { priceAddr = Price8Decimal.address modelAddr = LinearModel.address - underlyingAddr = addrs[network].underlying + underlyingAddr = consts.addrs[network].underlying } const fee = isLocal ? '0' : '1000000000000000' // 0.1% to be safe, oracle updates every ~0.49% price change const params = await deployer.deploy(isLocal ? MockParameters : Parameters, fee, modelAddr, priceAddr, hedge.address, leverage.address, underlyingAddr) const swap = await deployProxy(Swap, [params.address], { deployer, kind: "uups" }) await hedge.grantRole(await hedge.MINTER_ROLE.call(), swap.address) - await hedge.grantRole(await hedge.DEFAULT_ADMIN_ROLE.call(), Timelock.address) + await hedge.grantRole(await hedge.DEFAULT_ADMIN_ROLE.call(), timelockAddr) await hedge.revokeRole(await hedge.DEFAULT_ADMIN_ROLE.call(), accounts[0]) await leverage.grantRole(await leverage.MINTER_ROLE.call(), swap.address) - await leverage.grantRole(await leverage.DEFAULT_ADMIN_ROLE.call(), Timelock.address) + await leverage.grantRole(await leverage.DEFAULT_ADMIN_ROLE.call(), timelockAddr) await leverage.revokeRole(await leverage.DEFAULT_ADMIN_ROLE.call(), accounts[0]) if (!isLocal) { - await swap.transferOwnership(Timelock.address) + await swap.transferOwnership(timelockAddr) } - fs.writeFileSync(`deployments-${network}.json`, JSON.stringify({ - hedge: hedge.address, - leverage: leverage.address, - swap: swap.address, - timelock: Timelock.address, - }, undefined, 2)) + const filename = `deployments-${consts.addrs[network].name}.json` + let deployments + try { + deployments = JSON.parse(fs.readFileSync(filename)) + } catch (e) { + if (e.code !== 'ENOENT') { + throw e + } + deployments = {} + } + if (isLocal) { + deployments.hedge = hedge.address + deployments.leverage = leverage.address + } else { + deployments[consts.hedgeSymbol] = hedge.address + deployments[consts.leverageSymbol] = leverage.address + } + deployments[consts.swapName] = swap.address + deployments.timelock = timelockAddr + fs.writeFileSync(filename, JSON.stringify(deployments, undefined, 2)) } };