@strkfarm/sdk 1.1.69 → 2.0.0-dev.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/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +66861 -59746
- package/dist/index.browser.mjs +24970 -18579
- package/dist/index.d.ts +1969 -776
- package/dist/index.js +25259 -18845
- package/dist/index.mjs +25464 -19090
- package/package.json +80 -76
- package/src/data/extended-deposit.abi.json +3613 -0
- package/src/data/universal-vault.abi.json +135 -20
- package/src/dataTypes/address.ts +8 -1
- package/src/global.ts +240 -193
- package/src/interfaces/common.tsx +26 -2
- package/src/modules/ExtendedWrapperSDk/index.ts +62 -0
- package/src/modules/ExtendedWrapperSDk/types.ts +311 -0
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +395 -0
- package/src/modules/avnu.ts +17 -4
- package/src/modules/ekubo-quoter.ts +99 -11
- package/src/modules/erc20.ts +67 -21
- package/src/modules/harvests.ts +16 -29
- package/src/modules/index.ts +5 -1
- package/src/modules/lst-apr.ts +36 -0
- package/src/modules/midas.ts +159 -0
- package/src/modules/pricer-from-api.ts +2 -2
- package/src/modules/pricer.ts +3 -38
- package/src/modules/token-market-data.ts +202 -0
- package/src/node/deployer.ts +1 -36
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +20 -3
- package/src/strategies/ekubo-cl-vault.tsx +123 -306
- package/src/strategies/index.ts +4 -1
- package/src/strategies/svk-strategy.ts +247 -0
- package/src/strategies/universal-adapters/adapter-optimizer.ts +65 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +5 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +418 -0
- package/src/strategies/universal-adapters/baseAdapter.ts +181 -153
- package/src/strategies/universal-adapters/common-adapter.ts +98 -77
- package/src/strategies/universal-adapters/extended-adapter.ts +544 -0
- package/src/strategies/universal-adapters/index.ts +5 -1
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +220 -218
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +924 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
- package/src/strategies/universal-lst-muliplier-strategy.tsx +707 -774
- package/src/strategies/universal-strategy.tsx +1098 -1180
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +28 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +48 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +374 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +992 -0
- package/src/strategies/vesu-rebalance.tsx +16 -19
- package/src/utils/health-factor-math.ts +11 -5
package/src/global.ts
CHANGED
|
@@ -1,275 +1,322 @@
|
|
|
1
|
-
import axios from
|
|
2
|
-
import { TokenInfo } from
|
|
3
|
-
import { ContractAddr } from
|
|
4
|
-
import { logger } from
|
|
5
|
-
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { TokenInfo } from "./interfaces";
|
|
3
|
+
import { ContractAddr } from "./dataTypes";
|
|
4
|
+
import { logger } from "@/utils/logger";
|
|
6
5
|
|
|
7
6
|
export class FatalError extends Error {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
constructor(message: string, err?: Error) {
|
|
8
|
+
super(message);
|
|
9
|
+
logger.error(message);
|
|
10
|
+
if (err) logger.error(err.message);
|
|
11
|
+
this.name = "FatalError";
|
|
12
|
+
}
|
|
15
13
|
}
|
|
16
14
|
|
|
17
|
-
const defaultTokens: TokenInfo[] = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const defaultTokens: TokenInfo[] = [
|
|
16
|
+
{
|
|
17
|
+
name: "Starknet",
|
|
18
|
+
symbol: "STRK",
|
|
19
|
+
logo: "https://assets.troves.fi/integrations/tokens/strk.svg",
|
|
20
|
+
address: ContractAddr.from(
|
|
21
|
+
"0x4718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
|
|
22
|
+
),
|
|
22
23
|
decimals: 18,
|
|
23
|
-
coingeckId:
|
|
24
|
+
coingeckId: "starknet",
|
|
24
25
|
displayDecimals: 2,
|
|
25
|
-
priceCheckAmount: 1000,
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
priceCheckAmount: 1000,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "xSTRK",
|
|
30
|
+
symbol: "xSTRK",
|
|
31
|
+
logo: "https://assets.troves.fi/integrations/tokens/xstrk.svg",
|
|
32
|
+
address: ContractAddr.from(
|
|
33
|
+
"0x028d709c875c0ceac3dce7065bec5328186dc89fe254527084d1689910954b0a"
|
|
34
|
+
),
|
|
31
35
|
decimals: 18,
|
|
32
36
|
coingeckId: undefined,
|
|
33
|
-
priceCheckAmount: 1000,
|
|
37
|
+
priceCheckAmount: 1000,
|
|
34
38
|
displayDecimals: 2,
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "ETH",
|
|
42
|
+
symbol: "ETH",
|
|
43
|
+
logo: "https://assets.troves.fi/integrations/tokens/eth.svg",
|
|
44
|
+
address: ContractAddr.from(
|
|
45
|
+
"0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
|
|
46
|
+
),
|
|
40
47
|
decimals: 18,
|
|
41
48
|
coingeckId: undefined,
|
|
42
|
-
priceCheckAmount: 0.1,
|
|
49
|
+
priceCheckAmount: 0.1,
|
|
43
50
|
displayDecimals: 6,
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
priceCheckAmount: 1000,
|
|
53
|
-
}, {
|
|
54
|
-
name: 'USDC',
|
|
55
|
-
symbol: 'USDC',
|
|
56
|
-
logo: 'https://assets.troves.fi/integrations/tokens/usdc.svg',
|
|
57
|
-
address: ContractAddr.from('0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb'),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "USDCe",
|
|
54
|
+
symbol: "USDCe",
|
|
55
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
56
|
+
address: ContractAddr.from(
|
|
57
|
+
"0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8"
|
|
58
|
+
),
|
|
58
59
|
decimals: 6,
|
|
59
60
|
coingeckId: undefined,
|
|
60
61
|
displayDecimals: 2,
|
|
61
62
|
priceCheckAmount: 1000,
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "USDT",
|
|
66
|
+
symbol: "USDT",
|
|
67
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdt.svg",
|
|
68
|
+
address: ContractAddr.from(
|
|
69
|
+
"0x68f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8"
|
|
70
|
+
),
|
|
67
71
|
decimals: 6,
|
|
68
72
|
coingeckId: undefined,
|
|
69
73
|
priceCheckAmount: 1000,
|
|
70
74
|
displayDecimals: 2,
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "WBTC",
|
|
78
|
+
symbol: "WBTC",
|
|
79
|
+
logo: "https://assets.troves.fi/integrations/tokens/wbtc.svg",
|
|
80
|
+
address: ContractAddr.from(
|
|
81
|
+
"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac"
|
|
82
|
+
),
|
|
76
83
|
decimals: 8,
|
|
77
84
|
coingeckId: undefined,
|
|
78
85
|
displayDecimals: 6,
|
|
79
86
|
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "tBTC",
|
|
90
|
+
symbol: "tBTC",
|
|
91
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/tbtc.svg",
|
|
92
|
+
address: ContractAddr.from(
|
|
93
|
+
"0x4daa17763b286d1e59b97c283c0b8c949994c361e426a28f743c67bdfe9a32f"
|
|
94
|
+
),
|
|
85
95
|
decimals: 18,
|
|
86
96
|
coingeckId: undefined,
|
|
87
97
|
displayDecimals: 6,
|
|
88
98
|
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "solvBTC",
|
|
102
|
+
symbol: "solvBTC",
|
|
103
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/solvbtc.svg",
|
|
104
|
+
address: ContractAddr.from(
|
|
105
|
+
"0x0593e034dda23eea82d2ba9a30960ed42cf4a01502cc2351dc9b9881f9931a68"
|
|
106
|
+
),
|
|
94
107
|
decimals: 18,
|
|
95
108
|
coingeckId: undefined,
|
|
96
|
-
priceProxySymbol:
|
|
109
|
+
priceProxySymbol: "WBTC",
|
|
97
110
|
displayDecimals: 6,
|
|
98
111
|
priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "LBTC",
|
|
115
|
+
symbol: "LBTC",
|
|
116
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/lbtc.svg",
|
|
117
|
+
address: ContractAddr.from(
|
|
118
|
+
"0x036834a40984312f7f7de8d31e3f6305b325389eaeea5b1c0664b2fb936461a4"
|
|
119
|
+
),
|
|
104
120
|
decimals: 8,
|
|
105
121
|
coingeckId: undefined,
|
|
106
122
|
displayDecimals: 6,
|
|
107
|
-
priceProxySymbol:
|
|
123
|
+
priceProxySymbol: "WBTC",
|
|
108
124
|
priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "xWBTC",
|
|
128
|
+
symbol: "xWBTC",
|
|
129
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xwbtc.svg",
|
|
130
|
+
address: ContractAddr.from(
|
|
131
|
+
"0x6a567e68c805323525fe1649adb80b03cddf92c23d2629a6779f54192dffc13"
|
|
132
|
+
),
|
|
114
133
|
decimals: 8,
|
|
115
134
|
coingeckId: undefined,
|
|
116
135
|
displayDecimals: 6,
|
|
117
|
-
priceProxySymbol: 'WBTC',
|
|
118
136
|
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "xsBTC",
|
|
140
|
+
symbol: "xsBTC",
|
|
141
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xsbtc_solv.svg",
|
|
142
|
+
address: ContractAddr.from(
|
|
143
|
+
"0x580f3dc564a7b82f21d40d404b3842d490ae7205e6ac07b1b7af2b4a5183dc9"
|
|
144
|
+
),
|
|
124
145
|
decimals: 18,
|
|
125
146
|
coingeckId: undefined,
|
|
126
147
|
displayDecimals: 6,
|
|
127
|
-
priceProxySymbol:
|
|
148
|
+
priceProxySymbol: "WBTC",
|
|
128
149
|
priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
|
|
129
|
-
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
130
152
|
// todo upgrade proxy tokens once feeds are available
|
|
131
|
-
name:
|
|
132
|
-
symbol:
|
|
133
|
-
logo:
|
|
134
|
-
address: ContractAddr.from(
|
|
153
|
+
name: "xtBTC",
|
|
154
|
+
symbol: "xtBTC",
|
|
155
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xtbtc.svg",
|
|
156
|
+
address: ContractAddr.from(
|
|
157
|
+
"0x43a35c1425a0125ef8c171f1a75c6f31ef8648edcc8324b55ce1917db3f9b91"
|
|
158
|
+
),
|
|
135
159
|
decimals: 18,
|
|
136
160
|
coingeckId: undefined,
|
|
137
161
|
displayDecimals: 6,
|
|
138
162
|
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
name:
|
|
142
|
-
symbol:
|
|
143
|
-
logo:
|
|
144
|
-
address: ContractAddr.from(
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "xLBTC",
|
|
166
|
+
symbol: "xLBTC",
|
|
167
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/xlbtc.svg",
|
|
168
|
+
address: ContractAddr.from(
|
|
169
|
+
"0x07dd3c80de9fcc5545f0cb83678826819c79619ed7992cc06ff81fc67cd2efe0"
|
|
170
|
+
),
|
|
145
171
|
decimals: 8,
|
|
146
172
|
coingeckId: undefined,
|
|
147
173
|
displayDecimals: 6,
|
|
148
|
-
priceProxySymbol:
|
|
174
|
+
priceProxySymbol: "WBTC",
|
|
149
175
|
priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "mRe7BTC",
|
|
179
|
+
symbol: "mRe7BTC",
|
|
180
|
+
logo: "https://imagedelivery.net/0xPAQaDtnQhBs8IzYRIlNg/3a62ecee-1e58-45d3-9862-3ce90dff1900/logo",
|
|
181
|
+
address: ContractAddr.from(
|
|
182
|
+
"0x4e4fb1a9ca7e84bae609b9dc0078ad7719e49187ae7e425bb47d131710eddac"
|
|
183
|
+
),
|
|
155
184
|
decimals: 18,
|
|
156
185
|
coingeckId: undefined,
|
|
157
186
|
displayDecimals: 6,
|
|
158
187
|
priceCheckAmount: 0.0001, // 112000 * 0.0001 = $11.2
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "mRe7YIELD",
|
|
191
|
+
symbol: "mRe7YIELD",
|
|
192
|
+
logo: "https://midas.app/assets/mre7-BcOOHm7i.svg",
|
|
193
|
+
address: ContractAddr.from(
|
|
194
|
+
"0x4be8945e61dc3e19ebadd1579a6bd53b262f51ba89e6f8b0c4bc9a7e3c633fc"
|
|
195
|
+
),
|
|
164
196
|
decimals: 18,
|
|
165
197
|
coingeckId: undefined,
|
|
166
198
|
displayDecimals: 2,
|
|
167
199
|
priceCheckAmount: 100,
|
|
168
|
-
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "USDC",
|
|
203
|
+
symbol: "USDC",
|
|
204
|
+
logo: "https://assets.troves.fi/integrations/tokens/usdc.svg",
|
|
205
|
+
address: ContractAddr.from(
|
|
206
|
+
"0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb"
|
|
207
|
+
),
|
|
208
|
+
decimals: 6,
|
|
209
|
+
coingeckId: undefined,
|
|
210
|
+
displayDecimals: 2,
|
|
211
|
+
priceCheckAmount: 100,
|
|
212
|
+
},
|
|
213
|
+
];
|
|
169
214
|
const tokens: TokenInfo[] = defaultTokens;
|
|
170
215
|
|
|
171
|
-
/** Contains globally useful functions.
|
|
216
|
+
/** Contains globally useful functions.
|
|
172
217
|
* - fatalError: Things to do when a fatal error occurs
|
|
173
218
|
*/
|
|
174
219
|
export class Global {
|
|
175
|
-
|
|
220
|
+
static cache: Record<string, { value: any; ttl: number; timestamp: number }> =
|
|
221
|
+
{};
|
|
176
222
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
223
|
+
static fatalError(message: string, err?: Error) {
|
|
224
|
+
logger.error(message);
|
|
225
|
+
console.error(message, err);
|
|
226
|
+
if (err) console.error(err);
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
184
229
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
230
|
+
static httpError(url: string, err: Error, message?: string) {
|
|
231
|
+
logger.error(`${url}: ${message}`);
|
|
232
|
+
console.error(err);
|
|
233
|
+
}
|
|
189
234
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
235
|
+
static getDefaultTokens() {
|
|
236
|
+
return tokens;
|
|
237
|
+
}
|
|
193
238
|
|
|
194
|
-
|
|
195
|
-
|
|
239
|
+
static async getTokens(): Promise<TokenInfo[]> {
|
|
240
|
+
if (tokens.length) return tokens;
|
|
196
241
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
242
|
+
// fetch from avnu API
|
|
243
|
+
const data = await axios.get(
|
|
244
|
+
"https://assets.troves.fi/integrations/tokens.json"
|
|
245
|
+
);
|
|
246
|
+
const tokensData = data.data.content;
|
|
200
247
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
248
|
+
// Array of the following is returned
|
|
249
|
+
// {
|
|
250
|
+
// "name": "USD Coin",
|
|
251
|
+
// "address": "0x53c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
|
|
252
|
+
// "symbol": "USDC",
|
|
253
|
+
// "decimals": 6,
|
|
254
|
+
// "logoUri": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
|
|
255
|
+
// "lastDailyVolumeUsd": 2964287916.82621,
|
|
256
|
+
// "extensions": {
|
|
257
|
+
// "coingeckoId": "usd-coin"
|
|
258
|
+
// },
|
|
259
|
+
// "tags": [
|
|
260
|
+
// "AVNU",
|
|
261
|
+
// "Verified"
|
|
262
|
+
// ]
|
|
263
|
+
// }
|
|
217
264
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
265
|
+
tokensData.forEach((token: any) => {
|
|
266
|
+
// if tags do not contain Avnu and verified, ignore
|
|
267
|
+
// This would exclude meme coins for now
|
|
268
|
+
if (!token.tags.includes("AVNU") || !token.tags.includes("Verified")) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
224
271
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
272
|
+
tokens.push({
|
|
273
|
+
name: token.name,
|
|
274
|
+
symbol: token.symbol,
|
|
275
|
+
address: ContractAddr.from(token.address),
|
|
276
|
+
decimals: token.decimals,
|
|
277
|
+
logo: token.logoUri,
|
|
278
|
+
coingeckId: token.extensions.coingeckoId,
|
|
279
|
+
displayDecimals: 2,
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
console.log(tokens);
|
|
283
|
+
return tokens;
|
|
284
|
+
}
|
|
238
285
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
286
|
+
static assert(condition: any, message: string) {
|
|
287
|
+
if (!condition) {
|
|
288
|
+
throw new FatalError(message);
|
|
243
289
|
}
|
|
290
|
+
}
|
|
244
291
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
const token = tokens.find((token) => addr.eq(token.address));
|
|
252
|
-
if (!token) {
|
|
253
|
-
throw new FatalError(`Token not found: ${addr.address}`);
|
|
254
|
-
}
|
|
255
|
-
return token;
|
|
292
|
+
static async getTokenInfoFromAddr(addr: ContractAddr) {
|
|
293
|
+
// if tokens are not loaded, load them
|
|
294
|
+
if (tokens.length == defaultTokens.length) {
|
|
295
|
+
await Global.getTokens();
|
|
256
296
|
}
|
|
257
297
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
ttl,
|
|
262
|
-
timestamp: Date.now()
|
|
263
|
-
};
|
|
298
|
+
const token = tokens.find((token) => addr.eq(token.address));
|
|
299
|
+
if (!token) {
|
|
300
|
+
throw new FatalError(`Token not found: ${addr.address}`);
|
|
264
301
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
302
|
+
return token;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
static setGlobalCache(key: string, data: any, ttl: number = 60000) {
|
|
306
|
+
Global.cache[key] = {
|
|
307
|
+
value: data,
|
|
308
|
+
ttl,
|
|
309
|
+
timestamp: Date.now(),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
static getGlobalCache<T>(key: string): T | null {
|
|
314
|
+
const cached = Global.cache[key];
|
|
315
|
+
if (!cached) return null;
|
|
316
|
+
if (Date.now() - cached.timestamp > cached.ttl) {
|
|
317
|
+
delete Global.cache[key];
|
|
318
|
+
return null;
|
|
274
319
|
}
|
|
320
|
+
return cached.value;
|
|
321
|
+
}
|
|
275
322
|
}
|
|
@@ -211,7 +211,8 @@ export interface VaultPosition {
|
|
|
211
211
|
amount: Web3Number,
|
|
212
212
|
usdValue: number,
|
|
213
213
|
token: TokenInfo,
|
|
214
|
-
remarks: string
|
|
214
|
+
remarks: string,
|
|
215
|
+
protocol: IProtocol
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
const VesuProtocol: IProtocol = {
|
|
@@ -219,6 +220,11 @@ const VesuProtocol: IProtocol = {
|
|
|
219
220
|
logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
|
|
220
221
|
};
|
|
221
222
|
|
|
223
|
+
const AvnuProtocol: IProtocol = {
|
|
224
|
+
name: "Avnu",
|
|
225
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/avnu/logo.png"
|
|
226
|
+
}
|
|
227
|
+
|
|
222
228
|
const EndurProtocol: IProtocol = {
|
|
223
229
|
name: "Endur",
|
|
224
230
|
logo: "http://endur.fi/logo.png"
|
|
@@ -229,8 +235,26 @@ const ExtendedProtocol: IProtocol = {
|
|
|
229
235
|
logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
|
|
230
236
|
};
|
|
231
237
|
|
|
238
|
+
const EkuboProtocol: IProtocol = {
|
|
239
|
+
name: "Ekubo",
|
|
240
|
+
logo: "https://app.ekubo.org/favicon.ico"
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const NoneProtocol: IProtocol = {
|
|
244
|
+
name: "-",
|
|
245
|
+
logo: ""
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const VaultProtocol: IProtocol = {
|
|
249
|
+
name: "Vault",
|
|
250
|
+
logo: ""
|
|
251
|
+
}
|
|
232
252
|
export const Protocols = {
|
|
253
|
+
NONE: NoneProtocol,
|
|
233
254
|
VESU: VesuProtocol,
|
|
234
255
|
ENDUR: EndurProtocol,
|
|
235
|
-
EXTENDED: ExtendedProtocol
|
|
256
|
+
EXTENDED: ExtendedProtocol,
|
|
257
|
+
EKUBO: EkuboProtocol,
|
|
258
|
+
AVNU: AvnuProtocol,
|
|
259
|
+
VAULT: VaultProtocol
|
|
236
260
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extended Exchange TypeScript SDK
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive TypeScript wrapper for the Extended Exchange trading API.
|
|
5
|
+
* Provides type-safe access to all trading operations including orders, positions,
|
|
6
|
+
* balances, markets, and asset operations.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { ExtendedWrapper } from './ts';
|
|
11
|
+
*
|
|
12
|
+
* const client = new ExtendedWrapper({
|
|
13
|
+
* baseUrl: 'http://localhost:8000',
|
|
14
|
+
* apiKey: 'your-api-key'
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Create a buy order
|
|
18
|
+
* const order = await client.createBuyOrder('BTC-USD', '0.1', '50000');
|
|
19
|
+
*
|
|
20
|
+
* // Get positions
|
|
21
|
+
* const positions = await client.getPositions();
|
|
22
|
+
*
|
|
23
|
+
* // Get balance
|
|
24
|
+
* const balance = await client.getHoldings();
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export { ExtendedWrapper } from "./wrapper";
|
|
29
|
+
export { default } from "./wrapper";
|
|
30
|
+
|
|
31
|
+
// Export all types
|
|
32
|
+
export * from "./types";
|
|
33
|
+
|
|
34
|
+
// Re-export commonly used types for convenience
|
|
35
|
+
export type {
|
|
36
|
+
CreateOrderRequest,
|
|
37
|
+
WithdrawRequest,
|
|
38
|
+
SignedWithdrawRequest,
|
|
39
|
+
CancelOrderRequest,
|
|
40
|
+
PlacedOrder,
|
|
41
|
+
OpenOrder,
|
|
42
|
+
Position,
|
|
43
|
+
Balance,
|
|
44
|
+
Market,
|
|
45
|
+
MarketStats,
|
|
46
|
+
AssetOperation,
|
|
47
|
+
ExtendedApiResponse,
|
|
48
|
+
ExtendedWrapperConfig,
|
|
49
|
+
} from "./types";
|
|
50
|
+
|
|
51
|
+
// Re-export enums for convenience
|
|
52
|
+
export {
|
|
53
|
+
OrderSide,
|
|
54
|
+
TimeInForce,
|
|
55
|
+
OrderType,
|
|
56
|
+
OrderStatus,
|
|
57
|
+
OrderStatusReason,
|
|
58
|
+
PositionSide,
|
|
59
|
+
ExitType,
|
|
60
|
+
AssetOperationType,
|
|
61
|
+
AssetOperationStatus,
|
|
62
|
+
} from "./types";
|