Skip to content

Commit

Permalink
rapid relay to smart relay
Browse files Browse the repository at this point in the history
  • Loading branch information
codingki committed Apr 8, 2024
1 parent a27f989 commit 92bb5d8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion chain-registry
Submodule chain-registry updated 50 files
+6 −6 _IBC/axelar-bitsong.json
+32 −0 _IBC/dhealth-osmosis.json
+6 −6 _IBC/injective-noble.json
+31 −0 _IBC/migaloo-terra.json
+16 −0 _IBC/neutron-secretnetwork.json
+6 −6 _IBC/neutron-sei.json
+2 −1 _non-cosmos/solana/assetlist.json
+5 −0 _non-cosmos/tinkernet/assetlist.json
+1 −1 _non-cosmos/tinkernet/images/tnkr.svg
+11 −1 agoric/chain.json
+14 −0 bitcanna/chain.json
+10 −0 bitsong/chain.json
+7 −1 canto/chain.json
+24 −1 comdex/chain.json
+32 −6 composable/chain.json
+6 −6 desmos/chain.json
+34 −0 dhealth/assetlist.json
+154 −0 dhealth/chain.json
+ dhealth/images/dhp.png
+1 −0 dhealth/images/dhp.svg
+30 −1 evmos/assetlist.json
+7 −1 evmos/chain.json
+ evmos/images/crowdp.png
+86 −0 evmos/images/crowdp.svg
+ galactica/images/galactica.png
+1 −0 galactica/images/galactica.svg
+7 −1 gravitybridge/chain.json
+6 −6 humans/chain.json
+39 −5 impacthub/chain.json
+11 −1 meme/chain.json
+118 −1 migaloo/assetlist.json
+ migaloo/images/gash.png
+7 −7 neutron/chain.json
+41 −6 nibiru/chain.json
+3 −2 noble/chain.json
+76 −26 onomy/chain.json
+31 −1 persistence/chain.json
+17 −0 planq/chain.json
+11 −1 provenance/chain.json
+11 −1 rizon/chain.json
+14 −0 sge/chain.json
+11 −1 sifchain/chain.json
+14 −0 source/chain.json
+11 −7 terpnetwork/chain.json
+28 −1 terra/assetlist.json
+ terra/images/rakoff.png
+34 −0 testnets/galacticatestnet/assetlist.json
+125 −0 testnets/galacticatestnet/chain.json
+12 −0 testnets/persistencetestnet/chain.json
+18 −0 xpla/chain.json
22 changes: 11 additions & 11 deletions src/components/SwapWidget/SwapDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ export const SwapDetails = ({
}
}, [axelarTransferOperation, hyperlaneTransferOperation]);

const isRapidRelay = route.estimatedFees?.some((fee) => fee.feeType === "RAPID_RELAY");
const isSmartRelay = route.estimatedFees?.some((fee) => fee.feeType === "SMART_RELAY");

const rapidRelayFee = useMemo(() => {
if (!isRapidRelay) return;
const fee = route.estimatedFees.filter((fee) => fee.feeType === "RAPID_RELAY");
const smartRelayFee = useMemo(() => {
if (!isSmartRelay) return;
const fee = route.estimatedFees.filter((fee) => fee.feeType === "SMART_RELAY");
const sameAsset = fee.every((fee, i, arr) => fee.originAsset.symbol === arr[0].originAsset.symbol);
if (!sameAsset) return;
const computedAmount = fee.reduce((acc, fee) => acc + Number(fee.amount), 0);
Expand All @@ -87,14 +87,14 @@ export const SwapDetails = ({
inAsset: `${inAsset} ${fee[0].originAsset.symbol}`,
inUSD: `${formatUSD(computedUsd)}`,
};
}, [isRapidRelay, route.estimatedFees]);
}, [isSmartRelay, route.estimatedFees]);

const totalAmountOut = useMemo(() => {
if (isRapidRelay) {
return String(parseFloat(amountOut) + (rapidRelayFee?.amount || 0));
if (isSmartRelay) {
return String(parseFloat(amountOut) + (smartRelayFee?.amount || 0));
}
return amountOut;
}, [amountOut, isRapidRelay, rapidRelayFee?.amount]);
}, [amountOut, isSmartRelay, smartRelayFee?.amount]);

if (!(sourceChain && sourceAsset && destinationChain && destinationAsset)) {
return null;
Expand Down Expand Up @@ -231,12 +231,12 @@ export const SwapDetails = ({
</dd>
</>
)}
{rapidRelayFee && (
{smartRelayFee && (
<>
<dt>Relayer Fee</dt>
<dd>
{rapidRelayFee?.inAsset ?? "-"}{" "}
<span className="text-sm tabular-nums text-neutral-400">{rapidRelayFee?.inUSD ?? "-"}</span>
{smartRelayFee?.inAsset ?? "-"}{" "}
<span className="text-sm tabular-nums text-neutral-400">{smartRelayFee?.inUSD ?? "-"}</span>
</dd>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/solve/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function useRoute({
allowMultiTx: true,
allowUnsafe: true,
experimentalFeatures,
rapidRelay: true,
smartRelay: true,
}
: {
amountOut: amount,
Expand All @@ -144,7 +144,7 @@ export function useRoute({
allowMultiTx: true,
allowUnsafe: true,
experimentalFeatures,
rapidRelay: true,
smartRelay: true,
},
);

Expand Down

0 comments on commit 92bb5d8

Please sign in to comment.