@strkfarm/sdk 2.0.0-dev.35 → 2.0.0-dev.37
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 +19596 -28786
- package/dist/index.browser.mjs +8559 -17931
- package/dist/index.d.ts +578 -2746
- package/dist/index.js +8649 -18059
- package/dist/index.mjs +8577 -17949
- package/package.json +3 -3
- package/src/data/universal-vault.abi.json +8 -7
- package/src/dataTypes/bignumber.browser.ts +5 -1
- package/src/dataTypes/bignumber.node.ts +5 -0
- package/src/global.ts +21 -1
- package/src/interfaces/common.tsx +39 -4
- package/src/modules/avnu.ts +19 -10
- package/src/modules/index.ts +1 -1
- package/src/strategies/base-strategy.ts +92 -8
- package/src/strategies/constants.ts +8 -3
- package/src/strategies/ekubo-cl-vault.tsx +150 -16
- package/src/strategies/factory.ts +21 -1
- package/src/strategies/index.ts +2 -7
- package/src/strategies/registry.ts +28 -5
- package/src/strategies/sensei.ts +29 -13
- package/src/strategies/svk-strategy.ts +26 -2
- package/src/strategies/token-boosted-xstrk-carry-strategy.tsx +1223 -0
- package/src/strategies/universal-adapters/avnu-adapter.ts +16 -8
- package/src/strategies/universal-adapters/index.ts +1 -2
- package/src/strategies/universal-adapters/svk-troves-adapter.ts +19 -6
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +22 -3
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +75 -52
- package/src/strategies/universal-adapters/vesu-position-common.ts +38 -31
- package/src/strategies/universal-lst-muliplier-strategy.tsx +222 -269
- package/src/strategies/universal-strategy.tsx +166 -105
- package/src/strategies/vesu-rebalance.tsx +3 -6
- package/src/strategies/yoloVault.ts +1084 -0
- package/src/utils/health-factor-math.ts +29 -0
- package/src/modules/ExtendedWrapperSDk/index.ts +0 -62
- package/src/modules/ExtendedWrapperSDk/types.ts +0 -334
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +0 -611
- package/src/strategies/universal-adapters/extended-adapter.ts +0 -860
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +0 -200
- package/src/strategies/usdc-boosted-strategy.tsx +0 -693
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +0 -2234
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +0 -4254
- package/src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts +0 -783
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +0 -56
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +0 -88
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +0 -78
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +0 -48
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +0 -528
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +0 -1014
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strkfarm/sdk",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.37",
|
|
4
4
|
"description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@types/react": "^19.1.2",
|
|
58
58
|
"axios": "^1.7.2",
|
|
59
|
-
"react": "19.1.
|
|
60
|
-
"starknet": "
|
|
59
|
+
"react": "19.1.2",
|
|
60
|
+
"starknet": "9.2.1"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@apollo/client": "3.11.8",
|
|
@@ -1628,32 +1628,32 @@
|
|
|
1628
1628
|
{
|
|
1629
1629
|
"name": "ERC20Event",
|
|
1630
1630
|
"type": "openzeppelin_token::erc20::erc20::ERC20Component::Event",
|
|
1631
|
-
"kind": "
|
|
1631
|
+
"kind": "flat"
|
|
1632
1632
|
},
|
|
1633
1633
|
{
|
|
1634
1634
|
"name": "ERC4626Event",
|
|
1635
1635
|
"type": "openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Event",
|
|
1636
|
-
"kind": "
|
|
1636
|
+
"kind": "flat"
|
|
1637
1637
|
},
|
|
1638
1638
|
{
|
|
1639
1639
|
"name": "SRC5Event",
|
|
1640
1640
|
"type": "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
1641
|
-
"kind": "
|
|
1641
|
+
"kind": "flat"
|
|
1642
1642
|
},
|
|
1643
1643
|
{
|
|
1644
1644
|
"name": "AccessControlEvent",
|
|
1645
1645
|
"type": "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
|
|
1646
|
-
"kind": "
|
|
1646
|
+
"kind": "flat"
|
|
1647
1647
|
},
|
|
1648
1648
|
{
|
|
1649
1649
|
"name": "UpgradeableEvent",
|
|
1650
1650
|
"type": "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
1651
|
-
"kind": "
|
|
1651
|
+
"kind": "flat"
|
|
1652
1652
|
},
|
|
1653
1653
|
{
|
|
1654
1654
|
"name": "PausableEvent",
|
|
1655
1655
|
"type": "openzeppelin_security::pausable::PausableComponent::Event",
|
|
1656
|
-
"kind": "
|
|
1656
|
+
"kind": "flat"
|
|
1657
1657
|
},
|
|
1658
1658
|
{
|
|
1659
1659
|
"name": "RedeemRequested",
|
|
@@ -1677,4 +1677,5 @@
|
|
|
1677
1677
|
}
|
|
1678
1678
|
]
|
|
1679
1679
|
}
|
|
1680
|
-
]
|
|
1680
|
+
]
|
|
1681
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Uint256, uint256 } from "starknet";
|
|
2
2
|
import { _Web3Number } from "./_bignumber";
|
|
3
3
|
|
|
4
4
|
export class Web3Number extends _Web3Number<Web3Number> {
|
|
@@ -10,4 +10,8 @@ export class Web3Number extends _Web3Number<Web3Number> {
|
|
|
10
10
|
static fromNumber(number: number, decimals: number) {
|
|
11
11
|
return new Web3Number(number.toString(), decimals);
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
static fromUint256(uint256Value: Uint256): Web3Number {
|
|
15
|
+
return this.fromWei(uint256.uint256ToBN(uint256Value).toString(), 18);
|
|
16
|
+
}
|
|
13
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import util from 'util';
|
|
2
2
|
import { _Web3Number } from "./_bignumber";
|
|
3
|
+
import { Uint256, uint256 } from 'starknet';
|
|
3
4
|
|
|
4
5
|
export class Web3Number extends _Web3Number<Web3Number> {
|
|
5
6
|
|
|
@@ -12,6 +13,10 @@ export class Web3Number extends _Web3Number<Web3Number> {
|
|
|
12
13
|
return new Web3Number(number.toString(), decimals);
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
static fromUint256(uint256Value: Uint256): Web3Number {
|
|
17
|
+
return this.fromWei(uint256.uint256ToBN(uint256Value).toString(), 18);
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
[util.inspect.custom](depth: any, opts: any): string {
|
|
16
21
|
return this.toString();
|
|
17
22
|
}
|
package/src/global.ts
CHANGED
|
@@ -230,7 +230,27 @@ const defaultTokens: TokenInfo[] = [
|
|
|
230
230
|
coingeckId: undefined,
|
|
231
231
|
displayDecimals: 2,
|
|
232
232
|
priceCheckAmount: 100,
|
|
233
|
-
}
|
|
233
|
+
}, {
|
|
234
|
+
name: 'strkBTC',
|
|
235
|
+
symbol: 'strkBTC',
|
|
236
|
+
logo: 'https://assets.troves.fi/integrations/tokens/strkbtc.svg',
|
|
237
|
+
address: ContractAddr.from('0x0787150e306e6eae6e3f79dea881770e8bbff2c1b8eb490f969669ee945b3135'),
|
|
238
|
+
decimals: 8,
|
|
239
|
+
coingeckId: undefined,
|
|
240
|
+
displayDecimals: 6,
|
|
241
|
+
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
242
|
+
priceProxySymbol: 'WBTC',
|
|
243
|
+
}, {
|
|
244
|
+
name: 'xstrkBTC',
|
|
245
|
+
symbol: 'xstrkBTC',
|
|
246
|
+
logo: 'https://assets.troves.fi/integrations/tokens/xstrkbtc.svg',
|
|
247
|
+
address: ContractAddr.from('0x047751b3532fabca89b0f2e35ca1cb45e5a7b11d5e3d3663dfa1f4406b45fd88'),
|
|
248
|
+
decimals: 8,
|
|
249
|
+
coingeckId: undefined,
|
|
250
|
+
displayDecimals: 6,
|
|
251
|
+
priceCheckAmount: 0.001,
|
|
252
|
+
priceProxySymbol: 'WBTC',
|
|
253
|
+
},]
|
|
234
254
|
const tokens: TokenInfo[] = defaultTokens;
|
|
235
255
|
|
|
236
256
|
/** Contains globally useful functions.
|
|
@@ -55,6 +55,11 @@ export interface IProtocol {
|
|
|
55
55
|
logo: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export interface ICurator {
|
|
59
|
+
name: string;
|
|
60
|
+
logo: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
58
63
|
export enum StrategyTag {
|
|
59
64
|
META_VAULT = "Meta Vaults",
|
|
60
65
|
LEVERED = "Maxx",
|
|
@@ -67,6 +72,7 @@ export enum VaultType {
|
|
|
67
72
|
META_VAULT = "Meta Vault",
|
|
68
73
|
DELTA_NEUTRAL = "Delta Neutral",
|
|
69
74
|
AUTOMATED_LP = "Automated LP",
|
|
75
|
+
TVA = "Troves Value Averaging",
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
// Security metadata enums
|
|
@@ -83,6 +89,7 @@ export enum SourceCodeType {
|
|
|
83
89
|
export enum AccessControlType {
|
|
84
90
|
MULTISIG_ACCOUNT = "Multisig Account",
|
|
85
91
|
STANDARD_ACCOUNT = "Standard Account",
|
|
92
|
+
ROLE_BASED_ACCESS = "Role Based Access",
|
|
86
93
|
}
|
|
87
94
|
|
|
88
95
|
export enum InstantWithdrawalVault {
|
|
@@ -99,7 +106,7 @@ export interface SourceCodeInfo {
|
|
|
99
106
|
export interface AccessControlInfo {
|
|
100
107
|
type: AccessControlType;
|
|
101
108
|
addresses: ContractAddr[];
|
|
102
|
-
timeLock
|
|
109
|
+
timeLock?: string;
|
|
103
110
|
}
|
|
104
111
|
|
|
105
112
|
export interface SecurityMetadata {
|
|
@@ -160,6 +167,13 @@ export interface StrategySettings {
|
|
|
160
167
|
tags?: StrategyTag[];
|
|
161
168
|
}
|
|
162
169
|
|
|
170
|
+
export interface StrategyApyHistoryUIConfig {
|
|
171
|
+
// Defaults to true in UI if omitted.
|
|
172
|
+
showApyHistory?: boolean;
|
|
173
|
+
// Optional message shown when APY history is hidden.
|
|
174
|
+
noApyHistoryMessage?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
163
177
|
/**
|
|
164
178
|
* @property risk.riskFactor.factor - The risk factors that are considered for the strategy.
|
|
165
179
|
* @property risk.riskFactor.factor - The value of the risk factor from 0 to 10, 0 being the lowest and 10 being the highest.
|
|
@@ -170,6 +184,19 @@ export interface IStrategyMetadata<T> {
|
|
|
170
184
|
id: string;
|
|
171
185
|
name: string;
|
|
172
186
|
description: string | React.ReactNode;
|
|
187
|
+
/**
|
|
188
|
+
* Optional UI sort priority. Higher shows earlier.
|
|
189
|
+
* Intended for pinning flagship parent vaults (e.g. BTC above STRK).
|
|
190
|
+
*/
|
|
191
|
+
priority?: number;
|
|
192
|
+
/**
|
|
193
|
+
* Optional UI config for the variant intro popup (strategy page).
|
|
194
|
+
* Should be identical across strategies that share the same `parentId`.
|
|
195
|
+
*/
|
|
196
|
+
variantIntro?: {
|
|
197
|
+
title: string;
|
|
198
|
+
description: string;
|
|
199
|
+
};
|
|
173
200
|
address: ContractAddr;
|
|
174
201
|
launchBlock: number;
|
|
175
202
|
type: "ERC4626" | "ERC721" | "Other";
|
|
@@ -186,7 +213,7 @@ export interface IStrategyMetadata<T> {
|
|
|
186
213
|
notARisks: RiskType[];
|
|
187
214
|
};
|
|
188
215
|
apyMethodology?: string;
|
|
189
|
-
|
|
216
|
+
realizedApyMethodology?: string;
|
|
190
217
|
additionalInfo: T;
|
|
191
218
|
contractDetails: {
|
|
192
219
|
address: ContractAddr;
|
|
@@ -197,7 +224,7 @@ export interface IStrategyMetadata<T> {
|
|
|
197
224
|
points?: {multiplier: number, logo: string, toolTip?: string}[];
|
|
198
225
|
docs?: string;
|
|
199
226
|
investmentSteps: string[];
|
|
200
|
-
curator?:
|
|
227
|
+
curator?: ICurator,
|
|
201
228
|
isPreview?: boolean;
|
|
202
229
|
tags?: StrategyTag[];
|
|
203
230
|
security: SecurityMetadata;
|
|
@@ -210,6 +237,7 @@ export interface IStrategyMetadata<T> {
|
|
|
210
237
|
info?: React.ReactNode | string;
|
|
211
238
|
};
|
|
212
239
|
settings?: StrategySettings;
|
|
240
|
+
apyHistoryUIConfig?: StrategyApyHistoryUIConfig;
|
|
213
241
|
// Legacy field for multi-step strategies (deprecated, use investmentFlows instead)
|
|
214
242
|
actions?: Array<{
|
|
215
243
|
name?: string;
|
|
@@ -222,6 +250,8 @@ export interface IStrategyMetadata<T> {
|
|
|
222
250
|
amount?: string | number;
|
|
223
251
|
isDeposit?: boolean;
|
|
224
252
|
}>;
|
|
253
|
+
parentId?: string;
|
|
254
|
+
parentName?: string;
|
|
225
255
|
}
|
|
226
256
|
|
|
227
257
|
export interface IInvestmentFlow {
|
|
@@ -337,7 +367,7 @@ export function highlightTextWithLinks(
|
|
|
337
367
|
{parts.map((part, i) => {
|
|
338
368
|
const match = highlights.find(m => m.highlight.toLowerCase() === part.toLowerCase());
|
|
339
369
|
return match ? (
|
|
340
|
-
<a key={i} href={match.link} target="_blank" style={{ color: '
|
|
370
|
+
<a key={i} href={match.link} target="_blank" style={{ color: 'white', background: 'rgba(255, 255, 255, 0.04)' }}>
|
|
341
371
|
{part}
|
|
342
372
|
</a>
|
|
343
373
|
) : (
|
|
@@ -429,4 +459,9 @@ export const Protocols = {
|
|
|
429
459
|
AVNU: AvnuProtocol,
|
|
430
460
|
VAULT: VaultProtocol,
|
|
431
461
|
TROVES: TrovesProtocol
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export const UnwrapLabsCurator: ICurator = {
|
|
465
|
+
name: "Unwrap Labs",
|
|
466
|
+
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
432
467
|
}
|
package/src/modules/avnu.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Call, Uint256 } from "starknet";
|
|
|
4
4
|
import { AvnuOptions, fetchBuildExecuteTransaction, fetchQuotes, Quote } from "@avnu/avnu-sdk";
|
|
5
5
|
import { assert } from "../utils";
|
|
6
6
|
import { logger } from "@/utils/logger";
|
|
7
|
-
import { ContractAddr } from "@/dataTypes";
|
|
7
|
+
import { ContractAddr, Web3Number } from "@/dataTypes";
|
|
8
8
|
|
|
9
9
|
export interface Route {
|
|
10
10
|
token_from: string,
|
|
@@ -15,12 +15,12 @@ export interface Route {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface SwapInfo {
|
|
18
|
-
token_from_address: string,
|
|
19
|
-
token_from_amount: Uint256,
|
|
20
|
-
token_to_address: string,
|
|
21
|
-
token_to_amount: Uint256,
|
|
22
|
-
token_to_min_amount: Uint256,
|
|
23
|
-
beneficiary: string,
|
|
18
|
+
token_from_address: string,
|
|
19
|
+
token_from_amount: Uint256,
|
|
20
|
+
token_to_address: string,
|
|
21
|
+
token_to_amount: Uint256,
|
|
22
|
+
token_to_min_amount: Uint256,
|
|
23
|
+
beneficiary: string,
|
|
24
24
|
integrator_fee_amount_bps: number,
|
|
25
25
|
integrator_fee_recipient: string,
|
|
26
26
|
routes: Route[]
|
|
@@ -37,7 +37,7 @@ export class AvnuWrapper {
|
|
|
37
37
|
excludeSources = ['Haiko(Solvers)']
|
|
38
38
|
): Promise<Quote> {
|
|
39
39
|
const MAX_RETRY = 5;
|
|
40
|
-
|
|
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,
|
|
@@ -59,7 +59,7 @@ export class AvnuWrapper {
|
|
|
59
59
|
}
|
|
60
60
|
throw new Error('no quotes found')
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
return filteredQuotes[0];
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -140,12 +140,21 @@ export class AvnuWrapper {
|
|
|
140
140
|
async getSwapCallData(
|
|
141
141
|
quote: Pick<Quote, 'quoteId' | 'buyTokenAddress' | 'buyAmount' | 'sellTokenAddress' | 'sellAmount'>,
|
|
142
142
|
taker: string,
|
|
143
|
+
minAmount?: Web3Number,
|
|
143
144
|
) {
|
|
144
145
|
const calldata = await fetchBuildExecuteTransaction(quote.quoteId, taker, undefined, false);
|
|
145
146
|
const result = calldata.calls.map((call: Call) => {
|
|
146
147
|
const data = call.calldata as string[];
|
|
147
148
|
return data.map(x => BigInt(x));
|
|
148
149
|
});
|
|
150
|
+
|
|
151
|
+
// override with given min amount out
|
|
152
|
+
if (minAmount) {
|
|
153
|
+
logger.verbose(`AvnuWrapper: minAmount passed ${minAmount.toString()}`)
|
|
154
|
+
const u256 = uint256.bnToUint256(minAmount.toWei());
|
|
155
|
+
result[0][6] = BigInt(u256.low);
|
|
156
|
+
result[0][7] = BigInt(u256.high);
|
|
157
|
+
}
|
|
149
158
|
return result;
|
|
150
159
|
}
|
|
151
|
-
}
|
|
160
|
+
}
|
package/src/modules/index.ts
CHANGED
|
@@ -29,6 +29,9 @@ export interface DualTokenInfo {
|
|
|
29
29
|
token1: SingleTokenInfo
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export type StrategyInputMode = "single" | "dual";
|
|
33
|
+
export type InputModeFromAction<T> = T extends DualActionAmount ? "dual" : "single";
|
|
34
|
+
|
|
32
35
|
export interface NetAPYSplit {
|
|
33
36
|
apy: number;
|
|
34
37
|
id: string;
|
|
@@ -39,18 +42,59 @@ export interface NetAPYDetails {
|
|
|
39
42
|
splits: NetAPYSplit[];
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
export type UserPositionCardSubValueColor = "default" | "positive" | "negative" | "info";
|
|
46
|
+
|
|
47
|
+
export interface UserPositionCard {
|
|
48
|
+
title: string;
|
|
49
|
+
value: string;
|
|
50
|
+
tooltip?: string;
|
|
51
|
+
subValue?: string;
|
|
52
|
+
subValueColor?: UserPositionCardSubValueColor;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface UserPositionCardsInput {
|
|
56
|
+
user: ContractAddr;
|
|
57
|
+
investmentFlows?: Array<{ amount: string; type: string; timestamp: number; tx_hash: string }>;
|
|
58
|
+
usualTimeToEarnings?: string | null;
|
|
59
|
+
usualTimeToEarningsDescription?: string | null;
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
interface CacheData {
|
|
43
63
|
timestamp: number;
|
|
44
64
|
ttl: number;
|
|
45
65
|
data: any;
|
|
46
66
|
}
|
|
47
|
-
export class BaseStrategy<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
export class BaseStrategy<
|
|
68
|
+
TVLInfo,
|
|
69
|
+
DepositActionInfo,
|
|
70
|
+
WithdrawActionInfo = DepositActionInfo,
|
|
71
|
+
> extends CacheClass {
|
|
72
|
+
readonly config: IConfig;
|
|
73
|
+
readonly cache: Map<string, CacheData> = new Map();
|
|
74
|
+
private readonly _depositInputMode: InputModeFromAction<DepositActionInfo>;
|
|
75
|
+
private readonly _withdrawInputMode: InputModeFromAction<WithdrawActionInfo>;
|
|
76
|
+
|
|
77
|
+
constructor(
|
|
78
|
+
config: IConfig,
|
|
79
|
+
inputModes?: {
|
|
80
|
+
depositInputMode?: InputModeFromAction<DepositActionInfo>;
|
|
81
|
+
withdrawInputMode?: InputModeFromAction<WithdrawActionInfo>;
|
|
82
|
+
}
|
|
83
|
+
) {
|
|
52
84
|
super();
|
|
53
85
|
this.config = config;
|
|
86
|
+
this._depositInputMode = (inputModes?.depositInputMode ??
|
|
87
|
+
("single" as InputModeFromAction<DepositActionInfo>));
|
|
88
|
+
this._withdrawInputMode = (inputModes?.withdrawInputMode ??
|
|
89
|
+
("single" as InputModeFromAction<WithdrawActionInfo>));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
depositInputMode(): InputModeFromAction<DepositActionInfo> {
|
|
93
|
+
return this._depositInputMode;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
withdrawInputMode(): InputModeFromAction<WithdrawActionInfo> {
|
|
97
|
+
return this._withdrawInputMode;
|
|
54
98
|
}
|
|
55
99
|
|
|
56
100
|
async getUserTVL(user: ContractAddr, blockIdentifier?: BlockIdentifier): Promise<TVLInfo> {
|
|
@@ -61,11 +105,11 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
|
61
105
|
throw new Error("Not implemented");
|
|
62
106
|
}
|
|
63
107
|
|
|
64
|
-
async depositCall(amountInfo:
|
|
108
|
+
async depositCall(amountInfo: DepositActionInfo, receiver: ContractAddr): Promise<Call[]> {
|
|
65
109
|
throw new Error("Not implemented");
|
|
66
110
|
}
|
|
67
111
|
|
|
68
|
-
async withdrawCall(amountInfo:
|
|
112
|
+
async withdrawCall(amountInfo: WithdrawActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
|
|
69
113
|
throw new Error("Not implemented");
|
|
70
114
|
}
|
|
71
115
|
|
|
@@ -77,7 +121,7 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
|
77
121
|
blockIdentifier?: BlockIdentifier,
|
|
78
122
|
sinceBlocks?: number,
|
|
79
123
|
timeperiod?: "24h" | "7d" | "30d" | "3m"
|
|
80
|
-
): Promise<number | NetAPYDetails> {
|
|
124
|
+
): Promise<number | string | NetAPYDetails> {
|
|
81
125
|
throw new Error("Not implemented");
|
|
82
126
|
}
|
|
83
127
|
|
|
@@ -92,6 +136,46 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
|
92
136
|
throw new Error("Not implemented");
|
|
93
137
|
}
|
|
94
138
|
|
|
139
|
+
async getUserPositionCards(_input: UserPositionCardsInput): Promise<UserPositionCard[]> {
|
|
140
|
+
throw new Error("Not implemented");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async getMaxTVL() : Promise<Web3Number> {
|
|
144
|
+
// Can throw an error as well if needed, RN returning 0
|
|
145
|
+
return new Web3Number('0', 18)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
protected formatTokenAmountForCard(amount: Web3Number, tokenInfo: TokenInfo): string {
|
|
149
|
+
const displayDecimals = tokenInfo.displayDecimals ?? 2;
|
|
150
|
+
const fixed = Number(amount.toFixed(displayDecimals));
|
|
151
|
+
const normalized = Number.isFinite(fixed) ? fixed : 0;
|
|
152
|
+
return `${normalized.toLocaleString("en-US", {
|
|
153
|
+
maximumFractionDigits: displayDecimals,
|
|
154
|
+
minimumFractionDigits: 0,
|
|
155
|
+
})} ${tokenInfo.symbol}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
protected formatPercentForCard(value: number): string {
|
|
159
|
+
if (!Number.isFinite(value)) return "N/A";
|
|
160
|
+
return `${(value * 100).toFixed(2)}%`;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
protected formatUSDForCard(value: number): string {
|
|
164
|
+
if (!Number.isFinite(value)) return "$0.00";
|
|
165
|
+
return new Intl.NumberFormat("en-US", {
|
|
166
|
+
style: "currency",
|
|
167
|
+
currency: "USD",
|
|
168
|
+
maximumFractionDigits: 2,
|
|
169
|
+
}).format(value);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected getSubValueColorFromSignedNumber(value: number): UserPositionCardSubValueColor {
|
|
173
|
+
if (!Number.isFinite(value)) return "default";
|
|
174
|
+
if (value > 0) return "positive";
|
|
175
|
+
if (value < 0) return "negative";
|
|
176
|
+
return "default";
|
|
177
|
+
}
|
|
178
|
+
|
|
95
179
|
/**
|
|
96
180
|
* Calculate lifetime earnings for a user based on provided data from client
|
|
97
181
|
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { ContractAddr } from "@/dataTypes";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const MY_ACCESS_CONTROL = {
|
|
4
4
|
address: ContractAddr.from("0x0636a3f51cc37f5729e4da4b1de6a8549a28f3c0d5bf3b17f150971e451ff9c2"),
|
|
5
5
|
name: "Access Controller",
|
|
6
6
|
sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/blob/main/src/components/accessControl.cairo",
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const COMMON_CONTRACTS = [MY_ACCESS_CONTROL];
|
|
8
10
|
|
|
9
11
|
export const ENDPOINTS = {
|
|
10
12
|
VESU_BASE: "https://proxy.api.troves.fi/vesu",
|
|
11
13
|
VESU_BASE_STAGING: "https://proxy.api.troves.fi/vesu-staging"
|
|
12
|
-
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export const MAX_AVNU_RETRY_DELAY = Number(process.env.MAX_AVNU_RETRY_DELAY ?? 100);
|