diff --git a/web/pages/swap.tsx b/web/pages/swap.tsx index 3bc54a49..b347ab83 100644 --- a/web/pages/swap.tsx +++ b/web/pages/swap.tsx @@ -134,6 +134,67 @@ function Graph(props: { pool: Swap3Pool; previewMarker?: number }) { ) } +function LiquidityPanel(props: { + pool: Swap3Pool + setPool: (pool: Swap3Pool) => void +}) { + const { pool, setPool } = props + const [minTick, setMinTick] = useState(0) + const [maxTick, setMaxTick] = useState(0) + const [deltaL, setDeltaL] = useState(100) + + const { requiredN, requiredY } = calculateLPCost( + pool.tick, + minTick, + maxTick, + deltaL + ) + + return ( + +

Add liquidity

+ {/* */} + + setMinTick(inputPercentToTick(e))} + /> + {/* Min Tick: {minTick} */} + setMaxTick(inputPercentToTick(e))} + /> + {/* Max Tick: {maxTick} */} + setDeltaL(parseFloat(e.target.value))} + /> + + +
Y required: {requiredY.toFixed(2)}
+
N required: {requiredN.toFixed(2)}
{' '} +
+ + + ) +} + export default function Swap() { // Set up an initial pool with 100 liquidity from 0% to 100% // TODO: Not sure why maxTick of 2**23 breaks it, but 2**20 is okay... @@ -147,19 +208,8 @@ export default function Swap() { INIT_POOL = grossLiquidity(INIT_POOL) const [pool, setPool] = useState(INIT_POOL) - - const [minTick, setMinTick] = useState(0) - const [maxTick, setMaxTick] = useState(0) - const [deltaL, setDeltaL] = useState(100) const [buyAmount, setBuyAmount] = useState(0) - const { requiredN, requiredY } = calculateLPCost( - pool.tick, - minTick, - maxTick, - deltaL - ) - const { newPoolTick, yesPurchased } = buyYes(pool, buyAmount) return ( @@ -182,47 +232,7 @@ export default function Swap() { }} /> - -

Add liquidity

- {/* */} - - setMinTick(inputPercentToTick(e))} - /> - {/* Min Tick: {minTick} */} - setMaxTick(inputPercentToTick(e))} - /> - {/* Max Tick: {maxTick} */} - setDeltaL(parseFloat(e.target.value))} - /> - - -
Y required: {requiredY.toFixed(2)}
-
N required: {requiredN.toFixed(2)}
{' '} -
- - +

Limit Order