@gardenfi/orderbook 2.1.8-beta.2 → 2.1.9-beta.1
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/dist/index.cjs +1 -1
- package/dist/index.js +22 -18
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +70 -64
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +45 -16
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +81 -342
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +346 -186
- package/dist/src/index.d.ts +3 -1
- package/dist/src/lib/asset.d.ts +2 -0
- package/dist/src/lib/constants.d.ts +4 -4
- package/dist/src/lib/orderbook/orderbook.d.ts +3 -4
- package/dist/src/lib/orderbook/orderbook.types.d.ts +9 -10
- package/dist/src/lib/orders/orders.types.d.ts +60 -0
- package/dist/src/lib/orders/ordersProvider.d.ts +14 -0
- package/package.json +2 -2
package/dist/index5.js
CHANGED
|
@@ -1,190 +1,350 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { Chains as e } from "./index3.js";
|
|
2
|
+
const c = {
|
|
3
|
+
id: 1001,
|
|
4
|
+
name: "Starknet Localnet",
|
|
5
|
+
nativeCurrency: {
|
|
6
|
+
name: "Stark Token",
|
|
7
|
+
symbol: "STRK",
|
|
8
|
+
decimals: 18
|
|
9
|
+
},
|
|
10
|
+
rpcUrls: {
|
|
11
|
+
default: {
|
|
12
|
+
http: ["http://127.0.0.1:8547/"]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
testnet: !0
|
|
16
|
+
}, d = {
|
|
17
|
+
id: 31338,
|
|
18
|
+
name: "Arbitrum Localnet",
|
|
19
|
+
nativeCurrency: {
|
|
20
|
+
name: "Ethereum",
|
|
21
|
+
symbol: "ETH",
|
|
22
|
+
decimals: 18
|
|
23
|
+
},
|
|
24
|
+
rpcUrls: {
|
|
25
|
+
default: {
|
|
26
|
+
http: ["http://localhost:8546/"]
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
testnet: !0
|
|
30
|
+
}, o = {
|
|
31
|
+
id: 31337,
|
|
32
|
+
name: "Ethereum Localnet",
|
|
33
|
+
nativeCurrency: {
|
|
34
|
+
name: "Ethereum",
|
|
35
|
+
symbol: "ETH",
|
|
36
|
+
decimals: 18
|
|
37
|
+
},
|
|
38
|
+
rpcUrls: {
|
|
39
|
+
default: {
|
|
40
|
+
http: ["http://localhost:8545/"]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
testnet: !0
|
|
44
|
+
}, m = {
|
|
45
|
+
name: "Bitcoin Regtest",
|
|
46
|
+
decimals: 8,
|
|
47
|
+
symbol: "BTC",
|
|
48
|
+
chain: e.bitcoin_regtest,
|
|
49
|
+
atomicSwapAddress: "primary",
|
|
50
|
+
tokenAddress: "primary"
|
|
51
|
+
}, a = {
|
|
52
|
+
name: "WBTC Arbitrum Localnet",
|
|
53
|
+
decimals: 8,
|
|
54
|
+
symbol: "WBTC",
|
|
55
|
+
chain: e.arbitrum_localnet,
|
|
56
|
+
atomicSwapAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
|
|
57
|
+
tokenAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
|
|
58
|
+
}, t = {
|
|
59
|
+
name: "WBTC Ethereum Localnet",
|
|
60
|
+
decimals: 8,
|
|
61
|
+
symbol: "WBTC",
|
|
62
|
+
chain: e.ethereum_localnet,
|
|
63
|
+
atomicSwapAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
|
|
64
|
+
tokenAddress: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
|
|
65
|
+
}, s = {
|
|
66
|
+
name: "STRK Starknet Localnet",
|
|
67
|
+
decimals: 18,
|
|
68
|
+
symbol: "STRK",
|
|
69
|
+
chain: e.starknet_devnet,
|
|
70
|
+
atomicSwapAddress: "0x15cf8b127aa850c97ed10de6f8b300cabc4f09232a57e63667af02fdef8a55a",
|
|
71
|
+
tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
|
|
72
|
+
}, n = {
|
|
73
|
+
name: "ETH Starknet Localnet",
|
|
74
|
+
decimals: 18,
|
|
75
|
+
symbol: "ETH",
|
|
76
|
+
chain: e.starknet_devnet,
|
|
77
|
+
atomicSwapAddress: "0x1890470168440bbb9df50988748924a74ea22de10d22a081e458737b9574e75",
|
|
78
|
+
tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
|
|
79
|
+
}, r = {
|
|
80
|
+
localnet: {
|
|
81
|
+
arbitrum_localnet_WBTC: a,
|
|
82
|
+
ethereum_localnet_WBTC: t,
|
|
83
|
+
starknet_localnet_STRK: s,
|
|
84
|
+
starknet_localnet_ETH: n
|
|
85
|
+
},
|
|
86
|
+
testnet: {
|
|
87
|
+
bitcoin_testnet_BTC: {
|
|
88
|
+
name: "BTC",
|
|
89
|
+
decimals: 8,
|
|
90
|
+
symbol: "BTC",
|
|
91
|
+
chain: e.bitcoin_testnet,
|
|
92
|
+
tokenAddress: "primary",
|
|
93
|
+
atomicSwapAddress: "primary"
|
|
94
|
+
},
|
|
95
|
+
ethereum_sepolia_WBTC: {
|
|
96
|
+
name: "Wrapped Bitcoin",
|
|
97
|
+
decimals: 8,
|
|
98
|
+
symbol: "WBTC",
|
|
99
|
+
chain: e.ethereum_sepolia,
|
|
100
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
101
|
+
tokenAddress: "0x4D68da063577F98C55166c7AF6955cF58a97b20A",
|
|
102
|
+
atomicSwapAddress: "0x3C6a17b8cD92976D1D91E491c93c98cd81998265"
|
|
103
|
+
},
|
|
104
|
+
arbitrum_sepolia_WBTC: {
|
|
105
|
+
name: "Wrapped Bitcoin",
|
|
106
|
+
decimals: 8,
|
|
107
|
+
symbol: "WBTC",
|
|
108
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
109
|
+
chain: e.arbitrum_sepolia,
|
|
110
|
+
tokenAddress: "0x00ab86f54F436CfE15253845F139955ae0C00bAf",
|
|
111
|
+
atomicSwapAddress: "0xE918A5a47b8e0AFAC2382bC5D1e981613e63fB07"
|
|
112
|
+
},
|
|
113
|
+
arbitrum_sepolia_SEED: {
|
|
114
|
+
name: "Seed",
|
|
115
|
+
decimals: 18,
|
|
116
|
+
symbol: "SEED",
|
|
117
|
+
chain: e.arbitrum_sepolia,
|
|
118
|
+
logo: "https://garden-finance.imgix.net/token-images/seed.svg",
|
|
119
|
+
tokenAddress: "0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",
|
|
120
|
+
atomicSwapAddress: "0xB47716a220C319b25a532594511D63EC68702CEf"
|
|
121
|
+
},
|
|
122
|
+
arbitrum_sepolia_iBTC: {
|
|
123
|
+
name: "iBTC",
|
|
124
|
+
decimals: 8,
|
|
125
|
+
symbol: "iBTC",
|
|
126
|
+
chain: e.arbitrum_sepolia,
|
|
127
|
+
logo: "https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",
|
|
128
|
+
tokenAddress: "0x685437f025c5f33A94818408C286bc1F023201Fc",
|
|
129
|
+
atomicSwapAddress: "0x88e1032252c712681A3659986F452E910D2134D8"
|
|
130
|
+
},
|
|
131
|
+
base_sepolia_WBTC: {
|
|
132
|
+
name: "Wrapped Bitcoin",
|
|
133
|
+
decimals: 8,
|
|
134
|
+
symbol: "WBTC",
|
|
135
|
+
chain: e.base_sepolia,
|
|
136
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
137
|
+
tokenAddress: "0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",
|
|
138
|
+
atomicSwapAddress: "0x00ab86f54F436CfE15253845F139955ae0C00bAf"
|
|
139
|
+
},
|
|
140
|
+
base_sepolia_USDT: {
|
|
141
|
+
name: "Tether USD",
|
|
142
|
+
decimals: 6,
|
|
143
|
+
symbol: "USDT",
|
|
144
|
+
chain: e.base_sepolia,
|
|
145
|
+
logo: "https://garden-finance.imgix.net/token-images/usdt.svg",
|
|
146
|
+
tokenAddress: "0xD72Fc3e7D52301b3e5f7d4E3366F88d5C8747520",
|
|
147
|
+
atomicSwapAddress: "0xB391CA6D0A76CD2A927bC314856E8a374a225CFc"
|
|
148
|
+
},
|
|
149
|
+
base_sepolia_iBTC: {
|
|
150
|
+
name: "iBTC",
|
|
151
|
+
decimals: 8,
|
|
152
|
+
symbol: "iBTC",
|
|
153
|
+
chain: e.base_sepolia,
|
|
154
|
+
logo: "https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",
|
|
155
|
+
tokenAddress: "0xbaFb499B60F9E30fd82A54342cb7695C92F5B527",
|
|
156
|
+
atomicSwapAddress: "0xbcdad29ac77e5bb27fd528ab0045af630259fe4f"
|
|
157
|
+
},
|
|
158
|
+
citrea_testnet_WCBTC: {
|
|
159
|
+
name: "Wrapped Citrea Bitcoin",
|
|
160
|
+
decimals: 18,
|
|
161
|
+
symbol: "WCBTC",
|
|
162
|
+
chain: e.citrea_testnet,
|
|
163
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
164
|
+
tokenAddress: "0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",
|
|
165
|
+
atomicSwapAddress: "0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E"
|
|
166
|
+
},
|
|
167
|
+
citrea_testnet_cBTC: {
|
|
168
|
+
name: "Citrea Bitcoin",
|
|
169
|
+
decimals: 18,
|
|
170
|
+
symbol: "cBTC",
|
|
171
|
+
chain: e.citrea_testnet,
|
|
172
|
+
logo: "https://garden-finance.imgix.net/token-images/bitcoin.svg",
|
|
173
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
174
|
+
atomicSwapAddress: "0x6218FA00f47a61aCD8B46D6f1b15c4D730F803F2"
|
|
175
|
+
},
|
|
176
|
+
starknet_testnet_WBTC: {
|
|
177
|
+
name: "Wrapped Bitcoin",
|
|
178
|
+
decimals: 8,
|
|
179
|
+
symbol: "WBTC",
|
|
180
|
+
chain: e.starknet_sepolia,
|
|
181
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
182
|
+
tokenAddress: "0x496bef3ed20371382fbe0ca6a5a64252c5c848f9f1f0cccf8110fc4def912d5",
|
|
183
|
+
atomicSwapAddress: "0x06579d255314109429a4477d89629bc2b94f529ae01979c2f8014f9246482603"
|
|
184
|
+
},
|
|
185
|
+
monad_testnet_cbBTC: {
|
|
186
|
+
name: "Coinbase Bitcoin",
|
|
187
|
+
decimals: 8,
|
|
188
|
+
symbol: "cbBTC",
|
|
189
|
+
chain: e.monad_testnet,
|
|
190
|
+
logo: "https://garden-finance.imgix.net/token-images/cbBTC.svg",
|
|
191
|
+
tokenAddress: "0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E",
|
|
192
|
+
atomicSwapAddress: "0x1dC94FdcAd8Aee13cfd34Db8a26d26E31572805c"
|
|
193
|
+
},
|
|
194
|
+
monad_testnet_USDC: {
|
|
195
|
+
name: "USD Coin",
|
|
196
|
+
decimals: 6,
|
|
197
|
+
symbol: "USDC",
|
|
198
|
+
chain: e.monad_testnet,
|
|
199
|
+
logo: "https://garden-finance.imgix.net/token-images/usdc.svg",
|
|
200
|
+
tokenAddress: "0x00ab86f54F436CfE15253845F139955ae0C00bAf",
|
|
201
|
+
atomicSwapAddress: "0xE99D8A21d4F2ad2f90c279c869311503f9e25867"
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
mainnet: {
|
|
205
|
+
bitcoin_BTC: {
|
|
206
|
+
name: "BTC",
|
|
207
|
+
decimals: 8,
|
|
208
|
+
symbol: "BTC",
|
|
209
|
+
chain: e.bitcoin,
|
|
210
|
+
tokenAddress: "primary",
|
|
211
|
+
atomicSwapAddress: "primary"
|
|
212
|
+
},
|
|
213
|
+
base_cbBTC: {
|
|
214
|
+
name: "Coinbase Bitcoin",
|
|
215
|
+
decimals: 8,
|
|
216
|
+
symbol: "cbBTC",
|
|
217
|
+
chain: e.base,
|
|
218
|
+
logo: "https://garden-finance.imgix.net/token-images/cbBTC.svg",
|
|
219
|
+
tokenAddress: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
220
|
+
atomicSwapAddress: "0xeae7721d779276eb0f5837e2fe260118724a2ba4"
|
|
221
|
+
},
|
|
222
|
+
base_USDC: {
|
|
223
|
+
name: "USD Coin",
|
|
224
|
+
decimals: 6,
|
|
225
|
+
symbol: "USDC",
|
|
226
|
+
chain: e.base,
|
|
227
|
+
logo: "https://garden-finance.imgix.net/token-images/usdc.svg",
|
|
228
|
+
tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
229
|
+
atomicSwapAddress: "0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"
|
|
230
|
+
},
|
|
231
|
+
ethereum_WBTC: {
|
|
232
|
+
name: "Wrapped Bitcoin",
|
|
233
|
+
decimals: 8,
|
|
234
|
+
symbol: "WBTC",
|
|
235
|
+
chain: e.ethereum,
|
|
236
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
237
|
+
tokenAddress: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
238
|
+
atomicSwapAddress: "0x795dcb58d1cd4789169d5f938ea05e17eceb68ca"
|
|
239
|
+
},
|
|
240
|
+
ethereum_USDC: {
|
|
241
|
+
name: "USD Coin",
|
|
242
|
+
decimals: 6,
|
|
243
|
+
symbol: "USDC",
|
|
244
|
+
chain: e.ethereum,
|
|
245
|
+
logo: "https://garden-finance.imgix.net/token-images/usdc.svg",
|
|
246
|
+
tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
247
|
+
atomicSwapAddress: "0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"
|
|
248
|
+
},
|
|
249
|
+
ethereum_cbBTC: {
|
|
250
|
+
name: "Coinbase Bitcoin",
|
|
251
|
+
decimals: 8,
|
|
252
|
+
symbol: "cbBTC",
|
|
253
|
+
chain: e.ethereum,
|
|
254
|
+
logo: "https://garden-finance.imgix.net/token-images/cbBTC.svg",
|
|
255
|
+
tokenAddress: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
|
|
256
|
+
atomicSwapAddress: "0xeae7721d779276eb0f5837e2fe260118724a2ba4"
|
|
257
|
+
},
|
|
258
|
+
arbitrum_WBTC: {
|
|
259
|
+
name: "Wrapped Bitcoin",
|
|
260
|
+
decimals: 8,
|
|
261
|
+
symbol: "WBTC",
|
|
262
|
+
chain: e.arbitrum,
|
|
263
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
264
|
+
tokenAddress: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
|
|
265
|
+
atomicSwapAddress: "0x6b6303fab8ec7232b4f2a7b9fa58e5216f608fcb"
|
|
266
|
+
},
|
|
267
|
+
arbitrum_USDC: {
|
|
268
|
+
name: "USD Coin",
|
|
269
|
+
decimals: 6,
|
|
270
|
+
symbol: "USDC",
|
|
271
|
+
chain: e.arbitrum,
|
|
272
|
+
logo: "https://garden-finance.imgix.net/token-images/usdc.svg",
|
|
273
|
+
tokenAddress: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
274
|
+
atomicSwapAddress: "0xeae7721d779276eb0f5837e2fe260118724a2ba4"
|
|
275
|
+
},
|
|
276
|
+
arbitrum_iBTC: {
|
|
277
|
+
name: "iBTC",
|
|
278
|
+
decimals: 8,
|
|
279
|
+
symbol: "iBTC",
|
|
280
|
+
chain: e.arbitrum,
|
|
281
|
+
logo: "https://garden-finance.imgix.net/token-images/iBTC.svg",
|
|
282
|
+
tokenAddress: "0x050C24dBf1eEc17babE5fc585F06116A259CC77A",
|
|
283
|
+
atomicSwapAddress: "0xdc74a45e86dedf1ff7c6dac77e0c2f082f9e4f72"
|
|
284
|
+
},
|
|
285
|
+
bera_LBTC: {
|
|
286
|
+
name: "Lombard Bitcoin",
|
|
287
|
+
decimals: 8,
|
|
288
|
+
symbol: "LBTC",
|
|
289
|
+
chain: e.bera,
|
|
290
|
+
logo: "https://garden-finance.imgix.net/token-images/LBTC.svg",
|
|
291
|
+
tokenAddress: "0xecAc9C5F704e954931349Da37F60E39f515c11c1",
|
|
292
|
+
atomicSwapAddress: "0x39f3294352208905fc6ebf033954E6c6455CdB4C"
|
|
293
|
+
},
|
|
294
|
+
hyperliquid_uBTC: {
|
|
295
|
+
name: "Unit Bitcoin",
|
|
296
|
+
decimals: 8,
|
|
297
|
+
symbol: "uBTC",
|
|
298
|
+
chain: e.hyperliquid,
|
|
299
|
+
tokenAddress: "0x9FDBdA0A5e284c32744D2f17Ee5c74B284993463",
|
|
300
|
+
atomicSwapAddress: "0x39f3294352208905fc6ebf033954E6c6455CdB4C"
|
|
301
|
+
},
|
|
302
|
+
starknet_WBTC: {
|
|
303
|
+
name: "Wrapped Bitcoin",
|
|
304
|
+
decimals: 8,
|
|
305
|
+
symbol: "WBTC",
|
|
306
|
+
chain: e.starknet,
|
|
307
|
+
logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
|
|
308
|
+
tokenAddress: "0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",
|
|
309
|
+
atomicSwapAddress: "0x7defd8eb3b770005ab1ca5f89ad31f98fb5bc3c52deaeafd130be3b49f967b4"
|
|
310
|
+
},
|
|
311
|
+
unichain_USDC: {
|
|
312
|
+
name: "USD Coin",
|
|
313
|
+
decimals: 6,
|
|
314
|
+
symbol: "USDC",
|
|
315
|
+
chain: e.unichain,
|
|
316
|
+
logo: "https://garden-finance.imgix.net/token-images/usdc.svg",
|
|
317
|
+
tokenAddress: "0x078D782b760474a361dDA0AF3839290b0EF57AD6",
|
|
318
|
+
atomicSwapAddress: "0x795Dcb58d1cd4789169D5F938Ea05E17ecEB68cA"
|
|
319
|
+
},
|
|
320
|
+
corn_BTCN: {
|
|
321
|
+
name: "Bitcorn",
|
|
322
|
+
decimals: 18,
|
|
323
|
+
symbol: "BTCN",
|
|
324
|
+
chain: e.corn,
|
|
325
|
+
logo: "https://garden-finance.imgix.net/token-images/bitcorn.jpg",
|
|
326
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
327
|
+
atomicSwapAddress: "0xeaE7721d779276eb0f5837e2fE260118724a2Ba4"
|
|
328
|
+
},
|
|
329
|
+
botanix_BOTX: {
|
|
330
|
+
name: "Botanix",
|
|
331
|
+
decimals: 18,
|
|
332
|
+
symbol: "BTC",
|
|
333
|
+
chain: e.botanix,
|
|
334
|
+
logo: "https://garden-finance.imgix.net/chain_images/BotanixLogo.svg",
|
|
335
|
+
tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
|
|
336
|
+
atomicSwapAddress: "0x39f3294352208905fc6ebf033954E6c6455CdB4C"
|
|
337
|
+
}
|
|
17
338
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Retries a function until it succeeds or the max number of retries is reached
|
|
20
|
-
*
|
|
21
|
-
* @param {() => Promise<T>} fn - The function to retry
|
|
22
|
-
* @return {Promise<T>} a Promise that resolves to the result of the function
|
|
23
|
-
*/
|
|
24
|
-
async retry(t) {
|
|
25
|
-
let a = 0, r;
|
|
26
|
-
for (; a < this.maxRetries + 1; )
|
|
27
|
-
try {
|
|
28
|
-
return await t();
|
|
29
|
-
} catch (i) {
|
|
30
|
-
a++, r = i, await d(this.delay * a);
|
|
31
|
-
}
|
|
32
|
-
throw r;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
const v = (e) => {
|
|
36
|
-
try {
|
|
37
|
-
return JSON.parse(e);
|
|
38
|
-
} catch {
|
|
39
|
-
return e;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
class m {
|
|
43
|
-
static async _postWithFallback(t, a) {
|
|
44
|
-
let r = "";
|
|
45
|
-
for (const i of t)
|
|
46
|
-
try {
|
|
47
|
-
const s = await fetch(i, {
|
|
48
|
-
method: "POST",
|
|
49
|
-
...a
|
|
50
|
-
});
|
|
51
|
-
if (s.status >= 500) {
|
|
52
|
-
r = await (s.text() || s.json());
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
return await this.parse(s);
|
|
56
|
-
} catch (s) {
|
|
57
|
-
r = y(s);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
throw new Error(r || "All APIs failed");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Asynchronously sends a POST request to multiple URLs with fallback logic.
|
|
64
|
-
*
|
|
65
|
-
* @param {string[]} input - array of URLs to send the POST request to
|
|
66
|
-
* @param {RequestInit} [init] - optional request initialization options
|
|
67
|
-
* @return {Promise<T>} a Promise that resolves to the parsed response data
|
|
68
|
-
*/
|
|
69
|
-
static async postWithFallback(t, a) {
|
|
70
|
-
return await n(a).retry(
|
|
71
|
-
() => this._postWithFallback(t, a)
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
static async _getWithFallback(t, a) {
|
|
75
|
-
let r = "";
|
|
76
|
-
for (const i of t)
|
|
77
|
-
try {
|
|
78
|
-
const s = await fetch(i, a);
|
|
79
|
-
if (s.status >= 500) {
|
|
80
|
-
r = await (s.text() || s.json());
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
return await this.parse(s);
|
|
84
|
-
} catch (s) {
|
|
85
|
-
r = y(s);
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
throw new Error(r || "All APIs failed");
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Asynchronously sends a POST request to multiple URLs with fallback mechanism.
|
|
92
|
-
*
|
|
93
|
-
* @param {string[]} input - An array of URLs to retrieve data from.
|
|
94
|
-
* @param {RequestInit} [init] - Optional request options.
|
|
95
|
-
* @return {Promise<T>} A promise that resolves to the retrieved data.
|
|
96
|
-
*/
|
|
97
|
-
static async getWithFallback(t, a) {
|
|
98
|
-
return await n(a).retry(
|
|
99
|
-
() => this._getWithFallback(t, a)
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
static async _get(t, a) {
|
|
103
|
-
return await this.parse(await fetch(t, a));
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Asynchronously retrieves data of type T from the specified URL or RequestInfo, with optional initialization options.
|
|
107
|
-
*
|
|
108
|
-
* @param {RequestInfo | URL} input - The URL or RequestInfo to fetch data from
|
|
109
|
-
* @param {RequestInit} init - Optional initialization options for the fetch request
|
|
110
|
-
* @return {Promise<T>} The retrieved data of type T
|
|
111
|
-
*/
|
|
112
|
-
static async get(t, a) {
|
|
113
|
-
return await n(a).retry(() => this._get(t, a));
|
|
114
|
-
}
|
|
115
|
-
static async _post(t, a) {
|
|
116
|
-
return await this.parse(
|
|
117
|
-
await fetch(t, {
|
|
118
|
-
method: "POST",
|
|
119
|
-
...a
|
|
120
|
-
})
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Asynchronously sends a POST request to the specified URL or RequestInfo, with optional initialization options.
|
|
125
|
-
*/
|
|
126
|
-
static async post(t, a) {
|
|
127
|
-
return await n(a).retry(() => this._post(t, a));
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Parses the response and returns the result as the specified type.
|
|
131
|
-
*
|
|
132
|
-
* @param {Response} res - the response object to be parsed
|
|
133
|
-
* @return {Promise<T>} the parsed result of type T
|
|
134
|
-
*/
|
|
135
|
-
static async parse(t) {
|
|
136
|
-
const a = await t.text();
|
|
137
|
-
if (t.status >= 200 && t.status < 300)
|
|
138
|
-
return v(a);
|
|
139
|
-
throw new Error(a);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function y(e) {
|
|
143
|
-
return (e == null ? void 0 : e.message) || (e == null ? void 0 : e.toString()) || "unknown error";
|
|
144
|
-
}
|
|
145
|
-
const n = (e) => new g((e == null ? void 0 : e.retryCount) ?? 2, (e == null ? void 0 : e.retryDelay) ?? 1e3);
|
|
146
|
-
var o, c, l;
|
|
147
|
-
class f {
|
|
148
|
-
constructor(t, a, r = void 0) {
|
|
149
|
-
u(this, o, void 0), u(this, c, void 0), u(this, l, void 0), w(this, o, t), w(this, l, r), w(this, c, a);
|
|
150
|
-
}
|
|
151
|
-
get ok() {
|
|
152
|
-
return h(this, o);
|
|
153
|
-
}
|
|
154
|
-
get error() {
|
|
155
|
-
return h(this, l);
|
|
156
|
-
}
|
|
157
|
-
get val() {
|
|
158
|
-
return h(this, c);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
o = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap();
|
|
162
|
-
const k = (e) => new f(!0, e), W = (e, ...t) => {
|
|
163
|
-
if (typeof e == "string" && t && t.length > 0) {
|
|
164
|
-
let a = [e, ...t].map((r) => {
|
|
165
|
-
if (r) {
|
|
166
|
-
if (r instanceof Error)
|
|
167
|
-
return r.message;
|
|
168
|
-
if (typeof r == "string")
|
|
169
|
-
return r;
|
|
170
|
-
if (r != null && r.toString)
|
|
171
|
-
return r.toString();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return new f(
|
|
175
|
-
!1,
|
|
176
|
-
null,
|
|
177
|
-
a.filter((r) => r !== void 0).join(" ")
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
return new f(!1, null, e);
|
|
181
339
|
};
|
|
182
340
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
341
|
+
d as ArbitrumLocalnet,
|
|
342
|
+
n as ETHStarknetLocalnetAsset,
|
|
343
|
+
o as EthereumLocalnet,
|
|
344
|
+
s as STRKStarknetLocalnetAsset,
|
|
345
|
+
c as StarknetLocalnet,
|
|
346
|
+
r as SupportedAssets,
|
|
347
|
+
a as WBTCArbitrumLocalnetAsset,
|
|
348
|
+
t as WBTCEthereumLocalnetAsset,
|
|
349
|
+
m as bitcoinRegtestAsset
|
|
190
350
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Orderbook } from './lib/orderbook/orderbook';
|
|
2
2
|
export type * from './lib/orderbook/orderbook.types';
|
|
3
3
|
export type { Chain, EvmChain, Asset } from './lib/asset';
|
|
4
|
-
export { Chains, BlockchainType, isMainnet, isBitcoin, isEVM, isStarknet, getBlockchainType, NetworkType, NativeTokenAddress, isEvmNativeToken, } from './lib/asset';
|
|
4
|
+
export { Chains, BlockchainType, isMainnet, isBitcoin, isEVM, isStarknet, getBlockchainType, NetworkType, TimeLocks, getTimeLock, NativeTokenAddress, isEvmNativeToken, } from './lib/asset';
|
|
5
|
+
export { OrdersProvider } from './lib/orders/ordersProvider';
|
|
6
|
+
export type { IOrderProvider } from './lib/orders/orders.types';
|
|
5
7
|
export { WBTCArbitrumLocalnetAsset, WBTCEthereumLocalnetAsset, ArbitrumLocalnet, EthereumLocalnet, bitcoinRegtestAsset, SupportedAssets, StarknetLocalnet, STRKStarknetLocalnetAsset, } from './lib/constants';
|
package/dist/src/lib/asset.d.ts
CHANGED
|
@@ -61,6 +61,8 @@ export declare const isMainnet: (chain: Chain) => chain is "bitcoin" | "ethereum
|
|
|
61
61
|
export declare const isBitcoin: (chain: Chain) => chain is "bitcoin" | "bitcoin_testnet" | "bitcoin_regtest";
|
|
62
62
|
export declare const isEVM: (chain: Chain) => chain is "ethereum" | "base" | "arbitrum" | "ethereum_sepolia" | "arbitrum_localnet" | "arbitrum_sepolia" | "ethereum_localnet" | "base_sepolia" | "bera_testnet" | "citrea_testnet" | "bera" | "monad_testnet" | "hyperliquid_testnet" | "hyperliquid" | "unichain" | "corn" | "botanix";
|
|
63
63
|
export declare const isStarknet: (chain: Chain) => chain is "starknet" | "starknet_sepolia" | "starknet_devnet";
|
|
64
|
+
export declare const TimeLocks: Record<Chain, number>;
|
|
64
65
|
export declare const getBlockchainType: (chain: Chain) => BlockchainType;
|
|
66
|
+
export declare const getTimeLock: (chain: Chain) => number;
|
|
65
67
|
export declare const NativeTokenAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
66
68
|
export declare const isEvmNativeToken: (chain: Chain, tokenAddress: string) => boolean;
|
|
@@ -41,7 +41,7 @@ export declare const SupportedAssets: {
|
|
|
41
41
|
readonly logo: "https://garden-finance.imgix.net/token-images/wbtc.svg";
|
|
42
42
|
readonly chain: "arbitrum_sepolia";
|
|
43
43
|
readonly tokenAddress: "0x00ab86f54F436CfE15253845F139955ae0C00bAf";
|
|
44
|
-
readonly atomicSwapAddress: "
|
|
44
|
+
readonly atomicSwapAddress: "0xE918A5a47b8e0AFAC2382bC5D1e981613e63fB07";
|
|
45
45
|
};
|
|
46
46
|
readonly arbitrum_sepolia_SEED: {
|
|
47
47
|
readonly name: "Seed";
|
|
@@ -50,7 +50,7 @@ export declare const SupportedAssets: {
|
|
|
50
50
|
readonly chain: "arbitrum_sepolia";
|
|
51
51
|
readonly logo: "https://garden-finance.imgix.net/token-images/seed.svg";
|
|
52
52
|
readonly tokenAddress: "0x13DCec0762EcC5E666c207ab44Dc768e5e33070F";
|
|
53
|
-
readonly atomicSwapAddress: "
|
|
53
|
+
readonly atomicSwapAddress: "0xB47716a220C319b25a532594511D63EC68702CEf";
|
|
54
54
|
};
|
|
55
55
|
readonly arbitrum_sepolia_iBTC: {
|
|
56
56
|
readonly name: "iBTC";
|
|
@@ -58,8 +58,8 @@ export declare const SupportedAssets: {
|
|
|
58
58
|
readonly symbol: "iBTC";
|
|
59
59
|
readonly chain: "arbitrum_sepolia";
|
|
60
60
|
readonly logo: "https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg";
|
|
61
|
-
readonly tokenAddress: "
|
|
62
|
-
readonly atomicSwapAddress: "
|
|
61
|
+
readonly tokenAddress: "0x685437f025c5f33A94818408C286bc1F023201Fc";
|
|
62
|
+
readonly atomicSwapAddress: "0x88e1032252c712681A3659986F452E910D2134D8";
|
|
63
63
|
};
|
|
64
64
|
readonly base_sepolia_WBTC: {
|
|
65
65
|
readonly name: "Wrapped Bitcoin";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IAuth, Url } from '@gardenfi/utils';
|
|
1
|
+
import { CreateOrder, CreateOrderRequestWithAdditionalData, IOrderbook, MatchedOrder, PaginatedData, PaginationConfig, Status } from './orderbook.types';
|
|
2
|
+
import { AsyncResult, IAuth, Url } from '@gardenfi/utils';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* A class that allows you to create and manage orders with the orderbook url.
|
|
@@ -16,7 +15,7 @@ export declare class Orderbook implements IOrderbook {
|
|
|
16
15
|
* @param {IAuth} auth - The auth object.
|
|
17
16
|
* @returns {string} The create order ID.
|
|
18
17
|
*/
|
|
19
|
-
createOrder(order:
|
|
18
|
+
createOrder(order: CreateOrderRequestWithAdditionalData, auth: IAuth): AsyncResult<string, string>;
|
|
20
19
|
getOrder<T extends boolean>(id: string, matched: T): AsyncResult<T extends true ? MatchedOrder : CreateOrder, string>;
|
|
21
20
|
getMatchedOrders(address: string, status: Status, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<MatchedOrder>, string>;
|
|
22
21
|
getUnMatchedOrders(address: string, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<CreateOrder>, string>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { AsyncResult } from '@
|
|
2
|
-
import { APIResponse, IAuth, IStore } from '@gardenfi/utils';
|
|
1
|
+
import { APIResponse, AsyncResult, IAuth, IStore } from '@gardenfi/utils';
|
|
3
2
|
import { Asset, Chain } from '../asset';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -89,7 +88,7 @@ export interface IOrderbook {
|
|
|
89
88
|
* @param {CreateOrderConfig} orderConfig - The configuration for the creating the order.
|
|
90
89
|
* @returns {number} The create order ID.
|
|
91
90
|
*/
|
|
92
|
-
createOrder(order:
|
|
91
|
+
createOrder(order: CreateOrderRequestWithAdditionalData, auth: IAuth): AsyncResult<string, string>;
|
|
93
92
|
/**
|
|
94
93
|
* Get the order from orderbook based on provided Id and match status.
|
|
95
94
|
* @param id - The create Id of the order
|
|
@@ -192,18 +191,18 @@ export type CreateOrderRequest = {
|
|
|
192
191
|
destination_chain: string;
|
|
193
192
|
source_asset: string;
|
|
194
193
|
destination_asset: string;
|
|
194
|
+
initiator_source_address: string;
|
|
195
|
+
initiator_destination_address: string;
|
|
195
196
|
source_amount: string;
|
|
196
197
|
destination_amount: string;
|
|
198
|
+
fee: string;
|
|
197
199
|
nonce: string;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
secret_hash
|
|
200
|
+
min_destination_confirmations: number;
|
|
201
|
+
timelock: number;
|
|
202
|
+
secret_hash: string;
|
|
201
203
|
};
|
|
202
204
|
export type CreateOrderRequestWithAdditionalData = CreateOrderRequest & AdditionalData & AffiliateFeeList<AffiliateFeeWithAmount>;
|
|
203
205
|
export type CreateOrder = CreateOrderRequestWithAdditionalData & {
|
|
204
|
-
fee: string;
|
|
205
|
-
min_destination_confirmations: number;
|
|
206
|
-
timelock: number;
|
|
207
206
|
created_at: string;
|
|
208
207
|
updated_at: string;
|
|
209
208
|
deleted_at: string | null;
|
|
@@ -247,7 +246,7 @@ export type PaginatedData<T> = {
|
|
|
247
246
|
total_items: number;
|
|
248
247
|
per_page: number;
|
|
249
248
|
};
|
|
250
|
-
export type CreateOrderResponse = APIResponse<
|
|
249
|
+
export type CreateOrderResponse = APIResponse<string>;
|
|
251
250
|
export type PaginationConfig = {
|
|
252
251
|
page?: number;
|
|
253
252
|
per_page?: number;
|