@lifi/types 0.0.0-preview-97f0520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -0
- package/README.md +59 -0
- package/package.json +46 -0
- package/src/_cjs/api.js +99 -0
- package/src/_cjs/api.js.map +1 -0
- package/src/_cjs/balance/index.js +18 -0
- package/src/_cjs/balance/index.js.map +1 -0
- package/src/_cjs/balance/wallet.js +3 -0
- package/src/_cjs/balance/wallet.js.map +1 -0
- package/src/_cjs/bridges.js +3 -0
- package/src/_cjs/bridges.js.map +1 -0
- package/src/_cjs/chains/Chain.js +13 -0
- package/src/_cjs/chains/Chain.js.map +1 -0
- package/src/_cjs/chains/EVMChain.js +3 -0
- package/src/_cjs/chains/EVMChain.js.map +1 -0
- package/src/_cjs/chains/MVMChain.js +3 -0
- package/src/_cjs/chains/MVMChain.js.map +1 -0
- package/src/_cjs/chains/STLChain.js +3 -0
- package/src/_cjs/chains/STLChain.js.map +1 -0
- package/src/_cjs/chains/SVMChain.js +3 -0
- package/src/_cjs/chains/SVMChain.js.map +1 -0
- package/src/_cjs/chains/TVMChain.js +3 -0
- package/src/_cjs/chains/TVMChain.js.map +1 -0
- package/src/_cjs/chains/UTXOChain.js +3 -0
- package/src/_cjs/chains/UTXOChain.js.map +1 -0
- package/src/_cjs/chains/base.js +196 -0
- package/src/_cjs/chains/base.js.map +1 -0
- package/src/_cjs/chains/index.js +25 -0
- package/src/_cjs/chains/index.js.map +1 -0
- package/src/_cjs/earn.js +3 -0
- package/src/_cjs/earn.js.map +1 -0
- package/src/_cjs/errors.js +21 -0
- package/src/_cjs/errors.js.map +1 -0
- package/src/_cjs/exchanges.js +3 -0
- package/src/_cjs/exchanges.js.map +1 -0
- package/src/_cjs/index.js +28 -0
- package/src/_cjs/index.js.map +1 -0
- package/src/_cjs/package.json +1 -0
- package/src/_cjs/routeSlippage.js +13 -0
- package/src/_cjs/routeSlippage.js.map +1 -0
- package/src/_cjs/step.js +28 -0
- package/src/_cjs/step.js.map +1 -0
- package/src/_cjs/tokens/base.js +137 -0
- package/src/_cjs/tokens/base.js.map +1 -0
- package/src/_cjs/tokens/index.js +19 -0
- package/src/_cjs/tokens/index.js.map +1 -0
- package/src/_cjs/tokens/token.js +12 -0
- package/src/_cjs/tokens/token.js.map +1 -0
- package/src/_cjs/typed-data.js +3 -0
- package/src/_cjs/typed-data.js.map +1 -0
- package/src/_esm/api.js +126 -0
- package/src/_esm/api.js.map +1 -0
- package/src/_esm/balance/index.js +2 -0
- package/src/_esm/balance/index.js.map +1 -0
- package/src/_esm/balance/wallet.js +2 -0
- package/src/_esm/balance/wallet.js.map +1 -0
- package/src/_esm/bridges.js +2 -0
- package/src/_esm/bridges.js.map +1 -0
- package/src/_esm/chains/Chain.js +15 -0
- package/src/_esm/chains/Chain.js.map +1 -0
- package/src/_esm/chains/EVMChain.js +2 -0
- package/src/_esm/chains/EVMChain.js.map +1 -0
- package/src/_esm/chains/MVMChain.js +2 -0
- package/src/_esm/chains/MVMChain.js.map +1 -0
- package/src/_esm/chains/STLChain.js +2 -0
- package/src/_esm/chains/STLChain.js.map +1 -0
- package/src/_esm/chains/SVMChain.js +2 -0
- package/src/_esm/chains/SVMChain.js.map +1 -0
- package/src/_esm/chains/TVMChain.js +2 -0
- package/src/_esm/chains/TVMChain.js.map +1 -0
- package/src/_esm/chains/UTXOChain.js +2 -0
- package/src/_esm/chains/UTXOChain.js.map +1 -0
- package/src/_esm/chains/base.js +209 -0
- package/src/_esm/chains/base.js.map +1 -0
- package/src/_esm/chains/index.js +9 -0
- package/src/_esm/chains/index.js.map +1 -0
- package/src/_esm/earn.js +9 -0
- package/src/_esm/earn.js.map +1 -0
- package/src/_esm/errors.js +19 -0
- package/src/_esm/errors.js.map +1 -0
- package/src/_esm/exchanges.js +2 -0
- package/src/_esm/exchanges.js.map +1 -0
- package/src/_esm/index.js +12 -0
- package/src/_esm/index.js.map +1 -0
- package/src/_esm/package.json +1 -0
- package/src/_esm/routeSlippage.js +54 -0
- package/src/_esm/routeSlippage.js.map +1 -0
- package/src/_esm/step.js +25 -0
- package/src/_esm/step.js.map +1 -0
- package/src/_esm/tokens/base.js +144 -0
- package/src/_esm/tokens/base.js.map +1 -0
- package/src/_esm/tokens/index.js +3 -0
- package/src/_esm/tokens/index.js.map +1 -0
- package/src/_esm/tokens/token.js +10 -0
- package/src/_esm/tokens/token.js.map +1 -0
- package/src/_esm/typed-data.js +2 -0
- package/src/_esm/typed-data.js.map +1 -0
- package/src/_types/api.d.ts +891 -0
- package/src/_types/api.d.ts.map +1 -0
- package/src/_types/balance/index.d.ts +2 -0
- package/src/_types/balance/index.d.ts.map +1 -0
- package/src/_types/balance/wallet.d.ts +97 -0
- package/src/_types/balance/wallet.d.ts.map +1 -0
- package/src/_types/bridges.d.ts +29 -0
- package/src/_types/bridges.d.ts.map +1 -0
- package/src/_types/chains/Chain.d.ts +21 -0
- package/src/_types/chains/Chain.d.ts.map +1 -0
- package/src/_types/chains/EVMChain.d.ts +23 -0
- package/src/_types/chains/EVMChain.d.ts.map +1 -0
- package/src/_types/chains/MVMChain.d.ts +6 -0
- package/src/_types/chains/MVMChain.d.ts.map +1 -0
- package/src/_types/chains/STLChain.d.ts +6 -0
- package/src/_types/chains/STLChain.d.ts.map +1 -0
- package/src/_types/chains/SVMChain.d.ts +10 -0
- package/src/_types/chains/SVMChain.d.ts.map +1 -0
- package/src/_types/chains/TVMChain.d.ts +7 -0
- package/src/_types/chains/TVMChain.d.ts.map +1 -0
- package/src/_types/chains/UTXOChain.d.ts +6 -0
- package/src/_types/chains/UTXOChain.d.ts.map +1 -0
- package/src/_types/chains/base.d.ts +191 -0
- package/src/_types/chains/base.d.ts.map +1 -0
- package/src/_types/chains/index.d.ts +9 -0
- package/src/_types/chains/index.d.ts.map +1 -0
- package/src/_types/earn.d.ts +137 -0
- package/src/_types/earn.d.ts.map +1 -0
- package/src/_types/errors.d.ts +17 -0
- package/src/_types/errors.d.ts.map +1 -0
- package/src/_types/exchanges.d.ts +25 -0
- package/src/_types/exchanges.d.ts.map +1 -0
- package/src/_types/index.d.ts +12 -0
- package/src/_types/index.d.ts.map +1 -0
- package/src/_types/routeSlippage.d.ts +85 -0
- package/src/_types/routeSlippage.d.ts.map +1 -0
- package/src/_types/step.d.ts +218 -0
- package/src/_types/step.d.ts.map +1 -0
- package/src/_types/tokens/base.d.ts +133 -0
- package/src/_types/tokens/base.d.ts.map +1 -0
- package/src/_types/tokens/index.d.ts +3 -0
- package/src/_types/tokens/index.d.ts.map +1 -0
- package/src/_types/tokens/token.d.ts +54 -0
- package/src/_types/tokens/token.d.ts.map +1 -0
- package/src/_types/typed-data.d.ts +31 -0
- package/src/_types/typed-data.d.ts.map +1 -0
- package/src/api.ts +1185 -0
- package/src/balance/index.ts +1 -0
- package/src/balance/wallet.ts +102 -0
- package/src/bridges.ts +30 -0
- package/src/chains/Chain.ts +28 -0
- package/src/chains/EVMChain.ts +28 -0
- package/src/chains/MVMChain.ts +6 -0
- package/src/chains/STLChain.ts +6 -0
- package/src/chains/SVMChain.ts +11 -0
- package/src/chains/TVMChain.ts +7 -0
- package/src/chains/UTXOChain.ts +6 -0
- package/src/chains/base.ts +221 -0
- package/src/chains/index.ts +8 -0
- package/src/earn.ts +158 -0
- package/src/errors.ts +17 -0
- package/src/exchanges.ts +27 -0
- package/src/index.ts +11 -0
- package/src/routeSlippage.ts +97 -0
- package/src/step.ts +281 -0
- package/src/tokens/base.ts +152 -0
- package/src/tokens/index.ts +2 -0
- package/src/tokens/token.ts +63 -0
- package/src/typed-data.ts +34 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './wallet.js'
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { StaticToken, TokenExtended } from '../tokens/token.js'
|
|
2
|
+
import type { ChainId } from '../chains/base.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for getting wallet balance
|
|
6
|
+
*/
|
|
7
|
+
export interface GetWalletBalanceParams {
|
|
8
|
+
walletAddress: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Filter options for wallet balance requests
|
|
13
|
+
*/
|
|
14
|
+
export interface GetWalletBalanceFilter {
|
|
15
|
+
chainIds?: ChainId[]
|
|
16
|
+
offset?: string
|
|
17
|
+
limit?: number
|
|
18
|
+
extended?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Basic wallet token following EIP structure
|
|
23
|
+
*/
|
|
24
|
+
export interface WalletToken extends StaticToken {
|
|
25
|
+
amount: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Extended wallet token with pricing and metadata information
|
|
30
|
+
* Reuses TokenExtended but adapts for wallet context
|
|
31
|
+
*/
|
|
32
|
+
export interface WalletTokenExtended extends TokenExtended {
|
|
33
|
+
amount: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wallet balance response following EIP structure
|
|
38
|
+
* Balances are grouped by chainId as numeric keys
|
|
39
|
+
*
|
|
40
|
+
* @example Basic response
|
|
41
|
+
* ```json
|
|
42
|
+
* {
|
|
43
|
+
* "walletAddress": "0x742d35Cc6466C7b9d5b52b8e5d8bD9D9F4B12345",
|
|
44
|
+
* "balances": {
|
|
45
|
+
* "1": [
|
|
46
|
+
* {
|
|
47
|
+
* "address": "0x4200000000000000000000000000000000000006",
|
|
48
|
+
* "symbol": "WETH",
|
|
49
|
+
* "decimals": 18,
|
|
50
|
+
* "amount": "100000000000000"
|
|
51
|
+
* },
|
|
52
|
+
* {
|
|
53
|
+
* "address": "0x0000000000000000000000000000000000000000",
|
|
54
|
+
* "symbol": "ETH",
|
|
55
|
+
* "decimals": 18,
|
|
56
|
+
* "amount": "15965635006674968"
|
|
57
|
+
* }
|
|
58
|
+
* ]
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Extended response (with pricing data)
|
|
64
|
+
* ```json
|
|
65
|
+
* {
|
|
66
|
+
* "walletAddress": "0x742d35Cc6466C7b9d5b52b8e5d8bD9D9F4B12345",
|
|
67
|
+
* "balances": {
|
|
68
|
+
* "1": [
|
|
69
|
+
* {
|
|
70
|
+
* "address": "0x0000000000000000000000000000000000000000",
|
|
71
|
+
* "symbol": "ETH",
|
|
72
|
+
* "decimals": 18,
|
|
73
|
+
* "amount": "15965635006674968",
|
|
74
|
+
* "name": "ETH",
|
|
75
|
+
* "priceUSD": "3647.66",
|
|
76
|
+
* "marketCapUSD": 22112274762505,
|
|
77
|
+
* "volumeUSD24H": 67057337.09,
|
|
78
|
+
* "fdvUSD": null,
|
|
79
|
+
* "logoURI": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2/logo.png"
|
|
80
|
+
* }
|
|
81
|
+
* ]
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export interface GetWalletBalanceResponse {
|
|
87
|
+
walletAddress: string
|
|
88
|
+
balances: Record<number, WalletToken[]>
|
|
89
|
+
offset?: string
|
|
90
|
+
limit?: number
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Extended wallet balance response with enhanced token information
|
|
95
|
+
* Includes pricing data, market cap, volume, and other metadata
|
|
96
|
+
*/
|
|
97
|
+
export interface GetWalletBalanceExtendedResponse {
|
|
98
|
+
walletAddress: string
|
|
99
|
+
balances: Record<number, WalletTokenExtended[]>
|
|
100
|
+
offset?: string
|
|
101
|
+
limit?: number
|
|
102
|
+
}
|
package/src/bridges.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BaseToken } from './tokens/token.js'
|
|
2
|
+
|
|
3
|
+
export interface Bridge {
|
|
4
|
+
key: string
|
|
5
|
+
name: string
|
|
6
|
+
logoURI: string
|
|
7
|
+
bridgeUrl?: string
|
|
8
|
+
discordUrl?: string
|
|
9
|
+
supportUrl?: string
|
|
10
|
+
docsUrl?: string
|
|
11
|
+
explorerUrl?: string
|
|
12
|
+
analyticsUrl?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Should not be accessed via the types package anymore
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
export interface BridgeDefinition {
|
|
20
|
+
tool: string
|
|
21
|
+
fromChainId: number
|
|
22
|
+
fromToken: BaseToken
|
|
23
|
+
toChainId: number
|
|
24
|
+
toToken: BaseToken
|
|
25
|
+
maximumTransfer: string
|
|
26
|
+
minimumTransfer: string
|
|
27
|
+
swapFeeRate: string
|
|
28
|
+
swapFeeMinimum: string
|
|
29
|
+
swapFeeMaximum: string
|
|
30
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CoinKey } from '../tokens/base.js'
|
|
2
|
+
import type { ChainKey } from './base.js'
|
|
3
|
+
|
|
4
|
+
export enum ChainType {
|
|
5
|
+
EVM = 'EVM',
|
|
6
|
+
// Solana virtual machine
|
|
7
|
+
SVM = 'SVM',
|
|
8
|
+
// Move virtual machine
|
|
9
|
+
MVM = 'MVM',
|
|
10
|
+
// Unspent transaction output (e.g. Bitcoin)
|
|
11
|
+
UTXO = 'UTXO',
|
|
12
|
+
// Tron virtual machine
|
|
13
|
+
TVM = 'TVM',
|
|
14
|
+
// Stellar consensus protocol
|
|
15
|
+
STL = 'STL',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface _Chain {
|
|
19
|
+
key: ChainKey
|
|
20
|
+
chainType: ChainType
|
|
21
|
+
name: string
|
|
22
|
+
coin: CoinKey
|
|
23
|
+
id: number
|
|
24
|
+
mainnet: boolean
|
|
25
|
+
logoURI?: string
|
|
26
|
+
// faucetUrls is DEPRECATED - will be removed in the next breaking release
|
|
27
|
+
faucetUrls?: string[]
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { _Chain } from './Chain.js'
|
|
2
|
+
|
|
3
|
+
export interface EVMChain extends _Chain {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated tokenlistUrl is deprecated and will be removed in the next breaking release
|
|
6
|
+
*/
|
|
7
|
+
tokenlistUrl?: string
|
|
8
|
+
metamask: AddEthereumChainParameter
|
|
9
|
+
multicallAddress?: string
|
|
10
|
+
relayerSupported?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface AddEthereumChainParameter {
|
|
14
|
+
chainId: string
|
|
15
|
+
blockExplorerUrls: string[]
|
|
16
|
+
chainName: string
|
|
17
|
+
nativeCurrency: {
|
|
18
|
+
name: string
|
|
19
|
+
symbol: string
|
|
20
|
+
decimals: number
|
|
21
|
+
}
|
|
22
|
+
rpcUrls: string[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// This type alias is required to avoid breaking
|
|
26
|
+
// changes with the new non EVM support types release
|
|
27
|
+
// This will be removed in the future in favour of _Chain
|
|
28
|
+
export type Chain = EVMChain
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { _Chain } from './Chain.js'
|
|
2
|
+
import type { ChainId } from './base.js'
|
|
3
|
+
import type { AddEthereumChainParameter } from './EVMChain.js'
|
|
4
|
+
|
|
5
|
+
export type SVMChainId = ChainId.SOL | ChainId.FOG
|
|
6
|
+
|
|
7
|
+
export interface SVMChain extends _Chain {
|
|
8
|
+
tokenlistUrl?: string
|
|
9
|
+
metamask: AddEthereumChainParameter
|
|
10
|
+
multicallAddress?: string
|
|
11
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Please ensure the key and value are the same, only case difference is allowed,
|
|
2
|
+
export enum ChainKey {
|
|
3
|
+
// EVM
|
|
4
|
+
ETH = 'eth',
|
|
5
|
+
POL = 'pol',
|
|
6
|
+
BSC = 'bsc',
|
|
7
|
+
DAI = 'dai',
|
|
8
|
+
FTM = 'ftm',
|
|
9
|
+
AVA = 'ava',
|
|
10
|
+
ARB = 'arb',
|
|
11
|
+
OPT = 'opt',
|
|
12
|
+
ONE = 'one',
|
|
13
|
+
FSN = 'fsn',
|
|
14
|
+
MOR = 'mor',
|
|
15
|
+
CEL = 'cel',
|
|
16
|
+
FUS = 'fus',
|
|
17
|
+
TLO = 'tlo',
|
|
18
|
+
CRO = 'cro',
|
|
19
|
+
BOB = 'bob',
|
|
20
|
+
RSK = 'rsk',
|
|
21
|
+
VEL = 'vel',
|
|
22
|
+
MOO = 'moo',
|
|
23
|
+
MAM = 'mam',
|
|
24
|
+
AUR = 'aur',
|
|
25
|
+
EVM = 'evm',
|
|
26
|
+
ARN = 'arn',
|
|
27
|
+
ERA = 'era',
|
|
28
|
+
PZE = 'pze',
|
|
29
|
+
LNA = 'lna',
|
|
30
|
+
BAS = 'bas',
|
|
31
|
+
SCL = 'scl',
|
|
32
|
+
MOD = 'mod',
|
|
33
|
+
MNT = 'mnt',
|
|
34
|
+
BLS = 'bls',
|
|
35
|
+
SEI = 'sei',
|
|
36
|
+
FRA = 'fra',
|
|
37
|
+
GRA = 'gra',
|
|
38
|
+
IMX = 'imx',
|
|
39
|
+
KAI = 'kai',
|
|
40
|
+
XLY = 'xly',
|
|
41
|
+
OPB = 'opb',
|
|
42
|
+
WCC = 'wcc',
|
|
43
|
+
LSK = 'lsk',
|
|
44
|
+
ABS = 'abs',
|
|
45
|
+
BER = 'ber',
|
|
46
|
+
SON = 'son',
|
|
47
|
+
UNI = 'uni',
|
|
48
|
+
APE = 'ape',
|
|
49
|
+
SOE = 'soe',
|
|
50
|
+
INK = 'ink',
|
|
51
|
+
LNS = 'lns',
|
|
52
|
+
ETL = 'etl',
|
|
53
|
+
HYP = 'hyp',
|
|
54
|
+
XDC = 'xdc',
|
|
55
|
+
BOC = 'boc', // BOB was already taken by Boba
|
|
56
|
+
VIC = 'vic',
|
|
57
|
+
FLR = 'flr',
|
|
58
|
+
KAT = 'kat',
|
|
59
|
+
VAN = 'van',
|
|
60
|
+
RON = 'ron',
|
|
61
|
+
PLU = 'plu',
|
|
62
|
+
NIB = 'nib',
|
|
63
|
+
HPL = 'hpl',
|
|
64
|
+
PLA = 'pla',
|
|
65
|
+
FLW = 'flw',
|
|
66
|
+
HMI = 'hmi',
|
|
67
|
+
MON = 'mon',
|
|
68
|
+
STA = 'sta',
|
|
69
|
+
MEG = 'meg',
|
|
70
|
+
JOV = 'jov',
|
|
71
|
+
MOP = 'mop',
|
|
72
|
+
TEM = 'tem',
|
|
73
|
+
ZEROG = 'zerog',
|
|
74
|
+
PHR = 'phr',
|
|
75
|
+
LTR = 'ltr',
|
|
76
|
+
SOM = 'som',
|
|
77
|
+
OUT = 'out',
|
|
78
|
+
ARC = 'arc',
|
|
79
|
+
INJ = 'inj',
|
|
80
|
+
|
|
81
|
+
// None-EVM
|
|
82
|
+
TER = 'ter',
|
|
83
|
+
OAS = 'oas',
|
|
84
|
+
|
|
85
|
+
// SVM
|
|
86
|
+
SOL = 'sol',
|
|
87
|
+
FOG = 'fog',
|
|
88
|
+
|
|
89
|
+
// MVM
|
|
90
|
+
SUI = 'sui',
|
|
91
|
+
|
|
92
|
+
// UTXO
|
|
93
|
+
BTC = 'btc',
|
|
94
|
+
BCH = 'bch',
|
|
95
|
+
LTC = 'ltc',
|
|
96
|
+
DGE = 'dge',
|
|
97
|
+
ZEC = 'zec',
|
|
98
|
+
|
|
99
|
+
// Tron
|
|
100
|
+
TRN = 'trn',
|
|
101
|
+
|
|
102
|
+
// Stellar
|
|
103
|
+
XLM = 'xlm',
|
|
104
|
+
|
|
105
|
+
// Testnet
|
|
106
|
+
ARCT = 'arct',
|
|
107
|
+
OPST = 'opst',
|
|
108
|
+
BAST = 'bast',
|
|
109
|
+
ARBS = 'arbs',
|
|
110
|
+
ETHS = 'eths',
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export enum ChainId {
|
|
114
|
+
ETH = 1,
|
|
115
|
+
POL = 137,
|
|
116
|
+
BSC = 56,
|
|
117
|
+
DAI = 100,
|
|
118
|
+
FTM = 250,
|
|
119
|
+
AVA = 43114,
|
|
120
|
+
ARB = 42161,
|
|
121
|
+
OPT = 10,
|
|
122
|
+
ONE = 1666600000,
|
|
123
|
+
FSN = 32659,
|
|
124
|
+
MOR = 1285,
|
|
125
|
+
CEL = 42220,
|
|
126
|
+
FUS = 122,
|
|
127
|
+
TLO = 40,
|
|
128
|
+
CRO = 25,
|
|
129
|
+
BOB = 288,
|
|
130
|
+
RSK = 30,
|
|
131
|
+
VEL = 106,
|
|
132
|
+
MOO = 1284,
|
|
133
|
+
MAM = 1088,
|
|
134
|
+
AUR = 1313161554,
|
|
135
|
+
EVM = 9001,
|
|
136
|
+
ARN = 42170,
|
|
137
|
+
ERA = 324,
|
|
138
|
+
PZE = 1101,
|
|
139
|
+
LNA = 59144,
|
|
140
|
+
BAS = 8453,
|
|
141
|
+
SCL = 534352,
|
|
142
|
+
MOD = 34443,
|
|
143
|
+
MNT = 5000,
|
|
144
|
+
BLS = 81457,
|
|
145
|
+
SEI = 1329,
|
|
146
|
+
FRA = 252,
|
|
147
|
+
GRA = 1625,
|
|
148
|
+
IMX = 13371,
|
|
149
|
+
KAI = 8217,
|
|
150
|
+
XLY = 196,
|
|
151
|
+
OPB = 204,
|
|
152
|
+
WCC = 480,
|
|
153
|
+
LSK = 1135,
|
|
154
|
+
ABS = 2741,
|
|
155
|
+
BER = 80094,
|
|
156
|
+
SON = 146,
|
|
157
|
+
UNI = 130,
|
|
158
|
+
APE = 33139,
|
|
159
|
+
SOE = 1868,
|
|
160
|
+
INK = 57073,
|
|
161
|
+
LNS = 232,
|
|
162
|
+
ETL = 42793,
|
|
163
|
+
HYP = 999,
|
|
164
|
+
XDC = 50,
|
|
165
|
+
BOC = 60808, // BOB was already taken by Boba
|
|
166
|
+
VIC = 88,
|
|
167
|
+
FLR = 14,
|
|
168
|
+
KAT = 747474,
|
|
169
|
+
VAN = 1480,
|
|
170
|
+
RON = 2020,
|
|
171
|
+
PLU = 98866,
|
|
172
|
+
NIB = 6900,
|
|
173
|
+
HPL = 1337, // Hyperliquid's core (non-EVM) chain hard-codes 1337 in every EIP-712-signed message
|
|
174
|
+
PLA = 9745,
|
|
175
|
+
FLW = 747,
|
|
176
|
+
HMI = 43111,
|
|
177
|
+
MON = 143,
|
|
178
|
+
STA = 988,
|
|
179
|
+
MEG = 4326,
|
|
180
|
+
JOV = 5734951,
|
|
181
|
+
MOP = 2818,
|
|
182
|
+
TEM = 4217,
|
|
183
|
+
ZEROG = 16661,
|
|
184
|
+
PHR = 1672,
|
|
185
|
+
LTR = 3586256,
|
|
186
|
+
SOM = 5031,
|
|
187
|
+
OUT = 4663,
|
|
188
|
+
ARC = 5042,
|
|
189
|
+
INJ = 1776,
|
|
190
|
+
|
|
191
|
+
// None-EVM (IDs are made up by the LI.FI team)
|
|
192
|
+
TER = 1161011141099710,
|
|
193
|
+
OAS = 111971151099710,
|
|
194
|
+
|
|
195
|
+
// SVM
|
|
196
|
+
SOL = 1151111081099710,
|
|
197
|
+
FOG = 1021111031099710,
|
|
198
|
+
|
|
199
|
+
// MVM (IDs are made up by the LI.FI team)
|
|
200
|
+
SUI = 9270000000000000, // First 16 non-letter hex digits of SUI genesis blob
|
|
201
|
+
|
|
202
|
+
// UTXO (IDs are made up by the LI.FI team)
|
|
203
|
+
BTC = 20000000000001,
|
|
204
|
+
BCH = 20000000000002,
|
|
205
|
+
LTC = 20000000000003,
|
|
206
|
+
DGE = 20000000000004,
|
|
207
|
+
ZEC = 20000000000005,
|
|
208
|
+
|
|
209
|
+
// Tron
|
|
210
|
+
TRN = 728126428,
|
|
211
|
+
|
|
212
|
+
// Stellar (ID pattern: ASCII decimal of lowercase key letters + 1099710 suffix, x=120, l=108, m=109)
|
|
213
|
+
XLM = 1201081091099710,
|
|
214
|
+
|
|
215
|
+
// Testnet
|
|
216
|
+
ARCT = 5042002,
|
|
217
|
+
OPST = 11155420,
|
|
218
|
+
BAST = 84532,
|
|
219
|
+
ARBS = 421614,
|
|
220
|
+
ETHS = 11155111,
|
|
221
|
+
}
|
package/src/earn.ts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON response types for the LI.FI Earn Data API (`earn.li.fi/v1`).
|
|
3
|
+
*
|
|
4
|
+
* These describe the current response contract, not historical response shapes
|
|
5
|
+
* or guarantees inferred from a sample of vaults. Timestamps are serialized
|
|
6
|
+
* strings, and token metadata can be absent until it has been resolved.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** A protocol returned by the API. Use its id when filtering vaults. */
|
|
10
|
+
export interface EarnProtocol {
|
|
11
|
+
id: string
|
|
12
|
+
name: string
|
|
13
|
+
url: string
|
|
14
|
+
logoUri?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A vault token reference. Only its address is guaranteed to be available. */
|
|
18
|
+
export interface EarnToken {
|
|
19
|
+
address: string
|
|
20
|
+
symbol?: string
|
|
21
|
+
decimals?: number
|
|
22
|
+
/** Token price in USD, represented as a decimal string. */
|
|
23
|
+
priceUsd?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** An underlying asset held by a vault. */
|
|
27
|
+
export type EarnUnderlyingToken = EarnToken
|
|
28
|
+
|
|
29
|
+
/** An incentive token distributed by a vault. */
|
|
30
|
+
export type EarnRewardToken = EarnToken
|
|
31
|
+
|
|
32
|
+
/** A vault's deposit or redeem route metadata. */
|
|
33
|
+
export interface EarnPack {
|
|
34
|
+
name: string
|
|
35
|
+
stepsType: 'instant' | 'complex'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* APY values in percentage points: `5.34` means 5.34%, not 534%.
|
|
40
|
+
* A null component is unavailable; callers should not conflate it with zero.
|
|
41
|
+
*/
|
|
42
|
+
export interface EarnApy {
|
|
43
|
+
base: number | null
|
|
44
|
+
total: number
|
|
45
|
+
reward: number | null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Total value locked: USD is a JSON number, native units a decimal string. */
|
|
49
|
+
export interface EarnTvl {
|
|
50
|
+
usd: number
|
|
51
|
+
native?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface EarnAnalytics {
|
|
55
|
+
apy: EarnApy
|
|
56
|
+
tvl: EarnTvl
|
|
57
|
+
apy1d: number | null
|
|
58
|
+
apy7d: number | null
|
|
59
|
+
apy30d: number
|
|
60
|
+
/** ISO timestamp of the analytics observation, not a freshness guarantee. */
|
|
61
|
+
updatedAt: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Rule-based screening output, not a security audit or safety guarantee. */
|
|
65
|
+
export type EarnVerificationStatus = 'none' | 'flagged'
|
|
66
|
+
|
|
67
|
+
export type EarnVerificationReason =
|
|
68
|
+
| 'none'
|
|
69
|
+
| 'zero_apy'
|
|
70
|
+
| 'apy_outlier'
|
|
71
|
+
| 'stale_data'
|
|
72
|
+
|
|
73
|
+
export interface EarnVerificationBreakdown {
|
|
74
|
+
reason: EarnVerificationReason
|
|
75
|
+
result: EarnVerificationStatus
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Optional deposit capacity limits, represented as decimal strings. */
|
|
79
|
+
export interface EarnCaps {
|
|
80
|
+
totalCap?: string
|
|
81
|
+
maxCap?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A vault indexed by LI.FI Earn. */
|
|
85
|
+
export interface EarnVault {
|
|
86
|
+
address: string
|
|
87
|
+
chainId: number
|
|
88
|
+
name: string
|
|
89
|
+
slug: string
|
|
90
|
+
network: string
|
|
91
|
+
description?: string
|
|
92
|
+
protocol: EarnProtocol
|
|
93
|
+
/** ISO timestamp of the vault's sync. */
|
|
94
|
+
syncedAt: string
|
|
95
|
+
tags: string[]
|
|
96
|
+
underlyingTokens?: EarnUnderlyingToken[]
|
|
97
|
+
lpTokens?: EarnToken[]
|
|
98
|
+
rewardTokens?: EarnRewardToken[]
|
|
99
|
+
analytics: EarnAnalytics
|
|
100
|
+
/** Capability metadata; a successful executable quote is still required. */
|
|
101
|
+
isTransactional: boolean
|
|
102
|
+
isRedeemable: boolean
|
|
103
|
+
depositPacks: EarnPack[]
|
|
104
|
+
redeemPacks: EarnPack[]
|
|
105
|
+
verificationStatus: EarnVerificationStatus
|
|
106
|
+
verificationStatusBreakdown: EarnVerificationBreakdown[]
|
|
107
|
+
caps?: EarnCaps
|
|
108
|
+
timeLock?: number
|
|
109
|
+
kyc?: boolean
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** A page from GET /v1/vaults. */
|
|
113
|
+
export interface EarnVaultListResponse {
|
|
114
|
+
data: EarnVault[]
|
|
115
|
+
/** Omitted on the final page. Pass unchanged as the next request's cursor. */
|
|
116
|
+
nextCursor?: string
|
|
117
|
+
total: number
|
|
118
|
+
/** ISO timestamp of the catalog normalization. */
|
|
119
|
+
normalizedAt: string
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** GET /v1/chains returns a bare array of these objects. */
|
|
123
|
+
export interface EarnChain {
|
|
124
|
+
chainId: number
|
|
125
|
+
name: string
|
|
126
|
+
networkCaip: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** One position returned by GET /v1/portfolio/{userAddress}/positions. */
|
|
130
|
+
export interface EarnPosition {
|
|
131
|
+
chainId: number
|
|
132
|
+
/** The vault contract address, or null when unresolved. */
|
|
133
|
+
address: string | null
|
|
134
|
+
protocolName: string | null
|
|
135
|
+
asset: {
|
|
136
|
+
address: string
|
|
137
|
+
name: string
|
|
138
|
+
symbol: string
|
|
139
|
+
decimals: number
|
|
140
|
+
}
|
|
141
|
+
balanceUsd: string | null
|
|
142
|
+
balanceNative: string
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** A page from GET /v1/portfolio/{userAddress}/positions. */
|
|
146
|
+
export interface EarnPortfolioResponse {
|
|
147
|
+
data: EarnPosition[]
|
|
148
|
+
/** Omitted on the final page. Continue until no cursor is returned. */
|
|
149
|
+
nextCursor?: string
|
|
150
|
+
limit: number
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** One field-level issue in a validation error response's errors array. */
|
|
154
|
+
export interface EarnApiFieldError {
|
|
155
|
+
code: string
|
|
156
|
+
message: string
|
|
157
|
+
path: (string | number)[]
|
|
158
|
+
}
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Error codes emitted by the LI.FI API
|
|
2
|
+
export enum ErrorCode {
|
|
3
|
+
DefaultError = 1000,
|
|
4
|
+
FailedToBuildTransactionError = 1001,
|
|
5
|
+
NoQuoteError = 1002,
|
|
6
|
+
NotFoundError = 1003,
|
|
7
|
+
NotProcessableError = 1004,
|
|
8
|
+
RateLimitError = 1005,
|
|
9
|
+
ServerError = 1006,
|
|
10
|
+
SlippageError = 1007,
|
|
11
|
+
ThirdPartyError = 1008,
|
|
12
|
+
TimeoutError = 1009,
|
|
13
|
+
UnauthorizedError = 1010,
|
|
14
|
+
ValidationError = 1011,
|
|
15
|
+
RpcFailure = 1012,
|
|
16
|
+
MalformedSchema = 1013,
|
|
17
|
+
}
|
package/src/exchanges.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { StaticToken } from './tokens/token.js'
|
|
2
|
+
|
|
3
|
+
export interface ExchangeAggregator {
|
|
4
|
+
key: string
|
|
5
|
+
name: string
|
|
6
|
+
logoURI: string
|
|
7
|
+
webUrl: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Exchange {
|
|
11
|
+
key: string
|
|
12
|
+
name: string
|
|
13
|
+
chainId: number
|
|
14
|
+
logoURI: string
|
|
15
|
+
webUrl: string
|
|
16
|
+
graph?: string
|
|
17
|
+
tokenlistUrl: string
|
|
18
|
+
routerAddress: string
|
|
19
|
+
factoryAddress: string
|
|
20
|
+
initCodeHash: string
|
|
21
|
+
baseTokens: readonly StaticToken[]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ExchangeDefinition {
|
|
25
|
+
tool: string
|
|
26
|
+
chains: number[]
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './api.js'
|
|
2
|
+
export * from './balance/index.js'
|
|
3
|
+
export * from './bridges.js'
|
|
4
|
+
export * from './chains/index.js'
|
|
5
|
+
export * from './earn.js'
|
|
6
|
+
export * from './errors.js'
|
|
7
|
+
export * from './exchanges.js'
|
|
8
|
+
export * from './routeSlippage.js'
|
|
9
|
+
export * from './step.js'
|
|
10
|
+
export * from './tokens/index.js'
|
|
11
|
+
export * from './typed-data.js'
|