@vultisig/rujira 1.0.0
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/CHANGELOG.md +23 -0
- package/README.md +254 -0
- package/dist/assets/amount.d.ts +80 -0
- package/dist/assets/amount.d.ts.map +1 -0
- package/dist/assets/amount.js +186 -0
- package/dist/assets/asset.d.ts +43 -0
- package/dist/assets/asset.d.ts.map +1 -0
- package/dist/assets/asset.js +1 -0
- package/dist/assets/formats.d.ts +54 -0
- package/dist/assets/formats.d.ts.map +1 -0
- package/dist/assets/formats.js +164 -0
- package/dist/assets/index.d.ts +27 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/index.js +45 -0
- package/dist/assets/registry.d.ts +37 -0
- package/dist/assets/registry.d.ts.map +1 -0
- package/dist/assets/registry.js +487 -0
- package/dist/assets/router.d.ts +44 -0
- package/dist/assets/router.d.ts.map +1 -0
- package/dist/assets/router.js +142 -0
- package/dist/client.d.ts +70 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +250 -0
- package/dist/config/constants.d.ts +25 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +36 -0
- package/dist/config.d.ts +41 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +72 -0
- package/dist/discovery/discovery.d.ts +39 -0
- package/dist/discovery/discovery.d.ts.map +1 -0
- package/dist/discovery/discovery.js +250 -0
- package/dist/discovery/graphql-client.d.ts +46 -0
- package/dist/discovery/graphql-client.d.ts.map +1 -0
- package/dist/discovery/graphql-client.js +137 -0
- package/dist/discovery/index.d.ts +9 -0
- package/dist/discovery/index.d.ts.map +1 -0
- package/dist/discovery/index.js +7 -0
- package/dist/discovery/types.d.ts +62 -0
- package/dist/discovery/types.d.ts.map +1 -0
- package/dist/discovery/types.js +5 -0
- package/dist/easy-routes.d.ts +216 -0
- package/dist/easy-routes.d.ts.map +1 -0
- package/dist/easy-routes.js +241 -0
- package/dist/errors.d.ts +65 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +184 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/modules/assets.d.ts +68 -0
- package/dist/modules/assets.d.ts.map +1 -0
- package/dist/modules/assets.js +127 -0
- package/dist/modules/deposit.d.ts +152 -0
- package/dist/modules/deposit.d.ts.map +1 -0
- package/dist/modules/deposit.js +233 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules/index.d.ts.map +1 -0
- package/dist/modules/index.js +9 -0
- package/dist/modules/orderbook.d.ts +80 -0
- package/dist/modules/orderbook.d.ts.map +1 -0
- package/dist/modules/orderbook.js +320 -0
- package/dist/modules/swap.d.ts +48 -0
- package/dist/modules/swap.d.ts.map +1 -0
- package/dist/modules/swap.js +318 -0
- package/dist/modules/withdraw.d.ts +46 -0
- package/dist/modules/withdraw.d.ts.map +1 -0
- package/dist/modules/withdraw.js +218 -0
- package/dist/services/fee-estimator.d.ts +14 -0
- package/dist/services/fee-estimator.d.ts.map +1 -0
- package/dist/services/fee-estimator.js +89 -0
- package/dist/services/price-impact.d.ts +11 -0
- package/dist/services/price-impact.d.ts.map +1 -0
- package/dist/services/price-impact.js +58 -0
- package/dist/signer/index.d.ts +3 -0
- package/dist/signer/index.d.ts.map +1 -0
- package/dist/signer/index.js +1 -0
- package/dist/signer/keysign-builder.d.ts +21 -0
- package/dist/signer/keysign-builder.d.ts.map +1 -0
- package/dist/signer/keysign-builder.js +106 -0
- package/dist/signer/types.d.ts +81 -0
- package/dist/signer/types.d.ts.map +1 -0
- package/dist/signer/types.js +8 -0
- package/dist/signer/vultisig-provider.d.ts +33 -0
- package/dist/signer/vultisig-provider.d.ts.map +1 -0
- package/dist/signer/vultisig-provider.js +242 -0
- package/dist/types.d.ts +375 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +18 -0
- package/dist/utils/cache.d.ts +87 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +124 -0
- package/dist/utils/denom-conversion.d.ts +47 -0
- package/dist/utils/denom-conversion.d.ts.map +1 -0
- package/dist/utils/denom-conversion.js +105 -0
- package/dist/utils/encoding.d.ts +17 -0
- package/dist/utils/encoding.d.ts.map +1 -0
- package/dist/utils/encoding.js +55 -0
- package/dist/utils/format.d.ts +108 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +213 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/memo.d.ts +107 -0
- package/dist/utils/memo.d.ts.map +1 -0
- package/dist/utils/memo.js +190 -0
- package/dist/utils/rate-limiter.d.ts +38 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +67 -0
- package/dist/utils/type-guards.d.ts +22 -0
- package/dist/utils/type-guards.d.ts.map +1 -0
- package/dist/utils/type-guards.js +27 -0
- package/dist/validation/address-validator.d.ts +15 -0
- package/dist/validation/address-validator.d.ts.map +1 -0
- package/dist/validation/address-validator.js +75 -0
- package/package.json +98 -0
- package/src/__tests__/live/README.md +47 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of known assets with their formats and decimal specifications
|
|
3
|
+
* Complete Rujira asset coverage with correct FIN denom formats
|
|
4
|
+
*/
|
|
5
|
+
export const KNOWN_ASSETS = {
|
|
6
|
+
// Native L1 Assets
|
|
7
|
+
btc: {
|
|
8
|
+
id: 'btc',
|
|
9
|
+
name: 'Bitcoin',
|
|
10
|
+
chain: 'bitcoin',
|
|
11
|
+
decimals: {
|
|
12
|
+
native: 8,
|
|
13
|
+
thorchain: 8,
|
|
14
|
+
fin: 6,
|
|
15
|
+
},
|
|
16
|
+
formats: {
|
|
17
|
+
l1: 'BTC',
|
|
18
|
+
thorchain: 'BTC.BTC',
|
|
19
|
+
fin: 'btc-btc',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
eth: {
|
|
23
|
+
id: 'eth',
|
|
24
|
+
name: 'Ethereum',
|
|
25
|
+
chain: 'ethereum',
|
|
26
|
+
decimals: {
|
|
27
|
+
native: 18,
|
|
28
|
+
thorchain: 8,
|
|
29
|
+
fin: 6,
|
|
30
|
+
},
|
|
31
|
+
formats: {
|
|
32
|
+
l1: 'ETH',
|
|
33
|
+
thorchain: 'ETH.ETH',
|
|
34
|
+
fin: 'eth-eth',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
ltc: {
|
|
38
|
+
id: 'ltc',
|
|
39
|
+
name: 'Litecoin',
|
|
40
|
+
chain: 'litecoin',
|
|
41
|
+
decimals: {
|
|
42
|
+
native: 8,
|
|
43
|
+
thorchain: 8,
|
|
44
|
+
fin: 6,
|
|
45
|
+
},
|
|
46
|
+
formats: {
|
|
47
|
+
l1: 'LTC',
|
|
48
|
+
thorchain: 'LTC.LTC',
|
|
49
|
+
fin: 'ltc-ltc',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
bch: {
|
|
53
|
+
id: 'bch',
|
|
54
|
+
name: 'Bitcoin Cash',
|
|
55
|
+
chain: 'bitcoincash',
|
|
56
|
+
decimals: {
|
|
57
|
+
native: 8,
|
|
58
|
+
thorchain: 8,
|
|
59
|
+
fin: 6,
|
|
60
|
+
},
|
|
61
|
+
formats: {
|
|
62
|
+
l1: 'BCH',
|
|
63
|
+
thorchain: 'BCH.BCH',
|
|
64
|
+
fin: 'bch-bch',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
doge: {
|
|
68
|
+
id: 'doge',
|
|
69
|
+
name: 'Dogecoin',
|
|
70
|
+
chain: 'dogecoin',
|
|
71
|
+
decimals: {
|
|
72
|
+
native: 8,
|
|
73
|
+
thorchain: 8,
|
|
74
|
+
fin: 6,
|
|
75
|
+
},
|
|
76
|
+
formats: {
|
|
77
|
+
l1: 'DOGE',
|
|
78
|
+
thorchain: 'DOGE.DOGE',
|
|
79
|
+
fin: 'doge-doge',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
atom: {
|
|
83
|
+
id: 'atom',
|
|
84
|
+
name: 'Cosmos',
|
|
85
|
+
chain: 'cosmos',
|
|
86
|
+
decimals: {
|
|
87
|
+
native: 6,
|
|
88
|
+
thorchain: 8,
|
|
89
|
+
fin: 6,
|
|
90
|
+
},
|
|
91
|
+
formats: {
|
|
92
|
+
l1: 'ATOM',
|
|
93
|
+
thorchain: 'GAIA.ATOM',
|
|
94
|
+
fin: 'gaia-atom',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
avax: {
|
|
98
|
+
id: 'avax',
|
|
99
|
+
name: 'Avalanche',
|
|
100
|
+
chain: 'avalanche',
|
|
101
|
+
decimals: {
|
|
102
|
+
native: 18,
|
|
103
|
+
thorchain: 8,
|
|
104
|
+
fin: 6,
|
|
105
|
+
},
|
|
106
|
+
formats: {
|
|
107
|
+
l1: 'AVAX',
|
|
108
|
+
thorchain: 'AVAX.AVAX',
|
|
109
|
+
fin: 'avax-avax',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
bnb: {
|
|
113
|
+
id: 'bnb',
|
|
114
|
+
name: 'BNB Chain',
|
|
115
|
+
chain: 'binance',
|
|
116
|
+
decimals: {
|
|
117
|
+
native: 8,
|
|
118
|
+
thorchain: 8,
|
|
119
|
+
fin: 6,
|
|
120
|
+
},
|
|
121
|
+
formats: {
|
|
122
|
+
l1: 'BNB',
|
|
123
|
+
thorchain: 'BNB.BNB',
|
|
124
|
+
fin: 'bsc-bnb',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
xrp: {
|
|
128
|
+
id: 'xrp',
|
|
129
|
+
name: 'XRP Ledger',
|
|
130
|
+
chain: 'xrp',
|
|
131
|
+
decimals: {
|
|
132
|
+
native: 6,
|
|
133
|
+
thorchain: 8,
|
|
134
|
+
fin: 6,
|
|
135
|
+
},
|
|
136
|
+
formats: {
|
|
137
|
+
l1: 'XRP',
|
|
138
|
+
thorchain: 'XRP.XRP',
|
|
139
|
+
fin: 'xrp-xrp',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
base_eth: {
|
|
143
|
+
id: 'base_eth',
|
|
144
|
+
name: 'Base (Ethereum L2)',
|
|
145
|
+
chain: 'base',
|
|
146
|
+
decimals: {
|
|
147
|
+
native: 18,
|
|
148
|
+
thorchain: 8,
|
|
149
|
+
fin: 6,
|
|
150
|
+
},
|
|
151
|
+
formats: {
|
|
152
|
+
l1: 'ETH',
|
|
153
|
+
thorchain: 'BASE.ETH',
|
|
154
|
+
fin: 'base-eth',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
// THORChain Native Tokens
|
|
158
|
+
rune: {
|
|
159
|
+
id: 'rune',
|
|
160
|
+
name: 'THORChain',
|
|
161
|
+
chain: 'thorchain',
|
|
162
|
+
decimals: {
|
|
163
|
+
native: 8,
|
|
164
|
+
thorchain: 8,
|
|
165
|
+
fin: 6,
|
|
166
|
+
},
|
|
167
|
+
formats: {
|
|
168
|
+
l1: 'RUNE',
|
|
169
|
+
thorchain: 'THOR.RUNE',
|
|
170
|
+
fin: 'rune',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
tcy: {
|
|
174
|
+
id: 'tcy',
|
|
175
|
+
name: 'TCY Token',
|
|
176
|
+
chain: 'thorchain',
|
|
177
|
+
decimals: {
|
|
178
|
+
native: 8,
|
|
179
|
+
thorchain: 8,
|
|
180
|
+
fin: 6,
|
|
181
|
+
},
|
|
182
|
+
formats: {
|
|
183
|
+
l1: 'TCY',
|
|
184
|
+
thorchain: 'THOR.TCY',
|
|
185
|
+
fin: 'tcy',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
ruji: {
|
|
189
|
+
id: 'ruji',
|
|
190
|
+
name: 'RUJI Token',
|
|
191
|
+
chain: 'thorchain',
|
|
192
|
+
decimals: {
|
|
193
|
+
native: 8,
|
|
194
|
+
thorchain: 8,
|
|
195
|
+
fin: 6,
|
|
196
|
+
},
|
|
197
|
+
formats: {
|
|
198
|
+
l1: 'RUJI',
|
|
199
|
+
thorchain: 'THOR.RUJI',
|
|
200
|
+
fin: 'x/ruji',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
auto: {
|
|
204
|
+
id: 'auto',
|
|
205
|
+
name: 'AUTO Token',
|
|
206
|
+
chain: 'thorchain',
|
|
207
|
+
decimals: {
|
|
208
|
+
native: 8,
|
|
209
|
+
thorchain: 8,
|
|
210
|
+
fin: 6,
|
|
211
|
+
},
|
|
212
|
+
formats: {
|
|
213
|
+
l1: 'AUTO',
|
|
214
|
+
thorchain: 'THOR.AUTO',
|
|
215
|
+
fin: 'thor.auto',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
lqdy: {
|
|
219
|
+
id: 'lqdy',
|
|
220
|
+
name: 'LQDY Token',
|
|
221
|
+
chain: 'thorchain',
|
|
222
|
+
decimals: {
|
|
223
|
+
native: 8,
|
|
224
|
+
thorchain: 8,
|
|
225
|
+
fin: 6,
|
|
226
|
+
},
|
|
227
|
+
formats: {
|
|
228
|
+
l1: 'LQDY',
|
|
229
|
+
thorchain: 'THOR.LQDY',
|
|
230
|
+
fin: 'thor.lqdy',
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
nami: {
|
|
234
|
+
id: 'nami',
|
|
235
|
+
name: 'NAMI Token',
|
|
236
|
+
chain: 'thorchain',
|
|
237
|
+
decimals: {
|
|
238
|
+
native: 8,
|
|
239
|
+
thorchain: 8,
|
|
240
|
+
fin: 6,
|
|
241
|
+
},
|
|
242
|
+
formats: {
|
|
243
|
+
l1: 'NAMI',
|
|
244
|
+
thorchain: 'THOR.NAMI',
|
|
245
|
+
fin: 'thor.nami',
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
// Ethereum ERC20 Tokens
|
|
249
|
+
usdc_eth: {
|
|
250
|
+
id: 'usdc_eth',
|
|
251
|
+
name: 'USD Coin (Ethereum)',
|
|
252
|
+
chain: 'ethereum',
|
|
253
|
+
contract: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
254
|
+
decimals: {
|
|
255
|
+
native: 6,
|
|
256
|
+
thorchain: 8,
|
|
257
|
+
fin: 6,
|
|
258
|
+
},
|
|
259
|
+
formats: {
|
|
260
|
+
l1: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
261
|
+
thorchain: 'ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48',
|
|
262
|
+
fin: 'eth-usdc-0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
usdt_eth: {
|
|
266
|
+
id: 'usdt_eth',
|
|
267
|
+
name: 'Tether USD (Ethereum)',
|
|
268
|
+
chain: 'ethereum',
|
|
269
|
+
contract: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
270
|
+
decimals: {
|
|
271
|
+
native: 6,
|
|
272
|
+
thorchain: 8,
|
|
273
|
+
fin: 6,
|
|
274
|
+
},
|
|
275
|
+
formats: {
|
|
276
|
+
l1: '0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
277
|
+
thorchain: 'ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7',
|
|
278
|
+
fin: 'eth-usdt-0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
dai: {
|
|
282
|
+
id: 'dai',
|
|
283
|
+
name: 'Dai Stablecoin',
|
|
284
|
+
chain: 'ethereum',
|
|
285
|
+
contract: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
286
|
+
decimals: {
|
|
287
|
+
native: 18,
|
|
288
|
+
thorchain: 8,
|
|
289
|
+
fin: 6,
|
|
290
|
+
},
|
|
291
|
+
formats: {
|
|
292
|
+
l1: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
293
|
+
thorchain: 'ETH.DAI-0X6B175474E89094C44DA98B954EEDEAC495271D0F',
|
|
294
|
+
fin: 'eth-dai-0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
gusd: {
|
|
298
|
+
id: 'gusd',
|
|
299
|
+
name: 'Gemini Dollar',
|
|
300
|
+
chain: 'ethereum',
|
|
301
|
+
contract: '0x056fd409e1d7a124bd7017459dfea2f387b6d5cd',
|
|
302
|
+
decimals: {
|
|
303
|
+
native: 2,
|
|
304
|
+
thorchain: 8,
|
|
305
|
+
fin: 6,
|
|
306
|
+
},
|
|
307
|
+
formats: {
|
|
308
|
+
l1: '0x056fd409e1d7a124bd7017459dfea2f387b6d5cd',
|
|
309
|
+
thorchain: 'ETH.GUSD-0X056FD409E1D7A124BD7017459DFEA2F387B6D5CD',
|
|
310
|
+
fin: 'eth-gusd-0x056fd409e1d7a124bd7017459dfea2f387b6d5cd',
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
usdp: {
|
|
314
|
+
id: 'usdp',
|
|
315
|
+
name: 'Pax Dollar',
|
|
316
|
+
chain: 'ethereum',
|
|
317
|
+
contract: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
|
|
318
|
+
decimals: {
|
|
319
|
+
native: 18,
|
|
320
|
+
thorchain: 8,
|
|
321
|
+
fin: 6,
|
|
322
|
+
},
|
|
323
|
+
formats: {
|
|
324
|
+
l1: '0x8e870d67f660d95d5be530380d0ec0bd388289e1',
|
|
325
|
+
thorchain: 'ETH.USDP-0X8E870D67F660D95D5BE530380D0EC0BD388289E1',
|
|
326
|
+
fin: 'eth-usdp-0x8e870d67f660d95d5be530380d0ec0bd388289e1',
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
// Base Chain Tokens
|
|
330
|
+
usdc_base: {
|
|
331
|
+
id: 'usdc_base',
|
|
332
|
+
name: 'USD Coin (Base)',
|
|
333
|
+
chain: 'base',
|
|
334
|
+
contract: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
335
|
+
decimals: {
|
|
336
|
+
native: 6,
|
|
337
|
+
thorchain: 8,
|
|
338
|
+
fin: 6,
|
|
339
|
+
},
|
|
340
|
+
formats: {
|
|
341
|
+
l1: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
342
|
+
thorchain: 'BASE.USDC-0X833589FCD6EDB6E08F4C7C32D4F71B54BDA02913',
|
|
343
|
+
fin: 'base-usdc-0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
cbbtc: {
|
|
347
|
+
id: 'cbbtc',
|
|
348
|
+
name: 'Coinbase Wrapped BTC',
|
|
349
|
+
chain: 'base',
|
|
350
|
+
contract: '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
351
|
+
decimals: {
|
|
352
|
+
native: 8,
|
|
353
|
+
thorchain: 8,
|
|
354
|
+
fin: 6,
|
|
355
|
+
},
|
|
356
|
+
formats: {
|
|
357
|
+
l1: '0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
358
|
+
thorchain: 'BASE.CBBTC-0XCBB7C0000AB88B473B1F5AFD9EF808440EED33BF',
|
|
359
|
+
fin: 'base-cbbtc-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf',
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
// BSC Tokens
|
|
363
|
+
usdc_bsc: {
|
|
364
|
+
id: 'usdc_bsc',
|
|
365
|
+
name: 'USD Coin (BSC)',
|
|
366
|
+
chain: 'binance',
|
|
367
|
+
contract: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
|
|
368
|
+
decimals: {
|
|
369
|
+
native: 18,
|
|
370
|
+
thorchain: 8,
|
|
371
|
+
fin: 6,
|
|
372
|
+
},
|
|
373
|
+
formats: {
|
|
374
|
+
l1: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
|
|
375
|
+
thorchain: 'BNB.USDC-0X8AC76A51CC950D9822D68B83FE1AD97B32CD580D',
|
|
376
|
+
fin: 'bsc-usdc-0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d',
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
usdt_bsc: {
|
|
380
|
+
id: 'usdt_bsc',
|
|
381
|
+
name: 'Tether USD (BSC)',
|
|
382
|
+
chain: 'binance',
|
|
383
|
+
contract: '0x55d398326f99059ff775485246999027b3197955',
|
|
384
|
+
decimals: {
|
|
385
|
+
native: 18,
|
|
386
|
+
thorchain: 8,
|
|
387
|
+
fin: 6,
|
|
388
|
+
},
|
|
389
|
+
formats: {
|
|
390
|
+
l1: '0x55d398326f99059ff775485246999027b3197955',
|
|
391
|
+
thorchain: 'BNB.USDT-0X55D398326F99059FF775485246999027B3197955',
|
|
392
|
+
fin: 'bsc-usdt-0x55d398326f99059ff775485246999027b3197955',
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
// Avalanche Tokens
|
|
396
|
+
usdc_avax: {
|
|
397
|
+
id: 'usdc_avax',
|
|
398
|
+
name: 'USD Coin (Avalanche)',
|
|
399
|
+
chain: 'avalanche',
|
|
400
|
+
contract: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
401
|
+
decimals: {
|
|
402
|
+
native: 6,
|
|
403
|
+
thorchain: 8,
|
|
404
|
+
fin: 6,
|
|
405
|
+
},
|
|
406
|
+
formats: {
|
|
407
|
+
l1: '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
408
|
+
thorchain: 'AVAX.USDC-0XB97EF9EF8734C71904D8002F8B6BC66DD9C48A6E',
|
|
409
|
+
fin: 'avax-usdc-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e',
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
usdt_avax: {
|
|
413
|
+
id: 'usdt_avax',
|
|
414
|
+
name: 'Tether USD (Avalanche)',
|
|
415
|
+
chain: 'avalanche',
|
|
416
|
+
contract: '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
|
417
|
+
decimals: {
|
|
418
|
+
native: 6,
|
|
419
|
+
thorchain: 8,
|
|
420
|
+
fin: 6,
|
|
421
|
+
},
|
|
422
|
+
formats: {
|
|
423
|
+
l1: '0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
|
424
|
+
thorchain: 'AVAX.USDT-0X9702230A8EA53601F5CD2DC00FDBC13D4DF4A8C7',
|
|
425
|
+
fin: 'avax-usdt-0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7',
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Get asset by ID
|
|
431
|
+
*/
|
|
432
|
+
export function getAsset(id) {
|
|
433
|
+
return KNOWN_ASSETS[id.toLowerCase()] || null;
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Get all known assets
|
|
437
|
+
*/
|
|
438
|
+
export function getAllAssets() {
|
|
439
|
+
return Object.values(KNOWN_ASSETS);
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Find asset by any format
|
|
443
|
+
*/
|
|
444
|
+
export function findAssetByFormat(format) {
|
|
445
|
+
const normalizedFormat = format.toLowerCase();
|
|
446
|
+
for (const asset of Object.values(KNOWN_ASSETS)) {
|
|
447
|
+
if (asset.formats.l1.toLowerCase() === normalizedFormat ||
|
|
448
|
+
asset.formats.thorchain.toLowerCase() === normalizedFormat ||
|
|
449
|
+
asset.formats.fin.toLowerCase() === normalizedFormat ||
|
|
450
|
+
asset.id === normalizedFormat) {
|
|
451
|
+
return asset;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return null;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Get assets by chain
|
|
458
|
+
*/
|
|
459
|
+
export function getAssetsByChain(chain) {
|
|
460
|
+
return Object.values(KNOWN_ASSETS).filter(asset => asset.chain === chain);
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Get all supported chains
|
|
464
|
+
*/
|
|
465
|
+
export function getSupportedChains() {
|
|
466
|
+
const chains = new Set();
|
|
467
|
+
for (const asset of Object.values(KNOWN_ASSETS)) {
|
|
468
|
+
chains.add(asset.chain);
|
|
469
|
+
}
|
|
470
|
+
return Array.from(chains).sort();
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Get asset statistics
|
|
474
|
+
*/
|
|
475
|
+
export function getAssetStats() {
|
|
476
|
+
const assets = Object.values(KNOWN_ASSETS);
|
|
477
|
+
const chains = getSupportedChains();
|
|
478
|
+
const nativeAssets = assets.filter(a => !a.contract);
|
|
479
|
+
const tokenAssets = assets.filter(a => a.contract);
|
|
480
|
+
return {
|
|
481
|
+
totalAssets: assets.length,
|
|
482
|
+
supportedChains: chains.length,
|
|
483
|
+
nativeAssets: nativeAssets.length,
|
|
484
|
+
tokenAssets: tokenAssets.length,
|
|
485
|
+
chains,
|
|
486
|
+
};
|
|
487
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Amount } from './amount.js';
|
|
2
|
+
import { Asset, Quote } from './asset.js';
|
|
3
|
+
/**
|
|
4
|
+
* SwapRouter that selects the optimal path for swaps
|
|
5
|
+
*/
|
|
6
|
+
export declare class SwapRouter {
|
|
7
|
+
/**
|
|
8
|
+
* Auto-select best path and get quote
|
|
9
|
+
*
|
|
10
|
+
* Logic:
|
|
11
|
+
* - If both assets are secured on THORChain → use Rujira FIN
|
|
12
|
+
* - If swapping L1 to L1 → use THORChain LP
|
|
13
|
+
*/
|
|
14
|
+
quote(from: Asset, to: Asset, amount: Amount): Promise<Quote>;
|
|
15
|
+
/**
|
|
16
|
+
* Get quote from THORChain LP
|
|
17
|
+
*/
|
|
18
|
+
quoteThorchainLP(from: Asset, to: Asset, amount: Amount): Promise<Quote>;
|
|
19
|
+
/**
|
|
20
|
+
* Get quote from Rujira FIN
|
|
21
|
+
*/
|
|
22
|
+
quoteRujiraFIN(from: Asset, to: Asset, amount: Amount): Promise<Quote>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if asset is secured on THORChain
|
|
25
|
+
*/
|
|
26
|
+
private isSecuredOnThorchain;
|
|
27
|
+
/**
|
|
28
|
+
* Get mock exchange rate (in real app, would fetch from price feeds)
|
|
29
|
+
*/
|
|
30
|
+
private getMockRate;
|
|
31
|
+
/**
|
|
32
|
+
* Get the recommended path for a swap
|
|
33
|
+
*/
|
|
34
|
+
getRecommendedPath(from: Asset, to: Asset): 'thorchain-lp' | 'rujira-fin';
|
|
35
|
+
/**
|
|
36
|
+
* Check if a path is available for the given assets
|
|
37
|
+
*/
|
|
38
|
+
isPathAvailable(from: Asset, to: Asset, path: 'thorchain-lp' | 'rujira-fin'): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Get supported assets for a specific path
|
|
41
|
+
*/
|
|
42
|
+
getSupportedAssets(path: 'thorchain-lp' | 'rujira-fin'): string[];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/assets/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAEzC;;GAEG;AACH,qBAAa,UAAU;IACrB;;;;;;OAMG;IACG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAYnE;;OAEG;IACG,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IA4B9E;;OAEG;IACG,cAAc,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IA4B5E;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,cAAc,GAAG,YAAY;IAOzE;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,YAAY,GAAG,OAAO;IAcrF;;OAEG;IACH,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,YAAY,GAAG,MAAM,EAAE;CAalE"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Amount } from './amount.js';
|
|
2
|
+
/**
|
|
3
|
+
* SwapRouter that selects the optimal path for swaps
|
|
4
|
+
*/
|
|
5
|
+
export class SwapRouter {
|
|
6
|
+
/**
|
|
7
|
+
* Auto-select best path and get quote
|
|
8
|
+
*
|
|
9
|
+
* Logic:
|
|
10
|
+
* - If both assets are secured on THORChain → use Rujira FIN
|
|
11
|
+
* - If swapping L1 to L1 → use THORChain LP
|
|
12
|
+
*/
|
|
13
|
+
async quote(from, to, amount) {
|
|
14
|
+
// Check if both assets are secured on THORChain
|
|
15
|
+
const fromSecured = this.isSecuredOnThorchain(from);
|
|
16
|
+
const toSecured = this.isSecuredOnThorchain(to);
|
|
17
|
+
if (fromSecured && toSecured) {
|
|
18
|
+
return this.quoteRujiraFIN(from, to, amount);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return this.quoteThorchainLP(from, to, amount);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get quote from THORChain LP
|
|
26
|
+
*/
|
|
27
|
+
async quoteThorchainLP(from, to, amount) {
|
|
28
|
+
// Convert input to THORChain layer for calculation
|
|
29
|
+
const thorchainAmount = amount.toThorchain();
|
|
30
|
+
// Mock implementation - in real app, this would call THORChain APIs
|
|
31
|
+
const mockRate = this.getMockRate(from, to);
|
|
32
|
+
const outputRaw = (thorchainAmount.raw * BigInt(Math.floor(mockRate * 100))) / 100n;
|
|
33
|
+
const output = Amount.fromRaw(outputRaw, to, 'thorchain').toLayer(amount.layer);
|
|
34
|
+
const minimumOutput = output.multiply(0.97); // 3% slippage tolerance
|
|
35
|
+
// Mock fees
|
|
36
|
+
const networkFee = Amount.fromRaw(1000000n, from, 'thorchain').toLayer(amount.layer);
|
|
37
|
+
const protocolFee = amount.multiply(0.003); // 0.3% protocol fee
|
|
38
|
+
return {
|
|
39
|
+
path: 'thorchain-lp',
|
|
40
|
+
input: amount,
|
|
41
|
+
output,
|
|
42
|
+
minimumOutput,
|
|
43
|
+
priceImpact: '0.5%',
|
|
44
|
+
fees: {
|
|
45
|
+
network: networkFee,
|
|
46
|
+
protocol: protocolFee,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get quote from Rujira FIN
|
|
52
|
+
*/
|
|
53
|
+
async quoteRujiraFIN(from, to, amount) {
|
|
54
|
+
// Convert input to FIN layer for calculation
|
|
55
|
+
const finAmount = amount.toFin();
|
|
56
|
+
// Mock implementation - in real app, this would call Rujira APIs
|
|
57
|
+
const mockRate = this.getMockRate(from, to);
|
|
58
|
+
const outputRaw = (finAmount.raw * BigInt(Math.floor(mockRate * 1000000))) / 1000000n;
|
|
59
|
+
const output = Amount.fromRaw(outputRaw, to, 'fin').toLayer(amount.layer);
|
|
60
|
+
const minimumOutput = output.multiply(0.98); // 2% slippage tolerance (better on FIN)
|
|
61
|
+
// Mock fees
|
|
62
|
+
const networkFee = Amount.fromRaw(5000n, from, 'fin').toLayer(amount.layer);
|
|
63
|
+
const protocolFee = amount.multiply(0.002); // 0.2% protocol fee (lower on FIN)
|
|
64
|
+
return {
|
|
65
|
+
path: 'rujira-fin',
|
|
66
|
+
input: amount,
|
|
67
|
+
output,
|
|
68
|
+
minimumOutput,
|
|
69
|
+
priceImpact: '0.3%',
|
|
70
|
+
fees: {
|
|
71
|
+
network: networkFee,
|
|
72
|
+
protocol: protocolFee,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Check if asset is secured on THORChain
|
|
78
|
+
*/
|
|
79
|
+
isSecuredOnThorchain(asset) {
|
|
80
|
+
// Assets that are secured (have significant liquidity) on THORChain
|
|
81
|
+
const securedAssets = new Set(['btc', 'eth', 'rune', 'usdc', 'usdt', 'avax', 'atom']);
|
|
82
|
+
return securedAssets.has(asset.id);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get mock exchange rate (in real app, would fetch from price feeds)
|
|
86
|
+
*/
|
|
87
|
+
getMockRate(from, to) {
|
|
88
|
+
// Mock rates - in production, fetch from price APIs
|
|
89
|
+
const mockPrices = {
|
|
90
|
+
btc: 45000,
|
|
91
|
+
eth: 2500,
|
|
92
|
+
rune: 5,
|
|
93
|
+
usdc: 1,
|
|
94
|
+
usdt: 1,
|
|
95
|
+
avax: 35,
|
|
96
|
+
atom: 10,
|
|
97
|
+
doge: 0.08,
|
|
98
|
+
ltc: 70,
|
|
99
|
+
bch: 250,
|
|
100
|
+
bnb: 300,
|
|
101
|
+
};
|
|
102
|
+
const fromPrice = mockPrices[from.id] || 1;
|
|
103
|
+
const toPrice = mockPrices[to.id] || 1;
|
|
104
|
+
return fromPrice / toPrice;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the recommended path for a swap
|
|
108
|
+
*/
|
|
109
|
+
getRecommendedPath(from, to) {
|
|
110
|
+
const fromSecured = this.isSecuredOnThorchain(from);
|
|
111
|
+
const toSecured = this.isSecuredOnThorchain(to);
|
|
112
|
+
return fromSecured && toSecured ? 'rujira-fin' : 'thorchain-lp';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if a path is available for the given assets
|
|
116
|
+
*/
|
|
117
|
+
isPathAvailable(from, to, path) {
|
|
118
|
+
if (path === 'thorchain-lp') {
|
|
119
|
+
// THORChain LP supports most assets
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (path === 'rujira-fin') {
|
|
123
|
+
// FIN only supports secured assets
|
|
124
|
+
return this.isSecuredOnThorchain(from) && this.isSecuredOnThorchain(to);
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get supported assets for a specific path
|
|
130
|
+
*/
|
|
131
|
+
getSupportedAssets(path) {
|
|
132
|
+
if (path === 'thorchain-lp') {
|
|
133
|
+
// THORChain LP supports all known assets
|
|
134
|
+
return ['btc', 'eth', 'rune', 'usdc', 'usdt', 'avax', 'atom', 'doge', 'ltc', 'bch', 'bnb'];
|
|
135
|
+
}
|
|
136
|
+
if (path === 'rujira-fin') {
|
|
137
|
+
// FIN only supports secured assets
|
|
138
|
+
return ['btc', 'eth', 'rune', 'usdc', 'usdt', 'avax', 'atom'];
|
|
139
|
+
}
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
}
|