@strkfarm/sdk 2.0.0-dev.9 → 2.0.0-staging.2
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.browser.global.js +111371 -93151
- package/dist/index.browser.mjs +27815 -32690
- package/dist/index.d.ts +1095 -2011
- package/dist/index.js +27425 -32309
- package/dist/index.mjs +27590 -32452
- package/package.json +6 -5
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/data/universal-vault.abi.json +20 -135
- package/src/dataTypes/address.ts +0 -7
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +296 -288
- package/src/index.browser.ts +6 -5
- package/src/interfaces/common.tsx +324 -184
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -17
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +11 -88
- package/src/modules/erc20.ts +21 -67
- package/src/modules/harvests.ts +26 -15
- package/src/modules/index.ts +11 -13
- package/src/modules/lst-apr.ts +0 -36
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +150 -14
- package/src/modules/pricer.ts +2 -1
- package/src/modules/pricerBase.ts +2 -1
- package/src/node/deployer.ts +36 -1
- package/src/node/pricer-redis.ts +2 -1
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/base-strategy.ts +5 -22
- package/src/strategies/ekubo-cl-vault.tsx +2904 -2175
- package/src/strategies/factory.ts +165 -0
- package/src/strategies/index.ts +10 -11
- package/src/strategies/registry.ts +268 -0
- package/src/strategies/sensei.ts +416 -292
- package/src/strategies/universal-adapters/adapter-utils.ts +1 -5
- package/src/strategies/universal-adapters/baseAdapter.ts +153 -181
- package/src/strategies/universal-adapters/common-adapter.ts +77 -98
- package/src/strategies/universal-adapters/index.ts +1 -5
- package/src/strategies/universal-adapters/vesu-adapter.ts +218 -220
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +51 -58
- package/src/strategies/universal-lst-muliplier-strategy.tsx +1952 -992
- package/src/strategies/universal-strategy.tsx +1713 -1150
- package/src/strategies/vesu-rebalance.tsx +1189 -986
- package/src/utils/health-factor-math.ts +5 -11
- package/src/utils/index.ts +8 -9
- package/src/utils/strategy-utils.ts +57 -0
- package/src/data/extended-deposit.abi.json +0 -3613
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -311
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -395
- package/src/modules/midas.ts +0 -159
- package/src/modules/token-market-data.ts +0 -202
- package/src/strategies/svk-strategy.ts +0 -247
- package/src/strategies/universal-adapters/adapter-optimizer.ts +0 -65
- package/src/strategies/universal-adapters/avnu-adapter.ts +0 -413
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -972
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +0 -1306
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -34
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -77
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -49
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -370
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1379
|
@@ -3,258 +3,398 @@ import { BlockIdentifier, BlockTag, constants, RpcProvider } from "starknet";
|
|
|
3
3
|
import React, { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
export enum RiskType {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
MARKET_RISK = "Market Risk",
|
|
7
|
+
// if non-correalted pairs, this is 3 (STRK/USDC)
|
|
8
|
+
// if highly correalted pairs, this is 1 (e.g. xSTRK/STRK)
|
|
9
|
+
// if correalted pairs, this is 2 (e.g. BTC/SOL)
|
|
10
|
+
// If there is added leverage on top, can go till 5
|
|
11
|
+
IMPERMANENT_LOSS = "Impermanent Loss Risk",
|
|
12
|
+
LIQUIDATION_RISK = "Liquidation Risk",
|
|
13
|
+
LOW_LIQUIDITY_RISK = "Low Liquidity Risk",
|
|
14
|
+
SMART_CONTRACT_RISK = "Smart Contract Risk",
|
|
15
|
+
ORACLE_RISK = "Oracle Risk",
|
|
16
|
+
TECHNICAL_RISK = "Technical Risk",
|
|
17
|
+
COUNTERPARTY_RISK = "Counterparty Risk", // e.g. bad debt
|
|
18
|
+
DEPEG_RISK = "Depeg Risk" // e.g. USDC depeg
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface RiskFactor {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
type: RiskType;
|
|
23
|
+
value: number; // 0 to 5
|
|
24
|
+
weight: number; // 0 to 100
|
|
25
|
+
reason?: string; // optional reason for the risk factor
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface TokenInfo {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
name: string;
|
|
30
|
+
symbol: string;
|
|
31
|
+
address: ContractAddr;
|
|
32
|
+
decimals: number;
|
|
33
|
+
logo: string;
|
|
34
|
+
coingeckId?: string;
|
|
35
|
+
displayDecimals: number;
|
|
36
|
+
priceProxySymbol?: string; // for tokens like illiquid tokens, we use a proxy symbol to get the price
|
|
37
|
+
priceCheckAmount?: number; // for tokens like BTC, doing 1BTC price check may not be ideal, esp on illiquid netwrks like sn
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export enum Network {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
mainnet = "mainnet",
|
|
42
|
+
sepolia = "sepolia",
|
|
43
|
+
devnet = "devnet"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface IConfig {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
provider: RpcProvider;
|
|
48
|
+
network: Network;
|
|
49
|
+
stage: "production" | "staging";
|
|
50
|
+
heartbeatUrl?: string;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface IProtocol {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
name: string;
|
|
55
|
+
logo: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Strategy-level enums
|
|
59
|
+
export enum StrategyCategory {
|
|
60
|
+
ALL = "all",
|
|
61
|
+
BTC = "btc",
|
|
62
|
+
META_VAULTS = "meta-vaults"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Security metadata enums
|
|
66
|
+
export enum AuditStatus {
|
|
67
|
+
AUDITED = "Audited",
|
|
68
|
+
NOT_AUDITED = "Not Audited"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export enum SourceCodeType {
|
|
72
|
+
OPEN_SOURCE = "Open Source",
|
|
73
|
+
CLOSED_SOURCE = "Closed Source"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export enum AccessControlType {
|
|
77
|
+
MULTISIG_ACCOUNT = "Multisig Account",
|
|
78
|
+
STANDARD_ACCOUNT = "Standard Account"
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export enum InstantWithdrawalVault {
|
|
82
|
+
YES = "Yes",
|
|
83
|
+
NO = "No"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Security metadata interfaces
|
|
87
|
+
export interface SourceCodeInfo {
|
|
88
|
+
type: SourceCodeType;
|
|
89
|
+
contractLink: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface AccessControlInfo {
|
|
93
|
+
type: AccessControlType;
|
|
94
|
+
addresses: ContractAddr[];
|
|
95
|
+
timeLock: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface SecurityMetadata {
|
|
99
|
+
auditStatus: AuditStatus;
|
|
100
|
+
sourceCode: SourceCodeInfo;
|
|
101
|
+
accessControl: AccessControlInfo;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Redemption metadata interfaces
|
|
105
|
+
export interface RedemptionExpectedTime {
|
|
106
|
+
upto1M: string;
|
|
107
|
+
upto10M: string;
|
|
108
|
+
above10M: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface RedemptionInfo {
|
|
112
|
+
instantWithdrawalVault: InstantWithdrawalVault;
|
|
113
|
+
expectedRedemptionTime?: RedemptionExpectedTime;
|
|
56
114
|
}
|
|
57
115
|
|
|
58
116
|
export enum FlowChartColors {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
117
|
+
Green = "purple",
|
|
118
|
+
Blue = "#35484f",
|
|
119
|
+
Purple = "#6e53dc"
|
|
62
120
|
}
|
|
63
121
|
|
|
64
122
|
export interface FAQ {
|
|
65
|
-
|
|
66
|
-
|
|
123
|
+
question: string | React.ReactNode;
|
|
124
|
+
answer: string | React.ReactNode;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Strategy Live Status - indicates the current state of a strategy
|
|
129
|
+
*/
|
|
130
|
+
export enum StrategyLiveStatus {
|
|
131
|
+
ACTIVE = "Active",
|
|
132
|
+
NEW = "New",
|
|
133
|
+
COMING_SOON = "Coming Soon",
|
|
134
|
+
RETIRED = "Retired",
|
|
135
|
+
HOT = "Hot & New 🔥"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Strategy Tags - used for filtering and categorization
|
|
140
|
+
*/
|
|
141
|
+
export enum StrategyTag {
|
|
142
|
+
EKUBO = "Ekubo",
|
|
143
|
+
EVERGREEN = "Evergreen",
|
|
144
|
+
HYPER_LST = "Hyper-LST",
|
|
145
|
+
VESU = "Vesu",
|
|
146
|
+
SENSEI = "Sensei",
|
|
147
|
+
ENDUR = "Endur",
|
|
148
|
+
BTC = "BTC"
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Strategy Alert - informational or warning messages for users
|
|
153
|
+
*/
|
|
154
|
+
export interface StrategyAlert {
|
|
155
|
+
type: "warning" | "info";
|
|
156
|
+
text: string | React.ReactNode;
|
|
157
|
+
tab: "all" | "deposit" | "withdraw";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Strategy Settings - configuration and UI settings for strategies
|
|
162
|
+
*/
|
|
163
|
+
export interface StrategySettings {
|
|
164
|
+
maxTVL?: Web3Number;
|
|
165
|
+
liveStatus?: StrategyLiveStatus;
|
|
166
|
+
isPaused?: boolean;
|
|
167
|
+
isInMaintenance?: boolean;
|
|
168
|
+
isAudited: boolean;
|
|
169
|
+
isInstantWithdrawal?: boolean;
|
|
170
|
+
hideHarvestInfo?: boolean;
|
|
171
|
+
is_promoted?: boolean;
|
|
172
|
+
isTransactionHistDisabled?: boolean;
|
|
173
|
+
quoteToken: TokenInfo;
|
|
174
|
+
hideNetEarnings?: boolean;
|
|
175
|
+
showWithdrawalWarningModal?: boolean;
|
|
176
|
+
alerts?: StrategyAlert[];
|
|
177
|
+
tags?: StrategyTag[];
|
|
67
178
|
}
|
|
68
179
|
|
|
69
180
|
/**
|
|
70
181
|
* @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
|
|
71
182
|
* @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
|
|
183
|
+
* @property security - Security-related metadata including audit status, source code information, and access control details.
|
|
184
|
+
* @property redemptionInfo - Redemption information including instant withdrawal availability and expected redemption times.
|
|
72
185
|
*/
|
|
73
186
|
export interface IStrategyMetadata<T> {
|
|
74
|
-
|
|
75
|
-
description: string | React.ReactNode;
|
|
76
|
-
address: ContractAddr;
|
|
77
|
-
launchBlock: number;
|
|
78
|
-
type: "ERC4626" | "ERC721" | "Other";
|
|
79
|
-
depositTokens: TokenInfo[];
|
|
80
|
-
protocols: IProtocol[];
|
|
81
|
-
auditUrl?: string;
|
|
82
|
-
maxTVL: Web3Number;
|
|
83
|
-
risk: {
|
|
84
|
-
riskFactor: RiskFactor[];
|
|
85
|
-
netRisk: number;
|
|
86
|
-
notARisks: RiskType[];
|
|
87
|
-
};
|
|
88
|
-
apyMethodology?: string;
|
|
89
|
-
additionalInfo: T;
|
|
90
|
-
contractDetails: {
|
|
91
|
-
address: ContractAddr;
|
|
187
|
+
id: string;
|
|
92
188
|
name: string;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
189
|
+
description: string | React.ReactNode;
|
|
190
|
+
address: ContractAddr;
|
|
191
|
+
launchBlock: number;
|
|
192
|
+
type: "ERC4626" | "ERC721" | "Other";
|
|
193
|
+
depositTokens: TokenInfo[];
|
|
194
|
+
protocols: IProtocol[];
|
|
195
|
+
auditUrl?: string;
|
|
196
|
+
risk: {
|
|
197
|
+
riskFactor: RiskFactor[];
|
|
198
|
+
netRisk: number;
|
|
199
|
+
notARisks: RiskType[];
|
|
200
|
+
};
|
|
201
|
+
apyMethodology?: string;
|
|
202
|
+
additionalInfo: T;
|
|
203
|
+
contractDetails: {
|
|
204
|
+
address: ContractAddr;
|
|
205
|
+
name: string;
|
|
206
|
+
sourceCodeUrl?: string;
|
|
207
|
+
}[];
|
|
208
|
+
faqs: FAQ[];
|
|
209
|
+
points?: { multiplier: number; logo: string; toolTip?: string }[];
|
|
210
|
+
docs?: string;
|
|
211
|
+
investmentSteps: string[];
|
|
212
|
+
curator?: { name: string; logo: string };
|
|
213
|
+
isPreview?: boolean;
|
|
214
|
+
category?: StrategyCategory;
|
|
215
|
+
tags?: StrategyTag[];
|
|
216
|
+
security?: SecurityMetadata;
|
|
217
|
+
redemptionInfo?: RedemptionInfo;
|
|
218
|
+
settings?: StrategySettings;
|
|
219
|
+
// Legacy field for multi-step strategies (deprecated, use investmentFlows instead)
|
|
220
|
+
actions?: Array<{
|
|
221
|
+
name?: string;
|
|
222
|
+
pool?: {
|
|
223
|
+
protocol?: { name: string; logo: string };
|
|
224
|
+
pool?: { name: string; logos?: string[] };
|
|
225
|
+
apr?: number;
|
|
226
|
+
borrow?: { apr?: number };
|
|
227
|
+
};
|
|
228
|
+
amount?: string | number;
|
|
229
|
+
isDeposit?: boolean;
|
|
230
|
+
}>;
|
|
101
231
|
}
|
|
102
232
|
|
|
103
233
|
export interface IInvestmentFlow {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
234
|
+
id?: string; // used to link flows
|
|
235
|
+
title: string;
|
|
236
|
+
subItems: { key: string; value: string }[];
|
|
237
|
+
linkedFlows: IInvestmentFlow[];
|
|
238
|
+
style?: any;
|
|
109
239
|
}
|
|
110
240
|
|
|
111
241
|
export function getMainnetConfig(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
242
|
+
rpcUrl: string = "https://starknet-mainnet.public.blastapi.io",
|
|
243
|
+
blockIdentifier: BlockIdentifier = BlockTag.LATEST
|
|
244
|
+
// specVersion = constants.SupportedRpcVersion.v0_8_1
|
|
115
245
|
): IConfig {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
246
|
+
return {
|
|
247
|
+
provider: new RpcProvider({
|
|
248
|
+
nodeUrl: rpcUrl,
|
|
249
|
+
blockIdentifier: blockIdentifier
|
|
250
|
+
// specVersion
|
|
251
|
+
}),
|
|
252
|
+
stage: "production",
|
|
253
|
+
network: Network.mainnet
|
|
254
|
+
};
|
|
125
255
|
}
|
|
126
256
|
|
|
127
257
|
export const getRiskExplaination = (riskType: RiskType) => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
258
|
+
switch (riskType) {
|
|
259
|
+
case RiskType.MARKET_RISK:
|
|
260
|
+
return "The risk of the market moving against the position.";
|
|
261
|
+
case RiskType.IMPERMANENT_LOSS:
|
|
262
|
+
return "The temporary loss of value experienced by liquidity providers in AMMs when asset prices diverge compared to simply holding them.";
|
|
263
|
+
case RiskType.LIQUIDATION_RISK:
|
|
264
|
+
return "The risk of losing funds due to the position being liquidated.";
|
|
265
|
+
case RiskType.LOW_LIQUIDITY_RISK:
|
|
266
|
+
return "The risk of low liquidity in the pool, which can lead to high slippages or reduced in-abilities to quickly exit the position.";
|
|
267
|
+
case RiskType.ORACLE_RISK:
|
|
268
|
+
return "The risk of the oracle being manipulated or incorrect.";
|
|
269
|
+
case RiskType.SMART_CONTRACT_RISK:
|
|
270
|
+
return "The risk of the smart contract being vulnerable to attacks.";
|
|
271
|
+
case RiskType.TECHNICAL_RISK:
|
|
272
|
+
return "The risk of technical issues e.g. backend failure.";
|
|
273
|
+
case RiskType.COUNTERPARTY_RISK:
|
|
274
|
+
return "The risk of the counterparty defaulting e.g. bad debt on lending platforms.";
|
|
275
|
+
case RiskType.DEPEG_RISK:
|
|
276
|
+
return "The risk of a token losing its peg to the underlying asset, leading to potential losses for holders.";
|
|
277
|
+
}
|
|
148
278
|
};
|
|
149
279
|
|
|
150
280
|
export const getRiskColor = (risk: RiskFactor) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
281
|
+
const value = risk.value;
|
|
282
|
+
if (value <= 2) return "light_green_2";
|
|
283
|
+
if (value < 3) return "yellow";
|
|
284
|
+
return "red";
|
|
155
285
|
};
|
|
156
286
|
|
|
157
287
|
export const getNoRiskTags = (risks: RiskFactor[]) => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
288
|
+
const noRisks1 = risks
|
|
289
|
+
.filter((risk) => risk.value === 0)
|
|
290
|
+
.map((risk) => risk.type);
|
|
161
291
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
292
|
+
// const risks not present
|
|
293
|
+
const noRisks2 = Object.values(RiskType).filter(
|
|
294
|
+
(risk) => !risks.map((risk) => risk.type).includes(risk)
|
|
295
|
+
);
|
|
166
296
|
|
|
167
|
-
|
|
297
|
+
const mergedUnique = [...new Set([...noRisks1, ...noRisks2])];
|
|
168
298
|
|
|
169
|
-
|
|
170
|
-
|
|
299
|
+
// add `No` to the start of each risk
|
|
300
|
+
return mergedUnique;
|
|
171
301
|
};
|
|
172
302
|
|
|
173
303
|
interface HighlightLink {
|
|
174
|
-
|
|
175
|
-
|
|
304
|
+
highlight: string;
|
|
305
|
+
link: string;
|
|
176
306
|
}
|
|
177
307
|
|
|
178
308
|
export function highlightTextWithLinks(
|
|
179
|
-
|
|
180
|
-
|
|
309
|
+
put: string,
|
|
310
|
+
highlights: HighlightLink[]
|
|
181
311
|
): ReactNode {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
312
|
+
// Escape RegExp special characters in highlight strings
|
|
313
|
+
const escapeRegExp = (text: string) =>
|
|
314
|
+
text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
315
|
+
|
|
316
|
+
// Create a single regex for all highlight terms
|
|
317
|
+
const pattern = new RegExp(
|
|
318
|
+
`(${highlights.map((m) => escapeRegExp(m.highlight)).join("|")})`,
|
|
319
|
+
"gi"
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const parts = put.split(pattern);
|
|
323
|
+
|
|
324
|
+
return (
|
|
325
|
+
<>
|
|
326
|
+
{parts.map((part, i) => {
|
|
327
|
+
const match = highlights.find(
|
|
328
|
+
(m) => m.highlight.toLowerCase() === part.toLowerCase()
|
|
329
|
+
);
|
|
330
|
+
return match ? (
|
|
331
|
+
<a
|
|
332
|
+
key={i}
|
|
333
|
+
href={match.link}
|
|
334
|
+
target="_blank"
|
|
335
|
+
style={{
|
|
336
|
+
color: "var(--chakra-colors-white)",
|
|
337
|
+
background: "var(--chakra-colors-highlight)"
|
|
338
|
+
}}
|
|
339
|
+
>
|
|
340
|
+
{part}
|
|
341
|
+
</a>
|
|
342
|
+
) : (
|
|
343
|
+
<span key={i}>{part}</span>
|
|
344
|
+
);
|
|
345
|
+
})}
|
|
346
|
+
</>
|
|
347
|
+
);
|
|
208
348
|
}
|
|
209
349
|
|
|
210
350
|
export interface VaultPosition {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
protocol: IProtocol
|
|
351
|
+
amount: Web3Number;
|
|
352
|
+
usdValue: number;
|
|
353
|
+
token: TokenInfo;
|
|
354
|
+
remarks: string;
|
|
216
355
|
}
|
|
217
356
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
357
|
+
export interface AmountInfo {
|
|
358
|
+
amount: Web3Number;
|
|
359
|
+
usdValue: number;
|
|
360
|
+
tokenInfo: TokenInfo;
|
|
361
|
+
}
|
|
222
362
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
363
|
+
export interface AmountsInfo {
|
|
364
|
+
usdValue: number;
|
|
365
|
+
amounts: AmountInfo[];
|
|
226
366
|
}
|
|
227
367
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
368
|
+
/**
|
|
369
|
+
* Strategy capabilities interface
|
|
370
|
+
* Describes what optional methods a strategy instance supports
|
|
371
|
+
*/
|
|
372
|
+
export interface StrategyCapabilities {
|
|
373
|
+
hasMatchInputAmounts: boolean;
|
|
374
|
+
hasNetAPY: boolean;
|
|
375
|
+
hasGetInvestmentFlows: boolean;
|
|
376
|
+
hasGetPendingRewards: boolean;
|
|
377
|
+
hasHarvest: boolean;
|
|
378
|
+
hasRebalance: boolean;
|
|
231
379
|
}
|
|
232
380
|
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
381
|
+
const VesuProtocol: IProtocol = {
|
|
382
|
+
name: "Vesu",
|
|
383
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/vesu/logo.png"
|
|
236
384
|
};
|
|
237
385
|
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
|
|
386
|
+
const EndurProtocol: IProtocol = {
|
|
387
|
+
name: "Endur",
|
|
388
|
+
logo: "http://endur.fi/logo.png"
|
|
241
389
|
};
|
|
242
390
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
391
|
+
const ExtendedProtocol: IProtocol = {
|
|
392
|
+
name: "Extended",
|
|
393
|
+
logo: "https://static-assets-8zct.onrender.com/integrations/extended/extended.svg"
|
|
394
|
+
};
|
|
247
395
|
|
|
248
|
-
const VaultProtocol: IProtocol = {
|
|
249
|
-
name: "Vault",
|
|
250
|
-
logo: ""
|
|
251
|
-
}
|
|
252
396
|
export const Protocols = {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
EKUBO: EkuboProtocol,
|
|
258
|
-
AVNU: AvnuProtocol,
|
|
259
|
-
VAULT: VaultProtocol
|
|
260
|
-
}
|
|
397
|
+
VESU: VesuProtocol,
|
|
398
|
+
ENDUR: EndurProtocol,
|
|
399
|
+
EXTENDED: ExtendedProtocol
|
|
400
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
|
+
import { IConfig } from '@/interfaces';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates an Apollo Client instance configured for the appropriate environment
|
|
6
|
+
* @param config - The application config containing network and stage information
|
|
7
|
+
* @returns Configured Apollo Client instance
|
|
8
|
+
*/
|
|
9
|
+
export function createApolloClient(config: IConfig) {
|
|
10
|
+
// Determine the URI based on the environment
|
|
11
|
+
const uri = config.stage === 'production'
|
|
12
|
+
? 'https://api.troves.fi/'
|
|
13
|
+
: 'http://localhost:4000';
|
|
14
|
+
|
|
15
|
+
return new ApolloClient({
|
|
16
|
+
uri,
|
|
17
|
+
cache: new InMemoryCache(),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Default client for backward compatibility
|
|
22
|
+
const apolloClient = new ApolloClient({
|
|
23
|
+
uri: 'https://api.troves.fi/',
|
|
24
|
+
cache: new InMemoryCache(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default apolloClient;
|
|
28
|
+
|
package/src/modules/avnu.ts
CHANGED
|
@@ -37,7 +37,7 @@ export class AvnuWrapper {
|
|
|
37
37
|
excludeSources = ['Haiko(Solvers)']
|
|
38
38
|
): Promise<Quote> {
|
|
39
39
|
const MAX_RETRY = 5;
|
|
40
|
-
logger.verbose(`${AvnuWrapper.name}: getQuotes => Getting quotes for ${fromToken} -> ${toToken}, amount: ${amountWei}, taker: ${taker}, retry: ${retry}`);
|
|
40
|
+
// logger.verbose(`${AvnuWrapper.name}: getQuotes => Getting quotes for ${fromToken} -> ${toToken}, amount: ${amountWei}, taker: ${taker}, retry: ${retry}`);
|
|
41
41
|
const params: any = {
|
|
42
42
|
sellTokenAddress: fromToken,
|
|
43
43
|
buyTokenAddress: toToken,
|
|
@@ -100,9 +100,9 @@ export class AvnuWrapper {
|
|
|
100
100
|
// swapInfo as expected by the strategy
|
|
101
101
|
// fallback, max 1% slippage
|
|
102
102
|
const _minAmount = minAmount || (quote.buyAmount * 95n / 100n).toString();
|
|
103
|
-
logger.verbose(`${AvnuWrapper.name}: getSwapInfo => sellToken: ${quote.sellTokenAddress}, sellAmount: ${quote.sellAmount}`);
|
|
104
|
-
logger.verbose(`${AvnuWrapper.name}: getSwapInfo => buyToken: ${quote.buyTokenAddress}`);
|
|
105
|
-
logger.verbose(`${AvnuWrapper.name}: getSwapInfo => buyAmount: ${quote.buyAmount}, minAmount: ${_minAmount}`);
|
|
103
|
+
// logger.verbose(`${AvnuWrapper.name}: getSwapInfo => sellToken: ${quote.sellTokenAddress}, sellAmount: ${quote.sellAmount}`);
|
|
104
|
+
// logger.verbose(`${AvnuWrapper.name}: getSwapInfo => buyToken: ${quote.buyTokenAddress}`);
|
|
105
|
+
// logger.verbose(`${AvnuWrapper.name}: getSwapInfo => buyAmount: ${quote.buyAmount}, minAmount: ${_minAmount}`);
|
|
106
106
|
const swapInfo: SwapInfo = {
|
|
107
107
|
token_from_address: quote.sellTokenAddress,
|
|
108
108
|
token_from_amount: uint256.bnToUint256(quote.sellAmount),
|
|
@@ -135,17 +135,4 @@ export class AvnuWrapper {
|
|
|
135
135
|
routes: [],
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
async getSwapCallData(
|
|
141
|
-
quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>,
|
|
142
|
-
taker: string,
|
|
143
|
-
) {
|
|
144
|
-
const calldata = await fetchBuildExecuteTransaction(quote.quoteId, taker, undefined, false);
|
|
145
|
-
const result = calldata.calls.map((call: Call) => {
|
|
146
|
-
const data = call.calldata as string[];
|
|
147
|
-
return data.map(x => BigInt(x));
|
|
148
|
-
});
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
138
|
}
|