Skip to content

Commit

Permalink
improve: relax suggested-fees params (#895)
Browse files Browse the repository at this point in the history
* improve: relax endpoint send

* improve: use correct param
  • Loading branch information
james-a-morris authored Nov 1, 2023
1 parent 634bf7b commit c5e602b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
9 changes: 2 additions & 7 deletions src/hooks/useBridgeFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ export function useBridgeFees(
) {
const { block } = useBlock(toChainId);
const enabledQuery =
!!toChainId &&
!!fromChainId &&
!!block &&
!!tokenSymbol &&
amount.gt(0) &&
!!recipientAddress;
!!toChainId && !!fromChainId && !!block && !!tokenSymbol && amount.gt(0);
const queryKey = enabledQuery
? bridgeFeesQueryKey(
tokenSymbol,
Expand All @@ -44,7 +39,7 @@ export function useBridgeFees(
blockTimestamp: block!.timestamp,
toChainId: toChainId!,
fromChainId: fromChainId!,
recipientAddress: recipientAddress!,
recipientAddress,
});
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type GetBridgeFeesArgs = {
blockTimestamp: number;
fromChainId: ChainId;
toChainId: ChainId;
recipientAddress: string;
recipientAddress?: string;
};

export type GetBridgeFeesResult = BridgeFees & {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/serverless-api/mocked/coingecko.mocked.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export async function coingeckoMockedApiCall(
price: ethers.BigNumber;
}> {
return {
price: ethers.utils.parseEther(String("0.1")),
price: ethers.utils.parseEther(String("0.17")),
};
}
16 changes: 10 additions & 6 deletions src/utils/serverless-api/mocked/suggested-fees.mocked.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BigNumber, ethers } from "ethers";
import { ChainId } from "utils/constants";
import { ChainId, getTokenByAddress } from "utils/constants";
import { SuggestedApiFeeReturnType } from "../types";
import { parseUnits } from "utils/format";

/**
* Creates a mocked variant of the suggestedAPI Call
Expand All @@ -15,24 +16,27 @@ export async function suggestedFeesMockedApiCall(
_originToken: string,
_toChainid: ChainId,
_fromChainid: ChainId,
_recipientAddress: string
_recipientAddress?: string
): Promise<SuggestedApiFeeReturnType> {
const token = getTokenByAddress(_originToken);
const decimals = token?.decimals ?? 18;

return {
relayerFee: {
pct: BigNumber.from("1"),
total: BigNumber.from("1"),
total: parseUnits("0.5", decimals),
},
relayerCapitalFee: {
pct: BigNumber.from("1"),
total: BigNumber.from("1"),
total: parseUnits("0.5", decimals),
},
relayerGasFee: {
pct: BigNumber.from("1"),
total: BigNumber.from("1"),
total: parseUnits("0.5", decimals),
},
lpFee: {
pct: BigNumber.from("1"),
total: BigNumber.from("1"),
total: parseUnits("0.5", decimals),
},
isAmountTooLow: false,
quoteBlock: BigNumber.from("1"),
Expand Down
4 changes: 2 additions & 2 deletions src/utils/serverless-api/prod/suggested-fees.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export async function suggestedFeesApiCall(
originToken: string,
toChainid: ChainId,
fromChainid: ChainId,
recipientAddress: string
recipientAddress?: string
): Promise<SuggestedApiFeeReturnType> {
const response = await axios.get(`/api/suggested-fees`, {
params: {
token: originToken,
destinationChainId: toChainid,
originChainId: fromChainid,
recipientAddress,
recipient: recipientAddress,
amount: amount.toString(),
skipAmountLimit: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/utils/serverless-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type SuggestedApiFeeType = (
originToken: string,
toChainid: ChainId,
fromChainid: ChainId,
recipientAddress: string
recipientAddress?: string
) => Promise<SuggestedApiFeeReturnType>;

export type RetrieveLinkedWalletType = (
Expand Down

2 comments on commit c5e602b

@vercel
Copy link

@vercel vercel bot commented on c5e602b Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

goerli-frontend-v2 – ./

goerli-frontend-v2.vercel.app
goerli-frontend-v2-uma.vercel.app
goerli-frontend-v2-git-master-uma.vercel.app

@vercel
Copy link

@vercel vercel bot commented on c5e602b Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.