From d566eba8569eaa5d5487a4b92ee22ba5f3d27193 Mon Sep 17 00:00:00 2001 From: brightiron Date: Wed, 8 Nov 2023 19:57:21 -0600 Subject: [PATCH 1/7] contract updates --- src/constants/addresses.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 346e875f70..2adf0e9d17 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -144,12 +144,12 @@ export const BALANCER_VAULT_ADDRESSSES = { export const RANGE_OPERATOR_ADDRESSES = { [NetworkId.MAINNET]: "0x0374c001204eF5e7E4F5362A5A2430CB6c219326", - [NetworkId.TESTNET_GOERLI]: "0x255467F1ca090Cd0Ed20014DC957E942d846843b", + [NetworkId.TESTNET_GOERLI]: "0x6620592f9bdffAbadcea644a35946E7b93EaaF56", }; export const RANGE_ADDRESSES = { [NetworkId.MAINNET]: "0xb212D9584cfc56EFf1117F412Fe0bBdc53673954", - [NetworkId.TESTNET_GOERLI]: "0x446f06f8Df7d5f627B073c6349b948B95c1f9185", + [NetworkId.TESTNET_GOERLI]: "0xFF88b47af188d91aC05ff5E843B5F6863472EdD0", }; export const RANGE_PRICE_ADDRESSES = { From 3e07232811298c1c18cdb596dbebb1d049121605 Mon Sep 17 00:00:00 2001 From: brightiron Date: Wed, 15 Nov 2023 14:35:02 -0600 Subject: [PATCH 2/7] abi changes --- src/abi/Range.json | 614 +++++++++++++++++++++++++++------ src/views/Range/RangeChart.tsx | 25 +- src/views/Range/hooks.tsx | 39 +-- src/views/Range/index.tsx | 4 +- 4 files changed, 541 insertions(+), 141 deletions(-) diff --git a/src/abi/Range.json b/src/abi/Range.json index a65af8112b..c1a0dfddb2 100644 --- a/src/abi/Range.json +++ b/src/abi/Range.json @@ -2,32 +2,82 @@ "abi": [ { "inputs": [ - { "internalType": "contract Kernel", "name": "kernel_", "type": "address" }, - { "internalType": "contract ERC20", "name": "ohm_", "type": "address" }, - { "internalType": "contract ERC20", "name": "reserve_", "type": "address" }, - { "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }, - { "internalType": "uint256", "name": "cushionSpread_", "type": "uint256" }, - { "internalType": "uint256", "name": "wallSpread_", "type": "uint256" } + { + "internalType": "contract Kernel", + "name": "kernel_", + "type": "address" + }, + { + "internalType": "contract ERC20", + "name": "ohm_", + "type": "address" + }, + { + "internalType": "contract ERC20", + "name": "reserve_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "thresholdFactor_", + "type": "uint256" + }, + { + "internalType": "uint256[2]", + "name": "lowSpreads_", + "type": "uint256[2]" + }, + { + "internalType": "uint256[2]", + "name": "highSpreads_", + "type": "uint256[2]" + } ], "stateMutability": "nonpayable", "type": "constructor" }, { - "inputs": [{ "internalType": "address", "name": "caller_", "type": "address" }], + "inputs": [ + { + "internalType": "address", + "name": "caller_", + "type": "address" + } + ], "name": "KernelAdapter_OnlyKernel", "type": "error" }, { - "inputs": [{ "internalType": "address", "name": "policy_", "type": "address" }], + "inputs": [ + { + "internalType": "address", + "name": "policy_", + "type": "address" + } + ], "name": "Module_PolicyNotPermitted", "type": "error" }, - { "inputs": [], "name": "RANGE_InvalidParams", "type": "error" }, + { + "inputs": [], + "name": "RANGE_InvalidParams", + "type": "error" + }, { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, - { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" } + { + "indexed": false, + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp_", + "type": "uint256" + } ], "name": "CushionDown", "type": "event" @@ -35,9 +85,24 @@ { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, - { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } + { + "indexed": false, + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "capacity_", + "type": "uint256" + } ], "name": "CushionUp", "type": "event" @@ -45,10 +110,30 @@ { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "uint256", "name": "wallLowPrice_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "cushionLowPrice_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "cushionHighPrice_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "wallHighPrice_", "type": "uint256" } + { + "indexed": false, + "internalType": "uint256", + "name": "wallLowPrice_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cushionLowPrice_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cushionHighPrice_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wallHighPrice_", + "type": "uint256" + } ], "name": "PricesChanged", "type": "event" @@ -56,24 +141,62 @@ { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "uint256", "name": "cushionSpread_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "wallSpread_", "type": "uint256" } + { + "indexed": false, + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "cushionSpread_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wallSpread_", + "type": "uint256" + } ], "name": "SpreadsChanged", "type": "event" }, { "anonymous": false, - "inputs": [{ "indexed": false, "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }], + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "thresholdFactor_", + "type": "uint256" + } + ], "name": "ThresholdFactorChanged", "type": "event" }, { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, - { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } + { + "indexed": false, + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "capacity_", + "type": "uint256" + } ], "name": "WallDown", "type": "event" @@ -81,32 +204,71 @@ { "anonymous": false, "inputs": [ - { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, - { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, - { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } + { + "indexed": false, + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "timestamp_", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "capacity_", + "type": "uint256" + } ], "name": "WallUp", "type": "event" }, - { "inputs": [], "name": "INIT", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "INIT", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [], "name": "KEYCODE", - "outputs": [{ "internalType": "Keycode", "name": "", "type": "bytes5" }], + "outputs": [ + { + "internalType": "Keycode", + "name": "", + "type": "bytes5" + } + ], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "ONE_HUNDRED_PERCENT", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ONE_PERCENT", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, @@ -114,28 +276,66 @@ "inputs": [], "name": "VERSION", "outputs": [ - { "internalType": "uint8", "name": "major", "type": "uint8" }, - { "internalType": "uint8", "name": "minor", "type": "uint8" } + { + "internalType": "uint8", + "name": "major", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "minor", + "type": "uint8" + } ], "stateMutability": "pure", "type": "function" }, { - "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], + "inputs": [ + { + "internalType": "bool", + "name": "high_", + "type": "bool" + } + ], "name": "active", - "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], + "inputs": [ + { + "internalType": "bool", + "name": "high_", + "type": "bool" + } + ], "name": "capacity", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "contract Kernel", "name": "newKernel_", "type": "address" }], + "inputs": [ + { + "internalType": "contract Kernel", + "name": "newKernel_", + "type": "address" + } + ], "name": "changeKernel", "outputs": [], "stateMutability": "nonpayable", @@ -144,38 +344,88 @@ { "inputs": [], "name": "kernel", - "outputs": [{ "internalType": "contract Kernel", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "contract Kernel", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], + "inputs": [ + { + "internalType": "bool", + "name": "high_", + "type": "bool" + } + ], "name": "lastActive", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { - "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], + "inputs": [ + { + "internalType": "bool", + "name": "high_", + "type": "bool" + } + ], "name": "market", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ohm", - "outputs": [{ "internalType": "contract ERC20", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "bool", "name": "wall_", "type": "bool" }, - { "internalType": "bool", "name": "high_", "type": "bool" } + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "bool", + "name": "wall_", + "type": "bool" + } ], "name": "price", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, @@ -185,72 +435,140 @@ "outputs": [ { "components": [ - { - "components": [ - { "internalType": "bool", "name": "active", "type": "bool" }, - { "internalType": "uint48", "name": "lastActive", "type": "uint48" }, - { "internalType": "uint256", "name": "capacity", "type": "uint256" }, - { "internalType": "uint256", "name": "threshold", "type": "uint256" }, - { "internalType": "uint256", "name": "market", "type": "uint256" } - ], - "internalType": "struct RANGEv1.Side", - "name": "low", - "type": "tuple" - }, - { - "components": [ - { "internalType": "bool", "name": "active", "type": "bool" }, - { "internalType": "uint48", "name": "lastActive", "type": "uint48" }, - { "internalType": "uint256", "name": "capacity", "type": "uint256" }, - { "internalType": "uint256", "name": "threshold", "type": "uint256" }, - { "internalType": "uint256", "name": "market", "type": "uint256" } - ], - "internalType": "struct RANGEv1.Side", - "name": "high", - "type": "tuple" - }, { "components": [ { - "components": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], - "internalType": "struct RANGEv1.Line", - "name": "high", - "type": "tuple" + "internalType": "bool", + "name": "active", + "type": "bool" + }, + { + "internalType": "uint48", + "name": "lastActive", + "type": "uint48" + }, + { + "internalType": "uint256", + "name": "capacity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "market", + "type": "uint256" }, { - "components": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], - "internalType": "struct RANGEv1.Line", - "name": "low", + "components": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spread", + "type": "uint256" + } + ], + "internalType": "struct RANGEv2.Line", + "name": "cushion", "type": "tuple" }, - { "internalType": "uint256", "name": "spread", "type": "uint256" } + { + "components": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spread", + "type": "uint256" + } + ], + "internalType": "struct RANGEv2.Line", + "name": "wall", + "type": "tuple" + } ], - "internalType": "struct RANGEv1.Band", - "name": "cushion", + "internalType": "struct RANGEv2.Side", + "name": "low", "type": "tuple" }, { "components": [ { - "components": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], - "internalType": "struct RANGEv1.Line", - "name": "high", - "type": "tuple" + "internalType": "bool", + "name": "active", + "type": "bool" + }, + { + "internalType": "uint48", + "name": "lastActive", + "type": "uint48" }, { - "components": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], - "internalType": "struct RANGEv1.Line", - "name": "low", + "internalType": "uint256", + "name": "capacity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "threshold", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "market", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spread", + "type": "uint256" + } + ], + "internalType": "struct RANGEv2.Line", + "name": "cushion", "type": "tuple" }, - { "internalType": "uint256", "name": "spread", "type": "uint256" } + { + "components": [ + { + "internalType": "uint256", + "name": "price", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spread", + "type": "uint256" + } + ], + "internalType": "struct RANGEv2.Line", + "name": "wall", + "type": "tuple" + } ], - "internalType": "struct RANGEv1.Band", - "name": "wall", + "internalType": "struct RANGEv2.Side", + "name": "high", "type": "tuple" } ], - "internalType": "struct RANGEv1.Range", + "internalType": "struct RANGEv2.Range", "name": "", "type": "tuple" } @@ -260,8 +578,16 @@ }, { "inputs": [ - { "internalType": "bool", "name": "high_", "type": "bool" }, - { "internalType": "uint256", "name": "capacity_", "type": "uint256" } + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "capacity_", + "type": "uint256" + } ], "name": "regenerate", "outputs": [], @@ -271,14 +597,33 @@ { "inputs": [], "name": "reserve", - "outputs": [{ "internalType": "contract ERC20", "name": "", "type": "address" }], + "outputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "uint256", "name": "cushionSpread_", "type": "uint256" }, - { "internalType": "uint256", "name": "wallSpread_", "type": "uint256" } + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "cushionSpread_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "wallSpread_", + "type": "uint256" + } ], "name": "setSpreads", "outputs": [], @@ -286,30 +631,67 @@ "type": "function" }, { - "inputs": [{ "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }], + "inputs": [ + { + "internalType": "uint256", + "name": "thresholdFactor_", + "type": "uint256" + } + ], "name": "setThresholdFactor", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { - "inputs": [{ "internalType": "bool", "name": "wall_", "type": "bool" }], + "inputs": [ + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "bool", + "name": "wall_", + "type": "bool" + } + ], "name": "spread", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "thresholdFactor", - "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], "stateMutability": "view", "type": "function" }, { "inputs": [ - { "internalType": "bool", "name": "high_", "type": "bool" }, - { "internalType": "uint256", "name": "capacity_", "type": "uint256" } + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "capacity_", + "type": "uint256" + } ], "name": "updateCapacity", "outputs": [], @@ -318,9 +700,21 @@ }, { "inputs": [ - { "internalType": "bool", "name": "high_", "type": "bool" }, - { "internalType": "uint256", "name": "market_", "type": "uint256" }, - { "internalType": "uint256", "name": "marketCapacity_", "type": "uint256" } + { + "internalType": "bool", + "name": "high_", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "market_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "marketCapacity_", + "type": "uint256" + } ], "name": "updateMarket", "outputs": [], @@ -328,7 +722,13 @@ "type": "function" }, { - "inputs": [{ "internalType": "uint256", "name": "movingAverage_", "type": "uint256" }], + "inputs": [ + { + "internalType": "uint256", + "name": "target_", + "type": "uint256" + } + ], "name": "updatePrices", "outputs": [], "stateMutability": "nonpayable", diff --git a/src/views/Range/RangeChart.tsx b/src/views/Range/RangeChart.tsx index 874db34b1f..5c0767671b 100644 --- a/src/views/Range/RangeChart.tsx +++ b/src/views/Range/RangeChart.tsx @@ -16,6 +16,7 @@ import { } from "recharts"; import { NameType } from "recharts/types/component/DefaultTooltipContent"; import { formatCurrency, parseBigNumber, trim } from "src/helpers"; +import { RANGEv2 as OlympusRange } from "src/typechain/Range"; import { OperatorMovingAverage, OperatorTargetPrice, PriceHistory } from "src/views/Range/hooks"; const PREFIX = "RangeChart"; @@ -39,7 +40,7 @@ const StyledResponsiveContainer = styled(ResponsiveContainer)(({ theme }) => ({ * Component for Displaying RangeChart */ const RangeChart = (props: { - rangeData: any; + rangeData: OlympusRange.RangeStructOutput; currentPrice: number; bidPrice: number; askPrice: number; @@ -47,16 +48,18 @@ const RangeChart = (props: { reserveSymbol: string; }) => { const { rangeData, currentPrice, bidPrice, askPrice, reserveSymbol } = props; + + console.log(); //TODO - Figure out which Subgraphs to query. Currently Uniswap. const { data: priceData, isFetched } = PriceHistory({ reserveSymbol }); const { data: targetPrice } = OperatorTargetPrice(); const { data: movingAverage } = OperatorMovingAverage(); - const formattedWallHigh = trim(parseBigNumber(rangeData.wall.high.price, 18), 2); - const formattedWallLow = trim(parseBigNumber(rangeData.wall.low.price, 18), 2); - const formattedCushionHigh = trim(parseBigNumber(rangeData.cushion.high.price, 18), 2); - const formattedCushionLow = trim(parseBigNumber(rangeData.cushion.low.price, 18), 2); + const formattedWallHigh = trim(parseBigNumber(rangeData.high.wall.price, 18), 2); + const formattedWallLow = trim(parseBigNumber(rangeData.low.wall.price, 18), 2); + const formattedCushionHigh = trim(parseBigNumber(rangeData.high.cushion.price, 18), 2); + const formattedCushionLow = trim(parseBigNumber(rangeData.low.cushion.price, 18), 2); const chartData = priceData.map((item: any) => { return { ...item, @@ -128,19 +131,19 @@ const RangeChart = (props: { <> - Math.min(dataMin, askPrice, bidPrice, parseBigNumber(rangeData.wall.low.price, 18)) * 0.95, + Math.min(dataMin, askPrice, bidPrice, parseBigNumber(rangeData.low.wall.price, 18)) * 0.95, (dataMax: number) => - Math.max(dataMax, askPrice, bidPrice, parseBigNumber(rangeData.wall.low.price, 18)) * 1.05, + Math.max(dataMax, askPrice, bidPrice, parseBigNumber(rangeData.low.wall.price, 18)) * 1.05, ]} padding={{ top: 20, bottom: 20 }} tick={false} diff --git a/src/views/Range/hooks.tsx b/src/views/Range/hooks.tsx index 02e6385f60..2cf51e5271 100644 --- a/src/views/Range/hooks.tsx +++ b/src/views/Range/hooks.tsx @@ -18,7 +18,7 @@ import { queryAssertion } from "src/helpers/react-query/queryAssertion"; import { useOhmPrice } from "src/hooks/usePrices"; import { useTestableNetworks } from "src/hooks/useTestableNetworks"; import { BondFixedTermSDA__factory, BondTeller__factory, IERC20__factory } from "src/typechain"; -import { RANGEv1 as OlympusRange } from "src/typechain/Range"; +import { RANGEv2 as OlympusRange } from "src/typechain/Range"; import { useBondV3 } from "src/views/Bond/hooks/useBondV3"; import { useSigner } from "wagmi"; @@ -147,38 +147,34 @@ export const OperatorReserveSymbol = () => { export const RangeData = () => { const networks = useTestableNetworks(); const contract = RANGE_CONTRACT.getEthersContract(networks.MAINNET); - const { data = { high: sideStruct, low: sideStruct, - wall: band, - cushion: band, } as OlympusRange.RangeStructOutput, isFetched, isLoading, } = useQuery(["getRangeData", networks.MAINNET], async () => { const range = await contract.range(); + return range; }); return { data, isFetched, isLoading }; }; +const line: OlympusRange.LineStruct = { + price: BigNumber.from(0), + spread: BigNumber.from(0), +}; + const sideStruct: OlympusRange.SideStruct = { active: false, lastActive: 0, capacity: BigNumber.from(0), threshold: BigNumber.from(0), market: BigNumber.from(-1), -}; -const line: OlympusRange.LineStruct = { - price: BigNumber.from(0), -}; - -const band: OlympusRange.BandStruct = { - high: line, - low: line, - spread: BigNumber.from(0), + cushion: line, + wall: line, }; export const RangeBondMaxPayout = (id: BigNumber) => { @@ -235,6 +231,7 @@ export const DetermineRangePrice = (bidOrAsk: "bid" | "ask") => { const { data: rangeData } = RangeData(); const { data: upperBondMarket } = useBondV3({ id: rangeData.high.market.toString() }); const { data: lowerBondMarket } = useBondV3({ id: rangeData.low.market.toString(), isInverseBond: true }); + const { data = { price: 0, contract: "swap" }, isFetched, @@ -248,11 +245,11 @@ export const DetermineRangePrice = (bidOrAsk: "bid" | "ask") => { const activeBondMarket = market.gt(-1) && market.lt(ethers.constants.MaxUint256) && liveOnBondAggregator; //>=0 <=MAXUint256 const bondOutsideWall = bidOrAsk === "ask" - ? upperBondMarket?.price.inBaseToken.gt(new DecimalBigNumber(rangeData.wall.high.price, 18)) + ? upperBondMarket?.price.inBaseToken.gt(new DecimalBigNumber(rangeData.high.wall.price, 18)) : lowerBondMarket ? new DecimalBigNumber("1") .div(lowerBondMarket?.price.inBaseToken) - .lt(new DecimalBigNumber(rangeData.wall.low.price, 18)) + .lt(new DecimalBigNumber(rangeData.low.wall.price, 18)) : false; if (sideActive && activeBondMarket && !bondOutsideWall) { return { @@ -274,8 +271,8 @@ export const DetermineRangePrice = (bidOrAsk: "bid" | "ask") => { return { price: bidOrAsk === "ask" - ? parseBigNumber(rangeData.wall.high.price, 18) - : parseBigNumber(rangeData.wall.low.price, 18), + ? parseBigNumber(rangeData.high.wall.price, 18) + : parseBigNumber(rangeData.low.wall.price, 18), contract: "swap" as RangeContracts, }; } @@ -302,13 +299,13 @@ export const DetermineRangeDiscount = (bidOrAsk: "bid" | "ask") => { const bondDiscount = bidOrAskPrice.discount ? bidOrAskPrice.discount : undefined; const sellActive = bidOrAsk === "bid"; const swapWithOperator = sellActive - ? bidOrAskPrice.price < parseBigNumber(rangeData.wall.low.price, 18) - : bidOrAskPrice.price > parseBigNumber(rangeData.wall.high.price, 18); + ? bidOrAskPrice.price < parseBigNumber(rangeData.low.wall.price, 18) + : bidOrAskPrice.price > parseBigNumber(rangeData.high.wall.price, 18); const swapPrice = swapWithOperator ? sellActive - ? parseBigNumber(rangeData.wall.low.price, 18) - : parseBigNumber(rangeData.wall.high.price, 18) + ? parseBigNumber(rangeData.low.wall.price, 18) + : parseBigNumber(rangeData.high.wall.price, 18) : sellActive ? bidOrAskPrice.price : bidOrAskPrice.price; diff --git a/src/views/Range/index.tsx b/src/views/Range/index.tsx index daa51ac583..84fdf15ebe 100644 --- a/src/views/Range/index.tsx +++ b/src/views/Range/index.tsx @@ -77,10 +77,10 @@ export const Range = () => { }, [sellActive]); useEffect(() => { - if (currentPrice < parseBigNumber(rangeData.cushion.low.price, 18)) { + if (currentPrice < parseBigNumber(rangeData.low.cushion.price, 18)) { setSellActive(true); } - }, [rangeData.cushion.low.price, currentPrice]); + }, [rangeData.low.cushion.price, currentPrice]); const maxBalanceString = `${formatNumber(maxCapacity, 2)} ${buyAsset} (${formatNumber( sellActive ? maxCapacity / bidPrice.price : maxCapacity * askPrice.price, From 33da97f935e8e88aa8e8e4c4b736248248537464 Mon Sep 17 00:00:00 2001 From: brightiron Date: Wed, 15 Nov 2023 14:42:53 -0600 Subject: [PATCH 3/7] abi formatting --- src/abi/Range.json | 557 +++++++-------------------------------------- 1 file changed, 82 insertions(+), 475 deletions(-) diff --git a/src/abi/Range.json b/src/abi/Range.json index c1a0dfddb2..a79af84ddd 100644 --- a/src/abi/Range.json +++ b/src/abi/Range.json @@ -2,82 +2,32 @@ "abi": [ { "inputs": [ - { - "internalType": "contract Kernel", - "name": "kernel_", - "type": "address" - }, - { - "internalType": "contract ERC20", - "name": "ohm_", - "type": "address" - }, - { - "internalType": "contract ERC20", - "name": "reserve_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "thresholdFactor_", - "type": "uint256" - }, - { - "internalType": "uint256[2]", - "name": "lowSpreads_", - "type": "uint256[2]" - }, - { - "internalType": "uint256[2]", - "name": "highSpreads_", - "type": "uint256[2]" - } + { "internalType": "contract Kernel", "name": "kernel_", "type": "address" }, + { "internalType": "contract ERC20", "name": "ohm_", "type": "address" }, + { "internalType": "contract ERC20", "name": "reserve_", "type": "address" }, + { "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }, + { "internalType": "uint256[2]", "name": "lowSpreads_", "type": "uint256[2]" }, + { "internalType": "uint256[2]", "name": "highSpreads_", "type": "uint256[2]" } ], "stateMutability": "nonpayable", "type": "constructor" }, { - "inputs": [ - { - "internalType": "address", - "name": "caller_", - "type": "address" - } - ], + "inputs": [{ "internalType": "address", "name": "caller_", "type": "address" }], "name": "KernelAdapter_OnlyKernel", "type": "error" }, { - "inputs": [ - { - "internalType": "address", - "name": "policy_", - "type": "address" - } - ], + "inputs": [{ "internalType": "address", "name": "policy_", "type": "address" }], "name": "Module_PolicyNotPermitted", "type": "error" }, - { - "inputs": [], - "name": "RANGE_InvalidParams", - "type": "error" - }, + { "inputs": [], "name": "RANGE_InvalidParams", "type": "error" }, { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestamp_", - "type": "uint256" - } + { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, + { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" } ], "name": "CushionDown", "type": "event" @@ -85,24 +35,9 @@ { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestamp_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "capacity_", - "type": "uint256" - } + { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, + { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } ], "name": "CushionUp", "type": "event" @@ -110,30 +45,10 @@ { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "wallLowPrice_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "cushionLowPrice_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "cushionHighPrice_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "wallHighPrice_", - "type": "uint256" - } + { "indexed": false, "internalType": "uint256", "name": "wallLowPrice_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "cushionLowPrice_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "cushionHighPrice_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "wallHighPrice_", "type": "uint256" } ], "name": "PricesChanged", "type": "event" @@ -141,62 +56,25 @@ { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "cushionSpread_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "wallSpread_", - "type": "uint256" - } + { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, + { "indexed": false, "internalType": "uint256", "name": "cushionSpread_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "wallSpread_", "type": "uint256" } ], "name": "SpreadsChanged", "type": "event" }, { "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "thresholdFactor_", - "type": "uint256" - } - ], + "inputs": [{ "indexed": false, "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }], "name": "ThresholdFactorChanged", "type": "event" }, { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestamp_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "capacity_", - "type": "uint256" - } + { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, + { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } ], "name": "WallDown", "type": "event" @@ -204,24 +82,9 @@ { "anonymous": false, "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "timestamp_", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "capacity_", - "type": "uint256" - } + { "indexed": false, "internalType": "bool", "name": "high_", "type": "bool" }, + { "indexed": false, "internalType": "uint256", "name": "timestamp_", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "capacity_", "type": "uint256" } ], "name": "WallUp", "type": "event" @@ -236,39 +99,21 @@ { "inputs": [], "name": "KEYCODE", - "outputs": [ - { - "internalType": "Keycode", - "name": "", - "type": "bytes5" - } - ], + "outputs": [{ "internalType": "Keycode", "name": "", "type": "bytes5" }], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "ONE_HUNDRED_PERCENT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ONE_PERCENT", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, @@ -276,66 +121,28 @@ "inputs": [], "name": "VERSION", "outputs": [ - { - "internalType": "uint8", - "name": "major", - "type": "uint8" - }, - { - "internalType": "uint8", - "name": "minor", - "type": "uint8" - } + { "internalType": "uint8", "name": "major", "type": "uint8" }, + { "internalType": "uint8", "name": "minor", "type": "uint8" } ], "stateMutability": "pure", "type": "function" }, { - "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - } - ], + "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], "name": "active", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - } - ], + "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], "name": "capacity", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "contract Kernel", - "name": "newKernel_", - "type": "address" - } - ], + "inputs": [{ "internalType": "contract Kernel", "name": "newKernel_", "type": "address" }], "name": "changeKernel", "outputs": [], "stateMutability": "nonpayable", @@ -344,88 +151,38 @@ { "inputs": [], "name": "kernel", - "outputs": [ - { - "internalType": "contract Kernel", - "name": "", - "type": "address" - } - ], + "outputs": [{ "internalType": "contract Kernel", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - } - ], + "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], "name": "lastActive", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { - "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - } - ], + "inputs": [{ "internalType": "bool", "name": "high_", "type": "bool" }], "name": "market", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ohm", - "outputs": [ - { - "internalType": "contract ERC20", - "name": "", - "type": "address" - } - ], + "outputs": [{ "internalType": "contract ERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "bool", - "name": "wall_", - "type": "bool" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "bool", "name": "wall_", "type": "bool" } ], "name": "price", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, @@ -437,43 +194,15 @@ "components": [ { "components": [ - { - "internalType": "bool", - "name": "active", - "type": "bool" - }, - { - "internalType": "uint48", - "name": "lastActive", - "type": "uint48" - }, - { - "internalType": "uint256", - "name": "capacity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "threshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "market", - "type": "uint256" - }, + { "internalType": "bool", "name": "active", "type": "bool" }, + { "internalType": "uint48", "name": "lastActive", "type": "uint48" }, + { "internalType": "uint256", "name": "capacity", "type": "uint256" }, + { "internalType": "uint256", "name": "threshold", "type": "uint256" }, + { "internalType": "uint256", "name": "market", "type": "uint256" }, { "components": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "spread", - "type": "uint256" - } + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "spread", "type": "uint256" } ], "internalType": "struct RANGEv2.Line", "name": "cushion", @@ -481,16 +210,8 @@ }, { "components": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "spread", - "type": "uint256" - } + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "spread", "type": "uint256" } ], "internalType": "struct RANGEv2.Line", "name": "wall", @@ -503,43 +224,15 @@ }, { "components": [ - { - "internalType": "bool", - "name": "active", - "type": "bool" - }, - { - "internalType": "uint48", - "name": "lastActive", - "type": "uint48" - }, - { - "internalType": "uint256", - "name": "capacity", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "threshold", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "market", - "type": "uint256" - }, + { "internalType": "bool", "name": "active", "type": "bool" }, + { "internalType": "uint48", "name": "lastActive", "type": "uint48" }, + { "internalType": "uint256", "name": "capacity", "type": "uint256" }, + { "internalType": "uint256", "name": "threshold", "type": "uint256" }, + { "internalType": "uint256", "name": "market", "type": "uint256" }, { "components": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "spread", - "type": "uint256" - } + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "spread", "type": "uint256" } ], "internalType": "struct RANGEv2.Line", "name": "cushion", @@ -547,16 +240,8 @@ }, { "components": [ - { - "internalType": "uint256", - "name": "price", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "spread", - "type": "uint256" - } + { "internalType": "uint256", "name": "price", "type": "uint256" }, + { "internalType": "uint256", "name": "spread", "type": "uint256" } ], "internalType": "struct RANGEv2.Line", "name": "wall", @@ -578,16 +263,8 @@ }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "capacity_", - "type": "uint256" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "uint256", "name": "capacity_", "type": "uint256" } ], "name": "regenerate", "outputs": [], @@ -597,33 +274,15 @@ { "inputs": [], "name": "reserve", - "outputs": [ - { - "internalType": "contract ERC20", - "name": "", - "type": "address" - } - ], + "outputs": [{ "internalType": "contract ERC20", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "cushionSpread_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "wallSpread_", - "type": "uint256" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "uint256", "name": "cushionSpread_", "type": "uint256" }, + { "internalType": "uint256", "name": "wallSpread_", "type": "uint256" } ], "name": "setSpreads", "outputs": [], @@ -631,13 +290,7 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "uint256", - "name": "thresholdFactor_", - "type": "uint256" - } - ], + "inputs": [{ "internalType": "uint256", "name": "thresholdFactor_", "type": "uint256" }], "name": "setThresholdFactor", "outputs": [], "stateMutability": "nonpayable", @@ -645,53 +298,25 @@ }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "bool", - "name": "wall_", - "type": "bool" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "bool", "name": "wall_", "type": "bool" } ], "name": "spread", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "thresholdFactor", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "capacity_", - "type": "uint256" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "uint256", "name": "capacity_", "type": "uint256" } ], "name": "updateCapacity", "outputs": [], @@ -700,21 +325,9 @@ }, { "inputs": [ - { - "internalType": "bool", - "name": "high_", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "market_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "marketCapacity_", - "type": "uint256" - } + { "internalType": "bool", "name": "high_", "type": "bool" }, + { "internalType": "uint256", "name": "market_", "type": "uint256" }, + { "internalType": "uint256", "name": "marketCapacity_", "type": "uint256" } ], "name": "updateMarket", "outputs": [], @@ -722,13 +335,7 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "uint256", - "name": "target_", - "type": "uint256" - } - ], + "inputs": [{ "internalType": "uint256", "name": "target_", "type": "uint256" }], "name": "updatePrices", "outputs": [], "stateMutability": "nonpayable", From 81c88f4ea46ce705f2b338be25157a772ddb67d3 Mon Sep 17 00:00:00 2001 From: brightiron Date: Wed, 15 Nov 2023 14:44:19 -0600 Subject: [PATCH 4/7] formatting --- src/abi/Range.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/abi/Range.json b/src/abi/Range.json index a79af84ddd..24aed3e076 100644 --- a/src/abi/Range.json +++ b/src/abi/Range.json @@ -89,13 +89,7 @@ "name": "WallUp", "type": "event" }, - { - "inputs": [], - "name": "INIT", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, + { "inputs": [], "name": "INIT", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "KEYCODE", From 9ee874cfcd5c421f9be316fe79f05485254d7f1c Mon Sep 17 00:00:00 2001 From: brightiron Date: Thu, 16 Nov 2023 08:22:52 -0600 Subject: [PATCH 5/7] fix tests --- src/views/Range/__mocks__/mockRangeCalls.tsx | 32 +++++++++++--------- src/views/Range/__tests__/Range.test.tsx | 3 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/views/Range/__mocks__/mockRangeCalls.tsx b/src/views/Range/__mocks__/mockRangeCalls.tsx index db0aa79d85..b8a6bb91a4 100644 --- a/src/views/Range/__mocks__/mockRangeCalls.tsx +++ b/src/views/Range/__mocks__/mockRangeCalls.tsx @@ -1,22 +1,21 @@ import { BigNumber } from "ethers"; -import { RANGEv1 as OlympusRange } from "src/typechain/Range"; +import { RANGEv2 as OlympusRange } from "src/typechain/Range"; export const RangeData: OlympusRange.RangeStruct = { - cushion: { - high: { - price: BigNumber.from("22161077252064087762"), - }, - low: { - price: BigNumber.from("18131790478961526351"), - }, - spread: BigNumber.from("1000"), - }, high: { active: true, lastActive: 1656528651, capacity: BigNumber.from("605396958336933"), //9 decimals for OHM market: BigNumber.from("115792089237316195423570985008687907853269984665640564039457584007913129639935"), threshold: BigNumber.from("6054147227010"), + wall: { + price: BigNumber.from("24175720638615368468"), + spread: BigNumber.from(2000), + }, + cushion: { + price: BigNumber.from("22161077252064087762"), + spread: BigNumber.from(1000), + }, }, low: { active: true, @@ -24,11 +23,14 @@ export const RangeData: OlympusRange.RangeStruct = { capacity: BigNumber.from("10000000000000000000000000"), //18 decimals for Reserve market: BigNumber.from("115792089237316195423570985008687907853269984665640564039457584007913129639935"), threshold: BigNumber.from("100000000000000000000000"), - }, - wall: { - low: { price: BigNumber.from("13117147092410245645") }, - high: { price: BigNumber.from("24175720638615368468") }, - spread: BigNumber.from(2000), + wall: { + price: BigNumber.from("13117147092410245645"), + spread: BigNumber.from(2000), + }, + cushion: { + price: BigNumber.from("18131790478961526351"), + spread: BigNumber.from(1000), + }, }, }; diff --git a/src/views/Range/__tests__/Range.test.tsx b/src/views/Range/__tests__/Range.test.tsx index 1fb8b510a4..4d150e474e 100644 --- a/src/views/Range/__tests__/Range.test.tsx +++ b/src/views/Range/__tests__/Range.test.tsx @@ -9,6 +9,7 @@ import { connectWallet, invalidAddress } from "src/testHelpers"; import { fireEvent, render, screen } from "src/testUtils"; import * as IERC20Factory from "src/typechain/factories/IERC20__factory"; import * as RangeFactory from "src/typechain/factories/Range__factory"; +import { RANGEv2 as OlympusRange } from "src/typechain/Range"; import { RangeData } from "src/views/Range/__mocks__/mockRangeCalls"; import { Range } from "src/views/Range/index"; import { beforeEach, describe, expect, it, vi } from "vitest"; @@ -18,7 +19,7 @@ global.ResizeObserver = require("resize-observer-polyfill"); vi.mock("src/hooks/useContractAllowance"); vi.mock("src/views/Range/RangeChart", () => ({ default: (props: { - rangeData: any; + rangeData: OlympusRange.RangeStructOutput; currentPrice: number; bidPrice: number; askPrice: number; From 642d7b1450416b46d6ff13e4ef53ca0f48429cc6 Mon Sep 17 00:00:00 2001 From: brightiron Date: Thu, 16 Nov 2023 11:28:28 -0600 Subject: [PATCH 6/7] mainnet contracts --- src/constants/addresses.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 2adf0e9d17..a366f571ac 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -143,12 +143,12 @@ export const BALANCER_VAULT_ADDRESSSES = { }; export const RANGE_OPERATOR_ADDRESSES = { - [NetworkId.MAINNET]: "0x0374c001204eF5e7E4F5362A5A2430CB6c219326", + [NetworkId.MAINNET]: "0x0AE561226896dA978EaDA0Bec4a7d3CfAE04f506", [NetworkId.TESTNET_GOERLI]: "0x6620592f9bdffAbadcea644a35946E7b93EaaF56", }; export const RANGE_ADDRESSES = { - [NetworkId.MAINNET]: "0xb212D9584cfc56EFf1117F412Fe0bBdc53673954", + [NetworkId.MAINNET]: "0x399cD3685912bb56aAeD0949119dB6cE5Df60FB5", [NetworkId.TESTNET_GOERLI]: "0xFF88b47af188d91aC05ff5E843B5F6863472EdD0", }; From 49e7f4f93aed7feda9bfd0167b7961e184670189 Mon Sep 17 00:00:00 2001 From: brightiron Date: Thu, 16 Nov 2023 13:06:55 -0600 Subject: [PATCH 7/7] remove console log --- src/views/Range/RangeChart.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/views/Range/RangeChart.tsx b/src/views/Range/RangeChart.tsx index 5c0767671b..bc72883b3f 100644 --- a/src/views/Range/RangeChart.tsx +++ b/src/views/Range/RangeChart.tsx @@ -48,8 +48,6 @@ const RangeChart = (props: { reserveSymbol: string; }) => { const { rangeData, currentPrice, bidPrice, askPrice, reserveSymbol } = props; - - console.log(); //TODO - Figure out which Subgraphs to query. Currently Uniswap. const { data: priceData, isFetched } = PriceHistory({ reserveSymbol });