\n {inputFields.map(\n ({\n label,\n description,\n value,\n setter,\n min,\n max,\n step,\n prefix,\n suffix,\n format,\n toText,\n toNum\n }) => {\n function sanitizeInput(num: number = 0) {\n if (isNaN(num)) num = 0;\n if (num > max) num = max;\n else if (num < min) num = min;\n setter(num);\n }\n\n return (\n
\n \n \n \n\n \n {\n sanitizeInput(\n toNum ? toNum(e.target.value) : parseFloat(e.target.value)\n );\n onChangeCommited();\n }}\n InputProps={{\n inputComponent: NumberFormatCustom,\n disableUnderline: true,\n inputProps: {\n prefix,\n suffix\n }\n }}\n value={toText ? toText(value) : value}\n />\n \n\n \n sanitizeInput(Number(newValue))}\n onChangeCommitted={onChangeCommited}\n value={value}\n min={min}\n max={max}\n step={step}\n valueLabelFormat={value => format(value).replace(\"$\", \"\")}\n />\n \n \n );\n }\n )}\n
\n );\n}\n","export interface DescriptionObject {\n [key: string]: { name: string; text: string };\n}\n\nexport const parameterDescriptions: DescriptionObject = {\n theta: {\n name: \"Hatch Raise % to funding pool\",\n text:\n \"The percentage of the funds raised in the Hatch going directly to funding pool to be used to support the Commons, the rest goes to the collateral pool\"\n },\n p0: {\n name: \"Hatch price\",\n text: \"The price paid per token by when hatching the project\"\n },\n p1: {\n name: \"Post-Hatch price\",\n text:\n \"The price per token after the Hatch ends, the curve is set, and anyone can interact with the bonding curve\"\n },\n wFee: {\n name: \"Exit tribute\",\n text:\n \"The percentage that goes to the funding pool when token holders 'sell' by burning their token at the price determined by the bonding curve\"\n },\n vHalflife: {\n name: \"Vesting half-life\",\n text:\n \"Tokens that are purchased during the Hatch are locked for 8 weeks and then released slowly such that 50% of the tokens will be able to be sold after this many weeks and 87.5% of the tokens after 3x this many weeks\"\n },\n d0: {\n name: \"Hatch Raise\",\n text: \"Amount of funds contributed during the hatch period\"\n }\n};\n\nexport const supplyVsDemandChartDescription =\n \"Visualization of the bonding curve up to 4x the initial size of the Collateral Pool Post-Hatch. This result is deterministic given the curve parameters and the Hatch raise. It will never change regardless of the campaign's performance, it simply shows how the price will react to changes in the Collateral Pool.\";\n\nexport const simulationChartDescription =\n \"This chart shows a 52 week simulation of discrete transactions interacting with the Augmented Bonding Curve. Each transaction adds to or subtracts reserve from the system, modifying the price over time. The frequency, size and direction of each transaction is computed from a set of bounded random functions. This is a NOT a cadCAD simulation, but it showcases the intention behind cadCAD.\";\n\nexport const simulationParameterDescriptions: DescriptionObject = {\n price: {\n name: \"Price\",\n text: \"Price of the token over time.\"\n },\n floorPrice: {\n name: \"Floor price\",\n text:\n \"Lower bound of the price guaranteed by the vesting of hatch tokens. It decreases over time as more hatch tokens are allowed to be traded\"\n },\n totalRaised: {\n name: \"Total funds raised\",\n text: \"Cumulative sum of the funds sent to the Funding Pool\"\n }\n};\n\nexport const resultParameterDescriptions: DescriptionObject = {\n totalReserve: {\n name: \"Collateral pool balance\",\n text: \"Total DAI in the collateral pool at the end of the simulated period\"\n },\n slippage: {\n name: \"Median slippage\",\n text:\n \"Median of change in price a user experiences from the current price to the price received for exiting/selling/burning\"\n },\n initialHatchFunds: {\n name: \"Funds generated from Raise Hatch\",\n text: \"Funds raised during the Hatch that go directly to the cause\"\n },\n exitTributes: {\n name: \"Funds generated from exit tributes\",\n text:\n \"Cumulative sum of exit tributes collected from only exit / sell / burn transactions\"\n },\n totalRaised: {\n name: \"Total funds raised for your community\",\n text: \"Sum of funds from Raise Hatch + funds from exit tributes\"\n }\n};\n","import React, { useState, useEffect } from \"react\";\nimport { InputFieldInterface, CurveParamsInterface } from \"./types\";\nimport InputParams from \"./InputParams\";\nimport { parameterDescriptions } from \"./parametersDescriptions\";\n\nexport default function CurveDesignInputParams({\n curveParams,\n setCurveParams\n}: {\n curveParams: CurveParamsInterface;\n setCurveParams(newCurveParams: any): void;\n}) {\n const [theta, setTheta] = useState(curveParams.theta); // fraction allocated to reserve (.)\n const [p0, setP0] = useState(curveParams.p0); // Hatch sale Price p0 (DAI / token)\n const [p1, setP1] = useState(curveParams.p1); // Return factor (.)\n const [wFee, setWFee] = useState(curveParams.wFee); // friction coefficient (.)\n const [vHalflife, setVHalflife] = useState(curveParams.vHalflife); // friction coefficient (.)\n\n useEffect(() => {\n setTheta(curveParams.theta);\n setP0(curveParams.p0);\n setP1(curveParams.p1);\n setWFee(curveParams.wFee);\n setVHalflife(curveParams.vHalflife);\n }, [curveParams]);\n\n const maxReturnRate = 10;\n const minP1P0Rate = 1.5;\n\n function _setP0(newP0: number) {\n setP0(newP0);\n if (p1 < newP0 * minP1P0Rate) setP1(newP0 * minP1P0Rate);\n else if (p1 > newP0 * maxReturnRate) setP1(newP0 * maxReturnRate);\n }\n\n function setParentCurveParams() {\n setCurveParams((params: CurveParamsInterface) => ({\n ...params,\n theta,\n p0,\n p1,\n wFee,\n vHalflife\n }));\n }\n\n const inputFields: InputFieldInterface[] = [\n {\n label: parameterDescriptions.theta.name,\n description: parameterDescriptions.theta.text,\n value: theta,\n setter: setTheta,\n min: 0,\n max: 0.9,\n step: 0.01,\n suffix: \"%\",\n format: (n: number) => `${Math.round(100 * n)}%`,\n toText: (n: number) => String(+(n * 1e2).toFixed(0)),\n toNum: (n: string) => parseFloat(n) * 1e-2\n },\n {\n label: `${parameterDescriptions.p0.name} (DAI/token)`,\n description: parameterDescriptions.p0.text,\n value: p0,\n setter: _setP0,\n min: 0.01,\n max: 1,\n step: 0.01,\n toText: (n: number) => String(+n.toFixed(2)),\n toNum: (n: string) => parseFloat(n),\n format: (n: number) => `$${n}`\n },\n {\n label: `${parameterDescriptions.p1.name} (DAI/token)`,\n description: parameterDescriptions.p1.text,\n value: p1,\n setter: setP1,\n min: Number((minP1P0Rate * (p0 || 0.1)).toFixed(2)),\n max: Number((maxReturnRate * p0).toFixed(2)),\n step: 0.01,\n toText: (n: number) => String(+n.toFixed(2)),\n toNum: (n: string) => parseFloat(n),\n format: (n: number) => `$${n}`\n },\n {\n label: parameterDescriptions.wFee.name,\n description: parameterDescriptions.wFee.text,\n value: wFee,\n setter: setWFee,\n min: 0,\n max: 0.1,\n step: 0.001,\n suffix: \"%\",\n format: (n: number) => `${+(100 * n).toFixed(1)}%`,\n toText: (n: number) => String(+(n * 1e2).toFixed(1)),\n toNum: (n: string) => parseFloat(n) * 1e-2\n },\n {\n label: `${parameterDescriptions.vHalflife.name} (weeks)`,\n description: parameterDescriptions.vHalflife.text,\n value: vHalflife,\n setter: setVHalflife,\n min: 1,\n max: 52 * 2,\n step: 1,\n suffix: \"\",\n format: (n: number) => String(Math.round(n)),\n toText: (n: number) => String(Math.round(n)),\n toNum: (n: string) => Math.round(parseInt(n))\n }\n ];\n\n return (\n