diff --git a/src/App.tsx b/src/App.tsx index ee7ac1e..27bb18f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,7 +7,6 @@ import Box from "@material-ui/core/Box"; import Paper from "@material-ui/core/Paper"; import Grid from "@material-ui/core/Grid"; import Button from "@material-ui/core/Button"; -import Fade from "@material-ui/core/Fade"; // Components import Header from "./Header"; import InputParams from "./InputParams"; @@ -193,7 +192,7 @@ export default function App() { const { k, // Invariant power kappa (.) R0, // Initial reserve (DAI) - S0, // initial supply of tokens (token) + // S0, // initial supply of tokens (token) V0 // invariant coef } = getInitialParams({ d0, @@ -239,6 +238,7 @@ export default function App() { useEffect(() => { let canContinueSimulation = true; + async function simulateRandomDelta() { const R_t: number[] = [R0]; const p_t: number[] = [getPriceR({ R: R0, V0, k })]; @@ -287,9 +287,6 @@ export default function App() { setAvgTxSize(getAvg(avgTxSize_t)); setTotalReserve(getLast(R_t)); - // Make this run non-UI blocking - await pause(5); - setSimulationRunning(false); } diff --git a/src/InputParams.tsx b/src/InputParams.tsx index 49d5b90..66cb4e3 100644 --- a/src/InputParams.tsx +++ b/src/InputParams.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useMemo } from "react"; +import React, { useState } from "react"; import { createStyles, makeStyles, @@ -9,10 +9,7 @@ import Typography from "@material-ui/core/Typography"; import Slider from "@material-ui/core/Slider"; import Grid from "@material-ui/core/Grid"; import TextField from "@material-ui/core/TextField"; -import InputLabel from "@material-ui/core/InputLabel"; -import InputAdornment from "@material-ui/core/InputAdornment"; import NumberFormat from "react-number-format"; -import { throttle } from "lodash"; const PrettoSlider = withStyles({ root: { @@ -122,6 +119,12 @@ export default function InputParams({ const [p1, setP1] = useState(0.3); // Return factor (.) const [wFee, setWFee] = useState(0.05); // friction coefficient (.) + function _setP0(newP0: number) { + setP0(newP0); + if (p1 < newP0) setP1(newP0); + else if (p1 > newP0 * maxReturnRate) setP1(newP0 * maxReturnRate); + } + function setParentCurveParams() { setCurveParams({ d0, theta, p0, p1, wFee }); } @@ -172,7 +175,7 @@ export default function InputParams({ { label: "Hatch price", value: p0, - setter: setP0, + setter: _setP0, min: 0.01, max: 1, step: 0.01, @@ -210,11 +213,6 @@ export default function InputParams({ } ]; - useEffect(() => { - if (p1 < p0) setP1(p0); - else if (p1 > p0 * maxReturnRate) setP1(p0 * maxReturnRate); - }, [p0]); - const classes = useStyles(); return ( diff --git a/src/math.ts b/src/math.ts index 957959e..94050a4 100644 --- a/src/math.ts +++ b/src/math.ts @@ -1,5 +1,3 @@ -import { getAvg } from "./utils"; - /** * Computes the initial params given the "user friendly" params: * - Initial raise, `d0` (DAI)