Skip to content

Commit 2c87641

Browse files
committed
price warnings
1 parent ae8a3e0 commit 2c87641

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/EulerSwap.jsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,21 @@ export function EulerSwapViz(props) {
424424
};
425425

426426

427+
let priceWarning;
428+
429+
{
430+
let priceFloat = parseFloat(params.price);
431+
let oraclePrice = loadPrice();
432+
let priceToOracleRatio = priceFloat / oraclePrice;
433+
434+
if (isNaN(priceFloat)) priceWarning = 'Missing price';
435+
else if (priceFloat < 1e-7) priceWarning = 'Price unexpectedly small';
436+
else if (priceFloat > 1e7) priceWarning = 'Price unexpectedly large';
437+
else if (priceToOracleRatio < 1/1.1) priceWarning = 'Price less than 10% oracle price';
438+
else if (priceToOracleRatio > 1.1) priceWarning = 'Price greater than 10% oracle price';
439+
}
440+
441+
427442
let parsedPrice = LibEulerSwap.computePriceFraction(params.price, ctx.vaultDecimals(props.vault0), ctx.vaultDecimals(props.vault1));
428443

429444
let paramsRaw = {
@@ -718,7 +733,11 @@ export function EulerSwapViz(props) {
718733
</div>
719734
</div>
720735

721-
{!props.viewMode && <div className="mt-6 flex align-items-center justify-content-center">
736+
{priceWarning && <div className="mt-6" style={{ textAlign: 'center', }}>
737+
<Message severity="warn" text={priceWarning} />
738+
</div>}
739+
740+
{!props.viewMode && <div className="mt-4 flex align-items-center justify-content-center">
722741
<Button className="mr-6" label="Install" disabled={params.concentrationX === undefined || params.concentrationY === undefined || params.fee === undefined || !parsedPrice[0] || !parsedPrice[1]} onClick={installEulerSwap} />
723742
<Button className="mr-6" label="Show Raw" onClick={() => setShowRawDialog(true)} />
724743
</div>}

0 commit comments

Comments
 (0)