@strkfarm/sdk 1.1.8 → 1.1.10
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 +1241 -74
- package/dist/index.browser.mjs +1396 -227
- package/dist/index.d.ts +169 -30
- package/dist/index.js +1412 -239
- package/dist/index.mjs +1397 -228
- package/package.json +1 -1
- package/src/data/vesu-multiple.abi.json +475 -0
- package/src/dataTypes/_bignumber.ts +13 -0
- package/src/interfaces/common.tsx +2 -1
- 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 +497 -0
- package/src/strategies/universal-strategy.tsx +142 -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 }),
|
|
@@ -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,42 @@ 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
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
24605
|
+
if (this.metadata.isPreview) {
|
|
24606
|
+
return { net: 0, splits: [{
|
|
24607
|
+
apy: 0,
|
|
24608
|
+
id: "base"
|
|
24609
|
+
}, {
|
|
24610
|
+
apy: 0,
|
|
24611
|
+
id: "defispring"
|
|
24612
|
+
}] };
|
|
24613
|
+
}
|
|
24614
|
+
const prevAUM = await this.getPrevAUM();
|
|
24615
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24616
|
+
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
24617
|
+
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
24618
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num9.getHexString(p.id)));
|
|
24619
|
+
});
|
|
24620
|
+
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
24621
|
+
if (pools.some((p) => !p)) {
|
|
23871
24622
|
throw new Error("Pool not found");
|
|
23872
24623
|
}
|
|
23873
24624
|
;
|
|
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();
|
|
24625
|
+
const positions = await this.getVesuPositions();
|
|
23883
24626
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
24627
|
+
const baseAPYs = [];
|
|
24628
|
+
const rewardAPYs = [];
|
|
24629
|
+
for (const [index, pool] of pools.entries()) {
|
|
24630
|
+
const vesuAdapter = vesuAdapters[index];
|
|
24631
|
+
const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
|
|
24632
|
+
const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
|
|
24633
|
+
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
24634
|
+
const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
|
|
24635
|
+
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
24636
|
+
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
|
|
24637
|
+
}
|
|
24638
|
+
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
24639
|
+
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
24640
|
+
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
23884
24641
|
if (positions.every((p) => p.amount.isZero())) {
|
|
23885
24642
|
return { net: 0, splits: [{
|
|
23886
24643
|
apy: 0,
|
|
@@ -23891,11 +24648,10 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23891
24648
|
}] };
|
|
23892
24649
|
}
|
|
23893
24650
|
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);
|
|
24651
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
24652
|
+
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
24653
|
+
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
24654
|
+
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
23899
24655
|
const netAPY = baseAPY + rewardAPY;
|
|
23900
24656
|
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
23901
24657
|
return { net: netAPY, splits: [{
|
|
@@ -23906,11 +24662,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23906
24662
|
id: "defispring"
|
|
23907
24663
|
}] };
|
|
23908
24664
|
}
|
|
23909
|
-
computeAPY(apys, weights) {
|
|
24665
|
+
computeAPY(apys, weights, currentAUM) {
|
|
23910
24666
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
23911
24667
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
23912
|
-
|
|
23913
|
-
return weightedSum /
|
|
24668
|
+
logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
|
|
24669
|
+
return weightedSum / currentAUM.toNumber();
|
|
23914
24670
|
}
|
|
23915
24671
|
/**
|
|
23916
24672
|
* Calculates the total TVL of the strategy.
|
|
@@ -23942,24 +24698,48 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23942
24698
|
usdValue
|
|
23943
24699
|
};
|
|
23944
24700
|
}
|
|
23945
|
-
async
|
|
24701
|
+
async getVesuAUM(adapter) {
|
|
24702
|
+
const legAUM = await adapter.getPositions(this.config);
|
|
24703
|
+
const underlying = this.asset();
|
|
24704
|
+
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
24705
|
+
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
24706
|
+
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
24707
|
+
} else {
|
|
24708
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24709
|
+
vesuAum = vesuAum.plus(legAUM[1].usdValue / tokenPrice.price);
|
|
24710
|
+
}
|
|
24711
|
+
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
24712
|
+
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
24713
|
+
} else {
|
|
24714
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24715
|
+
vesuAum = vesuAum.minus(legAUM[1].usdValue / tokenPrice.price);
|
|
24716
|
+
}
|
|
24717
|
+
;
|
|
24718
|
+
logger.verbose(`${this.getTag()} Vesu AUM: ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
24719
|
+
return vesuAum;
|
|
24720
|
+
}
|
|
24721
|
+
async getPrevAUM() {
|
|
23946
24722
|
const currentAUM = await this.contract.call("aum", []);
|
|
23947
|
-
const
|
|
24723
|
+
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
24724
|
+
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
24725
|
+
return prevAum;
|
|
24726
|
+
}
|
|
24727
|
+
async getAUM() {
|
|
24728
|
+
const prevAum = await this.getPrevAUM();
|
|
23948
24729
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
23949
|
-
const
|
|
23950
|
-
|
|
23951
|
-
const
|
|
24730
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24731
|
+
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
24732
|
+
for (const adapter of vesuAdapters) {
|
|
24733
|
+
vesuAum = vesuAum.plus(await this.getVesuAUM(adapter));
|
|
24734
|
+
}
|
|
23952
24735
|
const balance = await this.getUnusedBalance();
|
|
23953
24736
|
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
24737
|
const zeroAmt = Web3Number.fromWei("0", this.asset().decimals);
|
|
23957
24738
|
const net = {
|
|
23958
24739
|
tokenInfo: this.asset(),
|
|
23959
24740
|
amount: zeroAmt,
|
|
23960
24741
|
usdValue: 0
|
|
23961
24742
|
};
|
|
23962
|
-
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
23963
24743
|
if (vesuAum.isZero()) {
|
|
23964
24744
|
return { net, splits: [{
|
|
23965
24745
|
aum: zeroAmt,
|
|
@@ -23971,16 +24751,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23971
24751
|
}
|
|
23972
24752
|
const aumToken = vesuAum.plus(balance.amount);
|
|
23973
24753
|
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}`);
|
|
24754
|
+
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
23984
24755
|
const newAUM = aumToken.plus(rewardAssets);
|
|
23985
24756
|
logger.verbose(`${this.getTag()} New AUM: ${newAUM}`);
|
|
23986
24757
|
net.amount = newAUM;
|
|
@@ -23994,6 +24765,21 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23994
24765
|
}];
|
|
23995
24766
|
return { net, splits, prevAum };
|
|
23996
24767
|
}
|
|
24768
|
+
// account for future rewards (e.g. defispring rewards)
|
|
24769
|
+
async getRewardsAUM(prevAum) {
|
|
24770
|
+
const lastReportTime = await this.contract.call("last_report_timestamp", []);
|
|
24771
|
+
const netAPY = await this.netAPY();
|
|
24772
|
+
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
24773
|
+
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
24774
|
+
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
24775
|
+
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
24776
|
+
const rewardAssets = prevAum.multipliedBy(growthRate);
|
|
24777
|
+
logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
|
|
24778
|
+
logger.verbose(`${this.getTag()} Current AUM: ${prevAum.toString()}`);
|
|
24779
|
+
logger.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
|
|
24780
|
+
logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
|
|
24781
|
+
return rewardAssets;
|
|
24782
|
+
}
|
|
23997
24783
|
getVesuAdapters() {
|
|
23998
24784
|
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
23999
24785
|
const vesuAdapter2 = this.getAdapter("vesu_leg2_adapter" /* VESU_LEG2 */);
|
|
@@ -24003,11 +24789,23 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
24003
24789
|
vesuAdapter2.networkConfig = this.config;
|
|
24004
24790
|
return [vesuAdapter1, vesuAdapter2];
|
|
24005
24791
|
}
|
|
24792
|
+
async getVesuPositions() {
|
|
24793
|
+
const adapters = this.getVesuAdapters();
|
|
24794
|
+
const positions = [];
|
|
24795
|
+
for (const adapter of adapters) {
|
|
24796
|
+
positions.push(...await adapter.getPositions(this.config));
|
|
24797
|
+
}
|
|
24798
|
+
return positions;
|
|
24799
|
+
}
|
|
24006
24800
|
async getVaultPositions() {
|
|
24007
|
-
const
|
|
24008
|
-
const
|
|
24009
|
-
|
|
24010
|
-
|
|
24801
|
+
const vesuPositions = await this.getVesuPositions();
|
|
24802
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
24803
|
+
return [...vesuPositions, {
|
|
24804
|
+
amount: unusedBalance.amount,
|
|
24805
|
+
usdValue: unusedBalance.usdValue,
|
|
24806
|
+
token: this.asset(),
|
|
24807
|
+
remarks: "Unused Balance"
|
|
24808
|
+
}];
|
|
24011
24809
|
}
|
|
24012
24810
|
getSetManagerCall(strategist, root = this.getMerkleRoot()) {
|
|
24013
24811
|
return this.managerContract.populate("set_manage_root", [strategist.address, num9.getHexString(root)]);
|
|
@@ -24145,7 +24943,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
24145
24943
|
return new Web3Number(newAmount.toFixed(8), debtTokenAmount.decimals);
|
|
24146
24944
|
}
|
|
24147
24945
|
}
|
|
24148
|
-
async
|
|
24946
|
+
async getVesuModifyPositionCall(params) {
|
|
24149
24947
|
const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
|
|
24150
24948
|
const leg1LTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
24151
24949
|
const leg2LTV = await vesuAdapter2.getLTVConfig(this.config);
|
|
@@ -24646,6 +25444,373 @@ var UniversalStrategies = [
|
|
|
24646
25444
|
}
|
|
24647
25445
|
];
|
|
24648
25446
|
|
|
25447
|
+
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
25448
|
+
import { Contract as Contract10, uint256 as uint2569 } from "starknet";
|
|
25449
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
25450
|
+
var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
|
|
25451
|
+
constructor(config, pricer, metadata) {
|
|
25452
|
+
super(config, pricer, metadata);
|
|
25453
|
+
this.quoteAmountToFetchPrice = new Web3Number(1, 18);
|
|
25454
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25455
|
+
const underlyingToken = this.getLSTUnderlyingTokenInfo();
|
|
25456
|
+
if (underlyingToken.address.eq(STRKToken.address)) {
|
|
25457
|
+
this.quoteAmountToFetchPrice = new Web3Number(100, 18);
|
|
25458
|
+
} else {
|
|
25459
|
+
this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
|
|
25460
|
+
}
|
|
25461
|
+
}
|
|
25462
|
+
// only one leg is used
|
|
25463
|
+
// todo support lending assets of underlying as well
|
|
25464
|
+
getVesuAdapters() {
|
|
25465
|
+
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
25466
|
+
vesuAdapter1.pricer = this.pricer;
|
|
25467
|
+
vesuAdapter1.networkConfig = this.config;
|
|
25468
|
+
return [vesuAdapter1];
|
|
25469
|
+
}
|
|
25470
|
+
// not applicable for this strategy
|
|
25471
|
+
// No rewards on collateral or borrowing of LST assets
|
|
25472
|
+
async getRewardsAUM(prevAum) {
|
|
25473
|
+
return Web3Number.fromWei("0", this.asset().decimals);
|
|
25474
|
+
}
|
|
25475
|
+
async getLSTDexPrice() {
|
|
25476
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25477
|
+
const lstTokenInfo = this.asset();
|
|
25478
|
+
const lstUnderlyingTokenInfo = this.getLSTUnderlyingTokenInfo();
|
|
25479
|
+
const quote = await ekuboQuoter.getQuote(
|
|
25480
|
+
lstTokenInfo.address.address,
|
|
25481
|
+
lstUnderlyingTokenInfo.address.address,
|
|
25482
|
+
this.quoteAmountToFetchPrice
|
|
25483
|
+
);
|
|
25484
|
+
const outputAmount = Web3Number.fromWei(quote.total_calculated, lstUnderlyingTokenInfo.decimals);
|
|
25485
|
+
const price = outputAmount.toNumber() / this.quoteAmountToFetchPrice.toNumber();
|
|
25486
|
+
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
25487
|
+
return price;
|
|
25488
|
+
}
|
|
25489
|
+
/**
|
|
25490
|
+
* Uses vesu's multiple call to create leverage on LST
|
|
25491
|
+
* Deposit amount is in LST
|
|
25492
|
+
* @param params
|
|
25493
|
+
*/
|
|
25494
|
+
async getVesuMultiplyCall(params) {
|
|
25495
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25496
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
25497
|
+
const existingPositions = await vesuAdapter1.getPositions(this.config);
|
|
25498
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
25499
|
+
const existingCollateralInfo = existingPositions[0];
|
|
25500
|
+
const existingDebtInfo = existingPositions[1];
|
|
25501
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
25502
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
25503
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
25504
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
25505
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
25506
|
+
const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
|
|
25507
|
+
const DEXPrice = await this.getLSTDexPrice();
|
|
25508
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
|
|
25509
|
+
const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
|
|
25510
|
+
const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
|
|
25511
|
+
const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / DEXPrice;
|
|
25512
|
+
const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
|
|
25513
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
|
|
25514
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
|
|
25515
|
+
const debtAmount = x_debt_usd.dividedBy(debtPrice);
|
|
25516
|
+
const marginAmount = addedCollateral;
|
|
25517
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
|
|
25518
|
+
return this.getModifyLeverCall({
|
|
25519
|
+
marginAmount,
|
|
25520
|
+
debtAmount,
|
|
25521
|
+
isIncrease: debtAmount.greaterThan(0)
|
|
25522
|
+
});
|
|
25523
|
+
}
|
|
25524
|
+
getLSTUnderlyingTokenInfo() {
|
|
25525
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25526
|
+
return vesuAdapter1.config.debt;
|
|
25527
|
+
}
|
|
25528
|
+
async getLSTExchangeRate() {
|
|
25529
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25530
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
25531
|
+
const lstABI = new Contract10({
|
|
25532
|
+
abi: erc4626_abi_default,
|
|
25533
|
+
address: lstTokenInfo.address.address,
|
|
25534
|
+
providerOrAccount: this.config.provider
|
|
25535
|
+
});
|
|
25536
|
+
const price = await lstABI.call("convert_to_assets", [uint2569.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
25537
|
+
const exchangeRate = Number(uint2569.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
25538
|
+
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
25539
|
+
return exchangeRate;
|
|
25540
|
+
}
|
|
25541
|
+
/**
|
|
25542
|
+
*
|
|
25543
|
+
* @param params marginAmount is in LST, debtAmount is in underlying
|
|
25544
|
+
*/
|
|
25545
|
+
async getModifyLeverCall(params) {
|
|
25546
|
+
assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
|
|
25547
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25548
|
+
const lstTokenInfo = this.asset();
|
|
25549
|
+
const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
|
|
25550
|
+
const proofsIDs = [];
|
|
25551
|
+
const manageCalls = [];
|
|
25552
|
+
if (params.marginAmount.greaterThan(0)) {
|
|
25553
|
+
const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
25554
|
+
const manage1Info = this.getProofs(STEP1_ID);
|
|
25555
|
+
const depositAmount = params.marginAmount;
|
|
25556
|
+
const manageCall1 = manage1Info.callConstructor({
|
|
25557
|
+
amount: depositAmount
|
|
25558
|
+
});
|
|
25559
|
+
proofsIDs.push(STEP1_ID);
|
|
25560
|
+
manageCalls.push(manageCall1);
|
|
25561
|
+
}
|
|
25562
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25563
|
+
const lstPrice = await this.getLSTExchangeRate();
|
|
25564
|
+
const marginSwap = [];
|
|
25565
|
+
const MAX_SLIPPAGE = 0.01;
|
|
25566
|
+
const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
|
|
25567
|
+
const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
|
|
25568
|
+
const leverSwapQuote = await ekuboQuoter.getQuote(
|
|
25569
|
+
fromToken.address.address,
|
|
25570
|
+
toToken.address.address,
|
|
25571
|
+
params.debtAmount
|
|
25572
|
+
// negative for exact amount out
|
|
25573
|
+
);
|
|
25574
|
+
assert(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
|
|
25575
|
+
const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
|
|
25576
|
+
const minExpectedDebt = params.debtAmount.dividedBy(lstPrice).multipliedBy(1 - MAX_SLIPPAGE);
|
|
25577
|
+
const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstPrice).multipliedBy(1 + MAX_SLIPPAGE);
|
|
25578
|
+
const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
|
|
25579
|
+
const manage2Info = this.getProofs(STEP2_ID);
|
|
25580
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
25581
|
+
delegation: true
|
|
25582
|
+
});
|
|
25583
|
+
const STEP3_ID = "multiply_vesu" /* MULTIPLY_VESU */;
|
|
25584
|
+
const manage3Info = this.getProofs(STEP3_ID);
|
|
25585
|
+
const multiplyParams = params.isIncrease ? {
|
|
25586
|
+
isIncrease: true,
|
|
25587
|
+
increaseParams: {
|
|
25588
|
+
add_margin: params.marginAmount,
|
|
25589
|
+
margin_swap: marginSwap,
|
|
25590
|
+
margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25591
|
+
lever_swap: leverSwap,
|
|
25592
|
+
lever_swap_limit_amount: minExpectedDebt
|
|
25593
|
+
}
|
|
25594
|
+
} : {
|
|
25595
|
+
isIncrease: false,
|
|
25596
|
+
decreaseParams: {
|
|
25597
|
+
sub_margin: params.marginAmount.multipliedBy(-1),
|
|
25598
|
+
lever_swap: leverSwap,
|
|
25599
|
+
lever_swap_limit_amount: maxUsedCollateral,
|
|
25600
|
+
// only required for close position
|
|
25601
|
+
lever_swap_weights: [],
|
|
25602
|
+
// no need to swap collateral to anything, and any residuals return our contract anyways.
|
|
25603
|
+
withdraw_swap: [],
|
|
25604
|
+
withdraw_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25605
|
+
withdraw_swap_weights: [],
|
|
25606
|
+
close_position: false
|
|
25607
|
+
}
|
|
25608
|
+
};
|
|
25609
|
+
const manageCall3 = manage3Info.callConstructor(multiplyParams);
|
|
25610
|
+
const STEP4_ID = "switch_delegation_off" /* SWITCH_DELEGATION_OFF */;
|
|
25611
|
+
const manage4Info = this.getProofs(STEP4_ID);
|
|
25612
|
+
const manageCall4 = manage4Info.callConstructor({
|
|
25613
|
+
delegation: false
|
|
25614
|
+
});
|
|
25615
|
+
proofsIDs.push(STEP2_ID, STEP3_ID, STEP4_ID);
|
|
25616
|
+
manageCalls.push(manageCall2, manageCall3, manageCall4);
|
|
25617
|
+
return [this.getManageCall(proofsIDs, manageCalls)];
|
|
25618
|
+
}
|
|
25619
|
+
};
|
|
25620
|
+
function VaultDescription() {
|
|
25621
|
+
const containerStyle = {
|
|
25622
|
+
maxWidth: "800px",
|
|
25623
|
+
margin: "0 auto",
|
|
25624
|
+
backgroundColor: "#111",
|
|
25625
|
+
color: "#eee",
|
|
25626
|
+
fontFamily: "Arial, sans-serif",
|
|
25627
|
+
borderRadius: "12px"
|
|
25628
|
+
};
|
|
25629
|
+
return /* @__PURE__ */ jsxs4("div", { style: containerStyle, children: [
|
|
25630
|
+
/* @__PURE__ */ jsx5("h1", { style: { fontSize: "18px", marginBottom: "10px" }, children: "Meta Vault \u2014 Automated Yield Router" }),
|
|
25631
|
+
/* @__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." }),
|
|
25632
|
+
/* @__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: [
|
|
25633
|
+
/* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
|
|
25634
|
+
" Requests can take up to ",
|
|
25635
|
+
/* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
|
|
25636
|
+
" to process as the vault unwinds and settles routing."
|
|
25637
|
+
] }) })
|
|
25638
|
+
] });
|
|
25639
|
+
}
|
|
25640
|
+
function getDescription2(tokenSymbol) {
|
|
25641
|
+
return VaultDescription();
|
|
25642
|
+
}
|
|
25643
|
+
function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
25644
|
+
vaultSettings.leafAdapters = [];
|
|
25645
|
+
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
25646
|
+
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
25647
|
+
const vesuAdapterLST = new VesuAdapter({
|
|
25648
|
+
poolId: pool1,
|
|
25649
|
+
collateral: lstToken,
|
|
25650
|
+
debt: underlyingToken,
|
|
25651
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
25652
|
+
id: "multiply_vesu" /* MULTIPLY_VESU */
|
|
25653
|
+
});
|
|
25654
|
+
const commonAdapter = new CommonAdapter({
|
|
25655
|
+
manager: vaultSettings.manager,
|
|
25656
|
+
asset: lstToken.address,
|
|
25657
|
+
id: "",
|
|
25658
|
+
vaultAddress: vaultSettings.vaultAddress,
|
|
25659
|
+
vaultAllocator: vaultSettings.vaultAllocator
|
|
25660
|
+
});
|
|
25661
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vesuAdapterLST.VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
25662
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
|
|
25663
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
25664
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
25665
|
+
vaultSettings.adapters.push(...[{
|
|
25666
|
+
id: "vesu_leg1_adapter" /* VESU_LEG1 */,
|
|
25667
|
+
adapter: vesuAdapterLST
|
|
25668
|
+
}, {
|
|
25669
|
+
id: "common_adapter" /* COMMON */,
|
|
25670
|
+
adapter: commonAdapter
|
|
25671
|
+
}]);
|
|
25672
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25673
|
+
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25674
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
|
|
25675
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25676
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
25677
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
|
|
25678
|
+
return vaultSettings;
|
|
25679
|
+
}
|
|
25680
|
+
function getFAQs2(lstSymbol, underlyingSymbol) {
|
|
25681
|
+
return [
|
|
25682
|
+
{
|
|
25683
|
+
question: `What is the Hyper ${lstSymbol} Vault?`,
|
|
25684
|
+
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.`
|
|
25685
|
+
},
|
|
25686
|
+
{
|
|
25687
|
+
question: "How does yield allocation work?",
|
|
25688
|
+
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.`
|
|
25689
|
+
},
|
|
25690
|
+
{
|
|
25691
|
+
question: "Which protocols/dApp are used??",
|
|
25692
|
+
answer: /* @__PURE__ */ jsxs4("span", { children: [
|
|
25693
|
+
"Currently, the LST is from ",
|
|
25694
|
+
/* @__PURE__ */ jsx5("strong", { children: "Endur" }),
|
|
25695
|
+
" while ",
|
|
25696
|
+
/* @__PURE__ */ jsx5("strong", { children: "Vesu" }),
|
|
25697
|
+
" is used to collateralize the looped position."
|
|
25698
|
+
] })
|
|
25699
|
+
},
|
|
25700
|
+
{
|
|
25701
|
+
question: "Can I get liquidated?",
|
|
25702
|
+
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."
|
|
25703
|
+
},
|
|
25704
|
+
{
|
|
25705
|
+
question: "What do I receive when I deposit?",
|
|
25706
|
+
answer: "Depositors receive vault tokens representing their proportional share of the vault. These tokens entitle holders to both the principal and accrued yield."
|
|
25707
|
+
},
|
|
25708
|
+
{
|
|
25709
|
+
question: "How long do withdrawals take?",
|
|
25710
|
+
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."
|
|
25711
|
+
},
|
|
25712
|
+
{
|
|
25713
|
+
question: "Is the Hyper xSTRK Vault non-custodial?",
|
|
25714
|
+
answer: "Yes. The Hyper xSTRK Vault operates entirely on-chain. Users always maintain control of their vault tokens, and the strategy is fully transparent."
|
|
25715
|
+
},
|
|
25716
|
+
{
|
|
25717
|
+
question: "Is the Vault audited?",
|
|
25718
|
+
answer: "Yes. The Hyper xSTRK Vault is audited by Zellic. Look for safety icon beside the strategy name for more details."
|
|
25719
|
+
},
|
|
25720
|
+
{
|
|
25721
|
+
question: "Are there any fees?",
|
|
25722
|
+
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."
|
|
25723
|
+
}
|
|
25724
|
+
];
|
|
25725
|
+
}
|
|
25726
|
+
var _riskFactor4 = [
|
|
25727
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 25, reason: "Audited by Zellic" },
|
|
25728
|
+
{ type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 1 /* VERY_LOW_PROBABILITY */, weight: 50, reason: "The collateral and debt are highly correlated" },
|
|
25729
|
+
{ 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." }
|
|
25730
|
+
];
|
|
25731
|
+
var hyperxSTRK = {
|
|
25732
|
+
vaultAddress: ContractAddr.from("0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"),
|
|
25733
|
+
manager: ContractAddr.from("0x5d499cd333757f461a0bedaca3dfc4d77320c773037e0aa299f22a6dbfdc03a"),
|
|
25734
|
+
vaultAllocator: ContractAddr.from("0x511d07953a09bc7c505970891507c5a2486d2ea22752601a14db092186d7caa"),
|
|
25735
|
+
redeemRequestNFT: ContractAddr.from("0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"),
|
|
25736
|
+
aumOracle: ContractAddr.from("0x48cf709870a1a0d453d37de108e0c41b8b89819ef54f95abc0e2e1f98bbe937"),
|
|
25737
|
+
leafAdapters: [],
|
|
25738
|
+
adapters: [],
|
|
25739
|
+
targetHealthFactor: 1.1,
|
|
25740
|
+
minHealthFactor: 1.05
|
|
25741
|
+
};
|
|
25742
|
+
var hyperxWBTC = {
|
|
25743
|
+
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
|
25744
|
+
manager: ContractAddr.from("0x75866db44c81e6986f06035206ee9c7d15833ddb22d6a22c016cfb5c866a491"),
|
|
25745
|
+
vaultAllocator: ContractAddr.from("0x57b5c1bb457b5e840a2714ae53ada87d77be2f3fd33a59b4fe709ef20c020c1"),
|
|
25746
|
+
redeemRequestNFT: ContractAddr.from("0x7a5dc288325456f05e70e9616e16bc02ffbe448f4b89f80b47c0970b989c7c"),
|
|
25747
|
+
aumOracle: ContractAddr.from(""),
|
|
25748
|
+
leafAdapters: [],
|
|
25749
|
+
adapters: [],
|
|
25750
|
+
targetHealthFactor: 1.1,
|
|
25751
|
+
minHealthFactor: 1.05
|
|
25752
|
+
};
|
|
25753
|
+
var hyperxtBTC = {
|
|
25754
|
+
vaultAddress: ContractAddr.from("0x47d5f68477e5637ce0e56436c6b5eee5a354e6828995dae106b11a48679328"),
|
|
25755
|
+
manager: ContractAddr.from("0xc4cc3e08029a0ae076f5fdfca70575abb78d23c5cd1c49a957f7e697885401"),
|
|
25756
|
+
vaultAllocator: ContractAddr.from("0x50bbd4fe69f841ecb13b2619fe50ebfa4e8944671b5d0ebf7868fd80c61b31e"),
|
|
25757
|
+
redeemRequestNFT: ContractAddr.from("0xeac9032f02057779816e38a6cb9185d12d86b3aacc9949b96b36de359c1e3"),
|
|
25758
|
+
aumOracle: ContractAddr.from(""),
|
|
25759
|
+
leafAdapters: [],
|
|
25760
|
+
adapters: [],
|
|
25761
|
+
targetHealthFactor: 1.1,
|
|
25762
|
+
minHealthFactor: 1.05
|
|
25763
|
+
};
|
|
25764
|
+
var hyperxsBTC = {
|
|
25765
|
+
vaultAddress: ContractAddr.from("0x437ef1e7d0f100b2e070b7a65cafec0b2be31b0290776da8b4112f5473d8d9"),
|
|
25766
|
+
manager: ContractAddr.from("0xc9ac023090625b0be3f6532ca353f086746f9c09f939dbc1b2613f09e5f821"),
|
|
25767
|
+
vaultAllocator: ContractAddr.from("0x60c2d856936b975459a5b4eb28b8672d91f757bd76cebb6241f8d670185dc01"),
|
|
25768
|
+
redeemRequestNFT: ContractAddr.from("0x429e8ee8bc7ecd1ade72630d350a2e0f10f9a2507c45f188ba17fe8f2ab4cf3"),
|
|
25769
|
+
aumOracle: ContractAddr.from(""),
|
|
25770
|
+
leafAdapters: [],
|
|
25771
|
+
adapters: [],
|
|
25772
|
+
targetHealthFactor: 1.1,
|
|
25773
|
+
minHealthFactor: 1.05
|
|
25774
|
+
};
|
|
25775
|
+
function getInvestmentSteps(lstSymbol, underlyingSymbol) {
|
|
25776
|
+
return [
|
|
25777
|
+
`Deposit ${underlyingSymbol} into the vault`,
|
|
25778
|
+
`The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
|
|
25779
|
+
`The vault manager collateralizes the ${lstSymbol} on Vesu`,
|
|
25780
|
+
`The vault manager borrows more ${underlyingSymbol} to loop further`,
|
|
25781
|
+
`Claim BTCFi STRK rewards weekly to swap to ${lstSymbol} and reinvest`,
|
|
25782
|
+
`If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
|
|
25783
|
+
];
|
|
25784
|
+
}
|
|
25785
|
+
function getStrategySettings(lstSymbol, underlyingSymbol, addresses, isPreview = false) {
|
|
25786
|
+
return {
|
|
25787
|
+
name: `Hyper ${lstSymbol}`,
|
|
25788
|
+
description: getDescription2(lstSymbol),
|
|
25789
|
+
address: addresses.vaultAddress,
|
|
25790
|
+
launchBlock: 0,
|
|
25791
|
+
type: "Other",
|
|
25792
|
+
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
|
|
25793
|
+
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
|
|
25794
|
+
risk: {
|
|
25795
|
+
riskFactor: _riskFactor4,
|
|
25796
|
+
netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
|
|
25797
|
+
notARisks: getNoRiskTags(_riskFactor4)
|
|
25798
|
+
},
|
|
25799
|
+
protocols: [Protocols.ENDUR, Protocols.VESU],
|
|
25800
|
+
maxTVL: Web3Number.fromWei(0, 18),
|
|
25801
|
+
contractDetails: getContractDetails(addresses),
|
|
25802
|
+
faqs: getFAQs2(lstSymbol, underlyingSymbol),
|
|
25803
|
+
investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol),
|
|
25804
|
+
isPreview
|
|
25805
|
+
};
|
|
25806
|
+
}
|
|
25807
|
+
var HyperLSTStrategies = [
|
|
25808
|
+
getStrategySettings("xSTRK", "STRK", hyperxSTRK, false),
|
|
25809
|
+
getStrategySettings("xWBTC", "WBTC", hyperxWBTC, true),
|
|
25810
|
+
getStrategySettings("xtBTC", "tBTC", hyperxtBTC, true),
|
|
25811
|
+
getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, true)
|
|
25812
|
+
];
|
|
25813
|
+
|
|
24649
25814
|
// src/notifs/telegram.ts
|
|
24650
25815
|
import TelegramBot from "node-telegram-bot-api";
|
|
24651
25816
|
var TelegramNotif = class {
|
|
@@ -25079,9 +26244,11 @@ export {
|
|
|
25079
26244
|
ERC20,
|
|
25080
26245
|
EkuboCLVault,
|
|
25081
26246
|
EkuboCLVaultStrategies,
|
|
26247
|
+
EkuboQuoter,
|
|
25082
26248
|
FatalError,
|
|
25083
26249
|
FlowChartColors,
|
|
25084
26250
|
Global,
|
|
26251
|
+
HyperLSTStrategies,
|
|
25085
26252
|
ILending,
|
|
25086
26253
|
Initializable,
|
|
25087
26254
|
MarginType,
|
|
@@ -25100,6 +26267,7 @@ export {
|
|
|
25100
26267
|
TelegramNotif,
|
|
25101
26268
|
UNIVERSAL_ADAPTERS,
|
|
25102
26269
|
UNIVERSAL_MANAGE_IDS,
|
|
26270
|
+
UniversalLstMultiplierStrategy,
|
|
25103
26271
|
UniversalStrategies,
|
|
25104
26272
|
UniversalStrategy,
|
|
25105
26273
|
VesuAdapter,
|
|
@@ -25112,6 +26280,7 @@ export {
|
|
|
25112
26280
|
ZkLend,
|
|
25113
26281
|
assert,
|
|
25114
26282
|
getAPIUsingHeadlessBrowser,
|
|
26283
|
+
getContractDetails,
|
|
25115
26284
|
getDefaultStoreConfig,
|
|
25116
26285
|
getMainnetConfig,
|
|
25117
26286
|
getNoRiskTags,
|