UI - added disclaimer and slippage

This commit is contained in:
Kevin Peters 2022-01-21 22:48:25 +00:00
parent e3ed8862fe
commit 409b4e0dfd
4 changed files with 37 additions and 9 deletions

View File

@ -70,7 +70,9 @@ export default function Settings({
type="number"
onChange={(event) => {
onSlippageChange(
clamp(parseFloat(event.target.value), 0, 100).toString()
event.target.value === ""
? ""
: clamp(parseFloat(event.target.value), 0, 100).toString()
);
}}
></TextField>
@ -88,7 +90,9 @@ export default function Settings({
type="number"
onChange={(event) => {
onDeadlineChange(
clamp(parseFloat(event.target.value), 1, 100).toString()
event.target.value === ""
? ""
: clamp(parseFloat(event.target.value), 1, 100).toString()
);
}}
></TextField>

View File

@ -313,10 +313,5 @@ export class UniswapToUniswapQuoter {
setDeadlines(deadline: string): void {
this.srcRouter.setDeadline(deadline);
this.dstRouter.setDeadline(deadline);
return;
}
estimateUstFee(gasPriceInNativeCurrency: string): string {
return "0";
}
}

View File

@ -672,4 +672,26 @@ export class UniswapToUniswapExecutor {
this.isNative
);
}
//getSwapResult(
// walletAddress: string,
// onSwapResult: (result: boolean) => void
//) {
// console.log(this.cachedExactInParams.dst.protocol);
// console.log(this.dstExecutionParams.crossChainSwap.address);
// const contract = makeCrossChainSwapContract(
// this.getDstProvider(),
// this.quoteType === QuoteType.ExactIn
// ? this.cachedExactInParams.dst.protocol
// : this.cachedExactOutParams.dst.protocol,
// this.dstExecutionParams.crossChainSwap.address
// );
// const filter = contract.filters.SwapResult(walletAddress);
// contract.once(
// filter,
// (recipient, tokenAddress, caller, amount, success) => {
// onSwapResult(success);
// }
// );
//}
}

View File

@ -245,7 +245,7 @@ export default function Home() {
setSourceTokenInfo(MATIC_TOKEN_INFO);
setTargetTokenInfo(ETH_TOKEN_INFO);
}
setAmountIn("0.0");
setAmountIn("");
setAmountOut("0.0");
}, []);
@ -254,6 +254,7 @@ export default function Home() {
try {
setIsSwapping(true);
await switchProviderNetwork(provider, sourceTokenInfo.chainId);
const sourceReceipt = await executor.approveAndSwap(signer);
console.info(
"firstSwapTransactionHash:",
@ -270,7 +271,6 @@ export default function Home() {
executor.vaaSearchParams.emitterAddress,
executor.vaaSearchParams.sequence
);
// Check if the signedVAA has redeemed by the relayer
enqueueSnackbar(null, {
content: (
<Alert severity="info">
@ -278,6 +278,7 @@ export default function Home() {
</Alert>
),
});
// Check if the signedVAA has redeemed by the relayer
const isCompleted = await getIsTransferCompletedEvmWithRetry(
executor.dstExecutionParams.wormhole.tokenBridgeAddress,
executor.quoter.dstProvider,
@ -309,6 +310,7 @@ export default function Home() {
});
}
setIsSwapping(false);
setAmountIn("");
}
}, [
provider,
@ -369,6 +371,7 @@ export default function Home() {
className={classes.numberField}
inputProps={{ readOnly: true }}
></TextField>
<Typography variant="subtitle2">{`Slippage tolerance: ${slippage}%`}</Typography>
{!isSwapping && <EthereumSignerKey />}
<ButtonWithLoader
disabled={!readyToSwap || isSwapping}
@ -377,6 +380,10 @@ export default function Home() {
>
Swap
</ButtonWithLoader>
<div className={classes.spacer} />
<Typography variant="subtitle2" color="error">
WARNING: this is a Testnet release only
</Typography>
</Paper>
<div className={classes.spacer} />
<Typography variant="subtitle1" color="textSecondary">