mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
new calculation
This commit is contained in:
parent
cbee8a714d
commit
9b6de84a1c
@ -4,5 +4,5 @@
|
|||||||
.advanced > div:last-child {
|
.advanced > div:last-child {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: calc(var(--spacer) / 2);
|
gap: calc(var(--spacer) / 2);
|
||||||
grid-template-columns: 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr;
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,14 @@ import FormHelp from '../../../atoms/Input/Help'
|
|||||||
|
|
||||||
export default function Advanced(props: InputProps): ReactElement {
|
export default function Advanced(props: InputProps): ReactElement {
|
||||||
const { price } = props.form.values as MetadataPublishForm
|
const { price } = props.form.values as MetadataPublishForm
|
||||||
const [weight, setWeight] = useState('10')
|
|
||||||
|
|
||||||
const liquidity = (price.cost * Number(weight)).toString()
|
const [ocean, setOcean] = useState('1')
|
||||||
|
const weight = '90' // in %
|
||||||
|
const tokensToMint = Number(ocean) * (Number(weight) / 100)
|
||||||
|
const cost = Number(ocean) / Number(tokensToMint)
|
||||||
|
|
||||||
function handleWeightChange(event: ChangeEvent<HTMLInputElement>) {
|
function handleOceanChange(event: ChangeEvent<HTMLInputElement>) {
|
||||||
setWeight(event.target.value)
|
setOcean(event.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -29,40 +31,65 @@ export default function Advanced(props: InputProps): ReactElement {
|
|||||||
</FormHelp>
|
</FormHelp>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Cost {...props} />
|
<div>
|
||||||
|
<Label htmlFor="ocean">Ocean Tokens</Label>
|
||||||
|
|
||||||
|
<InputElement
|
||||||
|
value={ocean}
|
||||||
|
name="ocean"
|
||||||
|
type="number"
|
||||||
|
prefix="OCEAN"
|
||||||
|
onChange={handleOceanChange}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Conversion price={ocean} className={stylesIndex.conversion} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Label htmlFor="dt">Data Tokens</Label>
|
||||||
|
<InputElement
|
||||||
|
value={tokensToMint.toString()}
|
||||||
|
name="dt"
|
||||||
|
type="number"
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="weight">Weight on Data Token</Label>
|
<Label htmlFor="weight">Weight on Data Token</Label>
|
||||||
<InputElement
|
<InputElement
|
||||||
value={weight}
|
value="90"
|
||||||
name="weight"
|
name="weight"
|
||||||
type="number"
|
|
||||||
onChange={handleWeightChange}
|
|
||||||
step="10"
|
step="10"
|
||||||
postfix="%"
|
postfix="%"
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles.liquidity}>
|
<div className={styles.liquidity}>
|
||||||
<Label htmlFor="liquidity">Liquidity</Label>
|
<Label htmlFor="liquidity">Liquidity to Provide</Label>
|
||||||
<InputElement
|
<InputElement
|
||||||
value={liquidity}
|
value={cost.toString()}
|
||||||
name="liquidity"
|
name="liquidity"
|
||||||
readOnly
|
readOnly
|
||||||
prefix="OCEAN"
|
prefix="OCEAN"
|
||||||
/>
|
/>
|
||||||
<Conversion price={liquidity} className={stylesIndex.conversion} />
|
<Conversion
|
||||||
</div>
|
price={cost.toString()}
|
||||||
<div>
|
className={stylesIndex.conversion}
|
||||||
<Label htmlFor="price.tokensToMint">Tokens to Mint</Label>
|
|
||||||
<InputElement
|
|
||||||
{...props.field}
|
|
||||||
value={(price && price.tokensToMint) || 1}
|
|
||||||
name="price.tokensToMint"
|
|
||||||
type="number"
|
|
||||||
disabled
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Hidden to fields to actually collect form values for Formik state */}
|
||||||
|
<input type="hidden" {...props.field} name="price.cost" value={cost} />
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
{...props.field}
|
||||||
|
name="price.tokensToMint"
|
||||||
|
value={tokensToMint}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export default function Cost(props: InputProps): ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="price.cost">Cost</Label>
|
<Label htmlFor="price.cost">Ocean Tokens</Label>
|
||||||
|
|
||||||
<InputElement
|
<InputElement
|
||||||
{...props.field}
|
{...props.field}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.content input {
|
.content input {
|
||||||
max-width: 8rem;
|
max-width: 6rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user