@strkfarm/sdk 2.0.0-staging.20 → 2.0.0-staging.22
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 +76 -0
- package/dist/index.browser.mjs +76 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +76 -0
- package/dist/index.mjs +76 -0
- package/package.json +1 -1
- package/src/global.ts +27 -0
- package/src/strategies/base-strategy.ts +54 -0
- package/src/strategies/ekubo-cl-vault.tsx +12 -1
- package/src/strategies/sensei.ts +12 -1
- package/src/utils/strategy-utils.ts +6 -2
|
@@ -73075,6 +73075,34 @@ ${JSON.stringify(data, null, 2)}`;
|
|
|
73075
73075
|
coingeckId: void 0,
|
|
73076
73076
|
displayDecimals: 2,
|
|
73077
73077
|
priceCheckAmount: 100
|
|
73078
|
+
}, {
|
|
73079
|
+
name: "fyeWBTC",
|
|
73080
|
+
symbol: "fyeWBTC",
|
|
73081
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
|
|
73082
|
+
address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
|
|
73083
|
+
decimals: 8,
|
|
73084
|
+
coingeckId: void 0,
|
|
73085
|
+
displayDecimals: 6,
|
|
73086
|
+
priceCheckAmount: 1e-3
|
|
73087
|
+
// 112000 * 0.0001 = $110.2
|
|
73088
|
+
}, {
|
|
73089
|
+
name: "fyETH",
|
|
73090
|
+
symbol: "fyETH",
|
|
73091
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
|
|
73092
|
+
address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
|
|
73093
|
+
decimals: 18,
|
|
73094
|
+
coingeckId: void 0,
|
|
73095
|
+
displayDecimals: 4,
|
|
73096
|
+
priceCheckAmount: 0.1
|
|
73097
|
+
}, {
|
|
73098
|
+
name: "fyeUSDC",
|
|
73099
|
+
symbol: "fyeUSDC",
|
|
73100
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
|
|
73101
|
+
address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
|
|
73102
|
+
decimals: 6,
|
|
73103
|
+
coingeckId: void 0,
|
|
73104
|
+
displayDecimals: 2,
|
|
73105
|
+
priceCheckAmount: 100
|
|
73078
73106
|
}];
|
|
73079
73107
|
var tokens = defaultTokens;
|
|
73080
73108
|
var _Global = class _Global {
|
|
@@ -92270,6 +92298,40 @@ spurious results.`);
|
|
|
92270
92298
|
async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
|
|
92271
92299
|
throw new Error("Not implemented");
|
|
92272
92300
|
}
|
|
92301
|
+
/**
|
|
92302
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
92303
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
92304
|
+
*
|
|
92305
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
92306
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
92307
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
92308
|
+
*/
|
|
92309
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
92310
|
+
const tokenDecimals = userTVL.tokenInfo.decimals;
|
|
92311
|
+
let totalDeposits = Web3Number.fromWei("0", tokenDecimals);
|
|
92312
|
+
let totalWithdrawals = Web3Number.fromWei("0", tokenDecimals);
|
|
92313
|
+
for (const flow of investmentFlows) {
|
|
92314
|
+
const amount = Web3Number.fromWei(flow.amount, tokenDecimals);
|
|
92315
|
+
if (flow.type === "deposit") {
|
|
92316
|
+
totalDeposits = totalDeposits.plus(amount);
|
|
92317
|
+
} else if (flow.type === "withdraw" || flow.type === "redeem") {
|
|
92318
|
+
totalWithdrawals = totalWithdrawals.plus(amount);
|
|
92319
|
+
}
|
|
92320
|
+
}
|
|
92321
|
+
const lifetimeEarnings = userTVL.amount.plus(totalWithdrawals).minus(totalDeposits);
|
|
92322
|
+
return {
|
|
92323
|
+
tokenInfo: {
|
|
92324
|
+
tokenInfo: userTVL.tokenInfo,
|
|
92325
|
+
amount: lifetimeEarnings,
|
|
92326
|
+
usdValue: 0
|
|
92327
|
+
// Lifetime earnings are not converted to USD
|
|
92328
|
+
},
|
|
92329
|
+
lifetimeEarnings,
|
|
92330
|
+
currentValue: userTVL.amount,
|
|
92331
|
+
totalDeposits,
|
|
92332
|
+
totalWithdrawals
|
|
92333
|
+
};
|
|
92334
|
+
}
|
|
92273
92335
|
};
|
|
92274
92336
|
|
|
92275
92337
|
// src/node/headless.browser.ts
|
|
@@ -104000,6 +104062,13 @@ spurious results.`);
|
|
|
104000
104062
|
) / 1e4;
|
|
104001
104063
|
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
104002
104064
|
}
|
|
104065
|
+
/**
|
|
104066
|
+
* Calculate lifetime earnings for a user
|
|
104067
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
104068
|
+
*/
|
|
104069
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
104070
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
104071
|
+
}
|
|
104003
104072
|
/**
|
|
104004
104073
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
104005
104074
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
@@ -115656,6 +115725,13 @@ spurious results.`);
|
|
|
115656
115725
|
this.setCache(CACHE_KEY, price);
|
|
115657
115726
|
return price;
|
|
115658
115727
|
}
|
|
115728
|
+
/**
|
|
115729
|
+
* Calculate lifetime earnings for a user
|
|
115730
|
+
* Not yet implemented for Sensei Vault strategy
|
|
115731
|
+
*/
|
|
115732
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
115733
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
115734
|
+
}
|
|
115659
115735
|
async netAPY() {
|
|
115660
115736
|
try {
|
|
115661
115737
|
const { pools } = await VesuAdapter.getVesuPools();
|
package/dist/index.browser.mjs
CHANGED
|
@@ -428,6 +428,34 @@ var defaultTokens = [{
|
|
|
428
428
|
coingeckId: void 0,
|
|
429
429
|
displayDecimals: 2,
|
|
430
430
|
priceCheckAmount: 100
|
|
431
|
+
}, {
|
|
432
|
+
name: "fyeWBTC",
|
|
433
|
+
symbol: "fyeWBTC",
|
|
434
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
|
|
435
|
+
address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
|
|
436
|
+
decimals: 8,
|
|
437
|
+
coingeckId: void 0,
|
|
438
|
+
displayDecimals: 6,
|
|
439
|
+
priceCheckAmount: 1e-3
|
|
440
|
+
// 112000 * 0.0001 = $110.2
|
|
441
|
+
}, {
|
|
442
|
+
name: "fyETH",
|
|
443
|
+
symbol: "fyETH",
|
|
444
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
|
|
445
|
+
address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
|
|
446
|
+
decimals: 18,
|
|
447
|
+
coingeckId: void 0,
|
|
448
|
+
displayDecimals: 4,
|
|
449
|
+
priceCheckAmount: 0.1
|
|
450
|
+
}, {
|
|
451
|
+
name: "fyeUSDC",
|
|
452
|
+
symbol: "fyeUSDC",
|
|
453
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
|
|
454
|
+
address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
|
|
455
|
+
decimals: 6,
|
|
456
|
+
coingeckId: void 0,
|
|
457
|
+
displayDecimals: 2,
|
|
458
|
+
priceCheckAmount: 100
|
|
431
459
|
}];
|
|
432
460
|
var tokens = defaultTokens;
|
|
433
461
|
var _Global = class _Global {
|
|
@@ -4846,6 +4874,40 @@ var BaseStrategy = class extends CacheClass {
|
|
|
4846
4874
|
async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
|
|
4847
4875
|
throw new Error("Not implemented");
|
|
4848
4876
|
}
|
|
4877
|
+
/**
|
|
4878
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
4879
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
4880
|
+
*
|
|
4881
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
4882
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
4883
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
4884
|
+
*/
|
|
4885
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
4886
|
+
const tokenDecimals = userTVL.tokenInfo.decimals;
|
|
4887
|
+
let totalDeposits = Web3Number.fromWei("0", tokenDecimals);
|
|
4888
|
+
let totalWithdrawals = Web3Number.fromWei("0", tokenDecimals);
|
|
4889
|
+
for (const flow of investmentFlows) {
|
|
4890
|
+
const amount = Web3Number.fromWei(flow.amount, tokenDecimals);
|
|
4891
|
+
if (flow.type === "deposit") {
|
|
4892
|
+
totalDeposits = totalDeposits.plus(amount);
|
|
4893
|
+
} else if (flow.type === "withdraw" || flow.type === "redeem") {
|
|
4894
|
+
totalWithdrawals = totalWithdrawals.plus(amount);
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
const lifetimeEarnings = userTVL.amount.plus(totalWithdrawals).minus(totalDeposits);
|
|
4898
|
+
return {
|
|
4899
|
+
tokenInfo: {
|
|
4900
|
+
tokenInfo: userTVL.tokenInfo,
|
|
4901
|
+
amount: lifetimeEarnings,
|
|
4902
|
+
usdValue: 0
|
|
4903
|
+
// Lifetime earnings are not converted to USD
|
|
4904
|
+
},
|
|
4905
|
+
lifetimeEarnings,
|
|
4906
|
+
currentValue: userTVL.amount,
|
|
4907
|
+
totalDeposits,
|
|
4908
|
+
totalWithdrawals
|
|
4909
|
+
};
|
|
4910
|
+
}
|
|
4849
4911
|
};
|
|
4850
4912
|
|
|
4851
4913
|
// src/node/headless.browser.ts
|
|
@@ -16589,6 +16651,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16589
16651
|
) / 1e4;
|
|
16590
16652
|
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
16591
16653
|
}
|
|
16654
|
+
/**
|
|
16655
|
+
* Calculate lifetime earnings for a user
|
|
16656
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
16657
|
+
*/
|
|
16658
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
16659
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
16660
|
+
}
|
|
16592
16661
|
/**
|
|
16593
16662
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
16594
16663
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
@@ -28252,6 +28321,13 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28252
28321
|
this.setCache(CACHE_KEY, price);
|
|
28253
28322
|
return price;
|
|
28254
28323
|
}
|
|
28324
|
+
/**
|
|
28325
|
+
* Calculate lifetime earnings for a user
|
|
28326
|
+
* Not yet implemented for Sensei Vault strategy
|
|
28327
|
+
*/
|
|
28328
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
28329
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
28330
|
+
}
|
|
28255
28331
|
async netAPY() {
|
|
28256
28332
|
try {
|
|
28257
28333
|
const { pools } = await VesuAdapter.getVesuPools();
|
package/dist/index.d.ts
CHANGED
|
@@ -615,6 +615,26 @@ declare class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
|
615
615
|
netAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number, timeperiod?: "24h" | "7d" | "30d" | "3m"): Promise<number | NetAPYDetails>;
|
|
616
616
|
getPendingRewards(): Promise<HarvestInfo[]>;
|
|
617
617
|
getUserRealizedAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
618
|
+
/**
|
|
619
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
620
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
621
|
+
*
|
|
622
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
623
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
624
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
625
|
+
*/
|
|
626
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
627
|
+
amount: string;
|
|
628
|
+
type: string;
|
|
629
|
+
timestamp: number;
|
|
630
|
+
tx_hash: string;
|
|
631
|
+
}>): {
|
|
632
|
+
tokenInfo: SingleTokenInfo;
|
|
633
|
+
lifetimeEarnings: Web3Number;
|
|
634
|
+
currentValue: Web3Number;
|
|
635
|
+
totalDeposits: Web3Number;
|
|
636
|
+
totalWithdrawals: Web3Number;
|
|
637
|
+
};
|
|
618
638
|
}
|
|
619
639
|
|
|
620
640
|
interface PoolProps {
|
|
@@ -908,6 +928,16 @@ declare class EkuboCLVault extends BaseStrategy<DualTokenInfo, DualActionAmount>
|
|
|
908
928
|
history: FeeHistory[];
|
|
909
929
|
}>;
|
|
910
930
|
netSharesBasedTrueAPY(blockIdentifier?: BlockIdentifier, sinceBlocks?: number): Promise<number>;
|
|
931
|
+
/**
|
|
932
|
+
* Calculate lifetime earnings for a user
|
|
933
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
934
|
+
*/
|
|
935
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
936
|
+
amount: string;
|
|
937
|
+
type: string;
|
|
938
|
+
timestamp: number;
|
|
939
|
+
tx_hash: string;
|
|
940
|
+
}>): any;
|
|
911
941
|
/**
|
|
912
942
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
913
943
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
@@ -1109,6 +1139,16 @@ declare class SenseiVault extends BaseStrategy<SingleTokenInfo, SingleActionAmou
|
|
|
1109
1139
|
}>;
|
|
1110
1140
|
getSecondaryTokenPriceRelativeToMain(retry?: number): Promise<number>;
|
|
1111
1141
|
getSettings: () => Promise<starknet.CallResult>;
|
|
1142
|
+
/**
|
|
1143
|
+
* Calculate lifetime earnings for a user
|
|
1144
|
+
* Not yet implemented for Sensei Vault strategy
|
|
1145
|
+
*/
|
|
1146
|
+
getLifetimeEarnings(userTVL: SingleTokenInfo, investmentFlows: Array<{
|
|
1147
|
+
amount: string;
|
|
1148
|
+
type: string;
|
|
1149
|
+
timestamp: number;
|
|
1150
|
+
tx_hash: string;
|
|
1151
|
+
}>): any;
|
|
1112
1152
|
netAPY(): Promise<number>;
|
|
1113
1153
|
/**
|
|
1114
1154
|
* Calculates user realized APY based on position growth accounting for deposits and withdrawals.
|
package/dist/index.js
CHANGED
|
@@ -607,6 +607,34 @@ var defaultTokens = [{
|
|
|
607
607
|
coingeckId: void 0,
|
|
608
608
|
displayDecimals: 2,
|
|
609
609
|
priceCheckAmount: 100
|
|
610
|
+
}, {
|
|
611
|
+
name: "fyeWBTC",
|
|
612
|
+
symbol: "fyeWBTC",
|
|
613
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
|
|
614
|
+
address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
|
|
615
|
+
decimals: 8,
|
|
616
|
+
coingeckId: void 0,
|
|
617
|
+
displayDecimals: 6,
|
|
618
|
+
priceCheckAmount: 1e-3
|
|
619
|
+
// 112000 * 0.0001 = $110.2
|
|
620
|
+
}, {
|
|
621
|
+
name: "fyETH",
|
|
622
|
+
symbol: "fyETH",
|
|
623
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
|
|
624
|
+
address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
|
|
625
|
+
decimals: 18,
|
|
626
|
+
coingeckId: void 0,
|
|
627
|
+
displayDecimals: 4,
|
|
628
|
+
priceCheckAmount: 0.1
|
|
629
|
+
}, {
|
|
630
|
+
name: "fyeUSDC",
|
|
631
|
+
symbol: "fyeUSDC",
|
|
632
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
|
|
633
|
+
address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
|
|
634
|
+
decimals: 6,
|
|
635
|
+
coingeckId: void 0,
|
|
636
|
+
displayDecimals: 2,
|
|
637
|
+
priceCheckAmount: 100
|
|
610
638
|
}];
|
|
611
639
|
var tokens = defaultTokens;
|
|
612
640
|
var _Global = class _Global {
|
|
@@ -4882,6 +4910,40 @@ var BaseStrategy = class extends CacheClass {
|
|
|
4882
4910
|
async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
|
|
4883
4911
|
throw new Error("Not implemented");
|
|
4884
4912
|
}
|
|
4913
|
+
/**
|
|
4914
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
4915
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
4916
|
+
*
|
|
4917
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
4918
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
4919
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
4920
|
+
*/
|
|
4921
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
4922
|
+
const tokenDecimals = userTVL.tokenInfo.decimals;
|
|
4923
|
+
let totalDeposits = Web3Number.fromWei("0", tokenDecimals);
|
|
4924
|
+
let totalWithdrawals = Web3Number.fromWei("0", tokenDecimals);
|
|
4925
|
+
for (const flow of investmentFlows) {
|
|
4926
|
+
const amount = Web3Number.fromWei(flow.amount, tokenDecimals);
|
|
4927
|
+
if (flow.type === "deposit") {
|
|
4928
|
+
totalDeposits = totalDeposits.plus(amount);
|
|
4929
|
+
} else if (flow.type === "withdraw" || flow.type === "redeem") {
|
|
4930
|
+
totalWithdrawals = totalWithdrawals.plus(amount);
|
|
4931
|
+
}
|
|
4932
|
+
}
|
|
4933
|
+
const lifetimeEarnings = userTVL.amount.plus(totalWithdrawals).minus(totalDeposits);
|
|
4934
|
+
return {
|
|
4935
|
+
tokenInfo: {
|
|
4936
|
+
tokenInfo: userTVL.tokenInfo,
|
|
4937
|
+
amount: lifetimeEarnings,
|
|
4938
|
+
usdValue: 0
|
|
4939
|
+
// Lifetime earnings are not converted to USD
|
|
4940
|
+
},
|
|
4941
|
+
lifetimeEarnings,
|
|
4942
|
+
currentValue: userTVL.amount,
|
|
4943
|
+
totalDeposits,
|
|
4944
|
+
totalWithdrawals
|
|
4945
|
+
};
|
|
4946
|
+
}
|
|
4885
4947
|
};
|
|
4886
4948
|
|
|
4887
4949
|
// src/node/headless.browser.ts
|
|
@@ -16621,6 +16683,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16621
16683
|
) / 1e4;
|
|
16622
16684
|
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
16623
16685
|
}
|
|
16686
|
+
/**
|
|
16687
|
+
* Calculate lifetime earnings for a user
|
|
16688
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
16689
|
+
*/
|
|
16690
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
16691
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
16692
|
+
}
|
|
16624
16693
|
/**
|
|
16625
16694
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
16626
16695
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
@@ -28385,6 +28454,13 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28385
28454
|
this.setCache(CACHE_KEY, price);
|
|
28386
28455
|
return price;
|
|
28387
28456
|
}
|
|
28457
|
+
/**
|
|
28458
|
+
* Calculate lifetime earnings for a user
|
|
28459
|
+
* Not yet implemented for Sensei Vault strategy
|
|
28460
|
+
*/
|
|
28461
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
28462
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
28463
|
+
}
|
|
28388
28464
|
async netAPY() {
|
|
28389
28465
|
try {
|
|
28390
28466
|
const { pools } = await VesuAdapter.getVesuPools();
|
package/dist/index.mjs
CHANGED
|
@@ -473,6 +473,34 @@ var defaultTokens = [{
|
|
|
473
473
|
coingeckId: void 0,
|
|
474
474
|
displayDecimals: 2,
|
|
475
475
|
priceCheckAmount: 100
|
|
476
|
+
}, {
|
|
477
|
+
name: "fyeWBTC",
|
|
478
|
+
symbol: "fyeWBTC",
|
|
479
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/wbtc.svg",
|
|
480
|
+
address: ContractAddr.from("0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492"),
|
|
481
|
+
decimals: 8,
|
|
482
|
+
coingeckId: void 0,
|
|
483
|
+
displayDecimals: 6,
|
|
484
|
+
priceCheckAmount: 1e-3
|
|
485
|
+
// 112000 * 0.0001 = $110.2
|
|
486
|
+
}, {
|
|
487
|
+
name: "fyETH",
|
|
488
|
+
symbol: "fyETH",
|
|
489
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/eth.svg",
|
|
490
|
+
address: ContractAddr.from("0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616"),
|
|
491
|
+
decimals: 18,
|
|
492
|
+
coingeckId: void 0,
|
|
493
|
+
displayDecimals: 4,
|
|
494
|
+
priceCheckAmount: 0.1
|
|
495
|
+
}, {
|
|
496
|
+
name: "fyeUSDC",
|
|
497
|
+
symbol: "fyeUSDC",
|
|
498
|
+
logo: "https://assets.strkfarm.com/integrations/tokens/usdc.svg",
|
|
499
|
+
address: ContractAddr.from("0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1"),
|
|
500
|
+
decimals: 6,
|
|
501
|
+
coingeckId: void 0,
|
|
502
|
+
displayDecimals: 2,
|
|
503
|
+
priceCheckAmount: 100
|
|
476
504
|
}];
|
|
477
505
|
var tokens = defaultTokens;
|
|
478
506
|
var _Global = class _Global {
|
|
@@ -4748,6 +4776,40 @@ var BaseStrategy = class extends CacheClass {
|
|
|
4748
4776
|
async getUserRealizedAPY(blockIdentifier, sinceBlocks) {
|
|
4749
4777
|
throw new Error("Not implemented");
|
|
4750
4778
|
}
|
|
4779
|
+
/**
|
|
4780
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
4781
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
4782
|
+
*
|
|
4783
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
4784
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
4785
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
4786
|
+
*/
|
|
4787
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
4788
|
+
const tokenDecimals = userTVL.tokenInfo.decimals;
|
|
4789
|
+
let totalDeposits = Web3Number.fromWei("0", tokenDecimals);
|
|
4790
|
+
let totalWithdrawals = Web3Number.fromWei("0", tokenDecimals);
|
|
4791
|
+
for (const flow of investmentFlows) {
|
|
4792
|
+
const amount = Web3Number.fromWei(flow.amount, tokenDecimals);
|
|
4793
|
+
if (flow.type === "deposit") {
|
|
4794
|
+
totalDeposits = totalDeposits.plus(amount);
|
|
4795
|
+
} else if (flow.type === "withdraw" || flow.type === "redeem") {
|
|
4796
|
+
totalWithdrawals = totalWithdrawals.plus(amount);
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
const lifetimeEarnings = userTVL.amount.plus(totalWithdrawals).minus(totalDeposits);
|
|
4800
|
+
return {
|
|
4801
|
+
tokenInfo: {
|
|
4802
|
+
tokenInfo: userTVL.tokenInfo,
|
|
4803
|
+
amount: lifetimeEarnings,
|
|
4804
|
+
usdValue: 0
|
|
4805
|
+
// Lifetime earnings are not converted to USD
|
|
4806
|
+
},
|
|
4807
|
+
lifetimeEarnings,
|
|
4808
|
+
currentValue: userTVL.amount,
|
|
4809
|
+
totalDeposits,
|
|
4810
|
+
totalWithdrawals
|
|
4811
|
+
};
|
|
4812
|
+
}
|
|
4751
4813
|
};
|
|
4752
4814
|
|
|
4753
4815
|
// src/node/headless.browser.ts
|
|
@@ -16491,6 +16553,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16491
16553
|
) / 1e4;
|
|
16492
16554
|
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
16493
16555
|
}
|
|
16556
|
+
/**
|
|
16557
|
+
* Calculate lifetime earnings for a user
|
|
16558
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
16559
|
+
*/
|
|
16560
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
16561
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
16562
|
+
}
|
|
16494
16563
|
/**
|
|
16495
16564
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
16496
16565
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
|
@@ -28255,6 +28324,13 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28255
28324
|
this.setCache(CACHE_KEY, price);
|
|
28256
28325
|
return price;
|
|
28257
28326
|
}
|
|
28327
|
+
/**
|
|
28328
|
+
* Calculate lifetime earnings for a user
|
|
28329
|
+
* Not yet implemented for Sensei Vault strategy
|
|
28330
|
+
*/
|
|
28331
|
+
getLifetimeEarnings(userTVL, investmentFlows) {
|
|
28332
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
28333
|
+
}
|
|
28258
28334
|
async netAPY() {
|
|
28259
28335
|
try {
|
|
28260
28336
|
const { pools } = await VesuAdapter.getVesuPools();
|
package/package.json
CHANGED
package/src/global.ts
CHANGED
|
@@ -165,6 +165,33 @@ const defaultTokens: TokenInfo[] = [{
|
|
|
165
165
|
coingeckId: undefined,
|
|
166
166
|
displayDecimals: 2,
|
|
167
167
|
priceCheckAmount: 100,
|
|
168
|
+
}, {
|
|
169
|
+
name: "fyeWBTC",
|
|
170
|
+
symbol: "fyeWBTC",
|
|
171
|
+
logo: 'https://assets.strkfarm.com/integrations/tokens/wbtc.svg',
|
|
172
|
+
address: ContractAddr.from('0x04dd39de0a588f5e1c7a8377e1bef2c49caaee49a11433429d2c48f587b3a492'),
|
|
173
|
+
decimals: 8,
|
|
174
|
+
coingeckId: undefined,
|
|
175
|
+
displayDecimals: 6,
|
|
176
|
+
priceCheckAmount: 0.001, // 112000 * 0.0001 = $110.2
|
|
177
|
+
}, {
|
|
178
|
+
name: "fyETH",
|
|
179
|
+
symbol: "fyETH",
|
|
180
|
+
logo: 'https://assets.strkfarm.com/integrations/tokens/eth.svg',
|
|
181
|
+
address: ContractAddr.from('0x050707bC3b8730022F10530C2c6f6b9467644129C50C2868Ad0036c5e4E9e616'),
|
|
182
|
+
decimals: 18,
|
|
183
|
+
coingeckId: undefined,
|
|
184
|
+
displayDecimals: 4,
|
|
185
|
+
priceCheckAmount: 0.1,
|
|
186
|
+
}, {
|
|
187
|
+
name: "fyeUSDC",
|
|
188
|
+
symbol: "fyeUSDC",
|
|
189
|
+
logo: 'https://assets.strkfarm.com/integrations/tokens/usdc.svg',
|
|
190
|
+
address: ContractAddr.from('0x07fdcec0cef01294c9c3d52415215949805c77bae8003702a7928fd6d2c36bc1'),
|
|
191
|
+
decimals: 6,
|
|
192
|
+
coingeckId: undefined,
|
|
193
|
+
displayDecimals: 2,
|
|
194
|
+
priceCheckAmount: 100,
|
|
168
195
|
}]
|
|
169
196
|
const tokens: TokenInfo[] = defaultTokens;
|
|
170
197
|
|
|
@@ -85,4 +85,58 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
|
|
|
85
85
|
): Promise<number> {
|
|
86
86
|
throw new Error("Not implemented");
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Calculate lifetime earnings for a user based on provided data from client
|
|
91
|
+
* Formula: lifetimeEarnings = currentValue + totalWithdrawals - totalDeposits
|
|
92
|
+
*
|
|
93
|
+
* @param userTVL - The user's current TVL (SingleTokenInfo with amount, usdValue, tokenInfo)
|
|
94
|
+
* @param investmentFlows - Array of investment flow transactions from client
|
|
95
|
+
* @returns Object containing lifetime earnings, current value, and total deposits/withdrawals
|
|
96
|
+
*/
|
|
97
|
+
getLifetimeEarnings(
|
|
98
|
+
userTVL: SingleTokenInfo,
|
|
99
|
+
investmentFlows: Array<{ amount: string; type: string; timestamp: number; tx_hash: string }>
|
|
100
|
+
): {
|
|
101
|
+
tokenInfo: SingleTokenInfo;
|
|
102
|
+
lifetimeEarnings: Web3Number;
|
|
103
|
+
currentValue: Web3Number;
|
|
104
|
+
totalDeposits: Web3Number;
|
|
105
|
+
totalWithdrawals: Web3Number;
|
|
106
|
+
} {
|
|
107
|
+
// Get token decimals from userTVL
|
|
108
|
+
const tokenDecimals = userTVL.tokenInfo.decimals;
|
|
109
|
+
|
|
110
|
+
// Initialize totals
|
|
111
|
+
let totalDeposits = Web3Number.fromWei("0", tokenDecimals);
|
|
112
|
+
let totalWithdrawals = Web3Number.fromWei("0", tokenDecimals);
|
|
113
|
+
|
|
114
|
+
// Process investment flows
|
|
115
|
+
for (const flow of investmentFlows) {
|
|
116
|
+
const amount = Web3Number.fromWei(flow.amount, tokenDecimals);
|
|
117
|
+
|
|
118
|
+
if (flow.type === 'deposit') {
|
|
119
|
+
totalDeposits = totalDeposits.plus(amount);
|
|
120
|
+
} else if (flow.type === 'withdraw' || flow.type === 'redeem') {
|
|
121
|
+
totalWithdrawals = totalWithdrawals.plus(amount);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Calculate lifetime earnings: current value + withdrawals - deposits
|
|
126
|
+
const lifetimeEarnings = userTVL.amount
|
|
127
|
+
.plus(totalWithdrawals)
|
|
128
|
+
.minus(totalDeposits);
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
tokenInfo: {
|
|
132
|
+
tokenInfo: userTVL.tokenInfo,
|
|
133
|
+
amount: lifetimeEarnings,
|
|
134
|
+
usdValue: 0, // Lifetime earnings are not converted to USD
|
|
135
|
+
},
|
|
136
|
+
lifetimeEarnings,
|
|
137
|
+
currentValue: userTVL.amount,
|
|
138
|
+
totalDeposits,
|
|
139
|
+
totalWithdrawals,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
88
142
|
}
|
|
@@ -36,7 +36,7 @@ import EkuboMathAbi from "@/data/ekubo-math.abi.json";
|
|
|
36
36
|
import ERC4626Abi from "@/data/erc4626.abi.json";
|
|
37
37
|
import { Global } from "@/global";
|
|
38
38
|
import { AvnuWrapper, ERC20, SwapInfo } from "@/modules";
|
|
39
|
-
import { BaseStrategy } from "./base-strategy";
|
|
39
|
+
import { BaseStrategy, SingleTokenInfo } from "./base-strategy";
|
|
40
40
|
import { DualActionAmount } from "./base-strategy";
|
|
41
41
|
import { DualTokenInfo } from "./base-strategy";
|
|
42
42
|
import { log } from "winston";
|
|
@@ -488,6 +488,17 @@ export class EkuboCLVault extends BaseStrategy<
|
|
|
488
488
|
return (apyForGivenBlocks * (365 * 24 * 3600)) / timeDiffSeconds;
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
+
/**
|
|
492
|
+
* Calculate lifetime earnings for a user
|
|
493
|
+
* Not yet implemented for Ekubo CL Vault strategy
|
|
494
|
+
*/
|
|
495
|
+
getLifetimeEarnings(
|
|
496
|
+
userTVL: SingleTokenInfo,
|
|
497
|
+
investmentFlows: Array<{ amount: string; type: string; timestamp: number; tx_hash: string }>
|
|
498
|
+
): any {
|
|
499
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
500
|
+
}
|
|
501
|
+
|
|
491
502
|
/**
|
|
492
503
|
* Calculates realized APY based on TVL per share growth, always valued in USDC.
|
|
493
504
|
* This is a vault-level metric (same for all users) and works for all strategies,
|
package/src/strategies/sensei.ts
CHANGED
|
@@ -238,6 +238,17 @@ export class SenseiVault extends BaseStrategy<
|
|
|
238
238
|
return settings;
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Calculate lifetime earnings for a user
|
|
243
|
+
* Not yet implemented for Sensei Vault strategy
|
|
244
|
+
*/
|
|
245
|
+
getLifetimeEarnings(
|
|
246
|
+
userTVL: SingleTokenInfo,
|
|
247
|
+
investmentFlows: Array<{ amount: string; type: string; timestamp: number; tx_hash: string }>
|
|
248
|
+
): any {
|
|
249
|
+
throw new Error("getLifetimeEarnings is not implemented yet for this strategy");
|
|
250
|
+
}
|
|
251
|
+
|
|
241
252
|
async netAPY(): Promise<number> {
|
|
242
253
|
try {
|
|
243
254
|
// Fetch Vesu pools and select the Re7 xSTRK pool
|
|
@@ -654,4 +665,4 @@ export const SenseiStrategies: IStrategyMetadata<SenseiVaultSettings>[] =
|
|
|
654
665
|
toolTip: "This strategy holds xSTRK. Earn 3-4x Endur points on your xSTRK due to the leverage. Points can be found on endur.fi.",
|
|
655
666
|
}]
|
|
656
667
|
},
|
|
657
|
-
];
|
|
668
|
+
];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { SingleTokenInfo, DualTokenInfo } from "../strategies/base-strategy";
|
|
2
2
|
import { BaseStrategy } from "../strategies/base-strategy";
|
|
3
3
|
import { AmountsInfo, StrategyCapabilities, TokenInfo } from "@/interfaces";
|
|
4
|
-
import { Web3Number } from "@/dataTypes";
|
|
4
|
+
import { ContractAddr, Web3Number } from "@/dataTypes";
|
|
5
|
+
import { gql } from "@apollo/client";
|
|
6
|
+
import apolloClient from "@/modules/apollo-client";
|
|
7
|
+
import { num } from "starknet";
|
|
8
|
+
import { logger } from "./logger";
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Convert SDK TVL info (SingleTokenInfo or DualTokenInfo) to client AmountsInfo format
|
|
@@ -54,4 +58,4 @@ export function detectCapabilities(
|
|
|
54
58
|
export function isDualTokenStrategy(strategy: BaseStrategy<any, any>): boolean {
|
|
55
59
|
// Check if strategy has matchInputAmounts (dual token strategies have this)
|
|
56
60
|
return typeof (strategy as any).matchInputAmounts === "function";
|
|
57
|
-
}
|
|
61
|
+
}
|