@strkfarm/sdk 2.0.0-dev.27 → 2.0.0-dev.28
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 +190 -36
- package/dist/cli.mjs +188 -34
- package/dist/index.browser.global.js +79130 -49357
- package/dist/index.browser.mjs +18039 -11434
- package/dist/index.d.ts +2869 -898
- package/dist/index.js +19036 -12210
- package/dist/index.mjs +18942 -12161
- package/package.json +1 -1
- package/src/data/avnu.abi.json +840 -0
- package/src/data/ekubo-price-fethcer.abi.json +265 -0
- package/src/dataTypes/_bignumber.ts +13 -4
- package/src/dataTypes/index.ts +3 -2
- package/src/dataTypes/mynumber.ts +141 -0
- package/src/global.ts +76 -41
- package/src/index.browser.ts +2 -1
- package/src/interfaces/common.tsx +167 -2
- package/src/modules/ExtendedWrapperSDk/types.ts +26 -4
- package/src/modules/ExtendedWrapperSDk/wrapper.ts +110 -67
- package/src/modules/apollo-client-config.ts +28 -0
- package/src/modules/avnu.ts +4 -4
- package/src/modules/ekubo-pricer.ts +79 -0
- package/src/modules/ekubo-quoter.ts +46 -30
- package/src/modules/erc20.ts +17 -0
- package/src/modules/harvests.ts +43 -29
- package/src/modules/pragma.ts +23 -8
- package/src/modules/pricer-from-api.ts +156 -15
- package/src/modules/pricer-lst.ts +1 -1
- package/src/modules/pricer.ts +40 -4
- 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/base-strategy.ts +78 -10
- package/src/strategies/ekubo-cl-vault.tsx +906 -347
- package/src/strategies/factory.ts +159 -0
- package/src/strategies/index.ts +6 -1
- package/src/strategies/registry.ts +239 -0
- package/src/strategies/sensei.ts +335 -7
- package/src/strategies/svk-strategy.ts +97 -27
- package/src/strategies/types.ts +4 -0
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -1
- package/src/strategies/universal-adapters/avnu-adapter.ts +177 -268
- package/src/strategies/universal-adapters/baseAdapter.ts +263 -251
- package/src/strategies/universal-adapters/common-adapter.ts +206 -203
- package/src/strategies/universal-adapters/extended-adapter.ts +155 -336
- package/src/strategies/universal-adapters/index.ts +9 -8
- package/src/strategies/universal-adapters/token-transfer-adapter.ts +200 -0
- package/src/strategies/universal-adapters/usdc<>usdce-adapter.ts +200 -0
- package/src/strategies/universal-adapters/vesu-adapter.ts +110 -75
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +476 -0
- package/src/strategies/universal-adapters/vesu-multiply-adapter.ts +762 -844
- package/src/strategies/universal-adapters/vesu-position-common.ts +251 -0
- package/src/strategies/universal-adapters/vesu-supply-only-adapter.ts +18 -3
- package/src/strategies/universal-lst-muliplier-strategy.tsx +396 -204
- package/src/strategies/universal-strategy.tsx +1426 -1178
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +2251 -0
- package/src/strategies/vesu-extended-strategy/services/extended-vesu-state-manager.ts +2941 -0
- package/src/strategies/vesu-extended-strategy/services/operationService.ts +12 -1
- package/src/strategies/vesu-extended-strategy/types/transaction-metadata.ts +52 -0
- package/src/strategies/vesu-extended-strategy/utils/config.runtime.ts +1 -0
- package/src/strategies/vesu-extended-strategy/utils/constants.ts +2 -0
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +158 -124
- package/src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx +377 -1788
- package/src/strategies/vesu-rebalance.tsx +255 -152
- package/src/utils/health-factor-math.ts +4 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/logger.browser.ts +22 -4
- package/src/utils/logger.node.ts +259 -24
- package/src/utils/starknet-call-parser.ts +1036 -0
- package/src/utils/strategy-utils.ts +61 -0
- package/src/strategies/universal-adapters/unused-balance-adapter.ts +0 -109
|
@@ -9,10 +9,18 @@ import {
|
|
|
9
9
|
IProtocol,
|
|
10
10
|
IStrategyMetadata,
|
|
11
11
|
RiskFactor,
|
|
12
|
-
RiskType
|
|
12
|
+
RiskType,
|
|
13
|
+
StrategyTag,
|
|
14
|
+
AuditStatus,
|
|
15
|
+
SourceCodeType,
|
|
16
|
+
AccessControlType,
|
|
17
|
+
InstantWithdrawalVault,
|
|
18
|
+
StrategySettings,
|
|
19
|
+
StrategyLiveStatus,
|
|
20
|
+
VaultType,
|
|
13
21
|
} from "@/interfaces";
|
|
14
22
|
import { AvnuWrapper, Pricer, SwapInfo } from "@/modules";
|
|
15
|
-
import { Account, CairoCustomEnum, Contract, num, uint256 } from "starknet";
|
|
23
|
+
import { Account, CairoCustomEnum, Contract, num, uint256, BlockIdentifier } from "starknet";
|
|
16
24
|
import VesuRebalanceAbi from "@/data/vesu-rebalance.abi.json";
|
|
17
25
|
import { Global } from "@/global";
|
|
18
26
|
import { assert } from "@/utils";
|
|
@@ -26,7 +34,7 @@ import {
|
|
|
26
34
|
SingleTokenInfo
|
|
27
35
|
} from "./base-strategy";
|
|
28
36
|
import { getAPIUsingHeadlessBrowser } from "@/node/headless";
|
|
29
|
-
import { VESU_REWARDS_ENDPOINT, VesuHarvests } from "@/modules/harvests";
|
|
37
|
+
import { VESU_REWARDS_ENDPOINT, VesuHarvests, HarvestInfo } from "@/modules/harvests";
|
|
30
38
|
import VesuPoolIDs from "@/data/vesu_pools.json";
|
|
31
39
|
import { COMMON_CONTRACTS, ENDPOINTS } from "./constants";
|
|
32
40
|
|
|
@@ -177,22 +185,26 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
177
185
|
return this.metadata.depositTokens[0].decimals; // same as underlying token
|
|
178
186
|
}
|
|
179
187
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const shares = await this.contract.balance_of(user.address);
|
|
187
|
-
const assets = await this.contract.convert_to_assets(
|
|
188
|
-
uint256.bnToUint256(shares)
|
|
188
|
+
async getUserTVL(user: ContractAddr, blockIdentifier: BlockIdentifier = "latest") {
|
|
189
|
+
const shares: any = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
190
|
+
const assets: any = await this.contract.call(
|
|
191
|
+
"convert_to_assets",
|
|
192
|
+
[uint256.bnToUint256(shares)],
|
|
193
|
+
{ blockIdentifier }
|
|
189
194
|
);
|
|
190
195
|
const amount = Web3Number.fromWei(
|
|
191
196
|
assets.toString(),
|
|
192
197
|
this.metadata.depositTokens[0].decimals
|
|
193
198
|
);
|
|
199
|
+
|
|
200
|
+
// Convert blockIdentifier to block number for pricer if it's a number
|
|
201
|
+
const blockNumber = typeof blockIdentifier === 'number' || typeof blockIdentifier === 'bigint'
|
|
202
|
+
? Number(blockIdentifier)
|
|
203
|
+
: undefined;
|
|
204
|
+
|
|
194
205
|
let price = await this.pricer.getPrice(
|
|
195
|
-
this.metadata.depositTokens[0].symbol
|
|
206
|
+
this.metadata.depositTokens[0].symbol,
|
|
207
|
+
blockNumber
|
|
196
208
|
);
|
|
197
209
|
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
198
210
|
return {
|
|
@@ -202,6 +214,105 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
202
214
|
};
|
|
203
215
|
}
|
|
204
216
|
|
|
217
|
+
/**
|
|
218
|
+
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
219
|
+
* Returns the APY as a number.
|
|
220
|
+
*/
|
|
221
|
+
async getUserRealizedAPY(
|
|
222
|
+
blockIdentifier: BlockIdentifier = "latest",
|
|
223
|
+
sinceBlocks = 600000
|
|
224
|
+
): Promise<number> {
|
|
225
|
+
logger.verbose(
|
|
226
|
+
`${VesuRebalance.name}: getUserRealizedAPY => starting with blockIdentifier=${blockIdentifier}, sinceBlocks=${sinceBlocks}`
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
// Determine current block number and timestamp
|
|
230
|
+
let blockNow =
|
|
231
|
+
typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint"
|
|
232
|
+
? Number(blockIdentifier)
|
|
233
|
+
: (await this.config.provider.getBlockLatestAccepted()).block_number;
|
|
234
|
+
const blockNowTime =
|
|
235
|
+
typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint"
|
|
236
|
+
? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp
|
|
237
|
+
: new Date().getTime() / 1000;
|
|
238
|
+
|
|
239
|
+
// Look back window, but never before launch block
|
|
240
|
+
const blockBefore = Math.max(
|
|
241
|
+
blockNow - sinceBlocks,
|
|
242
|
+
this.metadata.launchBlock
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
// TVL amounts (in underlying token units) and supply at current reference block
|
|
246
|
+
const assetsNowRaw: bigint = await this.contract.call("total_assets", [], {
|
|
247
|
+
blockIdentifier,
|
|
248
|
+
}) as bigint;
|
|
249
|
+
const amountNow = Web3Number.fromWei(
|
|
250
|
+
assetsNowRaw.toString(),
|
|
251
|
+
this.metadata.depositTokens[0].decimals
|
|
252
|
+
);
|
|
253
|
+
|
|
254
|
+
const supplyNowRaw: bigint = await this.contract.call("total_supply", [], {
|
|
255
|
+
blockIdentifier,
|
|
256
|
+
}) as bigint;
|
|
257
|
+
const supplyNow = Web3Number.fromWei(
|
|
258
|
+
supplyNowRaw.toString(),
|
|
259
|
+
this.metadata.depositTokens[0].decimals
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
// Historical TVL and supply
|
|
263
|
+
const assetsBeforeRaw: bigint = await this.contract.call(
|
|
264
|
+
"total_assets",
|
|
265
|
+
[],
|
|
266
|
+
{ blockIdentifier: blockBefore }
|
|
267
|
+
) as bigint;
|
|
268
|
+
const amountBefore = Web3Number.fromWei(
|
|
269
|
+
assetsBeforeRaw.toString(),
|
|
270
|
+
this.metadata.depositTokens[0].decimals
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const supplyBeforeRaw: bigint = await this.contract.call(
|
|
274
|
+
"total_supply",
|
|
275
|
+
[],
|
|
276
|
+
{ blockIdentifier: blockBefore }
|
|
277
|
+
) as bigint;
|
|
278
|
+
const supplyBefore = Web3Number.fromWei(
|
|
279
|
+
supplyBeforeRaw.toString(),
|
|
280
|
+
this.metadata.depositTokens[0].decimals
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const blockBeforeInfo = await this.config.provider.getBlockWithTxs(
|
|
284
|
+
blockBefore
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const assetsPerShareNow = amountNow
|
|
288
|
+
.multipliedBy(1e18)
|
|
289
|
+
.dividedBy(supplyNow.toString());
|
|
290
|
+
|
|
291
|
+
const assetsPerShareBf = amountBefore
|
|
292
|
+
.multipliedBy(1e18)
|
|
293
|
+
.dividedBy(supplyBefore.toString());
|
|
294
|
+
|
|
295
|
+
const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
|
|
296
|
+
|
|
297
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] assetsNow: ${amountNow.toString()}`);
|
|
298
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] assetsBefore: ${amountBefore.toString()}`);
|
|
299
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] assetsPerShareNow: ${assetsPerShareNow.toString()}`);
|
|
300
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] assetsPerShareBf: ${assetsPerShareBf.toString()}`);
|
|
301
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] Supply before: ${supplyBefore.toString()}`);
|
|
302
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] Supply now: ${supplyNow.toString()}`);
|
|
303
|
+
logger.verbose(`${VesuRebalance.name}:${this.metadata.name} [getUserRealizedAPY] Time diff in seconds: ${timeDiffSeconds}`);
|
|
304
|
+
|
|
305
|
+
const apyForGivenBlocks =
|
|
306
|
+
Number(
|
|
307
|
+
assetsPerShareNow
|
|
308
|
+
.minus(assetsPerShareBf)
|
|
309
|
+
.multipliedBy(10000)
|
|
310
|
+
.dividedBy(assetsPerShareBf)
|
|
311
|
+
) / 10000;
|
|
312
|
+
|
|
313
|
+
return (apyForGivenBlocks * (365 * 24 * 3600)) / timeDiffSeconds;
|
|
314
|
+
}
|
|
315
|
+
|
|
205
316
|
/**
|
|
206
317
|
* Calculates the total TVL of the strategy.
|
|
207
318
|
* @returns Object containing the total amount in token units and USD value
|
|
@@ -224,7 +335,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
224
335
|
}
|
|
225
336
|
|
|
226
337
|
static async getAllPossibleVerifiedPools(asset: ContractAddr) {
|
|
227
|
-
const data = await getAPIUsingHeadlessBrowser(`${ENDPOINTS.
|
|
338
|
+
const data = await getAPIUsingHeadlessBrowser(`${ENDPOINTS.VESU_BASE}/pools`);
|
|
228
339
|
const verifiedPools = data.data.filter((d: any) => d.isVerified);
|
|
229
340
|
const pools = verifiedPools
|
|
230
341
|
.map((p: any) => {
|
|
@@ -490,7 +601,7 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
490
601
|
let pools: any[] = [];
|
|
491
602
|
try {
|
|
492
603
|
const data = await getAPIUsingHeadlessBrowser(
|
|
493
|
-
`${ENDPOINTS.
|
|
604
|
+
`${ENDPOINTS.VESU_BASE}/pools`
|
|
494
605
|
);
|
|
495
606
|
pools = data.data;
|
|
496
607
|
|
|
@@ -767,10 +878,17 @@ export class VesuRebalance extends BaseStrategy<
|
|
|
767
878
|
return [baseFlow];
|
|
768
879
|
}
|
|
769
880
|
|
|
770
|
-
async
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
881
|
+
async getPendingRewards(): Promise<HarvestInfo[]> {
|
|
882
|
+
const vesuHarvests = new VesuHarvests(this.config);
|
|
883
|
+
return await vesuHarvests.getUnHarvestedRewards(this.address);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
async harvest(acc: Account) {
|
|
887
|
+
const pendingRewards = await this.getPendingRewards();
|
|
888
|
+
if (pendingRewards.length == 0) {
|
|
889
|
+
throw new Error(`No pending rewards found`);
|
|
890
|
+
}
|
|
891
|
+
const harvest = pendingRewards[0];
|
|
774
892
|
const avnu = new AvnuWrapper();
|
|
775
893
|
let swapInfo: SwapInfo = {
|
|
776
894
|
token_from_address: harvest.token.address,
|
|
@@ -902,6 +1020,95 @@ const _riskFactor: RiskFactor[] = [
|
|
|
902
1020
|
const AUDIT_URL =
|
|
903
1021
|
"https://assets.troves.fi/strkfarm/audit_report_vesu_and_ekubo_strats.pdf";
|
|
904
1022
|
|
|
1023
|
+
// Helper to create common risk object
|
|
1024
|
+
const getVesuRebalanceRisk = () => ({
|
|
1025
|
+
riskFactor: _riskFactor,
|
|
1026
|
+
netRisk:
|
|
1027
|
+
_riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) /
|
|
1028
|
+
_riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
|
|
1029
|
+
notARisks: getNoRiskTags(_riskFactor)
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
// Helper to create Vesu Rebalance strategy settings
|
|
1033
|
+
const createVesuRebalanceSettings = (tokenSymbol: string): StrategySettings => {
|
|
1034
|
+
const depositToken = Global.getDefaultTokens().find(
|
|
1035
|
+
(t) => t.symbol === tokenSymbol
|
|
1036
|
+
)!;
|
|
1037
|
+
return {
|
|
1038
|
+
maxTVL: Web3Number.fromWei("0", depositToken.decimals),
|
|
1039
|
+
isPaused: false,
|
|
1040
|
+
liveStatus: StrategyLiveStatus.DEPRECATED,
|
|
1041
|
+
isAudited: true,
|
|
1042
|
+
isInstantWithdrawal: true,
|
|
1043
|
+
quoteToken: depositToken,
|
|
1044
|
+
alerts: []
|
|
1045
|
+
};
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
// Helper to create a Vesu Rebalance strategy
|
|
1049
|
+
const createVesuRebalanceStrategy = (
|
|
1050
|
+
idSymbol: string,
|
|
1051
|
+
name: string,
|
|
1052
|
+
tokenSymbol: string,
|
|
1053
|
+
address: string
|
|
1054
|
+
): IStrategyMetadata<VesuRebalanceSettings> => ({
|
|
1055
|
+
id: `vesu_fusion_${idSymbol.toLowerCase()}`,
|
|
1056
|
+
name,
|
|
1057
|
+
description: _description.replace("{{TOKEN}}", tokenSymbol),
|
|
1058
|
+
address: ContractAddr.from(address),
|
|
1059
|
+
launchBlock: 0,
|
|
1060
|
+
type: "ERC4626" as const,
|
|
1061
|
+
vaultType: {
|
|
1062
|
+
type: VaultType.META_VAULT,
|
|
1063
|
+
description: `Automatically diversify ${tokenSymbol} holdings into different Vesu pools while reducing risk and maximizing yield. Defi spring ${tokenSymbol} Rewards are auto-compounded as well.`
|
|
1064
|
+
},
|
|
1065
|
+
depositTokens: [
|
|
1066
|
+
Global.getDefaultTokens().find((t) => t.symbol === tokenSymbol)!
|
|
1067
|
+
],
|
|
1068
|
+
protocols: [_protocol],
|
|
1069
|
+
auditUrl: AUDIT_URL,
|
|
1070
|
+
curator: {
|
|
1071
|
+
name: "Unwrap Labs",
|
|
1072
|
+
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
1073
|
+
},
|
|
1074
|
+
settings: createVesuRebalanceSettings(tokenSymbol),
|
|
1075
|
+
risk: getVesuRebalanceRisk(),
|
|
1076
|
+
additionalInfo: {
|
|
1077
|
+
feeBps: 1000
|
|
1078
|
+
},
|
|
1079
|
+
faqs,
|
|
1080
|
+
contractDetails: [],
|
|
1081
|
+
investmentSteps: [],
|
|
1082
|
+
tags: [],
|
|
1083
|
+
security: VESU_SECURITY,
|
|
1084
|
+
redemptionInfo: VESU_REDEMPTION_INFO,
|
|
1085
|
+
discontinuationInfo: {
|
|
1086
|
+
info: "This strategy has been deprecated and is no longer accepting new deposits."
|
|
1087
|
+
},
|
|
1088
|
+
usualTimeToEarnings: null,
|
|
1089
|
+
usualTimeToEarningsDescription: null,
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
// Shared security & redemption metadata for all Vesu strategies
|
|
1093
|
+
const VESU_SECURITY = {
|
|
1094
|
+
auditStatus: AuditStatus.AUDITED,
|
|
1095
|
+
sourceCode: {
|
|
1096
|
+
type: SourceCodeType.OPEN_SOURCE,
|
|
1097
|
+
contractLink: "https://github.com/trovesfi/troves-contracts",
|
|
1098
|
+
},
|
|
1099
|
+
accessControl: {
|
|
1100
|
+
type: AccessControlType.STANDARD_ACCOUNT,
|
|
1101
|
+
addresses: [ContractAddr.from("0x0")],
|
|
1102
|
+
timeLock: "2 Days",
|
|
1103
|
+
},
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
const VESU_REDEMPTION_INFO = {
|
|
1107
|
+
instantWithdrawalVault: InstantWithdrawalVault.YES,
|
|
1108
|
+
redemptionsInfo: [],
|
|
1109
|
+
alerts: [],
|
|
1110
|
+
};
|
|
1111
|
+
|
|
905
1112
|
const faqs: FAQ[] = [
|
|
906
1113
|
{
|
|
907
1114
|
question: "What is the Vesu Rebalancing Strategy?",
|
|
@@ -953,137 +1160,32 @@ const faqs: FAQ[] = [
|
|
|
953
1160
|
* Represents the Vesu Rebalance Strategies.
|
|
954
1161
|
*/
|
|
955
1162
|
export const VesuRebalanceStrategies: IStrategyMetadata<VesuRebalanceSettings>[] =
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
contractDetails: [],
|
|
983
|
-
investmentSteps: []
|
|
984
|
-
},
|
|
985
|
-
{
|
|
986
|
-
name: "Vesu Fusion ETH",
|
|
987
|
-
description: _description.replace("{{TOKEN}}", "ETH"),
|
|
988
|
-
address: ContractAddr.from(
|
|
989
|
-
"0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"
|
|
990
|
-
),
|
|
991
|
-
launchBlock: 0,
|
|
992
|
-
type: "ERC4626",
|
|
993
|
-
auditUrl: AUDIT_URL,
|
|
994
|
-
depositTokens: [
|
|
995
|
-
Global.getDefaultTokens().find((t) => t.symbol === "ETH")!
|
|
996
|
-
],
|
|
997
|
-
protocols: [_protocol],
|
|
998
|
-
maxTVL: Web3Number.fromWei("0", 18),
|
|
999
|
-
risk: {
|
|
1000
|
-
riskFactor: _riskFactor,
|
|
1001
|
-
netRisk:
|
|
1002
|
-
_riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) /
|
|
1003
|
-
_riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
|
|
1004
|
-
notARisks: getNoRiskTags(_riskFactor)
|
|
1005
|
-
},
|
|
1006
|
-
additionalInfo: {
|
|
1007
|
-
feeBps: 1000
|
|
1008
|
-
},
|
|
1009
|
-
faqs,
|
|
1010
|
-
contractDetails: [],
|
|
1011
|
-
investmentSteps: []
|
|
1012
|
-
},
|
|
1013
|
-
{
|
|
1014
|
-
name: "Vesu Fusion USDC",
|
|
1015
|
-
description: _description.replace("{{TOKEN}}", "USDC"),
|
|
1016
|
-
address: ContractAddr.from(
|
|
1017
|
-
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
1018
|
-
),
|
|
1019
|
-
launchBlock: 0,
|
|
1020
|
-
type: "ERC4626",
|
|
1021
|
-
auditUrl: AUDIT_URL,
|
|
1022
|
-
depositTokens: [
|
|
1023
|
-
Global.getDefaultTokens().find((t) => t.symbol === "USDC")!
|
|
1024
|
-
],
|
|
1025
|
-
protocols: [_protocol],
|
|
1026
|
-
maxTVL: Web3Number.fromWei("0", 6),
|
|
1027
|
-
risk: {
|
|
1028
|
-
riskFactor: _riskFactor,
|
|
1029
|
-
netRisk:
|
|
1030
|
-
_riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) /
|
|
1031
|
-
_riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
|
|
1032
|
-
notARisks: getNoRiskTags(_riskFactor)
|
|
1033
|
-
},
|
|
1034
|
-
additionalInfo: {
|
|
1035
|
-
feeBps: 1000
|
|
1036
|
-
},
|
|
1037
|
-
faqs,
|
|
1038
|
-
contractDetails: [],
|
|
1039
|
-
investmentSteps: []
|
|
1040
|
-
},
|
|
1041
|
-
{
|
|
1042
|
-
name: "Vesu Fusion USDT",
|
|
1043
|
-
description: _description.replace("{{TOKEN}}", "USDT"),
|
|
1044
|
-
address: ContractAddr.from(
|
|
1045
|
-
"0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"
|
|
1046
|
-
),
|
|
1047
|
-
launchBlock: 0,
|
|
1048
|
-
type: "ERC4626",
|
|
1049
|
-
depositTokens: [
|
|
1050
|
-
Global.getDefaultTokens().find((t) => t.symbol === "USDT")!
|
|
1051
|
-
],
|
|
1052
|
-
auditUrl: AUDIT_URL,
|
|
1053
|
-
protocols: [_protocol],
|
|
1054
|
-
maxTVL: Web3Number.fromWei("0", 6),
|
|
1055
|
-
risk: {
|
|
1056
|
-
riskFactor: _riskFactor,
|
|
1057
|
-
netRisk:
|
|
1058
|
-
_riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) /
|
|
1059
|
-
_riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
|
|
1060
|
-
notARisks: getNoRiskTags(_riskFactor)
|
|
1061
|
-
},
|
|
1062
|
-
additionalInfo: {
|
|
1063
|
-
feeBps: 1000
|
|
1064
|
-
},
|
|
1065
|
-
faqs,
|
|
1066
|
-
contractDetails: [],
|
|
1067
|
-
investmentSteps: []
|
|
1068
|
-
// }, {
|
|
1069
|
-
// name: 'Vesu Fusion WBTC',
|
|
1070
|
-
// description: _description.replace('{{TOKEN}}', 'WBTC'),
|
|
1071
|
-
// address: ContractAddr.from('0x778007f8136a5b827325d21613803e796bda4d676fbe1e34aeab0b2a2ec027f'),
|
|
1072
|
-
// type: 'ERC4626',
|
|
1073
|
-
// depositTokens: [Global.getDefaultTokens().find(t => t.symbol === 'WBTC')!],
|
|
1074
|
-
// auditUrl: AUDIT_URL,
|
|
1075
|
-
// protocols: [_protocol],
|
|
1076
|
-
// maxTVL: Web3Number.fromWei('0', 8),
|
|
1077
|
-
// risk: {
|
|
1078
|
-
// riskFactor: _riskFactor,
|
|
1079
|
-
// netRisk: _riskFactor.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor.reduce((acc, curr) => acc + curr.weight, 0),
|
|
1080
|
-
// },
|
|
1081
|
-
// additionalInfo: {
|
|
1082
|
-
// feeBps: 1000,
|
|
1083
|
-
// },
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
];
|
|
1163
|
+
[
|
|
1164
|
+
createVesuRebalanceStrategy(
|
|
1165
|
+
'strk',
|
|
1166
|
+
"Vesu Fusion STRK",
|
|
1167
|
+
"STRK",
|
|
1168
|
+
"0x7fb5bcb8525954a60fde4e8fb8220477696ce7117ef264775a1770e23571929"
|
|
1169
|
+
),
|
|
1170
|
+
createVesuRebalanceStrategy(
|
|
1171
|
+
'eth',
|
|
1172
|
+
"Vesu Fusion ETH",
|
|
1173
|
+
"ETH",
|
|
1174
|
+
"0x5eaf5ee75231cecf79921ff8ded4b5ffe96be718bcb3daf206690ad1a9ad0ca"
|
|
1175
|
+
),
|
|
1176
|
+
createVesuRebalanceStrategy(
|
|
1177
|
+
'usdc',
|
|
1178
|
+
"Vesu Fusion USDC.e",
|
|
1179
|
+
"USDC.e",
|
|
1180
|
+
"0xa858c97e9454f407d1bd7c57472fc8d8d8449a777c822b41d18e387816f29c"
|
|
1181
|
+
),
|
|
1182
|
+
createVesuRebalanceStrategy(
|
|
1183
|
+
'usdt',
|
|
1184
|
+
"Vesu Fusion USDT",
|
|
1185
|
+
"USDT",
|
|
1186
|
+
"0x115e94e722cfc4c77a2f15c4aefb0928c1c0029e5a57570df24c650cb7cec2c"
|
|
1187
|
+
)
|
|
1188
|
+
];
|
|
1087
1189
|
|
|
1088
1190
|
// auto assign contract details to each strategy
|
|
1089
1191
|
VesuRebalanceStrategies.forEach((s) => {
|
|
@@ -1092,7 +1194,7 @@ VesuRebalanceStrategies.forEach((s) => {
|
|
|
1092
1194
|
address: s.address,
|
|
1093
1195
|
name: "Vault",
|
|
1094
1196
|
sourceCodeUrl: "https://github.com/strkfarm/strkfarm-contracts/tree/main/src/strategies/vesu_rebalance"
|
|
1095
|
-
},
|
|
1197
|
+
},
|
|
1096
1198
|
...COMMON_CONTRACTS];
|
|
1097
1199
|
// set docs link
|
|
1098
1200
|
s.docs = "https://docs.troves.fi/p/strategies/vesu-fusion-rebalancing-vaults"
|
|
@@ -1115,4 +1217,5 @@ VesuRebalanceStrategies.forEach((s) => {
|
|
|
1115
1217
|
"Monitor and Rebalance funds across multiple Vesu pools to maximize yield",
|
|
1116
1218
|
"Harvest and supply Defi Spring STRK rewards every week (Auto-compound)",
|
|
1117
1219
|
]
|
|
1118
|
-
|
|
1220
|
+
|
|
1221
|
+
});
|
|
@@ -82,8 +82,11 @@ export class HealthFactorMath {
|
|
|
82
82
|
// => X * (HF - maxLTV) = 1 * cp * maxLTV
|
|
83
83
|
// => X = 1 * cp * maxLTV / (HF - maxLTV)
|
|
84
84
|
const numerator = collateralAmount.multipliedBy(collateralPrice).multipliedBy(maxLTV);
|
|
85
|
+
logger.verbose(`HealthFactorMath: Max debt amount numerator: ${numerator.toNumber()}, collateralAmount: ${collateralAmount.toNumber()}, collateralPrice: ${collateralPrice}, maxLTV: ${maxLTV}, targetHF: ${targetHF}, debtPrice: ${debtPrice}`);
|
|
85
86
|
const denominator = targetHF * debtPrice;
|
|
87
|
+
logger.verbose(`HealthFactorMath: Max debt amount denominator: ${denominator}, targetHF: ${targetHF}, debtPrice: ${debtPrice}`);
|
|
86
88
|
const debtAmount = numerator.dividedBy(denominator);
|
|
89
|
+
logger.verbose(`HealthFactorMath: Max debt amount: ${debtAmount.toNumber()}, numerator: ${numerator.toNumber()}, denominator: ${denominator}`);
|
|
87
90
|
return new Web3Number(debtAmount.toString(), debtTokenInfo.decimals);
|
|
88
91
|
}
|
|
89
|
-
}
|
|
92
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -4,6 +4,20 @@ interface LeveledLogMethod {
|
|
|
4
4
|
(message: any): void
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
export type LoggerLevel = "error" | "warn" | "info" | "verbose" | "debug";
|
|
8
|
+
|
|
9
|
+
export interface LoggerConfig {
|
|
10
|
+
level?: LoggerLevel;
|
|
11
|
+
consoleLevel?: LoggerLevel;
|
|
12
|
+
fileLevel?: LoggerLevel;
|
|
13
|
+
filePath?: string;
|
|
14
|
+
enableConsole?: boolean;
|
|
15
|
+
enableFile?: boolean;
|
|
16
|
+
colorizeConsole?: boolean;
|
|
17
|
+
shortErrorsInConsole?: boolean;
|
|
18
|
+
emitConfigLog?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
7
21
|
interface MyLogger {
|
|
8
22
|
error: LeveledLogMethod;
|
|
9
23
|
warn: LeveledLogMethod;
|
|
@@ -13,8 +27,12 @@ interface MyLogger {
|
|
|
13
27
|
}
|
|
14
28
|
|
|
15
29
|
export const logger: MyLogger = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
30
|
+
...console,
|
|
31
|
+
verbose(message: string) {
|
|
32
|
+
console.log(`[VERBOSE] ${message}`);
|
|
33
|
+
}
|
|
20
34
|
};
|
|
35
|
+
|
|
36
|
+
export function configureLogger(_config: LoggerConfig = {}): MyLogger {
|
|
37
|
+
return logger;
|
|
38
|
+
}
|