import { calculateLPCost, fromProb, getSwap3Probability, noShares, Swap3Pool, yesShares, } from 'common/calculate-swap3' import { formatPercent } from 'common/util/format' import { useState } from 'react' import { LiquidityGraph } from 'web/components/contract/liquidity-graph' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' const users = { alice: { M: 100, YES: 0, NO: 0, }, bob: { M: 200, YES: 0, NO: 0, }, kipply: { M: 300, YES: 0, NO: 0, }, } function BalanceTable() { /* Display all users current M, YES, and NO in a table */ return ( {Object.keys(users).map((user) => ( ))}
User M YES NO
{user} {users[user].M} {users[user].YES} {users[user].NO}
) } /* Show the values in pool */ function PoolTable(props: { pool: Swap3Pool }) { const { pool } = props return (
{pool.liquidity}
{pool.tick}
{yesShares(pool).toFixed(2)}
{noShares(pool).toFixed(2)}
{formatPercent(getSwap3Probability(pool))}
) } function Graph(props: { pool: Swap3Pool }) { const points = [ { x: 0, y: 100 }, { x: 0.2, y: 100 }, { x: 0.2, y: 200 }, { x: 0.33, y: 200 }, { x: 0.33, y: 100 }, { x: 1, y: 100 }, ] return } export default function Swap() { const [pool, setPool] = useState({ liquidity: 100, tick: fromProb(0.3), tickStates: [], }) const [minTick, setMinTick] = useState(0) const [maxTick, setMaxTick] = useState(0) const { requiredN, requiredY } = calculateLPCost( pool.tick, minTick, maxTick, 100 // deltaL ) return ( {/* */} setPool((p) => ({ ...p, tick: inputPercentToTick(e), })) } /> Alice: Add liquidity setMinTick(inputPercentToTick(e))} /> Min Tick: {minTick} setMaxTick(inputPercentToTick(e))} /> Max Tick: {maxTick}
Y required: {requiredY}
N required: {requiredN}
{' '}
Bob: Buy Tokens {/* */} ) } function inputPercentToTick(event: React.ChangeEvent) { return fromProb(parseFloat(event.target.value) / 100) }