diff --git a/web/components/contract/liquidity-graph.tsx b/web/components/contract/liquidity-graph.tsx
new file mode 100644
index 00000000..d85585ab
--- /dev/null
+++ b/web/components/contract/liquidity-graph.tsx
@@ -0,0 +1,101 @@
+import { DatumValue } from '@nivo/core'
+import { Point, ResponsiveLine } from '@nivo/line'
+import { NUMERIC_GRAPH_COLOR } from 'common/numeric-constants'
+import { memo } from 'react'
+import { range } from 'lodash'
+import { getDpmOutcomeProbabilities } from '../../../common/calculate-dpm'
+import { NumericContract } from '../../../common/contract'
+import { useWindowSize } from '../../hooks/use-window-size'
+import { Col } from '../layout/col'
+import { formatLargeNumber } from 'common/util/format'
+
+export type GraphPoint = {
+ // A probability between 0 and 1
+ x: number
+ // Amount of liquidity
+ y: number
+}
+
+export const LiquidityGraph = memo(function NumericGraph(props: {
+ min?: 0
+ max?: 1
+ points: GraphPoint[]
+ height?: number
+}) {
+ const { height, min, max, points } = props
+
+ // Really maxLiquidity
+ const maxLiquidity = 500
+ const data = [{ id: 'Probability', data: points, color: NUMERIC_GRAPH_COLOR }]
+
+ const yTickValues = [
+ 0,
+ 0.25 * maxLiquidity,
+ 0.5 * maxLiquidity,
+ 0.75 * maxLiquidity,
+ maxLiquidity,
+ ]
+
+ const { width } = useWindowSize()
+
+ const numXTickValues = !width || width < 800 ? 2 : 5
+
+ return (
+
= 800 ? 350 : 250) }}
+ >
+ `${formatLargeNumber(+d, 3)}`}
+ axisBottom={{
+ tickValues: numXTickValues,
+ format: (d) => `${formatLargeNumber(+d, 3)}`,
+ }}
+ colors={{ datum: 'color' }}
+ pointSize={0}
+ enableSlices="x"
+ sliceTooltip={({ slice }) => {
+ const point = slice.points[0]
+ return
+ }}
+ enableGridX={!!width && width >= 800}
+ enableArea
+ margin={{ top: 20, right: 28, bottom: 22, left: 50 }}
+ />
+
+ )
+})
+
+function formatLiquidity(y: DatumValue) {
+ const p = Math.round(+y * 100) / 100
+ return `${p}L`
+}
+
+function Tooltip(props: { point: Point }) {
+ const { point } = props
+ return (
+
+
+ {point.serieId} {point.data.yFormatted}
+
+ {formatLargeNumber(+point.data.x)}
+
+ )
+}
diff --git a/web/pages/swap.tsx b/web/pages/swap.tsx
index f5bbe7de..b213b8ae 100644
--- a/web/pages/swap.tsx
+++ b/web/pages/swap.tsx
@@ -6,6 +6,7 @@ import {
} 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'
@@ -86,12 +87,24 @@ function PoolTable(props: { pool: Swap3Pool }) {
)
}
+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,
sqrtRatio: 2,
tick: fromProb(0.3),
- ticks: [],
+ tickStates: [],
})
const [minTick, setMinTick] = useState(0)
@@ -106,8 +119,9 @@ export default function Swap() {
return (
-
+ {/* */}
+