Skip to content

Commit

Permalink
filter boostable whitelist for isBufferAllowed
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Dec 17, 2024
1 parent 5c3dc5f commit 8b44ba2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/nextjs/hooks/token/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type Token = {
logoURI: string;
hasBoostedVariant?: boolean;
underlyingTokenAddress: string | null;
isBufferAllowed: boolean;
priceRateProviderData: {
address: string;
summary: string;
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/hooks/token/useExoticToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function useExoticToken(searchText: string, filteredTokenOptions: Token[]
chainId: targetNetwork.id,
priceRateProviderData: null,
underlyingTokenAddress: null,
isBufferAllowed: false,
};
}
}, [exoticTokenAddress, name, symbol, decimals, targetNetwork.id]);
Expand Down
5 changes: 4 additions & 1 deletion packages/nextjs/hooks/v3/useBoostableWhitelist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const useBoostableWhitelist = () => {
logoURI
isErc4626
underlyingTokenAddress
isBufferAllowed
priceRateProviderData {
address
summary
Expand All @@ -69,8 +70,9 @@ export const useBoostableWhitelist = () => {
const data = json.data.tokenGetTokens;

// Create map of underlying token address to matching boosted variant info
// If the token has an underlyingTokenAddress and isBufferAllowed
const boostableTokensMap = data.reduce((acc: Record<Address, Token>, token: Token) => {
if (token.underlyingTokenAddress) acc[token.underlyingTokenAddress] = token;
if (token.underlyingTokenAddress && token.isBufferAllowed) acc[token.underlyingTokenAddress] = token;
return acc;
}, {});

Expand All @@ -83,6 +85,7 @@ type BoostableWhitelist = {
id: string;
name: string;
description: string;
icon: string;
addresses: {
[key: string]: Address[];
};
Expand Down

0 comments on commit 8b44ba2

Please sign in to comment.