@strkfarm/sdk 1.1.70 → 2.0.0-dev.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/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/index.browser.global.js +67016 -59681
- package/dist/index.browser.mjs +29832 -23221
- package/dist/index.d.ts +2006 -787
- package/dist/index.js +25403 -18769
- package/dist/index.mjs +25333 -18739
- 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 +7 -0
- 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 -10
- 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-lst.ts +1 -1
- 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 +411 -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 +661 -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 +34 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +49 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +376 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1134 -0
- package/src/strategies/vesu-rebalance.tsx +16 -19
- package/src/utils/health-factor-math.ts +11 -5
|
@@ -20,12 +20,13 @@ import { logger } from "@/utils/logger";
|
|
|
20
20
|
import axios from "axios";
|
|
21
21
|
import { PricerBase } from "@/modules/pricerBase";
|
|
22
22
|
import {
|
|
23
|
+
APYInfo,
|
|
23
24
|
BaseStrategy,
|
|
24
25
|
SingleActionAmount,
|
|
25
26
|
SingleTokenInfo
|
|
26
27
|
} from "./base-strategy";
|
|
27
28
|
import { getAPIUsingHeadlessBrowser } from "@/node/headless";
|
|
28
|
-
import {
|
|
29
|
+
import { VESU_REWARDS_ENDPOINT, VesuHarvests } from "@/modules/harvests";
|
|
29
30
|
import VesuPoolIDs from "@/data/vesu_pools.json";
|
|
30
31
|
import { COMMON_CONTRACTS, ENDPOINTS } from "./constants";
|
|
31
32
|
|
|
@@ -182,7 +183,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
182
183
|
* @returns Object containing the amount in token units and USD value
|
|
183
184
|
*/
|
|
184
185
|
async getUserTVL(user: ContractAddr) {
|
|
185
|
-
const shares = await this.contract.
|
|
186
|
+
const shares = await this.contract.balance_of(user.address);
|
|
186
187
|
const assets = await this.contract.convert_to_assets(
|
|
187
188
|
uint256.bnToUint256(shares)
|
|
188
189
|
);
|
|
@@ -288,7 +289,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
288
289
|
address: p.v_token.address,
|
|
289
290
|
providerOrAccount: this.config.provider
|
|
290
291
|
});
|
|
291
|
-
const bal = await vTokenContract.
|
|
292
|
+
const bal = await vTokenContract.balance_of(this.address.address);
|
|
292
293
|
const assets = await vTokenContract.convert_to_assets(
|
|
293
294
|
uint256.bnToUint256(bal.toString())
|
|
294
295
|
);
|
|
@@ -523,9 +524,12 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
523
524
|
* Calculates the weighted average APY across all pools based on USD value.
|
|
524
525
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
525
526
|
*/
|
|
526
|
-
async netAPY(): Promise<
|
|
527
|
+
async netAPY(): Promise<APYInfo > {
|
|
527
528
|
const { data: pools } = await this.getPools();
|
|
528
|
-
return
|
|
529
|
+
return {
|
|
530
|
+
net: await this.netAPYGivenPools(pools),
|
|
531
|
+
splits: []
|
|
532
|
+
};
|
|
529
533
|
}
|
|
530
534
|
|
|
531
535
|
/**
|
|
@@ -763,17 +767,10 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
763
767
|
return [baseFlow];
|
|
764
768
|
}
|
|
765
769
|
|
|
766
|
-
async
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
async harvest(acc: Account) {
|
|
772
|
-
const pendingRewards = await this.getPendingRewards();
|
|
773
|
-
if (pendingRewards.length == 0) {
|
|
774
|
-
throw new Error(`No pending rewards found`);
|
|
775
|
-
}
|
|
776
|
-
const harvest = pendingRewards[0];
|
|
770
|
+
async harvest(acc: Account, endpoint = VESU_REWARDS_ENDPOINT) {
|
|
771
|
+
const vesuHarvest = new VesuHarvests(this.config);
|
|
772
|
+
const harvests = await vesuHarvest.getUnHarvestedRewards(this.address, endpoint);
|
|
773
|
+
const harvest = harvests[0];
|
|
777
774
|
const avnu = new AvnuWrapper();
|
|
778
775
|
let swapInfo: SwapInfo = {
|
|
779
776
|
token_from_address: harvest.token.address,
|
|
@@ -1014,8 +1011,8 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
|
|
|
1014
1011
|
investmentSteps: []
|
|
1015
1012
|
},
|
|
1016
1013
|
{
|
|
1017
|
-
name: "Vesu Fusion USDC
|
|
1018
|
-
description: _description.replace("{{TOKEN}}", "USDC
|
|
1014
|
+
name: "Vesu Fusion USDC",
|
|
1015
|
+
description: _description.replace("{{TOKEN}}", "USDC"),
|
|
1019
1016
|
address: ContractAddr.from(
|
|
1020
1017
|
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
1021
1018
|
),
|
|
@@ -1023,7 +1020,7 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
|
|
|
1023
1020
|
type: "ERC4626",
|
|
1024
1021
|
auditUrl: AUDIT_URL,
|
|
1025
1022
|
depositTokens: [
|
|
1026
|
-
Global.getDefaultTokens().find((t) => t.symbol === "USDC
|
|
1023
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
|
|
1027
1024
|
],
|
|
1028
1025
|
protocols: [_protocol],
|
|
1029
1026
|
maxTVL: Web3Number.fromWei("0", 6),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Web3Number } from "@/dataTypes";
|
|
2
2
|
import { TokenInfo } from "@/interfaces";
|
|
3
|
+
import { logger } from "@/utils/logger";
|
|
3
4
|
|
|
4
5
|
export class HealthFactorMath {
|
|
5
6
|
static getCollateralRequired(
|
|
@@ -52,13 +53,18 @@ export class HealthFactorMath {
|
|
|
52
53
|
debtTokenInfo: TokenInfo
|
|
53
54
|
) {
|
|
54
55
|
// lets say debt usd value is X
|
|
55
|
-
// HF = ((
|
|
56
|
-
// => X * HF = ((
|
|
57
|
-
// => X * (HF - maxLTV) =
|
|
58
|
-
// => X =
|
|
56
|
+
// HF = ((ca * cp) + X) * maxLTV / (X)
|
|
57
|
+
// => X * HF = ((ca * cp) + X) * maxLTV
|
|
58
|
+
// => X * (HF - maxLTV) = ca * cp * maxLTV
|
|
59
|
+
// => X = ca * cp * maxLTV / (HF - maxLTV)
|
|
59
60
|
const numerator = collateralAmount.multipliedBy(collateralPrice).multipliedBy(maxLTV);
|
|
61
|
+
logger.verbose(`HealthFactorMath: Max debt amount on looping numerator: ${numerator.toNumber()}, collateralAmount: ${collateralAmount.toNumber()}, collateralPrice: ${collateralPrice}, maxLTV: ${maxLTV}, targetHF: ${targetHF}, debtPrice: ${debtPrice}`);
|
|
60
62
|
const denominator = targetHF - maxLTV;
|
|
61
|
-
|
|
63
|
+
logger.verbose(`HealthFactorMath: Max debt amount on looping denominator: ${denominator}`);
|
|
64
|
+
const debtAmountUSD = numerator.dividedBy(denominator);
|
|
65
|
+
logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmountUSD: ${debtAmountUSD.toNumber()}`);
|
|
66
|
+
const debtAmount = debtAmountUSD.dividedBy(debtPrice);
|
|
67
|
+
logger.verbose(`HealthFactorMath: Max debt amount on looping debtAmount: ${debtAmount.toNumber()}`);
|
|
62
68
|
return new Web3Number(debtAmount.toString(), debtTokenInfo.decimals);
|
|
63
69
|
}
|
|
64
70
|
|