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

copy rinkeby deploy folder and rename to goerli #287

Merged
merged 18 commits into from
Nov 2, 2022
Merged
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
23 changes: 23 additions & 0 deletions packages/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,28 @@
"perpHedgingReactor": "0xDd418b4Ec8396191D08957bD42F549e215B8e89a",
"USDC": "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8",
"WETH": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
},
"arbitrumGoerli": {
"OpynController": "0x11a602a5F5D823c103bb8b7184e22391Aae5F4C2",
"OpynAddressBook": "0xd6e67bF0b1Cdb34C37f31A2652812CB30746a94A",
"OpynOracle": "0x35578F5A49E1f1Cf34ed780B46A0BdABA23D4C0b",
"OpynNewCalculator": "0xcD270e755C2653e806e16dD3f78E16C89B7a1c9e",
"OpynOptionRegistry": "0x48A74b742bd97545ace8B0876F5BA7ED19DF6579",
"priceFeed": "0xDcA6c35228acb82363406CB2e7eee81B40c692aE",
"volFeed": "0x9Fc909273C6aF5b6fFd389Fa2B44492ff88a3be6",
"optionProtocol": "0x865Bd85b7275a33C87E8a7E31a125DD6338e6747",
"liquidityPool": "0x2ceDe96cd46C9B751EeB868A57FEDeD060Dbe6Bf",
"authority": "0xA524f4F9046a243c67A07dDE2D9477bf320Ed89E",
"portfolioValuesFeed": "0xbFC1eDc5c07ada83e0244b37A784486633910cD7",
"optionHandler": "0x8a265fa22aa5AF86fa763dC2cF04661bf06A52E6",
"opynInteractions": "0x5e5A98E2F7c71B159B9Ed771E4138d4B2464708c",
"normDist": "0xf63395764CAA20a54bF33fdCCdbC03b2BDc67453",
"BlackScholes": "0x8D3ac248d2598c0C43e1D48e5ad59093F9Cb1d40",
"optionsCompute": "0x8090b463afd758B59089905dc956300824cb2388",
"accounting": "0xCCc6ebF870aCcD83043e8dafaeB4366A4D1a2836",
"uniswapV3HedgingReactor": "0xE5b8F3b414a80b8C40ba438292Eb37918324d285",
"perpHedgingReactor": "0x34f5c89fC6b053728F264cd7f9F1cdFB887AEf86",
"USDC": "0x6775842ae82bf2f0f987b10526768ad89d79536e",
"WETH": "0x53320bE2A35649E9B2a0f244f9E9474929d3B699"
}
}
23 changes: 23 additions & 0 deletions packages/contracts/contracts.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,28 @@

"USDC": "0x0000000000000000000000000000000000000000",
"WETH": "0x0000000000000000000000000000000000000000"
},
"arbitrumGoerli": {
"OpynController": "0x11a602a5F5D823c103bb8b7184e22391Aae5F4C2",
"OpynAddressBook": "0xd6e67bF0b1Cdb34C37f31A2652812CB30746a94A",
"OpynOracle": "0x35578F5A49E1f1Cf34ed780B46A0BdABA23D4C0b",
"OpynNewCalculator": "0xcD270e755C2653e806e16dD3f78E16C89B7a1c9e",
"OpynOptionRegistry": "0x48A74b742bd97545ace8B0876F5BA7ED19DF6579",
"priceFeed": "0xDcA6c35228acb82363406CB2e7eee81B40c692aE",
"volFeed": "0x9Fc909273C6aF5b6fFd389Fa2B44492ff88a3be6",
"optionProtocol": "0x865Bd85b7275a33C87E8a7E31a125DD6338e6747",
"liquidityPool": "0x2ceDe96cd46C9B751EeB868A57FEDeD060Dbe6Bf",
"authority": "0xA524f4F9046a243c67A07dDE2D9477bf320Ed89E",
"portfolioValuesFeed": "0xbFC1eDc5c07ada83e0244b37A784486633910cD7",
"optionHandler": "0x8a265fa22aa5AF86fa763dC2cF04661bf06A52E6",
"opynInteractions": "0x5e5A98E2F7c71B159B9Ed771E4138d4B2464708c",
"normDist": "0xf63395764CAA20a54bF33fdCCdbC03b2BDc67453",
"BlackScholes": "0x8D3ac248d2598c0C43e1D48e5ad59093F9Cb1d40",
"optionsCompute": "0x8090b463afd758B59089905dc956300824cb2388",
"accounting": "0xCCc6ebF870aCcD83043e8dafaeB4366A4D1a2836",
"uniswapV3HedgingReactor": "0xE5b8F3b414a80b8C40ba438292Eb37918324d285",
"perpHedgingReactor": "0x34f5c89fC6b053728F264cd7f9F1cdFB887AEf86",
"USDC": "0x6775842ae82bf2f0f987b10526768ad89d79536e",
"WETH": "0x53320bE2A35649E9B2a0f244f9E9474929d3B699"
}
}
58 changes: 27 additions & 31 deletions packages/contracts/contracts/PortfolioValuesFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ contract PortfolioValuesFeed is AccessControl, ChainlinkClient {
);
event SetJobId(bytes32 jobId);
event SetFee(uint256 fee);
event SetOracle(address oracle);
event SetLiquidityPool(address liquidityPool);
event SetAddressStringMapping(address asset, string stringVersion);
event SetOracle(address oracle);
event SetLiquidityPool(address liquidityPool);
event SetAddressStringMapping(address asset, string stringVersion);

