-
Notifications
You must be signed in to change notification settings - Fork 637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SWAPS V2]: Adjust asset types + utils to match BX #5538
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d2ba1ce
adjust currencies to match bx
walmat f667170
bring over bx swaps asset types + utils
walmat 6e98353
bring over bx swaps asset types + utils
walmat b4d8909
Merge branch '@matthew/APP-1246' of https://github.com/rainbow-me/rai…
walmat 5249463
Merge branch 'develop' into @matthew/APP-1246
walmat 165ddff
break out uniqueId into a shared helper function
walmat fd73648
lint
walmat eb9c6d1
revert url change to github raw link
walmat 0947faf
Merge branch 'develop' into @matthew/APP-1246
walmat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import { Address } from 'viem'; | ||
|
||
import { ChainId, ChainName } from '@/__swaps__/screens/Swap/types/chains'; | ||
|
||
import { ETH_ADDRESS } from '@/references'; | ||
|
||
import { SearchAsset } from './search'; | ||
|
||
export type AddressOrEth = Address | typeof ETH_ADDRESS; | ||
|
||
export interface ParsedAsset { | ||
address: AddressOrEth; | ||
chainId: ChainId; | ||
chainName: ChainName; | ||
colors?: { | ||
primary?: string; | ||
fallback?: string; | ||
shadow?: string; | ||
}; | ||
isNativeAsset: boolean; | ||
name: string; | ||
native: { | ||
price?: { | ||
change: string; | ||
amount: number; | ||
display: string; | ||
}; | ||
}; | ||
mainnetAddress?: AddressOrEth; | ||
price?: ZerionAssetPrice; | ||
symbol: string; | ||
uniqueId: UniqueId; | ||
decimals: number; | ||
icon_url?: string; | ||
type?: AssetType; | ||
smallBalance?: boolean; | ||
standard?: 'erc-721' | 'erc-1155'; | ||
networks?: AssetApiResponse['networks']; | ||
bridging?: { | ||
isBridgeable: boolean; | ||
networks: { [id in ChainId]?: { bridgeable: boolean } }; | ||
}; | ||
} | ||
|
||
export interface ParsedUserAsset extends ParsedAsset { | ||
balance: { | ||
amount: string; | ||
display: string; | ||
}; | ||
native: { | ||
balance: { | ||
amount: string; | ||
display: string; | ||
}; | ||
price?: { | ||
change: string; | ||
amount: number; | ||
display: string; | ||
}; | ||
}; | ||
} | ||
|
||
export type SearchAssetWithPrice = SearchAsset & ParsedAsset; | ||
export type ParsedSearchAsset = SearchAsset & ParsedUserAsset; | ||
|
||
export type ParsedAssetsDict = Record<UniqueId, ParsedUserAsset>; | ||
|
||
export type ParsedAssetsDictByChain = Record<ChainId | number, ParsedAssetsDict>; | ||
|
||
export interface ZerionAssetPrice { | ||
value: number; | ||
relative_change_24h?: number; | ||
} | ||
|
||
export type AssetApiResponse = { | ||
asset_code: AddressOrEth; | ||
decimals: number; | ||
icon_url: string; | ||
name: string; | ||
chain_id?: number; | ||
price?: { | ||
value: number; | ||
changed_at: number; | ||
relative_change_24h: number; | ||
}; | ||
symbol: string; | ||
colors?: { primary?: string; fallback?: string; shadow?: string }; | ||
network?: ChainName; | ||
networks?: { | ||
[chainId in ChainId]?: { | ||
address: chainId extends ChainId.mainnet ? AddressOrEth : Address; | ||
decimals: number; | ||
}; | ||
}; | ||
type?: AssetType; | ||
interface?: 'erc-721' | 'erc-1155'; | ||
}; | ||
|
||
type AssetType = ProtocolType | 'nft'; | ||
|
||
export interface ZerionAsset { | ||
asset_code: AddressOrEth; | ||
colors?: { | ||
primary: string; | ||
fallback: string; | ||
}; | ||
implementations?: Record<string, { address: Address | null; decimals: number }>; | ||
mainnet_address?: AddressOrEth; | ||
name: string; | ||
symbol: string; | ||
decimals: number; | ||
type?: AssetType; | ||
icon_url?: string; | ||
is_displayable?: boolean; | ||
is_verified?: boolean; | ||
price?: ZerionAssetPrice; | ||
network?: ChainName; | ||
bridging: { | ||
bridgeable: boolean; | ||
networks: { [id in ChainId]?: { bridgeable: boolean } }; | ||
}; | ||
} | ||
|
||
// protocols https://github.com/rainbow-me/go-utils-lib/blob/master/pkg/enums/token_type.go#L44 | ||
export type ProtocolType = | ||
| 'aave-v2' | ||
| 'balancer' | ||
| 'curve' | ||
| 'compound' | ||
| 'compound-v3' | ||
| 'maker' | ||
| 'one-inch' | ||
| 'piedao-pool' | ||
| 'yearn' | ||
| 'yearn-v2' | ||
| 'uniswap-v2' | ||
| 'aave-v3' | ||
| 'harvest' | ||
| 'lido' | ||
| 'uniswap-v3' | ||
| 'convex' | ||
| 'convex-frax' | ||
| 'pancake-swap' | ||
| 'balancer-v2' | ||
| 'frax' | ||
| 'gmx' | ||
| 'aura' | ||
| 'pickle' | ||
| 'yearn-v3' | ||
| 'venus' | ||
| 'sushiswap'; | ||
|
||
export type AssetMetadata = { | ||
circulatingSupply: number; | ||
colors?: { primary: string; fallback?: string; shadow?: string }; | ||
decimals: number; | ||
description: string; | ||
fullyDilutedValuation: number; | ||
iconUrl: string; | ||
marketCap: number; | ||
name: string; | ||
networks?: { | ||
[chainId in ChainId]?: { | ||
address: chainId extends ChainId.mainnet ? AddressOrEth : Address; | ||
decimals: number; | ||
}; | ||
}; | ||
price: { | ||
value: number; | ||
relativeChange24h: number; | ||
}; | ||
symbol: string; | ||
totalSupply: number; | ||
volume1d: number; | ||
}; | ||
|
||
export type UniqueId = `${Address}_${ChainId}`; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting war flashbacks here, kind of a nbd if contained to swaps but testy about having too patterns here