@strkfarm/sdk 1.2.0 → 2.0.0-dev-strategy2.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/index.browser.global.js +76556 -66640
- package/dist/index.browser.mjs +34235 -24392
- package/dist/index.d.ts +2372 -793
- package/dist/index.js +31967 -22084
- package/dist/index.mjs +25545 -15719
- package/package.json +86 -76
- package/readme.md +56 -1
- package/src/data/extended-deposit.abi.json +3613 -0
- package/src/data/universal-vault.abi.json +135 -20
- package/src/dataTypes/_bignumber.ts +11 -0
- 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 +448 -0
- package/src/modules/avnu.ts +17 -4
- package/src/modules/ekubo-quoter.ts +89 -10
- package/src/modules/erc20.ts +67 -21
- package/src/modules/harvests.ts +29 -43
- 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/btc-vesu-extended-strategy/core-strategy.tsx +1486 -0
- package/src/strategies/btc-vesu-extended-strategy/services/operationService.ts +32 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/constants.ts +3 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/helper.ts +396 -0
- package/src/strategies/btc-vesu-extended-strategy/utils/types.ts +5 -0
- package/src/strategies/ekubo-cl-vault.tsx +123 -306
- package/src/strategies/index.ts +7 -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 +432 -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 +976 -0
- package/src/strategies/universal-adapters/index.ts +7 -1
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +109 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +230 -230
- package/src/strategies/universal-adapters/vesu-borrow-adapter.ts +1247 -0
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +1306 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +58 -51
- package/src/strategies/universal-lst-muliplier-strategy.tsx +716 -844
- package/src/strategies/universal-strategy.tsx +1103 -1181
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +34 -0
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +25 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +77 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +50 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +367 -0
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +1420 -0
- package/src/strategies/vesu-rebalance.tsx +16 -20
- package/src/utils/health-factor-math.ts +11 -5
|
@@ -17,15 +17,15 @@ import VesuRebalanceAbi from "@/data/vesu-rebalance.abi.json";
|
|
|
17
17
|
import { Global } from "@/global";
|
|
18
18
|
import { assert } from "@/utils";
|
|
19
19
|
import { logger } from "@/utils/logger";
|
|
20
|
-
import axios from "axios";
|
|
21
20
|
import { PricerBase } from "@/modules/pricerBase";
|
|
22
21
|
import {
|
|
22
|
+
APYInfo,
|
|
23
23
|
BaseStrategy,
|
|
24
24
|
SingleActionAmount,
|
|
25
25
|
SingleTokenInfo
|
|
26
26
|
} from "./base-strategy";
|
|
27
27
|
import { getAPIUsingHeadlessBrowser } from "@/node/headless";
|
|
28
|
-
import {
|
|
28
|
+
import { VESU_REWARDS_ENDPOINT, VesuHarvests } from "@/modules/harvests";
|
|
29
29
|
import VesuPoolIDs from "@/data/vesu_pools.json";
|
|
30
30
|
import { COMMON_CONTRACTS, ENDPOINTS } from "./constants";
|
|
31
31
|
|
|
@@ -182,7 +182,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
182
182
|
* @returns Object containing the amount in token units and USD value
|
|
183
183
|
*/
|
|
184
184
|
async getUserTVL(user: ContractAddr) {
|
|
185
|
-
const shares = await this.contract.
|
|
185
|
+
const shares = await this.contract.balance_of(user.address);
|
|
186
186
|
const assets = await this.contract.convert_to_assets(
|
|
187
187
|
uint256.bnToUint256(shares)
|
|
188
188
|
);
|
|
@@ -288,7 +288,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
288
288
|
address: p.v_token.address,
|
|
289
289
|
providerOrAccount: this.config.provider
|
|
290
290
|
});
|
|
291
|
-
const bal = await vTokenContract.
|
|
291
|
+
const bal = await vTokenContract.balance_of(this.address.address);
|
|
292
292
|
const assets = await vTokenContract.convert_to_assets(
|
|
293
293
|
uint256.bnToUint256(bal.toString())
|
|
294
294
|
);
|
|
@@ -523,9 +523,12 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
523
523
|
* Calculates the weighted average APY across all pools based on USD value.
|
|
524
524
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
525
525
|
*/
|
|
526
|
-
async netAPY(): Promise<
|
|
526
|
+
async netAPY(): Promise<APYInfo > {
|
|
527
527
|
const { data: pools } = await this.getPools();
|
|
528
|
-
return
|
|
528
|
+
return {
|
|
529
|
+
net: await this.netAPYGivenPools(pools),
|
|
530
|
+
splits: []
|
|
531
|
+
};
|
|
529
532
|
}
|
|
530
533
|
|
|
531
534
|
/**
|
|
@@ -763,17 +766,10 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
763
766
|
return [baseFlow];
|
|
764
767
|
}
|
|
765
768
|
|
|
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];
|
|
769
|
+
async harvest(acc: Account, endpoint = VESU_REWARDS_ENDPOINT) {
|
|
770
|
+
const vesuHarvest = new VesuHarvests(this.config);
|
|
771
|
+
const harvests = await vesuHarvest.getUnHarvestedRewards(this.address, endpoint);
|
|
772
|
+
const harvest = harvests[0];
|
|
777
773
|
const avnu = new AvnuWrapper();
|
|
778
774
|
let swapInfo: SwapInfo = {
|
|
779
775
|
token_from_address: harvest.token.address,
|
|
@@ -1014,8 +1010,8 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
|
|
|
1014
1010
|
investmentSteps: []
|
|
1015
1011
|
},
|
|
1016
1012
|
{
|
|
1017
|
-
name: "Vesu Fusion USDC
|
|
1018
|
-
description: _description.replace("{{TOKEN}}", "USDC
|
|
1013
|
+
name: "Vesu Fusion USDC",
|
|
1014
|
+
description: _description.replace("{{TOKEN}}", "USDC"),
|
|
1019
1015
|
address: ContractAddr.from(
|
|
1020
1016
|
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
1021
1017
|
),
|
|
@@ -1023,7 +1019,7 @@ export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[]
|
|
|
1023
1019
|
type: "ERC4626",
|
|
1024
1020
|
auditUrl: AUDIT_URL,
|
|
1025
1021
|
depositTokens: [
|
|
1026
|
-
Global.getDefaultTokens().find((t) => t.symbol === "USDC
|
|
1022
|
+
Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
|
|
1027
1023
|
],
|
|
1028
1024
|
protocols: [_protocol],
|
|
1029
1025
|
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
|
|