/**
* @notice Executes once when a contract is created to initialize state variables
Expand Down Expand Up @@ -85,35 +85,35 @@ contract PortfolioValuesFeed is AccessControl, ChainlinkClient {
///////////////
/// setters ///
///////////////

function setjobId(string memory _jobId) external {
_onlyGovernor();
_onlyGovernor();
jobId = stringToBytes32(_jobId);
emit SetJobId(jobId);
}
emit SetJobId(jobId);
}

function setFee(uint256 _fee) external {
_onlyGovernor();
_onlyGovernor();
fee = _fee;
emit SetFee(_fee);
}
}

function setOracle(address _oracle) external {
_onlyGovernor();
oracle = _oracle;
emit SetOracle(_oracle);
}
function setOracle(address _oracle) external {
_onlyGovernor();
oracle = _oracle;
emit SetOracle(_oracle);
}

function setLiquidityPool(address _liquidityPool) external {
_onlyGovernor();
liquidityPool = ILiquidityPool(_liquidityPool);
emit SetLiquidityPool(_liquidityPool);
emit SetLiquidityPool(_liquidityPool);
}

function setAddressStringMapping(address _asset, string memory _stringVersion) external {
_onlyGovernor();
stringedAddresses[_asset] = _stringVersion;
emit SetAddressStringMapping(_asset, _stringVersion);
emit SetAddressStringMapping(_asset, _stringVersion);
}

function setLink(address _link) external {
Expand Down Expand Up @@ -234,19 +234,15 @@ contract PortfolioValuesFeed is AccessControl, ChainlinkClient {
/// internal helpers //
///////////////////////

function stringToBytes32(string memory source)
private
pure
returns (bytes32 result)
{
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}

assembly {
// solhint-disable-line no-inline-assembly
result := mload(add(source, 32))
}
}
function stringToBytes32(string memory source) private pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}

assembly {
// solhint-disable-line no-inline-assembly
result := mload(add(source, 32))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,8 @@ contract MockPortfolioValuesFeed is AccessControl, ChainlinkClient {
int256 _vega,
int256 _theta,
int256 _callPutsValue,
uint256 _spotPrice
) external // recordChainlinkFulfillment(_requestId)
{
uint256 _spotPrice // recordChainlinkFulfillment(_requestId)
) external {
Types.PortfolioValues memory portfolioValue = Types.PortfolioValues({
delta: _delta,
gamma: _gamma,
Expand Down
44 changes: 44 additions & 0 deletions packages/contracts/deploy/Contract-addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,47 @@ accounting: '0x8DE2e57c48F7e6D12B4193311C2bC1d5e6C4C2bd'
uniswapV3HedgingReactor: '0xaa5FcA49bd299E7A3fd1a4b0CB89039413D5580C'

perpHedgingReactor: '0xed7a8131A77350967D0E0BF6290873F3f406567f'

## ARBITRUM GOERLI ALPHA

OpynController: '0x11a602a5F5D823c103bb8b7184e22391Aae5F4C2'

OpynAddressBook: '0xd6e67bF0b1Cdb34C37f31A2652812CB30746a94A'

OpynOracle: '0x35578F5A49E1f1Cf34ed780B46A0BdABA23D4C0b'

OpynNewCalculator: '0xcD270e755C2653e806e16dD3f78E16C89B7a1c9e'

OpynOptionRegistry: '0x48A74b742bd97545ace8B0876F5BA7ED19DF6579'

priceFeed: '0xDcA6c35228acb82363406CB2e7eee81B40c692aE'

volFeed: '0x9Fc909273C6aF5b6fFd389Fa2B44492ff88a3be6'

optionProtocol: '0x865Bd85b7275a33C87E8a7E31a125DD6338e6747'

liquidityPool: '0x2ceDe96cd46C9B751EeB868A57FEDeD060Dbe6Bf'

authority: '0xA524f4F9046a243c67A07dDE2D9477bf320Ed89E'

portfolioValuesFeed: '0xbFC1eDc5c07ada83e0244b37A784486633910cD7'

optionHandler: '0x8a265fa22aa5AF86fa763dC2cF04661bf06A52E6'

opynInteractions: '0x5e5A98E2F7c71B159B9Ed771E4138d4B2464708c'

normDist: '0xf63395764CAA20a54bF33fdCCdbC03b2BDc67453'

BlackScholes: '0x8D3ac248d2598c0C43e1D48e5ad59093F9Cb1d40'

optionsCompute: '0x8090b463afd758B59089905dc956300824cb2388'

accounting: '0xCCc6ebF870aCcD83043e8dafaeB4366A4D1a2836'

uniswapV3HedgingReactor: '0xE5b8F3b414a80b8C40ba438292Eb37918324d285'

perpHedgingReactor: '0x34f5c89fC6b053728F264cd7f9F1cdFB887AEf86'

USDC: '0x6775842ae82bf2f0f987b10526768ad89d79536e'

WETH: '0x53320bE2A35649E9B2a0f244f9E9474929d3B699'
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,41 @@ import { truncate } from "@ragetrade/sdk"
import { toWei } from "../../utils/conversion-helper"
import hre, { ethers } from "hardhat"
import path from "path"
import { WETH } from "../../types/WETH"
import { ERC20Interface } from "../../types/ERC20Interface"
import { MintableERC20 } from "../../types/MintableERC20"
import { OptionRegistry } from "../../types/OptionRegistry"
import { PriceFeed } from "../../types/PriceFeed"
import { VolatilityFeed } from "../../types/VolatilityFeed"
import { AlphaOptionHandler } from "../../types/AlphaOptionHandler"
import { Protocol } from "../../types/Protocol"
import { LiquidityPool } from "../../types/LiquidityPool"

import LiquidityPoolSol from "../../artifacts/contracts/LiquidityPool.sol/LiquidityPool.json"
import { AlphaPortfolioValuesFeed } from "../../types/AlphaPortfolioValuesFeed"
import { Accounting } from "../../types/Accounting"
import { BlackScholes } from "../../types/BlackScholes"
import { NormalDist } from "../../types/NormalDist"
import { PerpHedgingReactor } from "../../types/PerpHedgingReactor"
import {
WETH,
ERC20Interface,
MintableERC20,
OptionRegistry,
PriceFeed,
VolatilityFeed,
AlphaOptionHandler,
Protocol,
LiquidityPool,
AlphaPortfolioValuesFeed,
Accounting,
BlackScholes,
NormalDist,
PerpHedgingReactor
} from "../../types"

const addressPath = path.join(__dirname, "..", "..", "..", "contracts.json")

// Arbitrum rinkeby specific contract addresses. Change for other networks
const chainlinkOracleAddress = "0x5f0423B1a6935dc5596e7A24d98532b67A0AeFd8"
const gammaOracleAddress = "0xe4d64aed5e76bCcE2C255f3c819f4C3817D42f19"
const opynControllerProxyAddress = "0x2acb561509a082bf2c58ce86cd30df6c2c2017f6"
const opynAddressBookAddress = "0x2d3E178FFd961BD8C0b035C926F9f2363a436DdC"
const opynNewCalculatorAddress = "0xa91B46bDDB891fED2cEE626FB03E2929702951A6"
const oTokenFactoryAddress = "0xcBcC61d56bb2cD6076E2268Ea788F51309FA253B"
const marginPoolAddress = "0xDD91EB7C3822552D89a5Cb8D4166B1EB19A36Ff2"

// rage trade addresses for Arbitrum Rinkeby
const clearingHouseAddress = "0xe3B8eF0C2Ed6d8318F0b1b50A072e0cB508CDB04"
const vETHAddress = "0x164B8C1c65b73638e4C24dB781a0f41a87ba0501"
const usdcAddress = "0x33a010E74A354bd784a62cca3A4047C1A84Ceeab"
const wethAddress = "0xFCfbfcC11d12bCf816415794E5dc1BBcc5304e01"
// Arbitrum Goerli specific contract addresses. Change for other networks
const chainlinkOracleAddress = "0x62CAe0FA2da220f43a51F86Db2EDb36DcA9A5A08"
const gammaOracleAddress = "0x35578F5A49E1f1Cf34ed780B46A0BdABA23D4C0b"
const opynControllerProxyAddress = "0x11a602a5F5D823c103bb8b7184e22391Aae5F4C2"
const opynAddressBookAddress = "0xd6e67bF0b1Cdb34C37f31A2652812CB30746a94A"
const opynNewCalculatorAddress = "0xcD270e755C2653e806e16dD3f78E16C89B7a1c9e"
const oTokenFactoryAddress = "0xB19d2eA6f662b13F530CB84B048877E5Ed0bD8FE"
const marginPoolAddress = "0x0E0Ad3eA82EFAeAFb4476f5E8225b4746B88FD9f"

// rage trade addresses for Arbitrum Goerli
const clearingHouseAddress = "0x7047343e3eF25505263116212EE74430A2A12257"
const vETHAddress = "0xC85c06FCF9355876DF51a90C2c0290ECa913A04f"
const usdcAddress = "0x6775842ae82bf2f0f987b10526768ad89d79536e"
const wethAddress = "0x53320bE2A35649E9B2a0f244f9E9474929d3B699"

// uniswap v3 addresses (SAME FOR ALL CHAINS)
const uniswapV3SwapRouter = "0xE592427A0AEce92De3Edee1F18E0157C05861564"
Expand All @@ -47,8 +50,6 @@ const maxCallStrikePrice = utils.parseEther("5000")
const minPutStrikePrice = utils.parseEther("500")
const maxPutStrikePrice = utils.parseEther("5000")
const bidAskSpread = toWei("0.05")
const maxTimeDeviationThreshold = 600
const maxPriceDeviationThreshold = toWei("1")

const liquidityPoolTokenName = "Rysk DHV ETH/USDC"
const liquidityPoolTokenTicker = "ryUSDC-ETH"
Expand Down Expand Up @@ -96,8 +97,7 @@ async function main() {
portfolioValuesFeed,
authority.address,
priceFeed,
blackScholes,
normDist
blackScholes
)
const liquidityPool = lpParams.liquidityPool
const handler = lpParams.handler
Expand All @@ -113,28 +113,29 @@ async function main() {
// @ts-ignore
contractAddresses = JSON.parse(fs.readFileSync(addressPath))
} catch {
contractAddresses = { localhost: {}, arbitrumRinkeby: {} }
contractAddresses = { localhost: {}, arbitrumGoerli: {} }
}

// @ts-ignore
contractAddresses["arbitrumRinkeby"]["OpynController"] = opynControllerProxyAddress
contractAddresses["arbitrumRinkeby"]["OpynAddressBook"] = opynAddressBookAddress
contractAddresses["arbitrumRinkeby"]["OpynOracle"] = gammaOracleAddress
contractAddresses["arbitrumRinkeby"]["OpynNewCalculator"] = opynNewCalculatorAddress
contractAddresses["arbitrumRinkeby"]["OpynOptionRegistry"] = optionRegistry.address
contractAddresses["arbitrumRinkeby"]["priceFeed"] = priceFeed.address
contractAddresses["arbitrumRinkeby"]["volFeed"] = volFeed.address
contractAddresses["arbitrumRinkeby"]["optionProtocol"] = optionProtocol.address
contractAddresses["arbitrumRinkeby"]["liquidityPool"] = liquidityPool.address
contractAddresses["arbitrumRinkeby"]["authority"] = authority.address
contractAddresses["arbitrumRinkeby"]["portfolioValuesFeed"] = portfolioValuesFeed.address
contractAddresses["arbitrumRinkeby"]["optionHandler"] = handler.address
contractAddresses["arbitrumRinkeby"]["opynInteractions"] = interactions.address
contractAddresses["arbitrumRinkeby"]["normDist"] = normDist.address
contractAddresses["arbitrumRinkeby"]["BlackScholes"] = blackScholes.address
contractAddresses["arbitrumRinkeby"]["accounting"] = accounting.address
contractAddresses["arbitrumRinkeby"]["uniswapV3HedgingReactor"] = uniswapV3HedgingReactor.address
contractAddresses["arbitrumRinkeby"]["perpHedgingReactor"] = perpHedgingReactor.address
contractAddresses["arbitrumGoerli"]["OpynController"] = opynControllerProxyAddress
contractAddresses["arbitrumGoerli"]["OpynAddressBook"] = opynAddressBookAddress
contractAddresses["arbitrumGoerli"]["OpynOracle"] = gammaOracleAddress
contractAddresses["arbitrumGoerli"]["OpynNewCalculator"] = opynNewCalculatorAddress
contractAddresses["arbitrumGoerli"]["OpynOptionRegistry"] = optionRegistry.address
contractAddresses["arbitrumGoerli"]["priceFeed"] = priceFeed.address
contractAddresses["arbitrumGoerli"]["volFeed"] = volFeed.address
contractAddresses["arbitrumGoerli"]["optionProtocol"] = optionProtocol.address
contractAddresses["arbitrumGoerli"]["liquidityPool"] = liquidityPool.address
contractAddresses["arbitrumGoerli"]["authority"] = authority.address
contractAddresses["arbitrumGoerli"]["portfolioValuesFeed"] = portfolioValuesFeed.address
contractAddresses["arbitrumGoerli"]["optionHandler"] = handler.address
contractAddresses["arbitrumGoerli"]["opynInteractions"] = interactions.address
contractAddresses["arbitrumGoerli"]["normDist"] = normDist.address
contractAddresses["arbitrumGoerli"]["BlackScholes"] = blackScholes.address
contractAddresses["arbitrumGoerli"]["accounting"] = accounting.address
contractAddresses["arbitrumGoerli"]["uniswapV3HedgingReactor"] = uniswapV3HedgingReactor.address
contractAddresses["arbitrumGoerli"]["perpHedgingReactor"] = perpHedgingReactor.address
contractAddresses["arbitrumGoerli"]["optionsCompute"] = optionsCompute.address

fs.writeFileSync(addressPath, JSON.stringify(contractAddresses, null, 4))

Expand Down Expand Up @@ -412,8 +413,7 @@ export async function deployLiquidityPool(
pvFeed: AlphaPortfolioValuesFeed,
authority: string,
priceFeed: PriceFeed,
blackScholes: BlackScholes,
normDist: NormalDist
blackScholes: BlackScholes
) {
const optionsCompFactory = await ethers.getContractFactory("OptionsCompute", {
libraries: {}
Expand Down Expand Up @@ -609,7 +609,7 @@ export async function deployLiquidityPool(
usd.address,
weth.address,
liquidityPool.address,
3000,
500,
priceFeed.address,
authority
]
Expand All @@ -626,8 +626,6 @@ export async function deployLiquidityPool(
console.log("hedging reactors added to liquidity pool")

return {
normDist,
blackScholes,
optionsCompute,
liquidityPool: liquidityPool,
handler: handler,
Expand Down
Loading