From f22083ac3706130e28ffdde3b616a5e49b103fe4 Mon Sep 17 00:00:00 2001 From: kjr217 <55159119+kjr217@users.noreply.github.com> Date: Wed, 18 Jan 2023 18:26:11 +0000 Subject: [PATCH] Chore/level beyond to alpha (#352) * Fix/buyback otc (#285) * wip * labels * Feature - Performance Table with Price per Share (#282) * Show growthSinceFirstEpoch as Cumulative Yield * Fill PricePerShares Performance Chart * Comment * Copy Co-authored-by: Dan * Get first 1000 pricePerShares Instead of 30 * chart labels * Group PricePerShare Epochs by Day * Minor adjustments to Performance plot * Minor adjustments to Performance plot * Set Performance Plot line to natural * Revert group by day Scaling XAxis by time with a tick gap is enough Co-authored-by: Dan * Add Prettier (#283) * Add Prettier * Add es-lint-config-prettier + extend in .eslintrc.json * .prettierignore * npx prettier --write ./front-end/src * .prettierrc.json * npx prettier --write ./front-end/src * remove error if withdrawalAmount is 0 (#288) * remove error if withdrawalAmount is 0 * add test case * copy rinkeby deploy folder and rename to goerli (#287) * copy rinkeby deploy folder and rename to goerli * Bump @nomiclabs/hardhat-etherscan from 2.x to 3.x * Setup arbitrumGoerli in hardhat.config.ts * Refactor Arbitrum Rinkeby file copy for Goerli + lint file * Add arbitrumGoerli addresses in contracts.json * Add Arbitrum Goerli addresses TO Markdown * delete redundant copied rinkeby files * update ethers and remove deprecated testnets * update full protocol deploy script for goerli * update uniswap pool fee to 500 * edit deploy scripts for goerli and remove rinkeby network * redeploy contracts and update addresses * edit setup protocol script * update packages to fix failing tests' * resolve package conflicts * remove goerli ethers infura provider * remove arbitrum ethers infura provider * update hardhat config Co-authored-by: Yassine * Remove 11utc copy (#291) Remove 11am UTCs * fixed walletconnect (#295) * fixed walletconnect * Use react-app-rewired to include buffer - Remove require from App.tsc * Move react-app-rewired to dev dependencies Co-authored-by: Yassine * Use correct chainId for Arbitrum (#296) Use correct chain hex id for Arbitrum * Fix Yield y-axis domain (#298) * fix: parseFloat growthSinceFirstEpoch * docs: Comment about parseFloat of BigDecimal string * Fix issue with Yield timestamp order (#299) fix(charts): Use Array to build PPS graph data Using the map return doesn't guarantee order * Refresh style of Table (#304) * style(trades): Refresh style of Table * style(trades): Minor adjustments align amount right restyle trade tab column use normal font for first column * build(packages): Add react-fullscreen * feat(components): Fullscreen trades * feat(hooks): useElementOnScreen.tsx Hook that allows to check if an element is on screen or not. * feat(app): Merge policies for paged query For writeOptions, buybackOption and rebalanceDelta simply add incoming to the end of array * feat(components): 10 days paging for trades Retrieve last 10 days of trades on scroll, 10 by 10 * fix(components): fetch more if trades on screen In case last trade is still intersecting with viewport this triggers fetch more anyway as we move the ref to the last trade on render * build(package): react-content-loader * feat(components): Loaders for table * style(components): bg color of loaders * fix(components): bg of last td while fullscreen * Use correct epoch for Cumulative Yield (#306) fix(graph): Order pricePerShares by timestamp * Minor Alpha front-end fixes (#308) * fix(components): Fix svg card tabs to fit otherwise the tab stays smaller than the text in it * refactor(components): Hide progress bar if no collateral better ui * style(components): Move home banner closer to top better ui * refactor(components): Show query error in trades table if any + add bg-bone to fullscreen component * fix(graph): Skip query if !account in dashboard options otherwise it retrieves all of Graphs option as empty string is passed Closes #309 * fix(components): Allow any user to see orders already working for strangle but not single put or call order Closes #311 * Move front-end to Goerli (#292) * Move to Goerli (from Rinkeby) * Remove Rinkeby contracts * Update Explorer to Goerli for Testnet * Add deployed Opyn Gamma Goerli Subgraph * refactor: alpha sort constants * Only run hardhat on changes to SC code. (#329) * Performance chart public launch (#321) * Add eslint rule to remove unnecessary imports on React. * Clean up unused component. * Set baseUrl to allow cleaner imports. * Package additions for handling dates and animations. * Vault performance chart adjustments and readme. * Clean up after moving file location. * More readable text length. * Use react-helmet to "noindex, nofollow" every deployment except prod. Use REACT_APP_NETWORK over REACT_APP_ENV to determine network to use. * React 18 (#337) * Upgrade to React 18.2.0 and fix typing issues. * Fix react imports and typing issues. * Bump npm from 8.9.0 to 8.11.0 Bumps [npm](https://github.com/npm/cli) from 8.9.0 to 8.11.0. - [Release notes](https://github.com/npm/cli/releases) - [Changelog](https://github.com/npm/cli/blob/v8.11.0/CHANGELOG.md) - [Commits](https://github.com/npm/cli/compare/v8.9.0...v8.11.0) --- updated-dependencies: - dependency-name: npm dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Yarn workspaces (#338) * Clean up package.json files for better consistency. * Move to Yarn and Yarn workspaces. * Build without bash script. * Fix syntax errors. * Remove non-existent files. * Workspaces with nohoist for typechain packages. * Update docs. * Lock updates. * Remove console.logs and fix bad test. * Package upgrades and cleaning (#347) * Clean and upgrade contacts packages. Hoist shared packages to top level package file. * chore: remove bad test * Move non-package details to their own config files. * Remove unused code for @nivo package. * Remove unused code for react-scroll package. * API changes for framer-motion. * Remove unused code for humanize-duration package. * Remove singular use of Axios for native fetch. * Better typing. * Better typings. * Switch to dayjs. * chore: downgrade ethers to 5.4.0 Co-authored-by: kjr217 * chore: get branch level with alpha * chore: remove mention of rinkeby * chore: fix config bug * chore: update arbitrum with alchemy provider * chore: change arbitrum rpc creation location * Update hardhat.yml * chore: fix arbi rpc * chore: upgrade to dayjs from moments Signed-off-by: dependabot[bot] Co-authored-by: Dan Co-authored-by: Yassine Co-authored-by: Josh <55187183+JoshDAO@users.noreply.github.com> Co-authored-by: Tim Dunphy <54942744+MeanBoyCousin@users.noreply.github.com> Co-authored-by: Tim Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/hardhat.yml | 2 + .../contracts/deploy/Contract-addresses.md | 46 +++++++++- .../ArbitrumGoerliAlphaDeploy.ts | 1 - packages/contracts/hardhat.config.ts | 7 -- packages/contracts/package.json | 18 ++-- .../contracts/test/CreateOptionProducts.ts | 13 +-- packages/contracts/test/ExchangeActions.ts | 21 ++--- packages/contracts/test/LiquidityPool.ts | 7 +- packages/contracts/test/LiquidityPoolAlpha.ts | 3 + .../test/LiquidityPoolAlphaWithManager.ts | 14 --- .../test/LiquidityPoolPerpHedgingReactor.ts | 4 +- .../test/LiquidityPoolSellOptions.ts | 14 ++- .../LiquidityPoolUniswapV3HedgingReactor.ts | 5 ++ .../contracts/test/PerpHedgingReactorSc1.ts | 71 +++------------ .../contracts/test/PerpHedgingReactorSc2.ts | 86 +++---------------- packages/contracts/test/SlippagePricer.ts | 13 +-- packages/contracts/test/SpreadPricer.ts | 21 ++--- .../utils/generic-system-deployer.ts | 21 ++--- packages/front-end/src/types/global.d.ts | 3 + 19 files changed, 137 insertions(+), 233 deletions(-) create mode 100644 packages/front-end/src/types/global.d.ts diff --git a/.github/workflows/hardhat.yml b/.github/workflows/hardhat.yml index b3f226cd8..b7e6c5a18 100644 --- a/.github/workflows/hardhat.yml +++ b/.github/workflows/hardhat.yml @@ -17,6 +17,8 @@ jobs: env: ALCHEMY: ${{ secrets.ALCHEMY }} TEST_MNEMONIC: ${{ secrets.TEST_MNEMONIC }} + ARBITRUM: ${{ secrets.ARBITRUM }} + ARBITRUM_GOERLI: ${{ secrets.ARBITRUM_GOERLI }} steps: - uses: actions/checkout@v3 diff --git a/packages/contracts/deploy/Contract-addresses.md b/packages/contracts/deploy/Contract-addresses.md index 77c819670..f14f6224a 100644 --- a/packages/contracts/deploy/Contract-addresses.md +++ b/packages/contracts/deploy/Contract-addresses.md @@ -74,7 +74,7 @@ uniswapV3HedgingReactor: '0xaa5FcA49bd299E7A3fd1a4b0CB89039413D5580C' perpHedgingReactor: '0xed7a8131A77350967D0E0BF6290873F3f406567f' -# Arbitrum Goerli Addresses +# Arbitrum Goerli Addresses Beyond ## Gamma Protocol @@ -117,3 +117,47 @@ perpHedgingReactor: '0xed7a8131A77350967D0E0BF6290873F3f406567f' | UNISWAPV3Router - Auxiliary | 0xE592427A0AEce92De3Edee1F18E0157C05861564 | | USDC - Auxiliary | 0x6775842ae82bf2f0f987b10526768ad89d79536e | | WETH - Auxiliary | 0x53320bE2A35649E9B2a0f244f9E9474929d3B699 | + +## 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' diff --git a/packages/contracts/deploy/arbitrum-goerli/ArbitrumGoerliAlphaDeploy.ts b/packages/contracts/deploy/arbitrum-goerli/ArbitrumGoerliAlphaDeploy.ts index bab7f9539..3619beb68 100644 --- a/packages/contracts/deploy/arbitrum-goerli/ArbitrumGoerliAlphaDeploy.ts +++ b/packages/contracts/deploy/arbitrum-goerli/ArbitrumGoerliAlphaDeploy.ts @@ -496,7 +496,6 @@ export async function deployLiquidityPool( await optionRegistry.setLiquidityPool(liquidityPool.address) console.log("registry lp set") - await liquidityPool.setBidAskSpread(bidAskSpread) await pvFeed.setLiquidityPool(liquidityPool.address) await pvFeed.setProtocol(optionProtocol.address) await pvFeed.setKeeper(liquidityPool.address, true) diff --git a/packages/contracts/hardhat.config.ts b/packages/contracts/hardhat.config.ts index 65252f53d..be92ec4ce 100644 --- a/packages/contracts/hardhat.config.ts +++ b/packages/contracts/hardhat.config.ts @@ -160,13 +160,6 @@ module.exports = { accounts: process.env.DEPLOYER_PRIVATE_KEY ? [process.env.DEPLOYER_PRIVATE_KEY] : accounts, gas: 500000000 }, - arbitrumGoerli: { - url: arbitrumGoerli, - chainId: 421613, - saveDeployments: true, - accounts: process.env.DEPLOYER_PRIVATE_KEY ? [process.env.DEPLOYER_PRIVATE_KEY] : accounts, - gas: 500000000 - } }, etherscan: { apiKey: { diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 4ff261118..cc3a45706 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -16,20 +16,18 @@ ] }, "scripts": { - "buyoption:testnet": "npx hardhat run scripts/buySample.ts --network arbitrumRinkeby", - "compile": "hardhat clean && hardhat compile && ./copyABIsToFrontend.sh", - "create-otc-order:testnet": "npx hardhat run scripts/createOTCOrder.ts --network arbitrumRinkeby", - "create-otc-strangle:testnet": "npx hardhat run scripts/createOTCStrangle.ts --network arbitrumRinkeby", + "buyoption:testnet": "npx hardhat run scripts/buySample.ts --network arbitrumGoerli", + "compile": "hardhat clean && hardhat compile && hardhat typechain && ./copyABIsToFrontend.sh", + "create-otc-order:testnet": "npx hardhat run scripts/createOTCOrder.ts --network arbitrumGoerli", + "create-otc-strangle:testnet": "npx hardhat run scripts/createOTCStrangle.ts --network arbitrumGoerli", "deploy:arbitrumGoerli": "npx hardhat run deploy/arbitrum-goerli/ArbitrumGoerliDeploy.ts --network arbitrumGoerli", "deploy:localhost": "npx hardhat deploy --network localhost --tags localhost && ./copyAddressesToFrontEnd.sh --deploy-scripts deploy/localhost", - "deploy:rinkeby": "hardhat deploy --network rinkeby --tags testnet --deploy-scripts deploy/rinkeby", "deployAlpha:arbitrumGoerli": "npx hardhat run deploy/arbitrum-goerli/ArbitrumGoerliAlphaDeploy.ts --network arbitrumGoerli", - "deployAlpha:arbitrumRinkeby": "npx hardhat run deploy/arbitrum-rinkeby/ArbitrumRinkebyAlphaDeploy.ts --network arbitrumRinkeby", "deployAlpha:mainnet": "npx hardhat run deploy/arbitrum/ArbitrumAlphaDeploy.ts --network arbitrum", - "deployRangeOrderReactor:arbitrum": "npx hardhat run deploy/arbitrum/DeployRangeOrderReactor.ts --network arbitrum", - "deployRangeOrderReactor:arbitrumGoerli": "npx hardhat run deploy/arbitrum/DeployRangeOrderReactor.ts --network arbitrumGoerli", - "execute-epoch:testnet": "npx hardhat run scripts/executeEpochTestnet.ts --network arbitrumRinkeby", - "fulfill:testnet": "npx hardhat run scripts/fulfill.ts --network arbitrumRinkeby", + "deployRangeOrderReactor:arbitrum": "npx hardhat run deploy/arbitrum/DeployRangeOrderReactor.ts --network arbitrum", + "deployRangeOrderReactor:arbitrumGoerli": "npx hardhat run deploy/arbitrum/DeployRangeOrderReactor.ts --network arbitrumGoerli", + "execute-epoch:testnet": "npx hardhat run scripts/executeEpochTestnet.ts --network arbitrumGoerli", + "fulfill:testnet": "npx hardhat run scripts/fulfill.ts --network arbitrumGoerli", "test": "hardhat test", "test-coverage": "export NODE_OPTIONS='--max-old-space-size=8192' && hardhat coverage --testfiles 'test/*.ts'" }, diff --git a/packages/contracts/test/CreateOptionProducts.ts b/packages/contracts/test/CreateOptionProducts.ts index aef7de775..b6ec68df9 100644 --- a/packages/contracts/test/CreateOptionProducts.ts +++ b/packages/contracts/test/CreateOptionProducts.ts @@ -15,7 +15,8 @@ import { tFormatUSDC, scaleNum } from "../utils/conversion-helper" -import moment from "moment" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc" import { AbiCoder } from "ethers/lib/utils" //@ts-ignore import bs from "black-scholes" @@ -69,6 +70,9 @@ import { NewWhitelist } from "../types/NewWhitelist" import { OptionExchange } from "../types/OptionExchange" import { OtokenFactory } from "../types/OtokenFactory" import { OptionCatalogue } from "../types/OptionCatalogue" + +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let wethERC20: MintableERC20 @@ -177,11 +181,8 @@ const emptySeries = { } /* --- end variables to change --- */ -const expiration = moment.utc(expiryDate).add(3, "d").add(8, "h").valueOf() / 1000 -const expiration2 = moment.utc(expiryDate).add(1, "w").add(8, "h").valueOf() / 1000 // have another batch of options exire 1 week after the first -const expiration3 = moment.utc(expiryDate).add(2, "w").add(8, "h").valueOf() / 1000 -const invalidExpirationLong = moment.utc(invalidExpiryDateLong).add(8, "h").valueOf() / 1000 -const invalidExpirationShort = moment.utc(invalidExpiryDateShort).add(8, "h").valueOf() / 1000 +const expiration = dayjs.utc(expiryDate).add(3, "days").add(8, "hours").unix() +const expiration2 = dayjs.utc(expiryDate).add(1, "weeks").add(8, "hours").unix()// have another batch of options exire 1 week after the first const abiCode = new AbiCoder() const bcsLowerStrike = toWei("2200") diff --git a/packages/contracts/test/ExchangeActions.ts b/packages/contracts/test/ExchangeActions.ts index 7e1e95c0a..ee6f5a879 100644 --- a/packages/contracts/test/ExchangeActions.ts +++ b/packages/contracts/test/ExchangeActions.ts @@ -15,7 +15,8 @@ import { tFormatUSDC, scaleNum } from "../utils/conversion-helper" -import moment from "moment" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc" import { AbiCoder } from "ethers/lib/utils" //@ts-ignore import bs from "black-scholes" @@ -61,6 +62,9 @@ import { create } from "domain" import { NewWhitelist } from "../types/NewWhitelist" import { OptionExchange } from "../types/OptionExchange" import { OtokenFactory } from "../types/OtokenFactory" + +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let wethERC20: MintableERC20 @@ -103,14 +107,6 @@ const invalidExpiryDateShort: string = "2022-03-01" const rfr: string = "0" // edit depending on the chain id to be tested on const chainId = 1 -const oTokenDecimalShift18 = 10000000000 -// amount of dollars OTM written options will be (both puts and calls) -// use negative numbers for ITM options -const strike = "20" - -// hardcoded value for strike price that is outside of accepted bounds -const invalidStrikeHigh = utils.parseEther("12500") -const invalidStrikeLow = utils.parseEther("200") // balances to deposit into the LP const liquidityPoolUsdcDeposit = "100000" @@ -146,11 +142,8 @@ const expiryToValue = [ /* --- end variables to change --- */ -const expiration = moment.utc(expiryDate).add(8, "h").valueOf() / 1000 -const expiration2 = moment.utc(expiryDate).add(1, "w").add(8, "h").valueOf() / 1000 // have another batch of options exire 1 week after the first -const expiration3 = moment.utc(expiryDate).add(2, "w").add(8, "h").valueOf() / 1000 -const invalidExpirationLong = moment.utc(invalidExpiryDateLong).add(8, "h").valueOf() / 1000 -const invalidExpirationShort = moment.utc(invalidExpiryDateShort).add(8, "h").valueOf() / 1000 +const expiration = dayjs.utc(expiryDate).add(8, "hours").unix() +const expiration2 = dayjs.utc(expiryDate).add(1, "weeks").add(8, "hours").unix() // have another batch of options exire 1 week after the first const abiCode = new AbiCoder() let vaultIdCounter = 1 const CALL_FLAVOR = false diff --git a/packages/contracts/test/LiquidityPool.ts b/packages/contracts/test/LiquidityPool.ts index 4ab480c59..237bd3353 100644 --- a/packages/contracts/test/LiquidityPool.ts +++ b/packages/contracts/test/LiquidityPool.ts @@ -15,7 +15,8 @@ import { fromOpyn, toOpyn, tFormatUSDC, - scaleNum + scaleNum, + emptySeries } from "../utils/conversion-helper" import { deployOpyn } from "../utils/opyn-deployer" import Otoken from "../artifacts/contracts/packages/opyn/core/Otoken.sol/Otoken.json" @@ -120,7 +121,7 @@ const invalidStrikeHigh = utils.parseEther("12500") const invalidStrikeLow = utils.parseEther("200") // balances to deposit into the LP -const liquidityPoolUsdcDeposit = "100000" +const liquidityPoolUsdcDeposit = "500000" const minCallStrikePrice = utils.parseEther("500") const maxCallStrikePrice = utils.parseEther("10000") @@ -2108,7 +2109,7 @@ describe("Liquidity Pools", async () => { amount, pricer, true, - exchange, + catalogue, localDelta.div(amount.div(toWei("1"))), toWei("0").sub(toWei("50")) ) diff --git a/packages/contracts/test/LiquidityPoolAlpha.ts b/packages/contracts/test/LiquidityPoolAlpha.ts index fe50b42b8..bccc40cce 100644 --- a/packages/contracts/test/LiquidityPoolAlpha.ts +++ b/packages/contracts/test/LiquidityPoolAlpha.ts @@ -52,6 +52,9 @@ import { AbiCoder } from "ethers/lib/utils" dayjs.extend(utc) import { OptionCatalogue } from "../types/OptionCatalogue" + +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let wethERC20: ERC20Interface diff --git a/packages/contracts/test/LiquidityPoolAlphaWithManager.ts b/packages/contracts/test/LiquidityPoolAlphaWithManager.ts index c83143e81..0c6e870ea 100644 --- a/packages/contracts/test/LiquidityPoolAlphaWithManager.ts +++ b/packages/contracts/test/LiquidityPoolAlphaWithManager.ts @@ -29,20 +29,6 @@ import { Volatility } from "../types/Volatility" import { VolatilityFeed } from "../types/VolatilityFeed" import { WETH } from "../types/WETH" import { deployLiquidityPool, deploySystem } from "../utils/alpha-system-deployer" -import { - fromOpyn, - fromWei, - percentDiff, - scaleNum, - tFormatEth, - tFormatUSDC, - toOpyn, - toUSDC, - toWei, - toWeiFromUSDC -} from "../utils/conversion-helper" -import { deployOpyn } from "../utils/opyn-deployer" -import { deployRage, deployRangeOrder } from "../utils/rage-deployer" import { setupTestOracle, setupOracle, diff --git a/packages/contracts/test/LiquidityPoolPerpHedgingReactor.ts b/packages/contracts/test/LiquidityPoolPerpHedgingReactor.ts index 7959e37de..ec12dac95 100644 --- a/packages/contracts/test/LiquidityPoolPerpHedgingReactor.ts +++ b/packages/contracts/test/LiquidityPoolPerpHedgingReactor.ts @@ -44,7 +44,9 @@ import { setupTestOracle, makeIssueAndBuy, makeBuy, - getSeriesWithe18Strike + getSeriesWithe18Strike, + setupTestOracle, + setupOracle } from "./helpers" import { AlphaPortfolioValuesFeed } from "../types/AlphaPortfolioValuesFeed" import { BeyondOptionHandler } from "../types/BeyondOptionHandler" diff --git a/packages/contracts/test/LiquidityPoolSellOptions.ts b/packages/contracts/test/LiquidityPoolSellOptions.ts index 1b00ad574..7669dc322 100644 --- a/packages/contracts/test/LiquidityPoolSellOptions.ts +++ b/packages/contracts/test/LiquidityPoolSellOptions.ts @@ -15,7 +15,8 @@ import { tFormatUSDC, scaleNum } from "../utils/conversion-helper" -import moment from "moment" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc" import { AbiCoder } from "ethers/lib/utils" //@ts-ignore import bs from "black-scholes" @@ -76,6 +77,7 @@ import { OptionExchange } from "../types/OptionExchange" import { OtokenFactory } from "../types/OtokenFactory" import { OptionCatalogue } from "../types/OptionCatalogue" import { AlphaOptionHandler } from "../types/AlphaOptionHandler" +dayjs.extend(utc) let usd: MintableERC20 let weth: WETH let wethERC20: MintableERC20 @@ -177,11 +179,8 @@ const expiryToValue = [ /* --- end variables to change --- */ -const expiration = moment.utc(expiryDate).add(8, "h").valueOf() / 1000 -const expiration2 = moment.utc(expiryDate).add(1, "w").add(8, "h").valueOf() / 1000 // have another batch of options exire 1 week after the first -const expiration3 = moment.utc(expiryDate).add(2, "w").add(8, "h").valueOf() / 1000 -const invalidExpirationLong = moment.utc(invalidExpiryDateLong).add(8, "h").valueOf() / 1000 -const invalidExpirationShort = moment.utc(invalidExpiryDateShort).add(8, "h").valueOf() / 1000 +const expiration = dayjs.utc(expiryDate).add(8, "hours").unix() +const expiration2 = dayjs.utc(expiryDate).add(1, "weeks").add(8, "hours").unix()// have another batch of options exire 1 week after the first const abiCode = new AbiCoder() const CALL_FLAVOR = false @@ -3857,8 +3856,7 @@ describe("Liquidity Pools hedging reactor: gamma", async () => { await pricer.setSlippageGradientMultipliers( slippageGradientMultipliers, slippageGradientMultipliers) const acSlippageGradientMultipliers = await pricer.getCallSlippageGradientMultipliers() const apSlippageGradientMultipliers = await pricer.getPutSlippageGradientMultipliers() - console.log(slippageGradientMultipliers) - console.log(acSlippageGradientMultipliers) + for (let i=0; i < slippageGradientMultipliers.length; i++) { expect(acSlippageGradientMultipliers[i]).to.equal(slippageGradientMultipliers[i]) expect(apSlippageGradientMultipliers[i]).to.equal(slippageGradientMultipliers[i]) diff --git a/packages/contracts/test/LiquidityPoolUniswapV3HedgingReactor.ts b/packages/contracts/test/LiquidityPoolUniswapV3HedgingReactor.ts index a71a5e546..9bf3c94d5 100644 --- a/packages/contracts/test/LiquidityPoolUniswapV3HedgingReactor.ts +++ b/packages/contracts/test/LiquidityPoolUniswapV3HedgingReactor.ts @@ -56,6 +56,9 @@ import { BeyondOptionHandler } from "../types/BeyondOptionHandler" import { BeyondPricer } from "../types/BeyondPricer" import { OptionExchange } from "../types/OptionExchange" import { OptionCatalogue } from "../types/OptionCatalogue" + +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let optionRegistry: OptionRegistry @@ -80,6 +83,8 @@ let uniswapV3HedgingReactor: UniswapV3HedgingReactor let exchange: OptionExchange let pricer: BeyondPricer let authority: string +let catalogue: OptionCatalogue + /* --- variables to change --- */ diff --git a/packages/contracts/test/PerpHedgingReactorSc1.ts b/packages/contracts/test/PerpHedgingReactorSc1.ts index e9dc1cf22..2d752d938 100644 --- a/packages/contracts/test/PerpHedgingReactorSc1.ts +++ b/packages/contracts/test/PerpHedgingReactorSc1.ts @@ -213,15 +213,8 @@ describe("PerpHedgingReactor Sc1", () => { const reactorDeltaBefore = await liquidityPoolDummy.getDelta() const LpUsdcBalanceBefore = await usdcContract.balanceOf(liquidityPoolDummy.address) await liquidityPoolDummy.hedgeDelta(delta) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(deltaHedge).to.equal(reactorDeltaAfter) @@ -375,25 +368,11 @@ describe("PerpHedgingReactor Sc1", () => { await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) )[1] const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = -price - .mul(delta) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = -((price.mul(delta).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) @@ -421,25 +400,11 @@ describe("PerpHedgingReactor Sc1", () => { await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) )[1] const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = -price - .mul(delta) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = -((price.mul(delta).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) @@ -476,25 +441,11 @@ describe("PerpHedgingReactor Sc1", () => { await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) )[1] const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = -price - .mul(delta) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = -((price.mul(delta).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) diff --git a/packages/contracts/test/PerpHedgingReactorSc2.ts b/packages/contracts/test/PerpHedgingReactorSc2.ts index 5d20ab9d0..9ae487a82 100644 --- a/packages/contracts/test/PerpHedgingReactorSc2.ts +++ b/packages/contracts/test/PerpHedgingReactorSc2.ts @@ -213,15 +213,8 @@ describe("PerpHedgingReactor Sc2", () => { const reactorDeltaBefore = await liquidityPoolDummy.getDelta() const LpUsdcBalanceBefore = await usdcContract.balanceOf(liquidityPoolDummy.address) await liquidityPoolDummy.hedgeDelta(delta) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(deltaHedge).to.equal(reactorDeltaAfter) @@ -253,25 +246,11 @@ describe("PerpHedgingReactor Sc2", () => { ) await rageOracle.setSqrtPriceX96(realSqrtPrice) const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = price - .mul(deltaHedge.add(reactorDeltaBefore)) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = ((price.mul(deltaHedge.add(reactorDeltaBefore)).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) @@ -304,25 +283,11 @@ describe("PerpHedgingReactor Sc2", () => { ) await rageOracle.setSqrtPriceX96(realSqrtPrice) const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = price - .mul(deltaHedge.add(reactorDeltaBefore)) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = ((price.mul(deltaHedge.add(reactorDeltaBefore)).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) @@ -376,25 +341,11 @@ describe("PerpHedgingReactor Sc2", () => { ) await rageOracle.setSqrtPriceX96(realSqrtPrice) const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = price - .mul(deltaHedge.add(reactorDeltaBefore)) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = ((price.mul(deltaHedge.add(reactorDeltaBefore)).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const hedgeDeltaTx = await liquidityPoolDummy.hedgeDelta(delta) await hedgeDeltaTx.wait() - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) - const reactorCollatBalanceAfter = ( - await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) - )[1] - const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition( - 0, - truncate(vTokenAddress) - ) + const reactorCollatBalanceAfter = (await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId))[1] + const reactorWethBalanceAfter = await clearingHouse.getAccountNetTokenPosition(0, truncate(vTokenAddress)) const reactorDeltaAfter = await liquidityPoolDummy.getDelta() const LpUsdcBalanceAfter = await usdcContract.balanceOf(liquidityPoolDummy.address) expect(reactorDeltaAfter).to.equal(reactorDeltaBefore.sub(delta)) @@ -442,11 +393,7 @@ describe("PerpHedgingReactor Sc2", () => { const reactorUsdcBalanceBefore = await usdcContract.balanceOf(perpHedgingReactor.address) const withdrawAmount = "10000" const newCollat = reactorCollatBalanceBefore.sub(toUSDC(withdrawAmount)) - const expectedDelta = newCollat - .mul(10000) - .mul(e18) - .div((await perpHedgingReactor.healthFactor()).mul(price.div(USDC_SCALE))) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) + const expectedDelta = newCollat.mul(10000).mul(e18).div((await perpHedgingReactor.healthFactor()).mul(price.div(USDC_SCALE))); // withdraw more than current balance await liquidityPoolDummy.withdraw(ethers.utils.parseUnits(withdrawAmount, 18)) const reactorCollatBalanceAfter = ( @@ -488,14 +435,7 @@ describe("PerpHedgingReactor Sc2", () => { )[1] const reactorUsdcBalanceBefore = await usdcContract.balanceOf(perpHedgingReactor.address) const price = await priceFeed.getNormalizedRate(WETH_ADDRESS[chainId], USDC_ADDRESS[chainId]) - const collatRequired = price - .mul(reactorDeltaBefore) - .div(toWei("1")) - .mul(await perpHedgingReactor.healthFactor()) - .div(10000) - .div(USDC_SCALE) - console.log(await clearingHouse.getAccountMarketValueAndRequiredMargin(0, true)) - console.log(await clearingHouse.getAccountNetProfit(0)) + const collatRequired = ((price.mul(reactorDeltaBefore).div(toWei('1'))).mul(await perpHedgingReactor.healthFactor()).div(10000)).div(USDC_SCALE) const tx = await liquidityPoolDummy.update() const reactorCollatBalanceAfter = ( await clearingHouseLens.getAccountCollateralInfo(accountId, collateralId) diff --git a/packages/contracts/test/SlippagePricer.ts b/packages/contracts/test/SlippagePricer.ts index ee0f145ad..e8cf1293c 100644 --- a/packages/contracts/test/SlippagePricer.ts +++ b/packages/contracts/test/SlippagePricer.ts @@ -1,7 +1,8 @@ import hre, { ethers, network } from "hardhat" import { BigNumberish, Contract, utils, Signer, BigNumber } from "ethers" import { toWei, toUSDC, scaleNum } from "../utils/conversion-helper" -import moment from "moment" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc" import { AbiCoder } from "ethers/lib/utils" //@ts-ignore import { expect } from "chai" @@ -26,6 +27,9 @@ import { deployLiquidityPool, deploySystem } from "../utils/generic-system-deplo import { BeyondPricer } from "../types/BeyondPricer" import { NewWhitelist } from "../types/NewWhitelist" import { OptionExchange } from "../types/OptionExchange" + +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let wethERC20: MintableERC20 @@ -114,11 +118,8 @@ const expiryToValue = [ /* --- end variables to change --- */ -const expiration = moment.utc(expiryDate).add(8, "h").valueOf() / 1000 -const expiration2 = moment.utc(expiryDate).add(1, "w").add(8, "h").valueOf() / 1000 // have another batch of options exire 1 week after the first -const expiration3 = moment.utc(expiryDate).add(2, "w").add(8, "h").valueOf() / 1000 -const invalidExpirationLong = moment.utc(invalidExpiryDateLong).add(8, "h").valueOf() / 1000 -const invalidExpirationShort = moment.utc(invalidExpiryDateShort).add(8, "h").valueOf() / 1000 +const expiration = dayjs.utc(expiryDate).add(8, "hours").unix() +const expiration2 = dayjs.utc(expiryDate).add(1, "weeks").add(8, "hours").unix() // have another batch of options exire 1 week after the first const abiCode = new AbiCoder() const CALL_FLAVOR = false const PUT_FLAVOR = true diff --git a/packages/contracts/test/SpreadPricer.ts b/packages/contracts/test/SpreadPricer.ts index f20f0d243..5aa2356dc 100644 --- a/packages/contracts/test/SpreadPricer.ts +++ b/packages/contracts/test/SpreadPricer.ts @@ -1,7 +1,8 @@ import hre, { ethers, network } from "hardhat" import { BigNumberish, Contract, utils, Signer, BigNumber } from "ethers" import { toWei, toUSDC, scaleNum, fromUSDC } from "../utils/conversion-helper" -import moment from "moment" +import dayjs from "dayjs" +import utc from "dayjs/plugin/utc" import { AbiCoder } from "ethers/lib/utils" //@ts-ignore import { expect } from "chai" @@ -29,6 +30,8 @@ import { NewWhitelist } from "../types/NewWhitelist" import { OptionExchange } from "../types/OptionExchange" import { OptionCatalogue } from "../types/OptionCatalogue" +dayjs.extend(utc) + let usd: MintableERC20 let weth: WETH let wethERC20: MintableERC20 @@ -71,14 +74,6 @@ const invalidExpiryDateShort: string = "2022-03-01" const rfr: string = "0" // edit depending on the chain id to be tested on const chainId = 1 -const oTokenDecimalShift18 = 10000000000 -// amount of dollars OTM written options will be (both puts and calls) -// use negative numbers for ITM options -const strike = "20" - -// hardcoded value for strike price that is outside of accepted bounds -const invalidStrikeHigh = utils.parseEther("12500") -const invalidStrikeLow = utils.parseEther("200") // balances to deposit into the LP const liquidityPoolUsdcDeposit = "100000" @@ -118,11 +113,8 @@ const expiryToValue = [ /* --- end variables to change --- */ -const expiration = moment.utc(expiryDate).add(8, "h").valueOf() / 1000 -const expiration2 = moment.utc(expiryDate).add(1, "w").add(8, "h").valueOf() / 1000 // have another batch of options exire 1 week after the first -const expiration3 = moment.utc(expiryDate).add(2, "w").add(8, "h").valueOf() / 1000 -const invalidExpirationLong = moment.utc(invalidExpiryDateLong).add(8, "h").valueOf() / 1000 -const invalidExpirationShort = moment.utc(invalidExpiryDateShort).add(8, "h").valueOf() / 1000 +const expiration = dayjs.utc(expiryDate).add(8, "hours").unix() +const expiration2 = dayjs.utc(expiryDate).add(1, "weeks").add(8, "hours").unix() // have another batch of options exire 1 week after the first const abiCode = new AbiCoder() const CALL_FLAVOR = false const PUT_FLAVOR = true @@ -415,7 +407,6 @@ describe("Spread Pricer testing", async () => { pricer, toWei("0") ) - console.log({ quoteResponse: fromUSDC(quoteResponse[0]), localQuoteNoSpread }) expect(singleSellQuote).to.eq(quoteResponse[0].div(1000)) expect(parseFloat(fromUSDC(quoteResponse[0])) - localQuoteNoSpread).to.be.within(-0.1, 0.1) }) diff --git a/packages/contracts/utils/generic-system-deployer.ts b/packages/contracts/utils/generic-system-deployer.ts index b936c252f..0c2724673 100644 --- a/packages/contracts/utils/generic-system-deployer.ts +++ b/packages/contracts/utils/generic-system-deployer.ts @@ -5,30 +5,19 @@ import { expect } from "chai" import dayjs from "dayjs" import utc from "dayjs/plugin/utc" -import { ERC20Interface } from "../types/ERC20Interface" -import { MintableERC20 } from "../types/MintableERC20" -import { OptionRegistry } from "../types/OptionRegistry" -import { AlphaPortfolioValuesFeed, PortfolioValuesStruct } from "../types/AlphaPortfolioValuesFeed" -import { PriceFeed } from "../types/PriceFeed" -import { LiquidityPool } from "../types/LiquidityPool" -import { WETH } from "../types/WETH" -import { Protocol } from "../types/Protocol" -import { Volatility } from "../types/Volatility" import LiquidityPoolSol from "../artifacts/contracts/LiquidityPool.sol/LiquidityPool.json" import { ADDRESS_BOOK, GAMMA_CONTROLLER, MARGIN_POOL, OTOKEN_FACTORY, + UNISWAP_V3_SWAP_ROUTER, USDC_ADDRESS, - WETH_ADDRESS, USDC_OWNER_ADDRESS, - UNISWAP_V3_SWAP_ROUTER + WETH_ADDRESS } from "../test/constants" import { Accounting } from "../types/Accounting" -import { MockChainlinkAggregator } from "../types/MockChainlinkAggregator" -import { Oracle } from "../types/Oracle" -import { VolatilityFeed } from "../types/VolatilityFeed" + dayjs.extend(utc) @@ -37,6 +26,10 @@ import { OptionExchange } from "../types/OptionExchange" import { BeyondPricer } from "../types/BeyondPricer" import { OptionCatalogue } from "../types/OptionCatalogue" import { AlphaOptionHandler } from "../types/AlphaOptionHandler" +import { AlphaPortfolioValuesFeed, ERC20Interface, LiquidityPool, MintableERC20, MockChainlinkAggregator, OptionRegistry, Oracle, PriceFeed, Protocol, Volatility, VolatilityFeed, WETH } from "../types" + +dayjs.extend(utc) + const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" // edit depending on the chain id to be tested on diff --git a/packages/front-end/src/types/global.d.ts b/packages/front-end/src/types/global.d.ts new file mode 100644 index 000000000..a363ba070 --- /dev/null +++ b/packages/front-end/src/types/global.d.ts @@ -0,0 +1,3 @@ +declare module "black-scholes"; +declare module "greeks"; +declare module "implied-volatility";