@strkfarm/sdk 1.1.7 → 1.1.9
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.browser.global.js +1197 -76
- package/dist/index.browser.mjs +1352 -229
- package/dist/index.d.ts +170 -32
- package/dist/index.js +1368 -241
- package/dist/index.mjs +1353 -230
- package/package.json +1 -1
- package/src/data/vesu-multiple.abi.json +475 -0
- package/src/dataTypes/_bignumber.ts +13 -0
- package/src/modules/avnu.ts +4 -3
- package/src/modules/ekubo-quoter.ts +127 -0
- package/src/modules/index.ts +1 -0
- package/src/strategies/ekubo-cl-vault.tsx +25 -11
- package/src/strategies/index.ts +2 -1
- package/src/strategies/universal-adapters/adapter-utils.ts +3 -0
- package/src/strategies/universal-adapters/baseAdapter.ts +3 -3
- package/src/strategies/universal-adapters/vesu-adapter.ts +244 -3
- package/src/strategies/universal-lst-muliplier-strategy.tsx +457 -0
- package/src/strategies/universal-strategy.tsx +134 -60
- package/src/utils/index.ts +3 -1
- package/src/utils/logger.node.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -67,6 +67,17 @@ var _Web3Number = class extends BigNumber {
|
|
|
67
67
|
const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
|
|
68
68
|
return this.construct(answer.toString(), this.decimals);
|
|
69
69
|
}
|
|
70
|
+
abs() {
|
|
71
|
+
console.warn(`abs: this: ${this}`);
|
|
72
|
+
return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
|
|
73
|
+
}
|
|
74
|
+
toI129() {
|
|
75
|
+
const sign = this.isNegative() ? 1 : 0;
|
|
76
|
+
return {
|
|
77
|
+
mag: BigInt(this.toWei()) * (this.isNegative() ? -1n : 1n),
|
|
78
|
+
sign
|
|
79
|
+
};
|
|
80
|
+
}
|
|
70
81
|
};
|
|
71
82
|
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
72
83
|
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
@@ -133,7 +144,7 @@ var colors = {
|
|
|
133
144
|
};
|
|
134
145
|
winston.addColors(colors);
|
|
135
146
|
var logger = winston.createLogger({
|
|
136
|
-
level: "
|
|
147
|
+
level: "debug",
|
|
137
148
|
// Set the minimum logging level
|
|
138
149
|
format: format.combine(
|
|
139
150
|
format.colorize({ all: true }),
|
|
@@ -2144,8 +2155,8 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
2144
2155
|
}
|
|
2145
2156
|
return filteredQuotes[0];
|
|
2146
2157
|
}
|
|
2147
|
-
async getSwapInfo(quote, taker, integratorFeeBps, integratorFeeRecipient, minAmount) {
|
|
2148
|
-
const calldata = await fetchBuildExecuteTransaction(quote.quoteId);
|
|
2158
|
+
async getSwapInfo(quote, taker, integratorFeeBps, integratorFeeRecipient, minAmount, options) {
|
|
2159
|
+
const calldata = await fetchBuildExecuteTransaction(quote.quoteId, taker, void 0, void 0, options);
|
|
2149
2160
|
const call = calldata.calls[1];
|
|
2150
2161
|
const callData = call.calldata;
|
|
2151
2162
|
const routesLen = Number(callData[11]);
|
|
@@ -2196,6 +2207,61 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
2196
2207
|
}
|
|
2197
2208
|
};
|
|
2198
2209
|
|
|
2210
|
+
// src/modules/ekubo-quoter.ts
|
|
2211
|
+
import axios5 from "axios";
|
|
2212
|
+
var EkuboQuoter = class {
|
|
2213
|
+
// e.g. ETH/USDC'
|
|
2214
|
+
constructor(config) {
|
|
2215
|
+
this.config = config;
|
|
2216
|
+
this.ENDPOINT = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
*
|
|
2220
|
+
* @param fromToken
|
|
2221
|
+
* @param toToken
|
|
2222
|
+
* @param amount Can be negative too, which would mean to get exact amount out
|
|
2223
|
+
* @returns
|
|
2224
|
+
*/
|
|
2225
|
+
async getQuote(fromToken, toToken, amount) {
|
|
2226
|
+
let _fromToken = amount.gt(0) ? fromToken : toToken;
|
|
2227
|
+
let _toToken = amount.gt(0) ? toToken : fromToken;
|
|
2228
|
+
const quote = await axios5.get(this.ENDPOINT.replace("{{AMOUNT}}", amount.toWei()).replace("{{TOKEN_FROM_ADDRESS}}", _fromToken).replace("{{TOKEN_TO_ADDRESS}}", _toToken));
|
|
2229
|
+
console.log(`Ekubo quote from ${_fromToken} to ${_toToken} for ${amount.toString()}: ${JSON.stringify(quote.data)}`);
|
|
2230
|
+
return quote.data;
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Formats Ekubo response for Vesu multiple use
|
|
2234
|
+
* @param quote
|
|
2235
|
+
* @param fromTokenInfo
|
|
2236
|
+
* @returns
|
|
2237
|
+
*/
|
|
2238
|
+
getVesuMultiplyQuote(quote, fromTokenInfo, toTokenInfo) {
|
|
2239
|
+
return quote.splits.map((split) => {
|
|
2240
|
+
const isNegativeAmount = BigInt(split.amount_specified) < 0n;
|
|
2241
|
+
const token = isNegativeAmount ? toTokenInfo : fromTokenInfo;
|
|
2242
|
+
return {
|
|
2243
|
+
route: split.route.map((_route) => ({
|
|
2244
|
+
pool_key: {
|
|
2245
|
+
token0: ContractAddr.from(_route.pool_key.token0),
|
|
2246
|
+
token1: ContractAddr.from(_route.pool_key.token1),
|
|
2247
|
+
fee: _route.pool_key.fee,
|
|
2248
|
+
tick_spacing: _route.pool_key.tick_spacing.toString(),
|
|
2249
|
+
extension: _route.pool_key.extension
|
|
2250
|
+
},
|
|
2251
|
+
sqrt_ratio_limit: Web3Number.fromWei(_route.sqrt_ratio_limit, 18),
|
|
2252
|
+
// just for use, any decimal works
|
|
2253
|
+
skip_ahead: Web3Number.fromWei(_route.skip_ahead, 0)
|
|
2254
|
+
// no decimal for this
|
|
2255
|
+
})),
|
|
2256
|
+
token_amount: {
|
|
2257
|
+
token: token.address,
|
|
2258
|
+
amount: Web3Number.fromWei(split.amount_specified, token.decimals)
|
|
2259
|
+
}
|
|
2260
|
+
};
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
};
|
|
2264
|
+
|
|
2199
2265
|
// src/interfaces/common.tsx
|
|
2200
2266
|
import { BlockTag, RpcProvider as RpcProvider2 } from "starknet";
|
|
2201
2267
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
@@ -3902,9 +3968,9 @@ var BaseStrategy = class extends CacheClass {
|
|
|
3902
3968
|
};
|
|
3903
3969
|
|
|
3904
3970
|
// src/node/headless.browser.ts
|
|
3905
|
-
import
|
|
3971
|
+
import axios6 from "axios";
|
|
3906
3972
|
async function getAPIUsingHeadlessBrowser(url) {
|
|
3907
|
-
const res = await
|
|
3973
|
+
const res = await axios6.get(url);
|
|
3908
3974
|
return res.data;
|
|
3909
3975
|
}
|
|
3910
3976
|
|
|
@@ -16341,20 +16407,27 @@ var _protocol2 = {
|
|
|
16341
16407
|
name: "Ekubo",
|
|
16342
16408
|
logo: "https://app.ekubo.org/favicon.ico"
|
|
16343
16409
|
};
|
|
16344
|
-
var
|
|
16410
|
+
var _lstPoolRiskFactors = [
|
|
16345
16411
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16346
16412
|
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16347
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
|
|
16413
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16414
|
+
{ type: "Depeg Risk" /* DEPEG_RISK */, value: 2 /* GENERALLY_STABLE */, weight: 33, reason: "Generally stable pegged assets" }
|
|
16415
|
+
];
|
|
16416
|
+
var _stableCoinPoolRiskFactors = [
|
|
16417
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 1 /* BATTLE_TESTED */, weight: 34, reason: "Audited smart contracts" },
|
|
16418
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16419
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16420
|
+
{ type: "Depeg Risk" /* DEPEG_RISK */, value: 1 /* HIGHLY_STABLE */, weight: 33, reason: "Highly stable assets" }
|
|
16348
16421
|
];
|
|
16349
16422
|
var mediumVolatilityPoolRiskFactors = [
|
|
16350
16423
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16351
|
-
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "
|
|
16352
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "
|
|
16424
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
|
|
16425
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile can be moderate sometimes" }
|
|
16353
16426
|
];
|
|
16354
16427
|
var highVolatilityPoolRiskFactors = [
|
|
16355
16428
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16356
|
-
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "
|
|
16357
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "
|
|
16429
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
|
|
16430
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile is often high" }
|
|
16358
16431
|
];
|
|
16359
16432
|
var mediumRisk = {
|
|
16360
16433
|
riskFactor: mediumVolatilityPoolRiskFactors,
|
|
@@ -16427,9 +16500,9 @@ var xSTRKSTRK = {
|
|
|
16427
16500
|
auditUrl: AUDIT_URL2,
|
|
16428
16501
|
maxTVL: Web3Number.fromWei("0", 18),
|
|
16429
16502
|
risk: {
|
|
16430
|
-
riskFactor:
|
|
16431
|
-
netRisk:
|
|
16432
|
-
notARisks: getNoRiskTags(
|
|
16503
|
+
riskFactor: _lstPoolRiskFactors,
|
|
16504
|
+
netRisk: _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16505
|
+
notARisks: getNoRiskTags(_lstPoolRiskFactors)
|
|
16433
16506
|
},
|
|
16434
16507
|
apyMethodology: "APY based on 30-day historical performance, including fees and rewards.",
|
|
16435
16508
|
additionalInfo: {
|
|
@@ -16584,7 +16657,11 @@ var RE7Strategies = [
|
|
|
16584
16657
|
Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
16585
16658
|
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
16586
16659
|
],
|
|
16587
|
-
risk:
|
|
16660
|
+
risk: {
|
|
16661
|
+
riskFactor: _stableCoinPoolRiskFactors,
|
|
16662
|
+
netRisk: _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16663
|
+
notARisks: getNoRiskTags(_stableCoinPoolRiskFactors)
|
|
16664
|
+
}
|
|
16588
16665
|
},
|
|
16589
16666
|
{
|
|
16590
16667
|
...ETHUSDCRe7Strategy,
|
|
@@ -18768,6 +18845,7 @@ import { hash, num as num6, shortString } from "starknet";
|
|
|
18768
18845
|
|
|
18769
18846
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
18770
18847
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
18848
|
+
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
|
|
18771
18849
|
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
18772
18850
|
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
18773
18851
|
function toBigInt(value) {
|
|
@@ -18782,13 +18860,13 @@ function toBigInt(value) {
|
|
|
18782
18860
|
|
|
18783
18861
|
// src/strategies/universal-adapters/baseAdapter.ts
|
|
18784
18862
|
var BaseAdapter = class extends CacheClass {
|
|
18785
|
-
constructSimpleLeafData(params) {
|
|
18863
|
+
constructSimpleLeafData(params, sanitizer = SIMPLE_SANITIZER) {
|
|
18786
18864
|
const { id, target, method, packedArguments } = params;
|
|
18787
18865
|
return {
|
|
18788
18866
|
id: BigInt(num6.getDecimalString(shortString.encodeShortString(id))),
|
|
18789
18867
|
readableId: id,
|
|
18790
18868
|
data: [
|
|
18791
|
-
|
|
18869
|
+
sanitizer.toBigInt(),
|
|
18792
18870
|
// sanitizer address
|
|
18793
18871
|
target.toBigInt(),
|
|
18794
18872
|
// contract
|
|
@@ -21227,172 +21305,833 @@ var vesu_singleton_abi_default = [
|
|
|
21227
21305
|
}
|
|
21228
21306
|
];
|
|
21229
21307
|
|
|
21230
|
-
// src/
|
|
21231
|
-
var
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
21235
|
-
|
|
21236
|
-
|
|
21237
|
-
|
|
21238
|
-
|
|
21239
|
-
|
|
21240
|
-
|
|
21241
|
-
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
|
|
21262
|
-
|
|
21263
|
-
|
|
21264
|
-
|
|
21265
|
-
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21269
|
-
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21277
|
-
|
|
21278
|
-
|
|
21279
|
-
|
|
21280
|
-
|
|
21281
|
-
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
21286
|
-
}
|
|
21287
|
-
};
|
|
21288
|
-
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
|
|
21289
|
-
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21290
|
-
const call = singletonContract.populate("modify_position", {
|
|
21291
|
-
params: {
|
|
21292
|
-
pool_id: this.config.poolId.toBigInt(),
|
|
21293
|
-
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
21294
|
-
debt_asset: this.config.debt.address.toBigInt(),
|
|
21295
|
-
user: this.config.vaultAllocator.toBigInt(),
|
|
21296
|
-
collateral: _collateral,
|
|
21297
|
-
debt: _debt,
|
|
21298
|
-
data: [0]
|
|
21299
|
-
}
|
|
21300
|
-
});
|
|
21301
|
-
return {
|
|
21302
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
21303
|
-
call: {
|
|
21304
|
-
contractAddress: this.VESU_SINGLETON,
|
|
21305
|
-
selector: hash3.getSelectorFromName("modify_position"),
|
|
21306
|
-
calldata: [
|
|
21307
|
-
...call.calldata
|
|
21308
|
-
]
|
|
21309
|
-
}
|
|
21310
|
-
};
|
|
21311
|
-
};
|
|
21312
|
-
this.getDefispringRewardsAdapter = (id) => {
|
|
21313
|
-
return () => {
|
|
21314
|
-
const packedArguments = [];
|
|
21315
|
-
const output = {
|
|
21316
|
-
id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
|
|
21317
|
-
readableId: id,
|
|
21318
|
-
data: [
|
|
21319
|
-
SIMPLE_SANITIZER.toBigInt(),
|
|
21320
|
-
// sanitizer address
|
|
21321
|
-
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
21322
|
-
// contract
|
|
21323
|
-
toBigInt(hash3.getSelectorFromName("claim")),
|
|
21324
|
-
// method name
|
|
21325
|
-
BigInt(packedArguments.length),
|
|
21326
|
-
...packedArguments
|
|
21327
|
-
]
|
|
21328
|
-
};
|
|
21329
|
-
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
21330
|
-
};
|
|
21331
|
-
};
|
|
21332
|
-
this.getDefiSpringClaimCall = () => {
|
|
21333
|
-
return (params) => ({
|
|
21334
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
21335
|
-
call: {
|
|
21336
|
-
contractAddress: VESU_REWARDS_CONTRACT,
|
|
21337
|
-
selector: hash3.getSelectorFromName("claim"),
|
|
21338
|
-
calldata: [
|
|
21339
|
-
BigInt(params.amount.toWei()),
|
|
21340
|
-
BigInt(params.proofs.length),
|
|
21341
|
-
...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
|
|
21342
|
-
]
|
|
21343
|
-
}
|
|
21344
|
-
});
|
|
21345
|
-
};
|
|
21346
|
-
this.config = config;
|
|
21347
|
-
}
|
|
21348
|
-
static getDefaultModifyPositionCallParams(params) {
|
|
21349
|
-
return {
|
|
21350
|
-
collateralAmount: {
|
|
21351
|
-
amount_type: 0 /* Delta */,
|
|
21352
|
-
denomination: 1 /* Assets */,
|
|
21353
|
-
value: {
|
|
21354
|
-
abs: params.collateralAmount,
|
|
21355
|
-
is_negative: !params.isAddCollateral
|
|
21356
|
-
}
|
|
21308
|
+
// src/data/vesu-multiple.abi.json
|
|
21309
|
+
var vesu_multiple_abi_default = [
|
|
21310
|
+
{
|
|
21311
|
+
type: "impl",
|
|
21312
|
+
name: "LockerImpl",
|
|
21313
|
+
interface_name: "ekubo::interfaces::core::ILocker"
|
|
21314
|
+
},
|
|
21315
|
+
{
|
|
21316
|
+
type: "struct",
|
|
21317
|
+
name: "core::array::Span::<core::felt252>",
|
|
21318
|
+
members: [
|
|
21319
|
+
{
|
|
21320
|
+
name: "snapshot",
|
|
21321
|
+
type: "@core::array::Array::<core::felt252>"
|
|
21322
|
+
}
|
|
21323
|
+
]
|
|
21324
|
+
},
|
|
21325
|
+
{
|
|
21326
|
+
type: "interface",
|
|
21327
|
+
name: "ekubo::interfaces::core::ILocker",
|
|
21328
|
+
items: [
|
|
21329
|
+
{
|
|
21330
|
+
type: "function",
|
|
21331
|
+
name: "locked",
|
|
21332
|
+
inputs: [
|
|
21333
|
+
{
|
|
21334
|
+
name: "id",
|
|
21335
|
+
type: "core::integer::u32"
|
|
21336
|
+
},
|
|
21337
|
+
{
|
|
21338
|
+
name: "data",
|
|
21339
|
+
type: "core::array::Span::<core::felt252>"
|
|
21340
|
+
}
|
|
21341
|
+
],
|
|
21342
|
+
outputs: [
|
|
21343
|
+
{
|
|
21344
|
+
type: "core::array::Span::<core::felt252>"
|
|
21345
|
+
}
|
|
21346
|
+
],
|
|
21347
|
+
state_mutability: "external"
|
|
21348
|
+
}
|
|
21349
|
+
]
|
|
21350
|
+
},
|
|
21351
|
+
{
|
|
21352
|
+
type: "impl",
|
|
21353
|
+
name: "MultiplyImpl",
|
|
21354
|
+
interface_name: "vesu_periphery::multiply::IMultiply"
|
|
21355
|
+
},
|
|
21356
|
+
{
|
|
21357
|
+
type: "struct",
|
|
21358
|
+
name: "ekubo::types::keys::PoolKey",
|
|
21359
|
+
members: [
|
|
21360
|
+
{
|
|
21361
|
+
name: "token0",
|
|
21362
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21357
21363
|
},
|
|
21358
|
-
|
|
21359
|
-
|
|
21360
|
-
|
|
21361
|
-
|
|
21362
|
-
|
|
21363
|
-
|
|
21364
|
-
|
|
21364
|
+
{
|
|
21365
|
+
name: "token1",
|
|
21366
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21367
|
+
},
|
|
21368
|
+
{
|
|
21369
|
+
name: "fee",
|
|
21370
|
+
type: "core::integer::u128"
|
|
21371
|
+
},
|
|
21372
|
+
{
|
|
21373
|
+
name: "tick_spacing",
|
|
21374
|
+
type: "core::integer::u128"
|
|
21375
|
+
},
|
|
21376
|
+
{
|
|
21377
|
+
name: "extension",
|
|
21378
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21365
21379
|
}
|
|
21366
|
-
|
|
21367
|
-
}
|
|
21368
|
-
|
|
21369
|
-
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
|
|
21382
|
-
|
|
21383
|
-
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
|
|
21392
|
-
|
|
21393
|
-
|
|
21394
|
-
|
|
21395
|
-
|
|
21380
|
+
]
|
|
21381
|
+
},
|
|
21382
|
+
{
|
|
21383
|
+
type: "struct",
|
|
21384
|
+
name: "core::integer::u256",
|
|
21385
|
+
members: [
|
|
21386
|
+
{
|
|
21387
|
+
name: "low",
|
|
21388
|
+
type: "core::integer::u128"
|
|
21389
|
+
},
|
|
21390
|
+
{
|
|
21391
|
+
name: "high",
|
|
21392
|
+
type: "core::integer::u128"
|
|
21393
|
+
}
|
|
21394
|
+
]
|
|
21395
|
+
},
|
|
21396
|
+
{
|
|
21397
|
+
type: "struct",
|
|
21398
|
+
name: "vesu_periphery::swap::RouteNode",
|
|
21399
|
+
members: [
|
|
21400
|
+
{
|
|
21401
|
+
name: "pool_key",
|
|
21402
|
+
type: "ekubo::types::keys::PoolKey"
|
|
21403
|
+
},
|
|
21404
|
+
{
|
|
21405
|
+
name: "sqrt_ratio_limit",
|
|
21406
|
+
type: "core::integer::u256"
|
|
21407
|
+
},
|
|
21408
|
+
{
|
|
21409
|
+
name: "skip_ahead",
|
|
21410
|
+
type: "core::integer::u128"
|
|
21411
|
+
}
|
|
21412
|
+
]
|
|
21413
|
+
},
|
|
21414
|
+
{
|
|
21415
|
+
type: "enum",
|
|
21416
|
+
name: "core::bool",
|
|
21417
|
+
variants: [
|
|
21418
|
+
{
|
|
21419
|
+
name: "False",
|
|
21420
|
+
type: "()"
|
|
21421
|
+
},
|
|
21422
|
+
{
|
|
21423
|
+
name: "True",
|
|
21424
|
+
type: "()"
|
|
21425
|
+
}
|
|
21426
|
+
]
|
|
21427
|
+
},
|
|
21428
|
+
{
|
|
21429
|
+
type: "struct",
|
|
21430
|
+
name: "ekubo::types::i129::i129",
|
|
21431
|
+
members: [
|
|
21432
|
+
{
|
|
21433
|
+
name: "mag",
|
|
21434
|
+
type: "core::integer::u128"
|
|
21435
|
+
},
|
|
21436
|
+
{
|
|
21437
|
+
name: "sign",
|
|
21438
|
+
type: "core::bool"
|
|
21439
|
+
}
|
|
21440
|
+
]
|
|
21441
|
+
},
|
|
21442
|
+
{
|
|
21443
|
+
type: "struct",
|
|
21444
|
+
name: "vesu_periphery::swap::TokenAmount",
|
|
21445
|
+
members: [
|
|
21446
|
+
{
|
|
21447
|
+
name: "token",
|
|
21448
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21449
|
+
},
|
|
21450
|
+
{
|
|
21451
|
+
name: "amount",
|
|
21452
|
+
type: "ekubo::types::i129::i129"
|
|
21453
|
+
}
|
|
21454
|
+
]
|
|
21455
|
+
},
|
|
21456
|
+
{
|
|
21457
|
+
type: "struct",
|
|
21458
|
+
name: "vesu_periphery::swap::Swap",
|
|
21459
|
+
members: [
|
|
21460
|
+
{
|
|
21461
|
+
name: "route",
|
|
21462
|
+
type: "core::array::Array::<vesu_periphery::swap::RouteNode>"
|
|
21463
|
+
},
|
|
21464
|
+
{
|
|
21465
|
+
name: "token_amount",
|
|
21466
|
+
type: "vesu_periphery::swap::TokenAmount"
|
|
21467
|
+
}
|
|
21468
|
+
]
|
|
21469
|
+
},
|
|
21470
|
+
{
|
|
21471
|
+
type: "struct",
|
|
21472
|
+
name: "vesu_periphery::multiply::IncreaseLeverParams",
|
|
21473
|
+
members: [
|
|
21474
|
+
{
|
|
21475
|
+
name: "pool_id",
|
|
21476
|
+
type: "core::felt252"
|
|
21477
|
+
},
|
|
21478
|
+
{
|
|
21479
|
+
name: "collateral_asset",
|
|
21480
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21481
|
+
},
|
|
21482
|
+
{
|
|
21483
|
+
name: "debt_asset",
|
|
21484
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21485
|
+
},
|
|
21486
|
+
{
|
|
21487
|
+
name: "user",
|
|
21488
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21489
|
+
},
|
|
21490
|
+
{
|
|
21491
|
+
name: "add_margin",
|
|
21492
|
+
type: "core::integer::u128"
|
|
21493
|
+
},
|
|
21494
|
+
{
|
|
21495
|
+
name: "margin_swap",
|
|
21496
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21497
|
+
},
|
|
21498
|
+
{
|
|
21499
|
+
name: "margin_swap_limit_amount",
|
|
21500
|
+
type: "core::integer::u128"
|
|
21501
|
+
},
|
|
21502
|
+
{
|
|
21503
|
+
name: "lever_swap",
|
|
21504
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21505
|
+
},
|
|
21506
|
+
{
|
|
21507
|
+
name: "lever_swap_limit_amount",
|
|
21508
|
+
type: "core::integer::u128"
|
|
21509
|
+
}
|
|
21510
|
+
]
|
|
21511
|
+
},
|
|
21512
|
+
{
|
|
21513
|
+
type: "struct",
|
|
21514
|
+
name: "vesu_periphery::multiply::DecreaseLeverParams",
|
|
21515
|
+
members: [
|
|
21516
|
+
{
|
|
21517
|
+
name: "pool_id",
|
|
21518
|
+
type: "core::felt252"
|
|
21519
|
+
},
|
|
21520
|
+
{
|
|
21521
|
+
name: "collateral_asset",
|
|
21522
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21523
|
+
},
|
|
21524
|
+
{
|
|
21525
|
+
name: "debt_asset",
|
|
21526
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21527
|
+
},
|
|
21528
|
+
{
|
|
21529
|
+
name: "user",
|
|
21530
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21531
|
+
},
|
|
21532
|
+
{
|
|
21533
|
+
name: "sub_margin",
|
|
21534
|
+
type: "core::integer::u128"
|
|
21535
|
+
},
|
|
21536
|
+
{
|
|
21537
|
+
name: "recipient",
|
|
21538
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21539
|
+
},
|
|
21540
|
+
{
|
|
21541
|
+
name: "lever_swap",
|
|
21542
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21543
|
+
},
|
|
21544
|
+
{
|
|
21545
|
+
name: "lever_swap_limit_amount",
|
|
21546
|
+
type: "core::integer::u128"
|
|
21547
|
+
},
|
|
21548
|
+
{
|
|
21549
|
+
name: "lever_swap_weights",
|
|
21550
|
+
type: "core::array::Array::<core::integer::u128>"
|
|
21551
|
+
},
|
|
21552
|
+
{
|
|
21553
|
+
name: "withdraw_swap",
|
|
21554
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21555
|
+
},
|
|
21556
|
+
{
|
|
21557
|
+
name: "withdraw_swap_limit_amount",
|
|
21558
|
+
type: "core::integer::u128"
|
|
21559
|
+
},
|
|
21560
|
+
{
|
|
21561
|
+
name: "withdraw_swap_weights",
|
|
21562
|
+
type: "core::array::Array::<core::integer::u128>"
|
|
21563
|
+
},
|
|
21564
|
+
{
|
|
21565
|
+
name: "close_position",
|
|
21566
|
+
type: "core::bool"
|
|
21567
|
+
}
|
|
21568
|
+
]
|
|
21569
|
+
},
|
|
21570
|
+
{
|
|
21571
|
+
type: "enum",
|
|
21572
|
+
name: "vesu_periphery::multiply::ModifyLeverAction",
|
|
21573
|
+
variants: [
|
|
21574
|
+
{
|
|
21575
|
+
name: "IncreaseLever",
|
|
21576
|
+
type: "vesu_periphery::multiply::IncreaseLeverParams"
|
|
21577
|
+
},
|
|
21578
|
+
{
|
|
21579
|
+
name: "DecreaseLever",
|
|
21580
|
+
type: "vesu_periphery::multiply::DecreaseLeverParams"
|
|
21581
|
+
}
|
|
21582
|
+
]
|
|
21583
|
+
},
|
|
21584
|
+
{
|
|
21585
|
+
type: "struct",
|
|
21586
|
+
name: "vesu_periphery::multiply::ModifyLeverParams",
|
|
21587
|
+
members: [
|
|
21588
|
+
{
|
|
21589
|
+
name: "action",
|
|
21590
|
+
type: "vesu_periphery::multiply::ModifyLeverAction"
|
|
21591
|
+
}
|
|
21592
|
+
]
|
|
21593
|
+
},
|
|
21594
|
+
{
|
|
21595
|
+
type: "struct",
|
|
21596
|
+
name: "alexandria_math::i257::i257",
|
|
21597
|
+
members: [
|
|
21598
|
+
{
|
|
21599
|
+
name: "abs",
|
|
21600
|
+
type: "core::integer::u256"
|
|
21601
|
+
},
|
|
21602
|
+
{
|
|
21603
|
+
name: "is_negative",
|
|
21604
|
+
type: "core::bool"
|
|
21605
|
+
}
|
|
21606
|
+
]
|
|
21607
|
+
},
|
|
21608
|
+
{
|
|
21609
|
+
type: "struct",
|
|
21610
|
+
name: "vesu_periphery::multiply::ModifyLeverResponse",
|
|
21611
|
+
members: [
|
|
21612
|
+
{
|
|
21613
|
+
name: "collateral_delta",
|
|
21614
|
+
type: "alexandria_math::i257::i257"
|
|
21615
|
+
},
|
|
21616
|
+
{
|
|
21617
|
+
name: "debt_delta",
|
|
21618
|
+
type: "alexandria_math::i257::i257"
|
|
21619
|
+
},
|
|
21620
|
+
{
|
|
21621
|
+
name: "margin_delta",
|
|
21622
|
+
type: "alexandria_math::i257::i257"
|
|
21623
|
+
}
|
|
21624
|
+
]
|
|
21625
|
+
},
|
|
21626
|
+
{
|
|
21627
|
+
type: "interface",
|
|
21628
|
+
name: "vesu_periphery::multiply::IMultiply",
|
|
21629
|
+
items: [
|
|
21630
|
+
{
|
|
21631
|
+
type: "function",
|
|
21632
|
+
name: "modify_lever",
|
|
21633
|
+
inputs: [
|
|
21634
|
+
{
|
|
21635
|
+
name: "modify_lever_params",
|
|
21636
|
+
type: "vesu_periphery::multiply::ModifyLeverParams"
|
|
21637
|
+
}
|
|
21638
|
+
],
|
|
21639
|
+
outputs: [
|
|
21640
|
+
{
|
|
21641
|
+
type: "vesu_periphery::multiply::ModifyLeverResponse"
|
|
21642
|
+
}
|
|
21643
|
+
],
|
|
21644
|
+
state_mutability: "external"
|
|
21645
|
+
}
|
|
21646
|
+
]
|
|
21647
|
+
},
|
|
21648
|
+
{
|
|
21649
|
+
type: "struct",
|
|
21650
|
+
name: "ekubo::interfaces::core::ICoreDispatcher",
|
|
21651
|
+
members: [
|
|
21652
|
+
{
|
|
21653
|
+
name: "contract_address",
|
|
21654
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21655
|
+
}
|
|
21656
|
+
]
|
|
21657
|
+
},
|
|
21658
|
+
{
|
|
21659
|
+
type: "struct",
|
|
21660
|
+
name: "vesu::singleton::ISingletonDispatcher",
|
|
21661
|
+
members: [
|
|
21662
|
+
{
|
|
21663
|
+
name: "contract_address",
|
|
21664
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21665
|
+
}
|
|
21666
|
+
]
|
|
21667
|
+
},
|
|
21668
|
+
{
|
|
21669
|
+
type: "constructor",
|
|
21670
|
+
name: "constructor",
|
|
21671
|
+
inputs: [
|
|
21672
|
+
{
|
|
21673
|
+
name: "core",
|
|
21674
|
+
type: "ekubo::interfaces::core::ICoreDispatcher"
|
|
21675
|
+
},
|
|
21676
|
+
{
|
|
21677
|
+
name: "singleton",
|
|
21678
|
+
type: "vesu::singleton::ISingletonDispatcher"
|
|
21679
|
+
}
|
|
21680
|
+
]
|
|
21681
|
+
},
|
|
21682
|
+
{
|
|
21683
|
+
type: "event",
|
|
21684
|
+
name: "vesu_periphery::multiply::Multiply::IncreaseLever",
|
|
21685
|
+
kind: "struct",
|
|
21686
|
+
members: [
|
|
21687
|
+
{
|
|
21688
|
+
name: "pool_id",
|
|
21689
|
+
type: "core::felt252",
|
|
21690
|
+
kind: "key"
|
|
21691
|
+
},
|
|
21692
|
+
{
|
|
21693
|
+
name: "collateral_asset",
|
|
21694
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21695
|
+
kind: "key"
|
|
21696
|
+
},
|
|
21697
|
+
{
|
|
21698
|
+
name: "debt_asset",
|
|
21699
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21700
|
+
kind: "key"
|
|
21701
|
+
},
|
|
21702
|
+
{
|
|
21703
|
+
name: "user",
|
|
21704
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21705
|
+
kind: "key"
|
|
21706
|
+
},
|
|
21707
|
+
{
|
|
21708
|
+
name: "margin",
|
|
21709
|
+
type: "core::integer::u256",
|
|
21710
|
+
kind: "data"
|
|
21711
|
+
},
|
|
21712
|
+
{
|
|
21713
|
+
name: "collateral_delta",
|
|
21714
|
+
type: "core::integer::u256",
|
|
21715
|
+
kind: "data"
|
|
21716
|
+
},
|
|
21717
|
+
{
|
|
21718
|
+
name: "debt_delta",
|
|
21719
|
+
type: "core::integer::u256",
|
|
21720
|
+
kind: "data"
|
|
21721
|
+
}
|
|
21722
|
+
]
|
|
21723
|
+
},
|
|
21724
|
+
{
|
|
21725
|
+
type: "event",
|
|
21726
|
+
name: "vesu_periphery::multiply::Multiply::DecreaseLever",
|
|
21727
|
+
kind: "struct",
|
|
21728
|
+
members: [
|
|
21729
|
+
{
|
|
21730
|
+
name: "pool_id",
|
|
21731
|
+
type: "core::felt252",
|
|
21732
|
+
kind: "key"
|
|
21733
|
+
},
|
|
21734
|
+
{
|
|
21735
|
+
name: "collateral_asset",
|
|
21736
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21737
|
+
kind: "key"
|
|
21738
|
+
},
|
|
21739
|
+
{
|
|
21740
|
+
name: "debt_asset",
|
|
21741
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21742
|
+
kind: "key"
|
|
21743
|
+
},
|
|
21744
|
+
{
|
|
21745
|
+
name: "user",
|
|
21746
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21747
|
+
kind: "key"
|
|
21748
|
+
},
|
|
21749
|
+
{
|
|
21750
|
+
name: "margin",
|
|
21751
|
+
type: "core::integer::u256",
|
|
21752
|
+
kind: "data"
|
|
21753
|
+
},
|
|
21754
|
+
{
|
|
21755
|
+
name: "collateral_delta",
|
|
21756
|
+
type: "core::integer::u256",
|
|
21757
|
+
kind: "data"
|
|
21758
|
+
},
|
|
21759
|
+
{
|
|
21760
|
+
name: "debt_delta",
|
|
21761
|
+
type: "core::integer::u256",
|
|
21762
|
+
kind: "data"
|
|
21763
|
+
}
|
|
21764
|
+
]
|
|
21765
|
+
},
|
|
21766
|
+
{
|
|
21767
|
+
type: "event",
|
|
21768
|
+
name: "vesu_periphery::multiply::Multiply::Event",
|
|
21769
|
+
kind: "enum",
|
|
21770
|
+
variants: [
|
|
21771
|
+
{
|
|
21772
|
+
name: "IncreaseLever",
|
|
21773
|
+
type: "vesu_periphery::multiply::Multiply::IncreaseLever",
|
|
21774
|
+
kind: "nested"
|
|
21775
|
+
},
|
|
21776
|
+
{
|
|
21777
|
+
name: "DecreaseLever",
|
|
21778
|
+
type: "vesu_periphery::multiply::Multiply::DecreaseLever",
|
|
21779
|
+
kind: "nested"
|
|
21780
|
+
}
|
|
21781
|
+
]
|
|
21782
|
+
}
|
|
21783
|
+
];
|
|
21784
|
+
|
|
21785
|
+
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
21786
|
+
var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
|
|
21787
|
+
VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
|
|
21788
|
+
VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
|
|
21789
|
+
return VesuAmountType2;
|
|
21790
|
+
})(VesuAmountType || {});
|
|
21791
|
+
var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
|
|
21792
|
+
VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
|
|
21793
|
+
VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
|
|
21794
|
+
return VesuAmountDenomination2;
|
|
21795
|
+
})(VesuAmountDenomination || {});
|
|
21796
|
+
function getVesuMultiplyParams(isIncrease, params) {
|
|
21797
|
+
if (isIncrease) {
|
|
21798
|
+
const _params2 = params;
|
|
21799
|
+
return {
|
|
21800
|
+
action: new CairoCustomEnum2({ IncreaseLever: {
|
|
21801
|
+
pool_id: _params2.pool_id.toBigInt(),
|
|
21802
|
+
collateral_asset: _params2.collateral_asset.toBigInt(),
|
|
21803
|
+
debt_asset: _params2.debt_asset.toBigInt(),
|
|
21804
|
+
user: _params2.user.toBigInt(),
|
|
21805
|
+
add_margin: BigInt(_params2.add_margin.toWei()),
|
|
21806
|
+
margin_swap: _params2.margin_swap.map((swap) => ({
|
|
21807
|
+
route: swap.route.map((route) => ({
|
|
21808
|
+
pool_key: {
|
|
21809
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21810
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21811
|
+
fee: route.pool_key.fee,
|
|
21812
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21813
|
+
extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
|
|
21814
|
+
},
|
|
21815
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21816
|
+
skip_ahead: BigInt(100)
|
|
21817
|
+
})),
|
|
21818
|
+
token_amount: {
|
|
21819
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21820
|
+
amount: swap.token_amount.amount.toI129()
|
|
21821
|
+
}
|
|
21822
|
+
})),
|
|
21823
|
+
margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
|
|
21824
|
+
lever_swap: _params2.lever_swap.map((swap) => ({
|
|
21825
|
+
route: swap.route.map((route) => ({
|
|
21826
|
+
pool_key: {
|
|
21827
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21828
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21829
|
+
fee: route.pool_key.fee,
|
|
21830
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21831
|
+
extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
|
|
21832
|
+
},
|
|
21833
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21834
|
+
skip_ahead: BigInt(100)
|
|
21835
|
+
})),
|
|
21836
|
+
token_amount: {
|
|
21837
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21838
|
+
amount: swap.token_amount.amount.toI129()
|
|
21839
|
+
}
|
|
21840
|
+
})),
|
|
21841
|
+
lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
|
|
21842
|
+
} })
|
|
21843
|
+
};
|
|
21844
|
+
}
|
|
21845
|
+
const _params = params;
|
|
21846
|
+
return {
|
|
21847
|
+
action: new CairoCustomEnum2({ DecreaseLever: {
|
|
21848
|
+
pool_id: _params.pool_id.toBigInt(),
|
|
21849
|
+
collateral_asset: _params.collateral_asset.toBigInt(),
|
|
21850
|
+
debt_asset: _params.debt_asset.toBigInt(),
|
|
21851
|
+
user: _params.user.toBigInt(),
|
|
21852
|
+
sub_margin: BigInt(_params.sub_margin.toWei()),
|
|
21853
|
+
recipient: _params.recipient.toBigInt(),
|
|
21854
|
+
lever_swap: _params.lever_swap.map((swap) => ({
|
|
21855
|
+
route: swap.route.map((route) => ({
|
|
21856
|
+
pool_key: {
|
|
21857
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21858
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21859
|
+
fee: route.pool_key.fee,
|
|
21860
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21861
|
+
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
21862
|
+
},
|
|
21863
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21864
|
+
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
21865
|
+
})),
|
|
21866
|
+
token_amount: {
|
|
21867
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21868
|
+
amount: swap.token_amount.amount.toI129()
|
|
21869
|
+
}
|
|
21870
|
+
})),
|
|
21871
|
+
lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
|
|
21872
|
+
lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
|
|
21873
|
+
withdraw_swap: _params.withdraw_swap.map((swap) => ({
|
|
21874
|
+
route: swap.route.map((route) => ({
|
|
21875
|
+
pool_key: {
|
|
21876
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21877
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21878
|
+
fee: route.pool_key.fee,
|
|
21879
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21880
|
+
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
21881
|
+
},
|
|
21882
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21883
|
+
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
21884
|
+
})),
|
|
21885
|
+
token_amount: {
|
|
21886
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21887
|
+
amount: swap.token_amount.amount.toI129()
|
|
21888
|
+
}
|
|
21889
|
+
})),
|
|
21890
|
+
withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
|
|
21891
|
+
withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
|
|
21892
|
+
close_position: _params.close_position
|
|
21893
|
+
} })
|
|
21894
|
+
};
|
|
21895
|
+
}
|
|
21896
|
+
var VesuPools = {
|
|
21897
|
+
Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
|
|
21898
|
+
Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161")
|
|
21899
|
+
};
|
|
21900
|
+
var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
21901
|
+
constructor(config) {
|
|
21902
|
+
super();
|
|
21903
|
+
this.VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
|
|
21904
|
+
this.VESU_MULTIPLY = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
|
|
21905
|
+
this.getModifyPosition = () => {
|
|
21906
|
+
const positionData = [0n];
|
|
21907
|
+
const packedArguments = [
|
|
21908
|
+
toBigInt(this.config.poolId.toString()),
|
|
21909
|
+
// pool id
|
|
21910
|
+
toBigInt(this.config.collateral.address.toString()),
|
|
21911
|
+
// collateral
|
|
21912
|
+
toBigInt(this.config.debt.address.toString()),
|
|
21913
|
+
// debt
|
|
21914
|
+
toBigInt(this.config.vaultAllocator.toString()),
|
|
21915
|
+
// vault allocator
|
|
21916
|
+
toBigInt(positionData.length),
|
|
21917
|
+
...positionData
|
|
21918
|
+
];
|
|
21919
|
+
const output = this.constructSimpleLeafData({
|
|
21920
|
+
id: this.config.id,
|
|
21921
|
+
target: this.VESU_SINGLETON,
|
|
21922
|
+
method: "modify_position",
|
|
21923
|
+
packedArguments
|
|
21924
|
+
});
|
|
21925
|
+
return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
|
|
21926
|
+
};
|
|
21927
|
+
this.getModifyPositionCall = (params) => {
|
|
21928
|
+
const _collateral = {
|
|
21929
|
+
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
21930
|
+
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
21931
|
+
value: {
|
|
21932
|
+
abs: uint2567.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
21933
|
+
is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
|
|
21934
|
+
}
|
|
21935
|
+
};
|
|
21936
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
|
|
21937
|
+
const _debt = {
|
|
21938
|
+
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
21939
|
+
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
21940
|
+
value: {
|
|
21941
|
+
abs: uint2567.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
21942
|
+
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
21943
|
+
}
|
|
21944
|
+
};
|
|
21945
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
|
|
21946
|
+
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21947
|
+
const call = singletonContract.populate("modify_position", {
|
|
21948
|
+
params: {
|
|
21949
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
21950
|
+
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
21951
|
+
debt_asset: this.config.debt.address.toBigInt(),
|
|
21952
|
+
user: this.config.vaultAllocator.toBigInt(),
|
|
21953
|
+
collateral: _collateral,
|
|
21954
|
+
debt: _debt,
|
|
21955
|
+
data: [0]
|
|
21956
|
+
}
|
|
21957
|
+
});
|
|
21958
|
+
return {
|
|
21959
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
21960
|
+
call: {
|
|
21961
|
+
contractAddress: this.VESU_SINGLETON,
|
|
21962
|
+
selector: hash3.getSelectorFromName("modify_position"),
|
|
21963
|
+
calldata: [
|
|
21964
|
+
...call.calldata
|
|
21965
|
+
]
|
|
21966
|
+
}
|
|
21967
|
+
};
|
|
21968
|
+
};
|
|
21969
|
+
this.getMultiplyAdapter = () => {
|
|
21970
|
+
const packedArguments = [
|
|
21971
|
+
toBigInt(this.config.poolId.toString()),
|
|
21972
|
+
// pool id
|
|
21973
|
+
toBigInt(this.config.collateral.address.toString()),
|
|
21974
|
+
// collateral
|
|
21975
|
+
toBigInt(this.config.debt.address.toString()),
|
|
21976
|
+
// debt
|
|
21977
|
+
toBigInt(this.config.vaultAllocator.toString())
|
|
21978
|
+
// vault allocator
|
|
21979
|
+
];
|
|
21980
|
+
const output = this.constructSimpleLeafData({
|
|
21981
|
+
id: this.config.id,
|
|
21982
|
+
target: this.VESU_MULTIPLY,
|
|
21983
|
+
method: "modify_lever",
|
|
21984
|
+
packedArguments
|
|
21985
|
+
}, SIMPLE_SANITIZER_V2);
|
|
21986
|
+
return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
|
|
21987
|
+
};
|
|
21988
|
+
this.getMultiplyCall = (params) => {
|
|
21989
|
+
const isIncrease = params.isIncrease;
|
|
21990
|
+
const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
|
|
21991
|
+
if (!multiplyParams) {
|
|
21992
|
+
throw new Error("Multiply params are not provided");
|
|
21993
|
+
}
|
|
21994
|
+
const multiplyContract = new Contract8({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21995
|
+
const call = multiplyContract.populate("modify_lever", {
|
|
21996
|
+
modify_lever_params: getVesuMultiplyParams(isIncrease, {
|
|
21997
|
+
...multiplyParams,
|
|
21998
|
+
user: this.config.vaultAllocator,
|
|
21999
|
+
pool_id: this.config.poolId,
|
|
22000
|
+
collateral_asset: this.config.collateral.address,
|
|
22001
|
+
debt_asset: this.config.debt.address,
|
|
22002
|
+
recipient: this.config.vaultAllocator
|
|
22003
|
+
})
|
|
22004
|
+
});
|
|
22005
|
+
return {
|
|
22006
|
+
sanitizer: SIMPLE_SANITIZER_V2,
|
|
22007
|
+
call: {
|
|
22008
|
+
contractAddress: this.VESU_MULTIPLY,
|
|
22009
|
+
selector: hash3.getSelectorFromName("modify_lever"),
|
|
22010
|
+
calldata: [
|
|
22011
|
+
...call.calldata
|
|
22012
|
+
]
|
|
22013
|
+
}
|
|
22014
|
+
};
|
|
22015
|
+
};
|
|
22016
|
+
this.getVesuModifyDelegationAdapter = (id) => {
|
|
22017
|
+
return () => {
|
|
22018
|
+
const packedArguments = [
|
|
22019
|
+
toBigInt(this.config.poolId.toString()),
|
|
22020
|
+
// pool id
|
|
22021
|
+
toBigInt(this.VESU_MULTIPLY.toString())
|
|
22022
|
+
// vault allocator
|
|
22023
|
+
];
|
|
22024
|
+
const output = this.constructSimpleLeafData({
|
|
22025
|
+
id,
|
|
22026
|
+
target: this.VESU_SINGLETON,
|
|
22027
|
+
method: "modify_delegation",
|
|
22028
|
+
packedArguments
|
|
22029
|
+
}, SIMPLE_SANITIZER_V2);
|
|
22030
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
22031
|
+
};
|
|
22032
|
+
};
|
|
22033
|
+
this.getVesuModifyDelegationCall = (params) => {
|
|
22034
|
+
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
22035
|
+
const call = singletonContract.populate("modify_delegation", {
|
|
22036
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
22037
|
+
delegatee: this.VESU_MULTIPLY.toBigInt(),
|
|
22038
|
+
delegation: params.delegation
|
|
22039
|
+
});
|
|
22040
|
+
return {
|
|
22041
|
+
sanitizer: SIMPLE_SANITIZER_V2,
|
|
22042
|
+
call: {
|
|
22043
|
+
contractAddress: this.VESU_SINGLETON,
|
|
22044
|
+
selector: hash3.getSelectorFromName("modify_delegation"),
|
|
22045
|
+
calldata: [
|
|
22046
|
+
...call.calldata
|
|
22047
|
+
]
|
|
22048
|
+
}
|
|
22049
|
+
};
|
|
22050
|
+
};
|
|
22051
|
+
this.getDefispringRewardsAdapter = (id) => {
|
|
22052
|
+
return () => {
|
|
22053
|
+
const packedArguments = [];
|
|
22054
|
+
const output = {
|
|
22055
|
+
id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
|
|
22056
|
+
readableId: id,
|
|
22057
|
+
data: [
|
|
22058
|
+
SIMPLE_SANITIZER.toBigInt(),
|
|
22059
|
+
// sanitizer address
|
|
22060
|
+
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
22061
|
+
// contract
|
|
22062
|
+
toBigInt(hash3.getSelectorFromName("claim")),
|
|
22063
|
+
// method name
|
|
22064
|
+
BigInt(packedArguments.length),
|
|
22065
|
+
...packedArguments
|
|
22066
|
+
]
|
|
22067
|
+
};
|
|
22068
|
+
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
22069
|
+
};
|
|
22070
|
+
};
|
|
22071
|
+
this.getDefiSpringClaimCall = () => {
|
|
22072
|
+
return (params) => ({
|
|
22073
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
22074
|
+
call: {
|
|
22075
|
+
contractAddress: VESU_REWARDS_CONTRACT,
|
|
22076
|
+
selector: hash3.getSelectorFromName("claim"),
|
|
22077
|
+
calldata: [
|
|
22078
|
+
BigInt(params.amount.toWei()),
|
|
22079
|
+
BigInt(params.proofs.length),
|
|
22080
|
+
...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
|
|
22081
|
+
]
|
|
22082
|
+
}
|
|
22083
|
+
});
|
|
22084
|
+
};
|
|
22085
|
+
this.config = config;
|
|
22086
|
+
}
|
|
22087
|
+
static getDefaultModifyPositionCallParams(params) {
|
|
22088
|
+
return {
|
|
22089
|
+
collateralAmount: {
|
|
22090
|
+
amount_type: 0 /* Delta */,
|
|
22091
|
+
denomination: 1 /* Assets */,
|
|
22092
|
+
value: {
|
|
22093
|
+
abs: params.collateralAmount,
|
|
22094
|
+
is_negative: !params.isAddCollateral
|
|
22095
|
+
}
|
|
22096
|
+
},
|
|
22097
|
+
debtAmount: {
|
|
22098
|
+
amount_type: 0 /* Delta */,
|
|
22099
|
+
denomination: 1 /* Assets */,
|
|
22100
|
+
value: {
|
|
22101
|
+
abs: params.debtAmount,
|
|
22102
|
+
is_negative: !params.isBorrow
|
|
22103
|
+
}
|
|
22104
|
+
}
|
|
22105
|
+
};
|
|
22106
|
+
}
|
|
22107
|
+
formatAmountTypeEnum(amountType) {
|
|
22108
|
+
switch (amountType) {
|
|
22109
|
+
case 0 /* Delta */:
|
|
22110
|
+
return new CairoCustomEnum2({ Delta: {} });
|
|
22111
|
+
case 1 /* Target */:
|
|
22112
|
+
return new CairoCustomEnum2({ Target: {} });
|
|
22113
|
+
}
|
|
22114
|
+
throw new Error(`Unknown VesuAmountType: ${amountType}`);
|
|
22115
|
+
}
|
|
22116
|
+
formatAmountDenominationEnum(denomination) {
|
|
22117
|
+
switch (denomination) {
|
|
22118
|
+
case 0 /* Native */:
|
|
22119
|
+
return new CairoCustomEnum2({ Native: {} });
|
|
22120
|
+
case 1 /* Assets */:
|
|
22121
|
+
return new CairoCustomEnum2({ Assets: {} });
|
|
22122
|
+
}
|
|
22123
|
+
throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
|
|
22124
|
+
}
|
|
22125
|
+
getVesuSingletonContract(config) {
|
|
22126
|
+
return new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider });
|
|
22127
|
+
}
|
|
22128
|
+
async getLTVConfig(config) {
|
|
22129
|
+
const CACHE_KEY = "ltv_config";
|
|
22130
|
+
const cacheData = this.getCache(CACHE_KEY);
|
|
22131
|
+
if (cacheData) {
|
|
22132
|
+
return cacheData;
|
|
22133
|
+
}
|
|
22134
|
+
const output = await this.getVesuSingletonContract(config).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
|
|
21396
22135
|
this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 3e5);
|
|
21397
22136
|
return this.getCache(CACHE_KEY);
|
|
21398
22137
|
}
|
|
@@ -23732,10 +24471,10 @@ var vault_manager_abi_default = [
|
|
|
23732
24471
|
|
|
23733
24472
|
// src/strategies/universal-strategy.tsx
|
|
23734
24473
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
23735
|
-
var AUMTypes = /* @__PURE__ */ ((
|
|
23736
|
-
|
|
23737
|
-
|
|
23738
|
-
return
|
|
24474
|
+
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
24475
|
+
AUMTypes3["FINALISED"] = "finalised";
|
|
24476
|
+
AUMTypes3["DEFISPRING"] = "defispring";
|
|
24477
|
+
return AUMTypes3;
|
|
23739
24478
|
})(AUMTypes || {});
|
|
23740
24479
|
var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
23741
24480
|
constructor(config, pricer, metadata) {
|
|
@@ -23863,24 +24602,33 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23863
24602
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
23864
24603
|
*/
|
|
23865
24604
|
async netAPY() {
|
|
23866
|
-
const
|
|
23867
|
-
const
|
|
23868
|
-
const
|
|
23869
|
-
const
|
|
23870
|
-
|
|
24605
|
+
const prevAUM = await this.getPrevAUM();
|
|
24606
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24607
|
+
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
24608
|
+
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
24609
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num9.getHexString(p.id)));
|
|
24610
|
+
});
|
|
24611
|
+
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
24612
|
+
if (pools.some((p) => !p)) {
|
|
23871
24613
|
throw new Error("Pool not found");
|
|
23872
24614
|
}
|
|
23873
24615
|
;
|
|
23874
|
-
const
|
|
23875
|
-
const debtAsset1 = pool1.assets.find((a) => a.symbol === vesuAdapter1.config.debt.symbol)?.stats;
|
|
23876
|
-
const collateralAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.collateral.symbol)?.stats;
|
|
23877
|
-
const debtAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.debt.symbol)?.stats;
|
|
23878
|
-
const collateral1APY = Number(collateralAsset1.supplyApy.value) / 1e18;
|
|
23879
|
-
const debt1APY = Number(debtAsset1.borrowApr.value) / 1e18;
|
|
23880
|
-
const collateral2APY = Number(collateralAsset2.supplyApy.value) / 1e18;
|
|
23881
|
-
const debt2APY = Number(debtAsset2.borrowApr.value) / 1e18;
|
|
23882
|
-
const positions = await this.getVaultPositions();
|
|
24616
|
+
const positions = await this.getVesuPositions();
|
|
23883
24617
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
24618
|
+
const baseAPYs = [];
|
|
24619
|
+
const rewardAPYs = [];
|
|
24620
|
+
for (const [index, pool] of pools.entries()) {
|
|
24621
|
+
const vesuAdapter = vesuAdapters[index];
|
|
24622
|
+
const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
|
|
24623
|
+
const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
|
|
24624
|
+
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
24625
|
+
const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
|
|
24626
|
+
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
24627
|
+
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
|
|
24628
|
+
}
|
|
24629
|
+
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
24630
|
+
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
24631
|
+
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
23884
24632
|
if (positions.every((p) => p.amount.isZero())) {
|
|
23885
24633
|
return { net: 0, splits: [{
|
|
23886
24634
|
apy: 0,
|
|
@@ -23891,11 +24639,10 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23891
24639
|
}] };
|
|
23892
24640
|
}
|
|
23893
24641
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
23894
|
-
const
|
|
23895
|
-
|
|
23896
|
-
const
|
|
23897
|
-
const
|
|
23898
|
-
const rewardAPY = this.computeAPY(rewardAPYs, weights);
|
|
24642
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
24643
|
+
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
24644
|
+
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
24645
|
+
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
23899
24646
|
const netAPY = baseAPY + rewardAPY;
|
|
23900
24647
|
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
23901
24648
|
return { net: netAPY, splits: [{
|
|
@@ -23906,11 +24653,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23906
24653
|
id: "defispring"
|
|
23907
24654
|
}] };
|
|
23908
24655
|
}
|
|
23909
|
-
computeAPY(apys, weights) {
|
|
24656
|
+
computeAPY(apys, weights, currentAUM) {
|
|
23910
24657
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
23911
24658
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
23912
|
-
|
|
23913
|
-
return weightedSum /
|
|
24659
|
+
logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
|
|
24660
|
+
return weightedSum / currentAUM.toNumber();
|
|
23914
24661
|
}
|
|
23915
24662
|
/**
|
|
23916
24663
|
* Calculates the total TVL of the strategy.
|
|
@@ -23942,24 +24689,48 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23942
24689
|
usdValue
|
|
23943
24690
|
};
|
|
23944
24691
|
}
|
|
23945
|
-
async
|
|
24692
|
+
async getVesuAUM(adapter) {
|
|
24693
|
+
const legAUM = await adapter.getPositions(this.config);
|
|
24694
|
+
const underlying = this.asset();
|
|
24695
|
+
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
24696
|
+
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
24697
|
+
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
24698
|
+
} else {
|
|
24699
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24700
|
+
vesuAum = vesuAum.plus(legAUM[1].usdValue / tokenPrice.price);
|
|
24701
|
+
}
|
|
24702
|
+
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
24703
|
+
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
24704
|
+
} else {
|
|
24705
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24706
|
+
vesuAum = vesuAum.minus(legAUM[1].usdValue / tokenPrice.price);
|
|
24707
|
+
}
|
|
24708
|
+
;
|
|
24709
|
+
logger.verbose(`${this.getTag()} Vesu AUM: ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
24710
|
+
return vesuAum;
|
|
24711
|
+
}
|
|
24712
|
+
async getPrevAUM() {
|
|
23946
24713
|
const currentAUM = await this.contract.call("aum", []);
|
|
23947
|
-
const
|
|
24714
|
+
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
24715
|
+
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
24716
|
+
return prevAum;
|
|
24717
|
+
}
|
|
24718
|
+
async getAUM() {
|
|
24719
|
+
const prevAum = await this.getPrevAUM();
|
|
23948
24720
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
23949
|
-
const
|
|
23950
|
-
|
|
23951
|
-
const
|
|
24721
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24722
|
+
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
24723
|
+
for (const adapter of vesuAdapters) {
|
|
24724
|
+
vesuAum = vesuAum.plus(await this.getVesuAUM(adapter));
|
|
24725
|
+
}
|
|
23952
24726
|
const balance = await this.getUnusedBalance();
|
|
23953
24727
|
logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
23954
|
-
const vesuAum = leg1AUM[0].amount.plus(leg2AUM[0].usdValue / token1Price.price).minus(leg1AUM[1].usdValue / token1Price.price).minus(leg2AUM[1].amount);
|
|
23955
|
-
logger.verbose(`${this.getTag()} Vesu AUM: leg1: ${leg1AUM[0].amount.toNumber()}, ${leg1AUM[1].amount.toNumber()}, leg2: ${leg2AUM[0].amount.toNumber()}, ${leg2AUM[1].amount.toNumber()}`);
|
|
23956
24728
|
const zeroAmt = Web3Number.fromWei("0", this.asset().decimals);
|
|
23957
24729
|
const net = {
|
|
23958
24730
|
tokenInfo: this.asset(),
|
|
23959
24731
|
amount: zeroAmt,
|
|
23960
24732
|
usdValue: 0
|
|
23961
24733
|
};
|
|
23962
|
-
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
23963
24734
|
if (vesuAum.isZero()) {
|
|
23964
24735
|
return { net, splits: [{
|
|
23965
24736
|
aum: zeroAmt,
|
|
@@ -23971,16 +24742,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23971
24742
|
}
|
|
23972
24743
|
const aumToken = vesuAum.plus(balance.amount);
|
|
23973
24744
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
23974
|
-
const
|
|
23975
|
-
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
23976
|
-
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
23977
|
-
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
23978
|
-
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
23979
|
-
const rewardAssets = prevAum.multipliedBy(growthRate);
|
|
23980
|
-
logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
|
|
23981
|
-
logger.verbose(`${this.getTag()} Current AUM: ${currentAUM}`);
|
|
23982
|
-
logger.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
|
|
23983
|
-
logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
|
|
24745
|
+
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
23984
24746
|
const newAUM = aumToken.plus(rewardAssets);
|
|
23985
24747
|
logger.verbose(`${this.getTag()} New AUM: ${newAUM}`);
|
|
23986
24748
|
net.amount = newAUM;
|
|
@@ -23994,6 +24756,21 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23994
24756
|
}];
|
|
23995
24757
|
return { net, splits, prevAum };
|
|
23996
24758
|
}
|
|
24759
|
+
// account for future rewards (e.g. defispring rewards)
|
|
24760
|
+
async getRewardsAUM(prevAum) {
|
|
24761
|
+
const lastReportTime = await this.contract.call("last_report_timestamp", []);
|
|
24762
|
+
const netAPY = await this.netAPY();
|
|
24763
|
+
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
24764
|
+
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
24765
|
+
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
24766
|
+
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
24767
|
+
const rewardAssets = prevAum.multipliedBy(growthRate);
|
|
24768
|
+
logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
|
|
24769
|
+
logger.verbose(`${this.getTag()} Current AUM: ${prevAum.toString()}`);
|
|
24770
|
+
logger.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
|
|
24771
|
+
logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
|
|
24772
|
+
return rewardAssets;
|
|
24773
|
+
}
|
|
23997
24774
|
getVesuAdapters() {
|
|
23998
24775
|
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
23999
24776
|
const vesuAdapter2 = this.getAdapter("vesu_leg2_adapter" /* VESU_LEG2 */);
|
|
@@ -24003,11 +24780,23 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
24003
24780
|
vesuAdapter2.networkConfig = this.config;
|
|
24004
24781
|
return [vesuAdapter1, vesuAdapter2];
|
|
24005
24782
|
}
|
|
24783
|
+
async getVesuPositions() {
|
|
24784
|
+
const adapters = this.getVesuAdapters();
|
|
24785
|
+
const positions = [];
|
|
24786
|
+
for (const adapter of adapters) {
|
|
24787
|
+
positions.push(...await adapter.getPositions(this.config));
|
|
24788
|
+
}
|
|
24789
|
+
return positions;
|
|
24790
|
+
}
|
|
24006
24791
|
async getVaultPositions() {
|
|
24007
|
-
const
|
|
24008
|
-
const
|
|
24009
|
-
|
|
24010
|
-
|
|
24792
|
+
const vesuPositions = await this.getVesuPositions();
|
|
24793
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
24794
|
+
return [...vesuPositions, {
|
|
24795
|
+
amount: unusedBalance.amount,
|
|
24796
|
+
usdValue: unusedBalance.usdValue,
|
|
24797
|
+
token: this.asset(),
|
|
24798
|
+
remarks: "Unused Balance"
|
|
24799
|
+
}];
|
|
24011
24800
|
}
|
|
24012
24801
|
getSetManagerCall(strategist, root = this.getMerkleRoot()) {
|
|
24013
24802
|
return this.managerContract.populate("set_manage_root", [strategist.address, num9.getHexString(root)]);
|
|
@@ -24145,7 +24934,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
24145
24934
|
return new Web3Number(newAmount.toFixed(8), debtTokenAmount.decimals);
|
|
24146
24935
|
}
|
|
24147
24936
|
}
|
|
24148
|
-
async
|
|
24937
|
+
async getVesuModifyPositionCall(params) {
|
|
24149
24938
|
const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
|
|
24150
24939
|
const leg1LTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
24151
24940
|
const leg2LTV = await vesuAdapter2.getLTVConfig(this.config);
|
|
@@ -24646,6 +25435,336 @@ var UniversalStrategies = [
|
|
|
24646
25435
|
}
|
|
24647
25436
|
];
|
|
24648
25437
|
|
|
25438
|
+
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
25439
|
+
import { Contract as Contract10, uint256 as uint2569 } from "starknet";
|
|
25440
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
25441
|
+
var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
|
|
25442
|
+
constructor(config, pricer, metadata) {
|
|
25443
|
+
super(config, pricer, metadata);
|
|
25444
|
+
this.quoteAmountToFetchPrice = new Web3Number(1, 18);
|
|
25445
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25446
|
+
const underlyingToken = this.getLSTUnderlyingTokenInfo();
|
|
25447
|
+
if (underlyingToken.address.eq(STRKToken.address)) {
|
|
25448
|
+
this.quoteAmountToFetchPrice = new Web3Number(100, 18);
|
|
25449
|
+
} else {
|
|
25450
|
+
this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
|
|
25451
|
+
}
|
|
25452
|
+
}
|
|
25453
|
+
// only one leg is used
|
|
25454
|
+
// todo support lending assets of underlying as well
|
|
25455
|
+
getVesuAdapters() {
|
|
25456
|
+
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
25457
|
+
vesuAdapter1.pricer = this.pricer;
|
|
25458
|
+
vesuAdapter1.networkConfig = this.config;
|
|
25459
|
+
return [vesuAdapter1];
|
|
25460
|
+
}
|
|
25461
|
+
// not applicable for this strategy
|
|
25462
|
+
// No rewards on collateral or borrowing of LST assets
|
|
25463
|
+
async getRewardsAUM(prevAum) {
|
|
25464
|
+
return Web3Number.fromWei("0", this.asset().decimals);
|
|
25465
|
+
}
|
|
25466
|
+
async getLSTDexPrice() {
|
|
25467
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25468
|
+
const lstTokenInfo = this.asset();
|
|
25469
|
+
const lstUnderlyingTokenInfo = this.getLSTUnderlyingTokenInfo();
|
|
25470
|
+
const quote = await ekuboQuoter.getQuote(
|
|
25471
|
+
lstTokenInfo.address.address,
|
|
25472
|
+
lstUnderlyingTokenInfo.address.address,
|
|
25473
|
+
this.quoteAmountToFetchPrice
|
|
25474
|
+
);
|
|
25475
|
+
const outputAmount = Web3Number.fromWei(quote.total_calculated, lstUnderlyingTokenInfo.decimals);
|
|
25476
|
+
const price = outputAmount.toNumber() / this.quoteAmountToFetchPrice.toNumber();
|
|
25477
|
+
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
25478
|
+
return price;
|
|
25479
|
+
}
|
|
25480
|
+
/**
|
|
25481
|
+
* Uses vesu's multiple call to create leverage on LST
|
|
25482
|
+
* Deposit amount is in LST
|
|
25483
|
+
* @param params
|
|
25484
|
+
*/
|
|
25485
|
+
async getVesuMultiplyCall(params) {
|
|
25486
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25487
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
25488
|
+
const existingPositions = await vesuAdapter1.getPositions(this.config);
|
|
25489
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
25490
|
+
const existingCollateralInfo = existingPositions[0];
|
|
25491
|
+
const existingDebtInfo = existingPositions[1];
|
|
25492
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
25493
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
25494
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
25495
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
25496
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
25497
|
+
const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
|
|
25498
|
+
const DEXPrice = await this.getLSTDexPrice();
|
|
25499
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
|
|
25500
|
+
const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
|
|
25501
|
+
const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
|
|
25502
|
+
const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / DEXPrice;
|
|
25503
|
+
const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
|
|
25504
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
|
|
25505
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
|
|
25506
|
+
const debtAmount = x_debt_usd.dividedBy(debtPrice);
|
|
25507
|
+
const marginAmount = addedCollateral;
|
|
25508
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
|
|
25509
|
+
return this.getModifyLeverCall({
|
|
25510
|
+
marginAmount,
|
|
25511
|
+
debtAmount,
|
|
25512
|
+
isIncrease: debtAmount.greaterThan(0)
|
|
25513
|
+
});
|
|
25514
|
+
}
|
|
25515
|
+
getLSTUnderlyingTokenInfo() {
|
|
25516
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25517
|
+
return vesuAdapter1.config.debt;
|
|
25518
|
+
}
|
|
25519
|
+
async getLSTExchangeRate() {
|
|
25520
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25521
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
25522
|
+
const lstABI = new Contract10({
|
|
25523
|
+
abi: erc4626_abi_default,
|
|
25524
|
+
address: lstTokenInfo.address.address,
|
|
25525
|
+
providerOrAccount: this.config.provider
|
|
25526
|
+
});
|
|
25527
|
+
const price = await lstABI.call("convert_to_assets", [uint2569.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
25528
|
+
const exchangeRate = Number(uint2569.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
25529
|
+
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
25530
|
+
return exchangeRate;
|
|
25531
|
+
}
|
|
25532
|
+
/**
|
|
25533
|
+
*
|
|
25534
|
+
* @param params marginAmount is in LST, debtAmount is in underlying
|
|
25535
|
+
*/
|
|
25536
|
+
async getModifyLeverCall(params) {
|
|
25537
|
+
assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
|
|
25538
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25539
|
+
const lstTokenInfo = this.asset();
|
|
25540
|
+
const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
|
|
25541
|
+
const proofsIDs = [];
|
|
25542
|
+
const manageCalls = [];
|
|
25543
|
+
if (params.marginAmount.greaterThan(0)) {
|
|
25544
|
+
const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
25545
|
+
const manage1Info = this.getProofs(STEP1_ID);
|
|
25546
|
+
const depositAmount = params.marginAmount;
|
|
25547
|
+
const manageCall1 = manage1Info.callConstructor({
|
|
25548
|
+
amount: depositAmount
|
|
25549
|
+
});
|
|
25550
|
+
proofsIDs.push(STEP1_ID);
|
|
25551
|
+
manageCalls.push(manageCall1);
|
|
25552
|
+
}
|
|
25553
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25554
|
+
const lstPrice = await this.getLSTExchangeRate();
|
|
25555
|
+
const marginSwap = [];
|
|
25556
|
+
const MAX_SLIPPAGE = 0.01;
|
|
25557
|
+
const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
|
|
25558
|
+
const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
|
|
25559
|
+
const leverSwapQuote = await ekuboQuoter.getQuote(
|
|
25560
|
+
fromToken.address.address,
|
|
25561
|
+
toToken.address.address,
|
|
25562
|
+
params.debtAmount
|
|
25563
|
+
// negative for exact amount out
|
|
25564
|
+
);
|
|
25565
|
+
assert(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
|
|
25566
|
+
const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
|
|
25567
|
+
const minExpectedDebt = params.debtAmount.dividedBy(lstPrice).multipliedBy(1 - MAX_SLIPPAGE);
|
|
25568
|
+
const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstPrice).multipliedBy(1 + MAX_SLIPPAGE);
|
|
25569
|
+
const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
|
|
25570
|
+
const manage2Info = this.getProofs(STEP2_ID);
|
|
25571
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
25572
|
+
delegation: true
|
|
25573
|
+
});
|
|
25574
|
+
const STEP3_ID = "multiply_vesu" /* MULTIPLY_VESU */;
|
|
25575
|
+
const manage3Info = this.getProofs(STEP3_ID);
|
|
25576
|
+
const multiplyParams = params.isIncrease ? {
|
|
25577
|
+
isIncrease: true,
|
|
25578
|
+
increaseParams: {
|
|
25579
|
+
add_margin: params.marginAmount,
|
|
25580
|
+
margin_swap: marginSwap,
|
|
25581
|
+
margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25582
|
+
lever_swap: leverSwap,
|
|
25583
|
+
lever_swap_limit_amount: minExpectedDebt
|
|
25584
|
+
}
|
|
25585
|
+
} : {
|
|
25586
|
+
isIncrease: false,
|
|
25587
|
+
decreaseParams: {
|
|
25588
|
+
sub_margin: params.marginAmount.multipliedBy(-1),
|
|
25589
|
+
lever_swap: leverSwap,
|
|
25590
|
+
lever_swap_limit_amount: maxUsedCollateral,
|
|
25591
|
+
// only required for close position
|
|
25592
|
+
lever_swap_weights: [],
|
|
25593
|
+
// no need to swap collateral to anything, and any residuals return our contract anyways.
|
|
25594
|
+
withdraw_swap: [],
|
|
25595
|
+
withdraw_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25596
|
+
withdraw_swap_weights: [],
|
|
25597
|
+
close_position: false
|
|
25598
|
+
}
|
|
25599
|
+
};
|
|
25600
|
+
const manageCall3 = manage3Info.callConstructor(multiplyParams);
|
|
25601
|
+
const STEP4_ID = "switch_delegation_off" /* SWITCH_DELEGATION_OFF */;
|
|
25602
|
+
const manage4Info = this.getProofs(STEP4_ID);
|
|
25603
|
+
const manageCall4 = manage4Info.callConstructor({
|
|
25604
|
+
delegation: false
|
|
25605
|
+
});
|
|
25606
|
+
proofsIDs.push(STEP2_ID, STEP3_ID, STEP4_ID);
|
|
25607
|
+
manageCalls.push(manageCall2, manageCall3, manageCall4);
|
|
25608
|
+
return [this.getManageCall(proofsIDs, manageCalls)];
|
|
25609
|
+
}
|
|
25610
|
+
};
|
|
25611
|
+
function VaultDescription() {
|
|
25612
|
+
const containerStyle = {
|
|
25613
|
+
maxWidth: "800px",
|
|
25614
|
+
margin: "0 auto",
|
|
25615
|
+
backgroundColor: "#111",
|
|
25616
|
+
color: "#eee",
|
|
25617
|
+
fontFamily: "Arial, sans-serif",
|
|
25618
|
+
borderRadius: "12px"
|
|
25619
|
+
};
|
|
25620
|
+
return /* @__PURE__ */ jsxs4("div", { style: containerStyle, children: [
|
|
25621
|
+
/* @__PURE__ */ jsx5("h1", { style: { fontSize: "18px", marginBottom: "10px" }, children: "Meta Vault \u2014 Automated Yield Router" }),
|
|
25622
|
+
/* @__PURE__ */ jsx5("p", { style: { fontSize: "14px", lineHeight: "1.5", marginBottom: "16px" }, children: "This Levered Endur LST vault is a tokenized leveraged Vault, auto-compounding strategy that continuously allocates your deposited asset to the best available yield source in the ecosystem. Depositors receive vault shares that represent a proportional claim on the underlying assets and accrued yield. Allocation shifts are handled programmatically based on on-chain signals and risk filters, minimizing idle capital and maximizing net APY." }),
|
|
25623
|
+
/* @__PURE__ */ jsx5("div", { style: { backgroundColor: "#222", padding: "10px", borderRadius: "8px", marginBottom: "20px", border: "1px solid #444" }, children: /* @__PURE__ */ jsxs4("p", { style: { fontSize: "13px", color: "#ccc" }, children: [
|
|
25624
|
+
/* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
|
|
25625
|
+
" Requests can take up to ",
|
|
25626
|
+
/* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
|
|
25627
|
+
" to process as the vault unwinds and settles routing."
|
|
25628
|
+
] }) })
|
|
25629
|
+
] });
|
|
25630
|
+
}
|
|
25631
|
+
function getDescription2(tokenSymbol) {
|
|
25632
|
+
return VaultDescription();
|
|
25633
|
+
}
|
|
25634
|
+
function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
25635
|
+
vaultSettings.leafAdapters = [];
|
|
25636
|
+
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
25637
|
+
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
25638
|
+
const vesuAdapterLST = new VesuAdapter({
|
|
25639
|
+
poolId: pool1,
|
|
25640
|
+
collateral: lstToken,
|
|
25641
|
+
debt: underlyingToken,
|
|
25642
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
25643
|
+
id: "multiply_vesu" /* MULTIPLY_VESU */
|
|
25644
|
+
});
|
|
25645
|
+
const commonAdapter = new CommonAdapter({
|
|
25646
|
+
manager: vaultSettings.manager,
|
|
25647
|
+
asset: lstToken.address,
|
|
25648
|
+
id: "",
|
|
25649
|
+
vaultAddress: vaultSettings.vaultAddress,
|
|
25650
|
+
vaultAllocator: vaultSettings.vaultAllocator
|
|
25651
|
+
});
|
|
25652
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vesuAdapterLST.VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
25653
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
|
|
25654
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
25655
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
25656
|
+
vaultSettings.adapters.push(...[{
|
|
25657
|
+
id: "vesu_leg1_adapter" /* VESU_LEG1 */,
|
|
25658
|
+
adapter: vesuAdapterLST
|
|
25659
|
+
}, {
|
|
25660
|
+
id: "common_adapter" /* COMMON */,
|
|
25661
|
+
adapter: commonAdapter
|
|
25662
|
+
}]);
|
|
25663
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25664
|
+
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25665
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
|
|
25666
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25667
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
25668
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
|
|
25669
|
+
return vaultSettings;
|
|
25670
|
+
}
|
|
25671
|
+
function getFAQs2(lstSymbol, underlyingSymbol) {
|
|
25672
|
+
return [
|
|
25673
|
+
{
|
|
25674
|
+
question: `What is the Hyper ${lstSymbol} Vault?`,
|
|
25675
|
+
answer: `The Hyper ${lstSymbol} Vault is a tokenized strategy that automatically loops your ${underlyingSymbol} or ${lstSymbol} to create up to 4x leverage to hence yield in a very low risk manner.`
|
|
25676
|
+
},
|
|
25677
|
+
{
|
|
25678
|
+
question: "How does yield allocation work?",
|
|
25679
|
+
answer: `The strategy uses deposited ${lstSymbol} to collateralize it on Vesu, borrow more ${underlyingSymbol} to loop further. Instead of manually doing this, using flash loan, this leverage is created in a single gas efficient step. Our continuous monitoring systems gauge current yield and available liquidity in real time to make sure yield is optimal. For instance, if the looping becomes in-efficient in future, the strategy will rebalance to reduce leverage or simply hold ${lstSymbol} to continue earning yield.`
|
|
25680
|
+
},
|
|
25681
|
+
{
|
|
25682
|
+
question: "Which protocols/dApp are used??",
|
|
25683
|
+
answer: /* @__PURE__ */ jsxs4("span", { children: [
|
|
25684
|
+
"Currently, the LST is from ",
|
|
25685
|
+
/* @__PURE__ */ jsx5("strong", { children: "Endur" }),
|
|
25686
|
+
" while ",
|
|
25687
|
+
/* @__PURE__ */ jsx5("strong", { children: "Vesu" }),
|
|
25688
|
+
" is used to collateralize the looped position."
|
|
25689
|
+
] })
|
|
25690
|
+
},
|
|
25691
|
+
{
|
|
25692
|
+
question: "Can I get liquidated?",
|
|
25693
|
+
answer: "The strategy uses highly correlated assets which drastically reduces the risk of liquidation. However, overtime, if left un-monitored, debt can increase enough to trigger a liquidation. But no worries, our continuous monitoring systems look for situations with reduced health factor and balance collateral/debt to bring it back to safe levels. With Troves, you can have a peaceful sleep."
|
|
25694
|
+
},
|
|
25695
|
+
{
|
|
25696
|
+
question: "What do I receive when I deposit?",
|
|
25697
|
+
answer: "Depositors receive vault tokens representing their proportional share of the vault. These tokens entitle holders to both the principal and accrued yield."
|
|
25698
|
+
},
|
|
25699
|
+
{
|
|
25700
|
+
question: "How long do withdrawals take?",
|
|
25701
|
+
answer: "Withdrawals may take up to 1-2 hours to process, as the vault unwinds and settles liquidity routing across integrated protocols. In case of large withdrawals, to avoid slippage, we may slowly unwind the position, which could make the withdrawals longer."
|
|
25702
|
+
},
|
|
25703
|
+
{
|
|
25704
|
+
question: "Is the Hyper xSTRK Vault non-custodial?",
|
|
25705
|
+
answer: "Yes. The Hyper xSTRK Vault operates entirely on-chain. Users always maintain control of their vault tokens, and the strategy is fully transparent."
|
|
25706
|
+
},
|
|
25707
|
+
{
|
|
25708
|
+
question: "Is the Vault audited?",
|
|
25709
|
+
answer: "Yes. The Hyper xSTRK Vault is audited by Zellic. Look for safety icon beside the strategy name for more details."
|
|
25710
|
+
},
|
|
25711
|
+
{
|
|
25712
|
+
question: "Are there any fees?",
|
|
25713
|
+
answer: "Troves charges a performance of 10% on the yield generated. The APY shown is net of this fee. This fee is only applied to the profits earned, ensuring that users retain their initial capital."
|
|
25714
|
+
}
|
|
25715
|
+
];
|
|
25716
|
+
}
|
|
25717
|
+
var _riskFactor4 = [
|
|
25718
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 25, reason: "Audited by Zellic" },
|
|
25719
|
+
{ type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 1 /* VERY_LOW_PROBABILITY */, weight: 50, reason: "The collateral and debt are highly correlated" },
|
|
25720
|
+
{ type: "Technical Risk" /* TECHNICAL_RISK */, value: 1 /* STABLE_INFRASTRUCTURE */, weight: 50, reason: "Liquidation can only happen if vault is left un-monitored for weeks, which is highly unlikely. We actively monitor all services on a daily basis." }
|
|
25721
|
+
];
|
|
25722
|
+
var hyperxSTRK = {
|
|
25723
|
+
vaultAddress: ContractAddr.from("0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"),
|
|
25724
|
+
manager: ContractAddr.from("0x5d499cd333757f461a0bedaca3dfc4d77320c773037e0aa299f22a6dbfdc03a"),
|
|
25725
|
+
vaultAllocator: ContractAddr.from("0x511d07953a09bc7c505970891507c5a2486d2ea22752601a14db092186d7caa"),
|
|
25726
|
+
redeemRequestNFT: ContractAddr.from("0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"),
|
|
25727
|
+
aumOracle: ContractAddr.from("0x48cf709870a1a0d453d37de108e0c41b8b89819ef54f95abc0e2e1f98bbe937"),
|
|
25728
|
+
leafAdapters: [],
|
|
25729
|
+
adapters: [],
|
|
25730
|
+
targetHealthFactor: 1.1,
|
|
25731
|
+
minHealthFactor: 1.05
|
|
25732
|
+
};
|
|
25733
|
+
function getInvestmentSteps(lstSymbol, underlyingSymbol) {
|
|
25734
|
+
return [
|
|
25735
|
+
`Deposit ${underlyingSymbol} into the vault`,
|
|
25736
|
+
`The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
|
|
25737
|
+
`The vault manager collateralizes the ${lstSymbol} on Vesu`,
|
|
25738
|
+
`The vault manager borrows more ${underlyingSymbol} to loop further`,
|
|
25739
|
+
`Claim BTCFi STRK rewards weekly to swap to ${lstSymbol} and reinvest`,
|
|
25740
|
+
`If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
|
|
25741
|
+
];
|
|
25742
|
+
}
|
|
25743
|
+
function getStrategySettings(lstSymbol, underlyingSymbol, addresses) {
|
|
25744
|
+
return {
|
|
25745
|
+
name: `Hyper ${lstSymbol}`,
|
|
25746
|
+
description: getDescription2(lstSymbol),
|
|
25747
|
+
address: addresses.vaultAddress,
|
|
25748
|
+
launchBlock: 0,
|
|
25749
|
+
type: "Other",
|
|
25750
|
+
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
|
|
25751
|
+
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
|
|
25752
|
+
risk: {
|
|
25753
|
+
riskFactor: _riskFactor4,
|
|
25754
|
+
netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
|
|
25755
|
+
notARisks: getNoRiskTags(_riskFactor4)
|
|
25756
|
+
},
|
|
25757
|
+
protocols: [Protocols.ENDUR, Protocols.VESU],
|
|
25758
|
+
maxTVL: Web3Number.fromWei(0, 18),
|
|
25759
|
+
contractDetails: getContractDetails(addresses),
|
|
25760
|
+
faqs: getFAQs2(lstSymbol, underlyingSymbol),
|
|
25761
|
+
investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol)
|
|
25762
|
+
};
|
|
25763
|
+
}
|
|
25764
|
+
var HyperLSTStrategies = [
|
|
25765
|
+
getStrategySettings("xSTRK", "STRK", hyperxSTRK)
|
|
25766
|
+
];
|
|
25767
|
+
|
|
24649
25768
|
// src/notifs/telegram.ts
|
|
24650
25769
|
import TelegramBot from "node-telegram-bot-api";
|
|
24651
25770
|
var TelegramNotif = class {
|
|
@@ -25079,9 +26198,11 @@ export {
|
|
|
25079
26198
|
ERC20,
|
|
25080
26199
|
EkuboCLVault,
|
|
25081
26200
|
EkuboCLVaultStrategies,
|
|
26201
|
+
EkuboQuoter,
|
|
25082
26202
|
FatalError,
|
|
25083
26203
|
FlowChartColors,
|
|
25084
26204
|
Global,
|
|
26205
|
+
HyperLSTStrategies,
|
|
25085
26206
|
ILending,
|
|
25086
26207
|
Initializable,
|
|
25087
26208
|
MarginType,
|
|
@@ -25100,6 +26221,7 @@ export {
|
|
|
25100
26221
|
TelegramNotif,
|
|
25101
26222
|
UNIVERSAL_ADAPTERS,
|
|
25102
26223
|
UNIVERSAL_MANAGE_IDS,
|
|
26224
|
+
UniversalLstMultiplierStrategy,
|
|
25103
26225
|
UniversalStrategies,
|
|
25104
26226
|
UniversalStrategy,
|
|
25105
26227
|
VesuAdapter,
|
|
@@ -25112,6 +26234,7 @@ export {
|
|
|
25112
26234
|
ZkLend,
|
|
25113
26235
|
assert,
|
|
25114
26236
|
getAPIUsingHeadlessBrowser,
|
|
26237
|
+
getContractDetails,
|
|
25115
26238
|
getDefaultStoreConfig,
|
|
25116
26239
|
getMainnetConfig,
|
|
25117
26240
|
getNoRiskTags,
|