diff --git a/src/App.tsx b/src/App.tsx
index bcc6162..759d2ae 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -91,11 +91,11 @@ export default function App() {
d0: 1e6, // Initial raise, d0 (DAI)
theta: 0.35, // fraction allocated to reserve (.)
p0: 0.1, // Hatch sale price p0 (DAI / token)
- returnF: 3, // Return factor (.)
+ p1: 0.3, // Return factor (.)
wFee: 0.05 // friction coefficient (.)
});
- const { d0, theta, p0, returnF, wFee } = curveParams;
+ const { d0, theta, p0, p1, wFee } = curveParams;
/**
* Throttle the curve update to prevent the expensive chart
@@ -116,7 +116,7 @@ export default function App() {
d0,
theta,
p0,
- returnF
+ p1
});
const [priceTimeseries, setPriceTimeseries] = useState([0]);
@@ -270,12 +270,7 @@ export default function App() {
-
+
@@ -321,6 +316,7 @@ export default function App() {
priceTimeseries={priceTimeseries}
withdrawFeeTimeseries={withdrawFeeTimeseries}
p0={p0}
+ p1={p1}
/>
diff --git a/src/InputParams.tsx b/src/InputParams.tsx
index 35d3158..2e99be7 100644
--- a/src/InputParams.tsx
+++ b/src/InputParams.tsx
@@ -111,7 +111,7 @@ export default function InputParams({
d0: number;
theta: number;
p0: number;
- returnF: number;
+ p1: number;
wFee: number;
};
setCurveParams(newCurveParams: any): void;
@@ -119,13 +119,15 @@ export default function InputParams({
const [d0, setD0] = useState(1e6); // Initial raise, d0 (DAI)
const [theta, setTheta] = useState(0.35); // fraction allocated to reserve (.)
const [p0, setP0] = useState(0.1); // Hatch sale Price p0 (DAI / token)
- const [returnF, setReturnF] = useState(3); // Return factor (.)
+ const [p1, setP1] = useState(0.3); // Return factor (.)
const [wFee, setWFee] = useState(0.05); // friction coefficient (.)
function setParentCurveParams() {
- setCurveParams({ d0, theta, p0, returnF, wFee });
+ setCurveParams({ d0, theta, p0, p1, wFee });
}
+ const maxReturnRate = 10;
+
const inputFields: {
label: string;
value: number;
@@ -168,7 +170,7 @@ export default function InputParams({
toNum: (n: string) => parseFloat(n) * 1e-2
},
{
- label: "Initial token price",
+ label: "Hatch sale price",
value: p0,
setter: setP0,
min: 0.01,
@@ -181,17 +183,17 @@ export default function InputParams({
format: (n: number) => `$${n}`
},
{
- label: "Return factor",
- value: returnF,
- setter: setReturnF,
- min: 1,
- max: 10,
- step: 0.1,
- unit: "x",
- suffix: "x",
- toText: (n: number) => String(+n.toFixed(1)),
+ label: "After hatch price",
+ value: p1,
+ setter: setP1,
+ min: p0 || 0.1,
+ max: Number((maxReturnRate * p0).toFixed(2)),
+ step: 0.01,
+ unit: "$",
+ prefix: "$",
+ toText: (n: number) => String(+n.toFixed(2)),
toNum: (n: string) => parseFloat(n),
- format: (n: number) => `${n}x`
+ format: (n: number) => `$${n}`
},
{
label: "Withdrawl fee",
@@ -208,6 +210,11 @@ 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/PriceSimulationChart.tsx b/src/PriceSimulationChart.tsx
index 45d84c3..b558c9b 100644
--- a/src/PriceSimulationChart.tsx
+++ b/src/PriceSimulationChart.tsx
@@ -6,6 +6,7 @@ import {
YAxis,
CartesianGrid,
Legend,
+ ReferenceLine,
ResponsiveContainer,
Tooltip
} from "recharts";
@@ -15,11 +16,13 @@ import { linspace } from "./utils";
function PriceSimulationChart({
priceTimeseries,
withdrawFeeTimeseries,
- p0
+ p0,
+ p1
}: {
priceTimeseries: number[];
withdrawFeeTimeseries: number[];
p0: number;
+ p1: number;
}) {
// d0 - Initial raise, d0 (DAI)
// theta - fraction allocated to reserve (.)
@@ -50,6 +53,21 @@ function PriceSimulationChart({
const formatter = (n: number) => (+n.toPrecision(3)).toLocaleString();
+ function ReferenceLabel(props: any) {
+ const { textAnchor, viewBox, text } = props;
+ console.log(props);
+ return (
+
+ {text}
+
+ );
+ }
+
return (
+
+ {/* Price time evolution */}
Number(value)} />
+
+ }
+ />
+ }
+ />
{/* Capital collected from withdraw fees - AREA */}
S0 * (R / R0) ** (1 / k);
// Function setup
@@ -138,7 +146,7 @@ function SupplyVsDemandChart({
/>
}
/>
diff --git a/src/math.ts b/src/math.ts
index 335d0b9..109bcf3 100644
--- a/src/math.ts
+++ b/src/math.ts
@@ -11,14 +11,14 @@ export function getInitialParams({
d0,
theta,
p0,
- returnF
+ p1
}: {
d0: number;
theta: number;
p0: number;
- returnF: number;
+ p1: number;
}) {
- const k = returnF / (1 - theta); // Invariant power kappa (.)
+ const k = p1 / p0 / (1 - theta); // Invariant power kappa (.)
const R0 = (1 - theta) * d0; // Initial reserve (DAI)
const S0 = d0 / p0; // initial supply of tokens (token)
const V0 = S0 ** k / R0; // invariant coef