@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.browser.mjs
CHANGED
|
@@ -64,6 +64,17 @@ var _Web3Number = class extends BigNumber {
|
|
|
64
64
|
const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
|
|
65
65
|
return this.construct(answer.toString(), this.decimals);
|
|
66
66
|
}
|
|
67
|
+
abs() {
|
|
68
|
+
console.warn(`abs: this: ${this}`);
|
|
69
|
+
return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
|
|
70
|
+
}
|
|
71
|
+
toI129() {
|
|
72
|
+
const sign = this.isNegative() ? 1 : 0;
|
|
73
|
+
return {
|
|
74
|
+
mag: BigInt(this.toWei()) * (this.isNegative() ? -1n : 1n),
|
|
75
|
+
sign
|
|
76
|
+
};
|
|
77
|
+
}
|
|
67
78
|
};
|
|
68
79
|
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
69
80
|
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
@@ -2095,8 +2106,8 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
2095
2106
|
}
|
|
2096
2107
|
return filteredQuotes[0];
|
|
2097
2108
|
}
|
|
2098
|
-
async getSwapInfo(quote, taker, integratorFeeBps, integratorFeeRecipient, minAmount) {
|
|
2099
|
-
const calldata = await fetchBuildExecuteTransaction(quote.quoteId);
|
|
2109
|
+
async getSwapInfo(quote, taker, integratorFeeBps, integratorFeeRecipient, minAmount, options) {
|
|
2110
|
+
const calldata = await fetchBuildExecuteTransaction(quote.quoteId, taker, void 0, void 0, options);
|
|
2100
2111
|
const call = calldata.calls[1];
|
|
2101
2112
|
const callData = call.calldata;
|
|
2102
2113
|
const routesLen = Number(callData[11]);
|
|
@@ -2147,6 +2158,61 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
2147
2158
|
}
|
|
2148
2159
|
};
|
|
2149
2160
|
|
|
2161
|
+
// src/modules/ekubo-quoter.ts
|
|
2162
|
+
import axios5 from "axios";
|
|
2163
|
+
var EkuboQuoter = class {
|
|
2164
|
+
// e.g. ETH/USDC'
|
|
2165
|
+
constructor(config) {
|
|
2166
|
+
this.config = config;
|
|
2167
|
+
this.ENDPOINT = "https://quoter-mainnet-api.ekubo.org/{{AMOUNT}}/{{TOKEN_FROM_ADDRESS}}/{{TOKEN_TO_ADDRESS}}";
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
*
|
|
2171
|
+
* @param fromToken
|
|
2172
|
+
* @param toToken
|
|
2173
|
+
* @param amount Can be negative too, which would mean to get exact amount out
|
|
2174
|
+
* @returns
|
|
2175
|
+
*/
|
|
2176
|
+
async getQuote(fromToken, toToken, amount) {
|
|
2177
|
+
let _fromToken = amount.gt(0) ? fromToken : toToken;
|
|
2178
|
+
let _toToken = amount.gt(0) ? toToken : fromToken;
|
|
2179
|
+
const quote = await axios5.get(this.ENDPOINT.replace("{{AMOUNT}}", amount.toWei()).replace("{{TOKEN_FROM_ADDRESS}}", _fromToken).replace("{{TOKEN_TO_ADDRESS}}", _toToken));
|
|
2180
|
+
console.log(`Ekubo quote from ${_fromToken} to ${_toToken} for ${amount.toString()}: ${JSON.stringify(quote.data)}`);
|
|
2181
|
+
return quote.data;
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Formats Ekubo response for Vesu multiple use
|
|
2185
|
+
* @param quote
|
|
2186
|
+
* @param fromTokenInfo
|
|
2187
|
+
* @returns
|
|
2188
|
+
*/
|
|
2189
|
+
getVesuMultiplyQuote(quote, fromTokenInfo, toTokenInfo) {
|
|
2190
|
+
return quote.splits.map((split) => {
|
|
2191
|
+
const isNegativeAmount = BigInt(split.amount_specified) < 0n;
|
|
2192
|
+
const token = isNegativeAmount ? toTokenInfo : fromTokenInfo;
|
|
2193
|
+
return {
|
|
2194
|
+
route: split.route.map((_route) => ({
|
|
2195
|
+
pool_key: {
|
|
2196
|
+
token0: ContractAddr.from(_route.pool_key.token0),
|
|
2197
|
+
token1: ContractAddr.from(_route.pool_key.token1),
|
|
2198
|
+
fee: _route.pool_key.fee,
|
|
2199
|
+
tick_spacing: _route.pool_key.tick_spacing.toString(),
|
|
2200
|
+
extension: _route.pool_key.extension
|
|
2201
|
+
},
|
|
2202
|
+
sqrt_ratio_limit: Web3Number.fromWei(_route.sqrt_ratio_limit, 18),
|
|
2203
|
+
// just for use, any decimal works
|
|
2204
|
+
skip_ahead: Web3Number.fromWei(_route.skip_ahead, 0)
|
|
2205
|
+
// no decimal for this
|
|
2206
|
+
})),
|
|
2207
|
+
token_amount: {
|
|
2208
|
+
token: token.address,
|
|
2209
|
+
amount: Web3Number.fromWei(split.amount_specified, token.decimals)
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
|
|
2150
2216
|
// src/interfaces/common.tsx
|
|
2151
2217
|
import { BlockTag, RpcProvider as RpcProvider2 } from "starknet";
|
|
2152
2218
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
@@ -3853,9 +3919,9 @@ var BaseStrategy = class extends CacheClass {
|
|
|
3853
3919
|
};
|
|
3854
3920
|
|
|
3855
3921
|
// src/node/headless.browser.ts
|
|
3856
|
-
import
|
|
3922
|
+
import axios6 from "axios";
|
|
3857
3923
|
async function getAPIUsingHeadlessBrowser(url) {
|
|
3858
|
-
const res = await
|
|
3924
|
+
const res = await axios6.get(url);
|
|
3859
3925
|
return res.data;
|
|
3860
3926
|
}
|
|
3861
3927
|
|
|
@@ -16292,20 +16358,27 @@ var _protocol2 = {
|
|
|
16292
16358
|
name: "Ekubo",
|
|
16293
16359
|
logo: "https://app.ekubo.org/favicon.ico"
|
|
16294
16360
|
};
|
|
16295
|
-
var
|
|
16361
|
+
var _lstPoolRiskFactors = [
|
|
16296
16362
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16297
16363
|
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16298
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" }
|
|
16364
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16365
|
+
{ type: "Depeg Risk" /* DEPEG_RISK */, value: 2 /* GENERALLY_STABLE */, weight: 33, reason: "Generally stable pegged assets" }
|
|
16366
|
+
];
|
|
16367
|
+
var _stableCoinPoolRiskFactors = [
|
|
16368
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 1 /* BATTLE_TESTED */, weight: 34, reason: "Audited smart contracts" },
|
|
16369
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 1 /* HIGHLY_CORRELATED */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16370
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 1 /* VERY_LOW_VOLATILITY */, weight: 33, reason: "Low risk due to co-related assets" },
|
|
16371
|
+
{ type: "Depeg Risk" /* DEPEG_RISK */, value: 1 /* HIGHLY_STABLE */, weight: 33, reason: "Highly stable assets" }
|
|
16299
16372
|
];
|
|
16300
16373
|
var mediumVolatilityPoolRiskFactors = [
|
|
16301
16374
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16302
|
-
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "
|
|
16303
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "
|
|
16375
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
|
|
16376
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 3 /* MODERATE_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile can be moderate sometimes" }
|
|
16304
16377
|
];
|
|
16305
16378
|
var highVolatilityPoolRiskFactors = [
|
|
16306
16379
|
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 34, reason: "Audited smart contracts" },
|
|
16307
|
-
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "
|
|
16308
|
-
{ type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "
|
|
16380
|
+
{ type: "Impermanent Loss Risk" /* IMPERMANENT_LOSS */, value: 3 /* NON_CORRELATED */, weight: 33, reason: "Assets are not correlated, often volatile" },
|
|
16381
|
+
{ type: "Market Risk" /* MARKET_RISK */, value: 4 /* HIGH_VOLATILITY */, weight: 33, reason: "Assets are not correlated, relative volatile is often high" }
|
|
16309
16382
|
];
|
|
16310
16383
|
var mediumRisk = {
|
|
16311
16384
|
riskFactor: mediumVolatilityPoolRiskFactors,
|
|
@@ -16378,9 +16451,9 @@ var xSTRKSTRK = {
|
|
|
16378
16451
|
auditUrl: AUDIT_URL2,
|
|
16379
16452
|
maxTVL: Web3Number.fromWei("0", 18),
|
|
16380
16453
|
risk: {
|
|
16381
|
-
riskFactor:
|
|
16382
|
-
netRisk:
|
|
16383
|
-
notARisks: getNoRiskTags(
|
|
16454
|
+
riskFactor: _lstPoolRiskFactors,
|
|
16455
|
+
netRisk: _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _lstPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16456
|
+
notARisks: getNoRiskTags(_lstPoolRiskFactors)
|
|
16384
16457
|
},
|
|
16385
16458
|
apyMethodology: "APY based on 30-day historical performance, including fees and rewards.",
|
|
16386
16459
|
additionalInfo: {
|
|
@@ -16535,7 +16608,11 @@ var RE7Strategies = [
|
|
|
16535
16608
|
Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
16536
16609
|
Global.getDefaultTokens().find((t) => t.symbol === "USDT")
|
|
16537
16610
|
],
|
|
16538
|
-
risk:
|
|
16611
|
+
risk: {
|
|
16612
|
+
riskFactor: _stableCoinPoolRiskFactors,
|
|
16613
|
+
netRisk: _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _stableCoinPoolRiskFactors.reduce((acc, curr) => acc + curr.weight, 0),
|
|
16614
|
+
notARisks: getNoRiskTags(_stableCoinPoolRiskFactors)
|
|
16615
|
+
}
|
|
16539
16616
|
},
|
|
16540
16617
|
{
|
|
16541
16618
|
...ETHUSDCRe7Strategy,
|
|
@@ -18719,6 +18796,7 @@ import { hash, num as num6, shortString } from "starknet";
|
|
|
18719
18796
|
|
|
18720
18797
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
18721
18798
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
18799
|
+
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a");
|
|
18722
18800
|
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
18723
18801
|
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
18724
18802
|
function toBigInt(value) {
|
|
@@ -18733,13 +18811,13 @@ function toBigInt(value) {
|
|
|
18733
18811
|
|
|
18734
18812
|
// src/strategies/universal-adapters/baseAdapter.ts
|
|
18735
18813
|
var BaseAdapter = class extends CacheClass {
|
|
18736
|
-
constructSimpleLeafData(params) {
|
|
18814
|
+
constructSimpleLeafData(params, sanitizer = SIMPLE_SANITIZER) {
|
|
18737
18815
|
const { id, target, method, packedArguments } = params;
|
|
18738
18816
|
return {
|
|
18739
18817
|
id: BigInt(num6.getDecimalString(shortString.encodeShortString(id))),
|
|
18740
18818
|
readableId: id,
|
|
18741
18819
|
data: [
|
|
18742
|
-
|
|
18820
|
+
sanitizer.toBigInt(),
|
|
18743
18821
|
// sanitizer address
|
|
18744
18822
|
target.toBigInt(),
|
|
18745
18823
|
// contract
|
|
@@ -21178,172 +21256,833 @@ var vesu_singleton_abi_default = [
|
|
|
21178
21256
|
}
|
|
21179
21257
|
];
|
|
21180
21258
|
|
|
21181
|
-
// src/
|
|
21182
|
-
var
|
|
21183
|
-
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
|
|
21190
|
-
|
|
21191
|
-
|
|
21192
|
-
|
|
21193
|
-
|
|
21194
|
-
|
|
21195
|
-
|
|
21196
|
-
|
|
21197
|
-
|
|
21198
|
-
|
|
21199
|
-
|
|
21200
|
-
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21208
|
-
|
|
21209
|
-
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21218
|
-
|
|
21219
|
-
|
|
21220
|
-
|
|
21221
|
-
|
|
21222
|
-
|
|
21223
|
-
|
|
21224
|
-
|
|
21225
|
-
|
|
21226
|
-
|
|
21227
|
-
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
21235
|
-
|
|
21236
|
-
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
21237
|
-
}
|
|
21238
|
-
};
|
|
21239
|
-
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
|
|
21240
|
-
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21241
|
-
const call = singletonContract.populate("modify_position", {
|
|
21242
|
-
params: {
|
|
21243
|
-
pool_id: this.config.poolId.toBigInt(),
|
|
21244
|
-
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
21245
|
-
debt_asset: this.config.debt.address.toBigInt(),
|
|
21246
|
-
user: this.config.vaultAllocator.toBigInt(),
|
|
21247
|
-
collateral: _collateral,
|
|
21248
|
-
debt: _debt,
|
|
21249
|
-
data: [0]
|
|
21250
|
-
}
|
|
21251
|
-
});
|
|
21252
|
-
return {
|
|
21253
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
21254
|
-
call: {
|
|
21255
|
-
contractAddress: this.VESU_SINGLETON,
|
|
21256
|
-
selector: hash3.getSelectorFromName("modify_position"),
|
|
21257
|
-
calldata: [
|
|
21258
|
-
...call.calldata
|
|
21259
|
-
]
|
|
21260
|
-
}
|
|
21261
|
-
};
|
|
21262
|
-
};
|
|
21263
|
-
this.getDefispringRewardsAdapter = (id) => {
|
|
21264
|
-
return () => {
|
|
21265
|
-
const packedArguments = [];
|
|
21266
|
-
const output = {
|
|
21267
|
-
id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
|
|
21268
|
-
readableId: id,
|
|
21269
|
-
data: [
|
|
21270
|
-
SIMPLE_SANITIZER.toBigInt(),
|
|
21271
|
-
// sanitizer address
|
|
21272
|
-
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
21273
|
-
// contract
|
|
21274
|
-
toBigInt(hash3.getSelectorFromName("claim")),
|
|
21275
|
-
// method name
|
|
21276
|
-
BigInt(packedArguments.length),
|
|
21277
|
-
...packedArguments
|
|
21278
|
-
]
|
|
21279
|
-
};
|
|
21280
|
-
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
21281
|
-
};
|
|
21282
|
-
};
|
|
21283
|
-
this.getDefiSpringClaimCall = () => {
|
|
21284
|
-
return (params) => ({
|
|
21285
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
21286
|
-
call: {
|
|
21287
|
-
contractAddress: VESU_REWARDS_CONTRACT,
|
|
21288
|
-
selector: hash3.getSelectorFromName("claim"),
|
|
21289
|
-
calldata: [
|
|
21290
|
-
BigInt(params.amount.toWei()),
|
|
21291
|
-
BigInt(params.proofs.length),
|
|
21292
|
-
...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
|
|
21293
|
-
]
|
|
21294
|
-
}
|
|
21295
|
-
});
|
|
21296
|
-
};
|
|
21297
|
-
this.config = config;
|
|
21298
|
-
}
|
|
21299
|
-
static getDefaultModifyPositionCallParams(params) {
|
|
21300
|
-
return {
|
|
21301
|
-
collateralAmount: {
|
|
21302
|
-
amount_type: 0 /* Delta */,
|
|
21303
|
-
denomination: 1 /* Assets */,
|
|
21304
|
-
value: {
|
|
21305
|
-
abs: params.collateralAmount,
|
|
21306
|
-
is_negative: !params.isAddCollateral
|
|
21307
|
-
}
|
|
21259
|
+
// src/data/vesu-multiple.abi.json
|
|
21260
|
+
var vesu_multiple_abi_default = [
|
|
21261
|
+
{
|
|
21262
|
+
type: "impl",
|
|
21263
|
+
name: "LockerImpl",
|
|
21264
|
+
interface_name: "ekubo::interfaces::core::ILocker"
|
|
21265
|
+
},
|
|
21266
|
+
{
|
|
21267
|
+
type: "struct",
|
|
21268
|
+
name: "core::array::Span::<core::felt252>",
|
|
21269
|
+
members: [
|
|
21270
|
+
{
|
|
21271
|
+
name: "snapshot",
|
|
21272
|
+
type: "@core::array::Array::<core::felt252>"
|
|
21273
|
+
}
|
|
21274
|
+
]
|
|
21275
|
+
},
|
|
21276
|
+
{
|
|
21277
|
+
type: "interface",
|
|
21278
|
+
name: "ekubo::interfaces::core::ILocker",
|
|
21279
|
+
items: [
|
|
21280
|
+
{
|
|
21281
|
+
type: "function",
|
|
21282
|
+
name: "locked",
|
|
21283
|
+
inputs: [
|
|
21284
|
+
{
|
|
21285
|
+
name: "id",
|
|
21286
|
+
type: "core::integer::u32"
|
|
21287
|
+
},
|
|
21288
|
+
{
|
|
21289
|
+
name: "data",
|
|
21290
|
+
type: "core::array::Span::<core::felt252>"
|
|
21291
|
+
}
|
|
21292
|
+
],
|
|
21293
|
+
outputs: [
|
|
21294
|
+
{
|
|
21295
|
+
type: "core::array::Span::<core::felt252>"
|
|
21296
|
+
}
|
|
21297
|
+
],
|
|
21298
|
+
state_mutability: "external"
|
|
21299
|
+
}
|
|
21300
|
+
]
|
|
21301
|
+
},
|
|
21302
|
+
{
|
|
21303
|
+
type: "impl",
|
|
21304
|
+
name: "MultiplyImpl",
|
|
21305
|
+
interface_name: "vesu_periphery::multiply::IMultiply"
|
|
21306
|
+
},
|
|
21307
|
+
{
|
|
21308
|
+
type: "struct",
|
|
21309
|
+
name: "ekubo::types::keys::PoolKey",
|
|
21310
|
+
members: [
|
|
21311
|
+
{
|
|
21312
|
+
name: "token0",
|
|
21313
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21308
21314
|
},
|
|
21309
|
-
|
|
21310
|
-
|
|
21311
|
-
|
|
21312
|
-
|
|
21313
|
-
|
|
21314
|
-
|
|
21315
|
-
|
|
21315
|
+
{
|
|
21316
|
+
name: "token1",
|
|
21317
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21318
|
+
},
|
|
21319
|
+
{
|
|
21320
|
+
name: "fee",
|
|
21321
|
+
type: "core::integer::u128"
|
|
21322
|
+
},
|
|
21323
|
+
{
|
|
21324
|
+
name: "tick_spacing",
|
|
21325
|
+
type: "core::integer::u128"
|
|
21326
|
+
},
|
|
21327
|
+
{
|
|
21328
|
+
name: "extension",
|
|
21329
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21316
21330
|
}
|
|
21317
|
-
|
|
21318
|
-
}
|
|
21319
|
-
|
|
21320
|
-
|
|
21321
|
-
|
|
21322
|
-
|
|
21323
|
-
|
|
21324
|
-
|
|
21325
|
-
|
|
21326
|
-
|
|
21327
|
-
|
|
21328
|
-
|
|
21329
|
-
|
|
21330
|
-
|
|
21331
|
-
|
|
21332
|
-
|
|
21333
|
-
|
|
21334
|
-
|
|
21335
|
-
|
|
21336
|
-
|
|
21337
|
-
|
|
21338
|
-
|
|
21339
|
-
|
|
21340
|
-
|
|
21341
|
-
|
|
21342
|
-
|
|
21343
|
-
|
|
21344
|
-
|
|
21345
|
-
|
|
21346
|
-
|
|
21331
|
+
]
|
|
21332
|
+
},
|
|
21333
|
+
{
|
|
21334
|
+
type: "struct",
|
|
21335
|
+
name: "core::integer::u256",
|
|
21336
|
+
members: [
|
|
21337
|
+
{
|
|
21338
|
+
name: "low",
|
|
21339
|
+
type: "core::integer::u128"
|
|
21340
|
+
},
|
|
21341
|
+
{
|
|
21342
|
+
name: "high",
|
|
21343
|
+
type: "core::integer::u128"
|
|
21344
|
+
}
|
|
21345
|
+
]
|
|
21346
|
+
},
|
|
21347
|
+
{
|
|
21348
|
+
type: "struct",
|
|
21349
|
+
name: "vesu_periphery::swap::RouteNode",
|
|
21350
|
+
members: [
|
|
21351
|
+
{
|
|
21352
|
+
name: "pool_key",
|
|
21353
|
+
type: "ekubo::types::keys::PoolKey"
|
|
21354
|
+
},
|
|
21355
|
+
{
|
|
21356
|
+
name: "sqrt_ratio_limit",
|
|
21357
|
+
type: "core::integer::u256"
|
|
21358
|
+
},
|
|
21359
|
+
{
|
|
21360
|
+
name: "skip_ahead",
|
|
21361
|
+
type: "core::integer::u128"
|
|
21362
|
+
}
|
|
21363
|
+
]
|
|
21364
|
+
},
|
|
21365
|
+
{
|
|
21366
|
+
type: "enum",
|
|
21367
|
+
name: "core::bool",
|
|
21368
|
+
variants: [
|
|
21369
|
+
{
|
|
21370
|
+
name: "False",
|
|
21371
|
+
type: "()"
|
|
21372
|
+
},
|
|
21373
|
+
{
|
|
21374
|
+
name: "True",
|
|
21375
|
+
type: "()"
|
|
21376
|
+
}
|
|
21377
|
+
]
|
|
21378
|
+
},
|
|
21379
|
+
{
|
|
21380
|
+
type: "struct",
|
|
21381
|
+
name: "ekubo::types::i129::i129",
|
|
21382
|
+
members: [
|
|
21383
|
+
{
|
|
21384
|
+
name: "mag",
|
|
21385
|
+
type: "core::integer::u128"
|
|
21386
|
+
},
|
|
21387
|
+
{
|
|
21388
|
+
name: "sign",
|
|
21389
|
+
type: "core::bool"
|
|
21390
|
+
}
|
|
21391
|
+
]
|
|
21392
|
+
},
|
|
21393
|
+
{
|
|
21394
|
+
type: "struct",
|
|
21395
|
+
name: "vesu_periphery::swap::TokenAmount",
|
|
21396
|
+
members: [
|
|
21397
|
+
{
|
|
21398
|
+
name: "token",
|
|
21399
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21400
|
+
},
|
|
21401
|
+
{
|
|
21402
|
+
name: "amount",
|
|
21403
|
+
type: "ekubo::types::i129::i129"
|
|
21404
|
+
}
|
|
21405
|
+
]
|
|
21406
|
+
},
|
|
21407
|
+
{
|
|
21408
|
+
type: "struct",
|
|
21409
|
+
name: "vesu_periphery::swap::Swap",
|
|
21410
|
+
members: [
|
|
21411
|
+
{
|
|
21412
|
+
name: "route",
|
|
21413
|
+
type: "core::array::Array::<vesu_periphery::swap::RouteNode>"
|
|
21414
|
+
},
|
|
21415
|
+
{
|
|
21416
|
+
name: "token_amount",
|
|
21417
|
+
type: "vesu_periphery::swap::TokenAmount"
|
|
21418
|
+
}
|
|
21419
|
+
]
|
|
21420
|
+
},
|
|
21421
|
+
{
|
|
21422
|
+
type: "struct",
|
|
21423
|
+
name: "vesu_periphery::multiply::IncreaseLeverParams",
|
|
21424
|
+
members: [
|
|
21425
|
+
{
|
|
21426
|
+
name: "pool_id",
|
|
21427
|
+
type: "core::felt252"
|
|
21428
|
+
},
|
|
21429
|
+
{
|
|
21430
|
+
name: "collateral_asset",
|
|
21431
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21432
|
+
},
|
|
21433
|
+
{
|
|
21434
|
+
name: "debt_asset",
|
|
21435
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21436
|
+
},
|
|
21437
|
+
{
|
|
21438
|
+
name: "user",
|
|
21439
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21440
|
+
},
|
|
21441
|
+
{
|
|
21442
|
+
name: "add_margin",
|
|
21443
|
+
type: "core::integer::u128"
|
|
21444
|
+
},
|
|
21445
|
+
{
|
|
21446
|
+
name: "margin_swap",
|
|
21447
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21448
|
+
},
|
|
21449
|
+
{
|
|
21450
|
+
name: "margin_swap_limit_amount",
|
|
21451
|
+
type: "core::integer::u128"
|
|
21452
|
+
},
|
|
21453
|
+
{
|
|
21454
|
+
name: "lever_swap",
|
|
21455
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21456
|
+
},
|
|
21457
|
+
{
|
|
21458
|
+
name: "lever_swap_limit_amount",
|
|
21459
|
+
type: "core::integer::u128"
|
|
21460
|
+
}
|
|
21461
|
+
]
|
|
21462
|
+
},
|
|
21463
|
+
{
|
|
21464
|
+
type: "struct",
|
|
21465
|
+
name: "vesu_periphery::multiply::DecreaseLeverParams",
|
|
21466
|
+
members: [
|
|
21467
|
+
{
|
|
21468
|
+
name: "pool_id",
|
|
21469
|
+
type: "core::felt252"
|
|
21470
|
+
},
|
|
21471
|
+
{
|
|
21472
|
+
name: "collateral_asset",
|
|
21473
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21474
|
+
},
|
|
21475
|
+
{
|
|
21476
|
+
name: "debt_asset",
|
|
21477
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21478
|
+
},
|
|
21479
|
+
{
|
|
21480
|
+
name: "user",
|
|
21481
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21482
|
+
},
|
|
21483
|
+
{
|
|
21484
|
+
name: "sub_margin",
|
|
21485
|
+
type: "core::integer::u128"
|
|
21486
|
+
},
|
|
21487
|
+
{
|
|
21488
|
+
name: "recipient",
|
|
21489
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21490
|
+
},
|
|
21491
|
+
{
|
|
21492
|
+
name: "lever_swap",
|
|
21493
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21494
|
+
},
|
|
21495
|
+
{
|
|
21496
|
+
name: "lever_swap_limit_amount",
|
|
21497
|
+
type: "core::integer::u128"
|
|
21498
|
+
},
|
|
21499
|
+
{
|
|
21500
|
+
name: "lever_swap_weights",
|
|
21501
|
+
type: "core::array::Array::<core::integer::u128>"
|
|
21502
|
+
},
|
|
21503
|
+
{
|
|
21504
|
+
name: "withdraw_swap",
|
|
21505
|
+
type: "core::array::Array::<vesu_periphery::swap::Swap>"
|
|
21506
|
+
},
|
|
21507
|
+
{
|
|
21508
|
+
name: "withdraw_swap_limit_amount",
|
|
21509
|
+
type: "core::integer::u128"
|
|
21510
|
+
},
|
|
21511
|
+
{
|
|
21512
|
+
name: "withdraw_swap_weights",
|
|
21513
|
+
type: "core::array::Array::<core::integer::u128>"
|
|
21514
|
+
},
|
|
21515
|
+
{
|
|
21516
|
+
name: "close_position",
|
|
21517
|
+
type: "core::bool"
|
|
21518
|
+
}
|
|
21519
|
+
]
|
|
21520
|
+
},
|
|
21521
|
+
{
|
|
21522
|
+
type: "enum",
|
|
21523
|
+
name: "vesu_periphery::multiply::ModifyLeverAction",
|
|
21524
|
+
variants: [
|
|
21525
|
+
{
|
|
21526
|
+
name: "IncreaseLever",
|
|
21527
|
+
type: "vesu_periphery::multiply::IncreaseLeverParams"
|
|
21528
|
+
},
|
|
21529
|
+
{
|
|
21530
|
+
name: "DecreaseLever",
|
|
21531
|
+
type: "vesu_periphery::multiply::DecreaseLeverParams"
|
|
21532
|
+
}
|
|
21533
|
+
]
|
|
21534
|
+
},
|
|
21535
|
+
{
|
|
21536
|
+
type: "struct",
|
|
21537
|
+
name: "vesu_periphery::multiply::ModifyLeverParams",
|
|
21538
|
+
members: [
|
|
21539
|
+
{
|
|
21540
|
+
name: "action",
|
|
21541
|
+
type: "vesu_periphery::multiply::ModifyLeverAction"
|
|
21542
|
+
}
|
|
21543
|
+
]
|
|
21544
|
+
},
|
|
21545
|
+
{
|
|
21546
|
+
type: "struct",
|
|
21547
|
+
name: "alexandria_math::i257::i257",
|
|
21548
|
+
members: [
|
|
21549
|
+
{
|
|
21550
|
+
name: "abs",
|
|
21551
|
+
type: "core::integer::u256"
|
|
21552
|
+
},
|
|
21553
|
+
{
|
|
21554
|
+
name: "is_negative",
|
|
21555
|
+
type: "core::bool"
|
|
21556
|
+
}
|
|
21557
|
+
]
|
|
21558
|
+
},
|
|
21559
|
+
{
|
|
21560
|
+
type: "struct",
|
|
21561
|
+
name: "vesu_periphery::multiply::ModifyLeverResponse",
|
|
21562
|
+
members: [
|
|
21563
|
+
{
|
|
21564
|
+
name: "collateral_delta",
|
|
21565
|
+
type: "alexandria_math::i257::i257"
|
|
21566
|
+
},
|
|
21567
|
+
{
|
|
21568
|
+
name: "debt_delta",
|
|
21569
|
+
type: "alexandria_math::i257::i257"
|
|
21570
|
+
},
|
|
21571
|
+
{
|
|
21572
|
+
name: "margin_delta",
|
|
21573
|
+
type: "alexandria_math::i257::i257"
|
|
21574
|
+
}
|
|
21575
|
+
]
|
|
21576
|
+
},
|
|
21577
|
+
{
|
|
21578
|
+
type: "interface",
|
|
21579
|
+
name: "vesu_periphery::multiply::IMultiply",
|
|
21580
|
+
items: [
|
|
21581
|
+
{
|
|
21582
|
+
type: "function",
|
|
21583
|
+
name: "modify_lever",
|
|
21584
|
+
inputs: [
|
|
21585
|
+
{
|
|
21586
|
+
name: "modify_lever_params",
|
|
21587
|
+
type: "vesu_periphery::multiply::ModifyLeverParams"
|
|
21588
|
+
}
|
|
21589
|
+
],
|
|
21590
|
+
outputs: [
|
|
21591
|
+
{
|
|
21592
|
+
type: "vesu_periphery::multiply::ModifyLeverResponse"
|
|
21593
|
+
}
|
|
21594
|
+
],
|
|
21595
|
+
state_mutability: "external"
|
|
21596
|
+
}
|
|
21597
|
+
]
|
|
21598
|
+
},
|
|
21599
|
+
{
|
|
21600
|
+
type: "struct",
|
|
21601
|
+
name: "ekubo::interfaces::core::ICoreDispatcher",
|
|
21602
|
+
members: [
|
|
21603
|
+
{
|
|
21604
|
+
name: "contract_address",
|
|
21605
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21606
|
+
}
|
|
21607
|
+
]
|
|
21608
|
+
},
|
|
21609
|
+
{
|
|
21610
|
+
type: "struct",
|
|
21611
|
+
name: "vesu::singleton::ISingletonDispatcher",
|
|
21612
|
+
members: [
|
|
21613
|
+
{
|
|
21614
|
+
name: "contract_address",
|
|
21615
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
21616
|
+
}
|
|
21617
|
+
]
|
|
21618
|
+
},
|
|
21619
|
+
{
|
|
21620
|
+
type: "constructor",
|
|
21621
|
+
name: "constructor",
|
|
21622
|
+
inputs: [
|
|
21623
|
+
{
|
|
21624
|
+
name: "core",
|
|
21625
|
+
type: "ekubo::interfaces::core::ICoreDispatcher"
|
|
21626
|
+
},
|
|
21627
|
+
{
|
|
21628
|
+
name: "singleton",
|
|
21629
|
+
type: "vesu::singleton::ISingletonDispatcher"
|
|
21630
|
+
}
|
|
21631
|
+
]
|
|
21632
|
+
},
|
|
21633
|
+
{
|
|
21634
|
+
type: "event",
|
|
21635
|
+
name: "vesu_periphery::multiply::Multiply::IncreaseLever",
|
|
21636
|
+
kind: "struct",
|
|
21637
|
+
members: [
|
|
21638
|
+
{
|
|
21639
|
+
name: "pool_id",
|
|
21640
|
+
type: "core::felt252",
|
|
21641
|
+
kind: "key"
|
|
21642
|
+
},
|
|
21643
|
+
{
|
|
21644
|
+
name: "collateral_asset",
|
|
21645
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21646
|
+
kind: "key"
|
|
21647
|
+
},
|
|
21648
|
+
{
|
|
21649
|
+
name: "debt_asset",
|
|
21650
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21651
|
+
kind: "key"
|
|
21652
|
+
},
|
|
21653
|
+
{
|
|
21654
|
+
name: "user",
|
|
21655
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21656
|
+
kind: "key"
|
|
21657
|
+
},
|
|
21658
|
+
{
|
|
21659
|
+
name: "margin",
|
|
21660
|
+
type: "core::integer::u256",
|
|
21661
|
+
kind: "data"
|
|
21662
|
+
},
|
|
21663
|
+
{
|
|
21664
|
+
name: "collateral_delta",
|
|
21665
|
+
type: "core::integer::u256",
|
|
21666
|
+
kind: "data"
|
|
21667
|
+
},
|
|
21668
|
+
{
|
|
21669
|
+
name: "debt_delta",
|
|
21670
|
+
type: "core::integer::u256",
|
|
21671
|
+
kind: "data"
|
|
21672
|
+
}
|
|
21673
|
+
]
|
|
21674
|
+
},
|
|
21675
|
+
{
|
|
21676
|
+
type: "event",
|
|
21677
|
+
name: "vesu_periphery::multiply::Multiply::DecreaseLever",
|
|
21678
|
+
kind: "struct",
|
|
21679
|
+
members: [
|
|
21680
|
+
{
|
|
21681
|
+
name: "pool_id",
|
|
21682
|
+
type: "core::felt252",
|
|
21683
|
+
kind: "key"
|
|
21684
|
+
},
|
|
21685
|
+
{
|
|
21686
|
+
name: "collateral_asset",
|
|
21687
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21688
|
+
kind: "key"
|
|
21689
|
+
},
|
|
21690
|
+
{
|
|
21691
|
+
name: "debt_asset",
|
|
21692
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21693
|
+
kind: "key"
|
|
21694
|
+
},
|
|
21695
|
+
{
|
|
21696
|
+
name: "user",
|
|
21697
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
21698
|
+
kind: "key"
|
|
21699
|
+
},
|
|
21700
|
+
{
|
|
21701
|
+
name: "margin",
|
|
21702
|
+
type: "core::integer::u256",
|
|
21703
|
+
kind: "data"
|
|
21704
|
+
},
|
|
21705
|
+
{
|
|
21706
|
+
name: "collateral_delta",
|
|
21707
|
+
type: "core::integer::u256",
|
|
21708
|
+
kind: "data"
|
|
21709
|
+
},
|
|
21710
|
+
{
|
|
21711
|
+
name: "debt_delta",
|
|
21712
|
+
type: "core::integer::u256",
|
|
21713
|
+
kind: "data"
|
|
21714
|
+
}
|
|
21715
|
+
]
|
|
21716
|
+
},
|
|
21717
|
+
{
|
|
21718
|
+
type: "event",
|
|
21719
|
+
name: "vesu_periphery::multiply::Multiply::Event",
|
|
21720
|
+
kind: "enum",
|
|
21721
|
+
variants: [
|
|
21722
|
+
{
|
|
21723
|
+
name: "IncreaseLever",
|
|
21724
|
+
type: "vesu_periphery::multiply::Multiply::IncreaseLever",
|
|
21725
|
+
kind: "nested"
|
|
21726
|
+
},
|
|
21727
|
+
{
|
|
21728
|
+
name: "DecreaseLever",
|
|
21729
|
+
type: "vesu_periphery::multiply::Multiply::DecreaseLever",
|
|
21730
|
+
kind: "nested"
|
|
21731
|
+
}
|
|
21732
|
+
]
|
|
21733
|
+
}
|
|
21734
|
+
];
|
|
21735
|
+
|
|
21736
|
+
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
21737
|
+
var VesuAmountType = /* @__PURE__ */ ((VesuAmountType2) => {
|
|
21738
|
+
VesuAmountType2[VesuAmountType2["Delta"] = 0] = "Delta";
|
|
21739
|
+
VesuAmountType2[VesuAmountType2["Target"] = 1] = "Target";
|
|
21740
|
+
return VesuAmountType2;
|
|
21741
|
+
})(VesuAmountType || {});
|
|
21742
|
+
var VesuAmountDenomination = /* @__PURE__ */ ((VesuAmountDenomination2) => {
|
|
21743
|
+
VesuAmountDenomination2[VesuAmountDenomination2["Native"] = 0] = "Native";
|
|
21744
|
+
VesuAmountDenomination2[VesuAmountDenomination2["Assets"] = 1] = "Assets";
|
|
21745
|
+
return VesuAmountDenomination2;
|
|
21746
|
+
})(VesuAmountDenomination || {});
|
|
21747
|
+
function getVesuMultiplyParams(isIncrease, params) {
|
|
21748
|
+
if (isIncrease) {
|
|
21749
|
+
const _params2 = params;
|
|
21750
|
+
return {
|
|
21751
|
+
action: new CairoCustomEnum2({ IncreaseLever: {
|
|
21752
|
+
pool_id: _params2.pool_id.toBigInt(),
|
|
21753
|
+
collateral_asset: _params2.collateral_asset.toBigInt(),
|
|
21754
|
+
debt_asset: _params2.debt_asset.toBigInt(),
|
|
21755
|
+
user: _params2.user.toBigInt(),
|
|
21756
|
+
add_margin: BigInt(_params2.add_margin.toWei()),
|
|
21757
|
+
margin_swap: _params2.margin_swap.map((swap) => ({
|
|
21758
|
+
route: swap.route.map((route) => ({
|
|
21759
|
+
pool_key: {
|
|
21760
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21761
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21762
|
+
fee: route.pool_key.fee,
|
|
21763
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21764
|
+
extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
|
|
21765
|
+
},
|
|
21766
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21767
|
+
skip_ahead: BigInt(100)
|
|
21768
|
+
})),
|
|
21769
|
+
token_amount: {
|
|
21770
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21771
|
+
amount: swap.token_amount.amount.toI129()
|
|
21772
|
+
}
|
|
21773
|
+
})),
|
|
21774
|
+
margin_swap_limit_amount: BigInt(_params2.margin_swap_limit_amount.toWei()),
|
|
21775
|
+
lever_swap: _params2.lever_swap.map((swap) => ({
|
|
21776
|
+
route: swap.route.map((route) => ({
|
|
21777
|
+
pool_key: {
|
|
21778
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21779
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21780
|
+
fee: route.pool_key.fee,
|
|
21781
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21782
|
+
extension: BigInt(num8.hexToDecimalString(route.pool_key.extension))
|
|
21783
|
+
},
|
|
21784
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21785
|
+
skip_ahead: BigInt(100)
|
|
21786
|
+
})),
|
|
21787
|
+
token_amount: {
|
|
21788
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21789
|
+
amount: swap.token_amount.amount.toI129()
|
|
21790
|
+
}
|
|
21791
|
+
})),
|
|
21792
|
+
lever_swap_limit_amount: BigInt(_params2.lever_swap_limit_amount.toWei())
|
|
21793
|
+
} })
|
|
21794
|
+
};
|
|
21795
|
+
}
|
|
21796
|
+
const _params = params;
|
|
21797
|
+
return {
|
|
21798
|
+
action: new CairoCustomEnum2({ DecreaseLever: {
|
|
21799
|
+
pool_id: _params.pool_id.toBigInt(),
|
|
21800
|
+
collateral_asset: _params.collateral_asset.toBigInt(),
|
|
21801
|
+
debt_asset: _params.debt_asset.toBigInt(),
|
|
21802
|
+
user: _params.user.toBigInt(),
|
|
21803
|
+
sub_margin: BigInt(_params.sub_margin.toWei()),
|
|
21804
|
+
recipient: _params.recipient.toBigInt(),
|
|
21805
|
+
lever_swap: _params.lever_swap.map((swap) => ({
|
|
21806
|
+
route: swap.route.map((route) => ({
|
|
21807
|
+
pool_key: {
|
|
21808
|
+
token0: route.pool_key.token0.toBigInt(),
|
|
21809
|
+
token1: route.pool_key.token1.toBigInt(),
|
|
21810
|
+
fee: route.pool_key.fee,
|
|
21811
|
+
tick_spacing: route.pool_key.tick_spacing,
|
|
21812
|
+
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
21813
|
+
},
|
|
21814
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21815
|
+
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
21816
|
+
})),
|
|
21817
|
+
token_amount: {
|
|
21818
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21819
|
+
amount: swap.token_amount.amount.toI129()
|
|
21820
|
+
}
|
|
21821
|
+
})),
|
|
21822
|
+
lever_swap_limit_amount: BigInt(_params.lever_swap_limit_amount.toWei()),
|
|
21823
|
+
lever_swap_weights: _params.lever_swap_weights.map((weight) => BigInt(weight.toWei())),
|
|
21824
|
+
withdraw_swap: _params.withdraw_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: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
21832
|
+
},
|
|
21833
|
+
sqrt_ratio_limit: uint2567.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
21834
|
+
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
21835
|
+
})),
|
|
21836
|
+
token_amount: {
|
|
21837
|
+
token: swap.token_amount.token.toBigInt(),
|
|
21838
|
+
amount: swap.token_amount.amount.toI129()
|
|
21839
|
+
}
|
|
21840
|
+
})),
|
|
21841
|
+
withdraw_swap_limit_amount: BigInt(_params.withdraw_swap_limit_amount.toWei()),
|
|
21842
|
+
withdraw_swap_weights: _params.withdraw_swap_weights.map((weight) => BigInt(weight.toWei())),
|
|
21843
|
+
close_position: _params.close_position
|
|
21844
|
+
} })
|
|
21845
|
+
};
|
|
21846
|
+
}
|
|
21847
|
+
var VesuPools = {
|
|
21848
|
+
Genesis: ContractAddr.from("0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28"),
|
|
21849
|
+
Re7xSTRK: ContractAddr.from("0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161")
|
|
21850
|
+
};
|
|
21851
|
+
var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
21852
|
+
constructor(config) {
|
|
21853
|
+
super();
|
|
21854
|
+
this.VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
|
|
21855
|
+
this.VESU_MULTIPLY = ContractAddr.from("0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67");
|
|
21856
|
+
this.getModifyPosition = () => {
|
|
21857
|
+
const positionData = [0n];
|
|
21858
|
+
const packedArguments = [
|
|
21859
|
+
toBigInt(this.config.poolId.toString()),
|
|
21860
|
+
// pool id
|
|
21861
|
+
toBigInt(this.config.collateral.address.toString()),
|
|
21862
|
+
// collateral
|
|
21863
|
+
toBigInt(this.config.debt.address.toString()),
|
|
21864
|
+
// debt
|
|
21865
|
+
toBigInt(this.config.vaultAllocator.toString()),
|
|
21866
|
+
// vault allocator
|
|
21867
|
+
toBigInt(positionData.length),
|
|
21868
|
+
...positionData
|
|
21869
|
+
];
|
|
21870
|
+
const output = this.constructSimpleLeafData({
|
|
21871
|
+
id: this.config.id,
|
|
21872
|
+
target: this.VESU_SINGLETON,
|
|
21873
|
+
method: "modify_position",
|
|
21874
|
+
packedArguments
|
|
21875
|
+
});
|
|
21876
|
+
return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
|
|
21877
|
+
};
|
|
21878
|
+
this.getModifyPositionCall = (params) => {
|
|
21879
|
+
const _collateral = {
|
|
21880
|
+
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
21881
|
+
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
21882
|
+
value: {
|
|
21883
|
+
abs: uint2567.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
21884
|
+
is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
|
|
21885
|
+
}
|
|
21886
|
+
};
|
|
21887
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Collateral::${JSON.stringify(_collateral)}`);
|
|
21888
|
+
const _debt = {
|
|
21889
|
+
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
21890
|
+
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
21891
|
+
value: {
|
|
21892
|
+
abs: uint2567.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
21893
|
+
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
21894
|
+
}
|
|
21895
|
+
};
|
|
21896
|
+
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
|
|
21897
|
+
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21898
|
+
const call = singletonContract.populate("modify_position", {
|
|
21899
|
+
params: {
|
|
21900
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
21901
|
+
collateral_asset: this.config.collateral.address.toBigInt(),
|
|
21902
|
+
debt_asset: this.config.debt.address.toBigInt(),
|
|
21903
|
+
user: this.config.vaultAllocator.toBigInt(),
|
|
21904
|
+
collateral: _collateral,
|
|
21905
|
+
debt: _debt,
|
|
21906
|
+
data: [0]
|
|
21907
|
+
}
|
|
21908
|
+
});
|
|
21909
|
+
return {
|
|
21910
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
21911
|
+
call: {
|
|
21912
|
+
contractAddress: this.VESU_SINGLETON,
|
|
21913
|
+
selector: hash3.getSelectorFromName("modify_position"),
|
|
21914
|
+
calldata: [
|
|
21915
|
+
...call.calldata
|
|
21916
|
+
]
|
|
21917
|
+
}
|
|
21918
|
+
};
|
|
21919
|
+
};
|
|
21920
|
+
this.getMultiplyAdapter = () => {
|
|
21921
|
+
const packedArguments = [
|
|
21922
|
+
toBigInt(this.config.poolId.toString()),
|
|
21923
|
+
// pool id
|
|
21924
|
+
toBigInt(this.config.collateral.address.toString()),
|
|
21925
|
+
// collateral
|
|
21926
|
+
toBigInt(this.config.debt.address.toString()),
|
|
21927
|
+
// debt
|
|
21928
|
+
toBigInt(this.config.vaultAllocator.toString())
|
|
21929
|
+
// vault allocator
|
|
21930
|
+
];
|
|
21931
|
+
const output = this.constructSimpleLeafData({
|
|
21932
|
+
id: this.config.id,
|
|
21933
|
+
target: this.VESU_MULTIPLY,
|
|
21934
|
+
method: "modify_lever",
|
|
21935
|
+
packedArguments
|
|
21936
|
+
}, SIMPLE_SANITIZER_V2);
|
|
21937
|
+
return { leaf: output, callConstructor: this.getMultiplyCall.bind(this) };
|
|
21938
|
+
};
|
|
21939
|
+
this.getMultiplyCall = (params) => {
|
|
21940
|
+
const isIncrease = params.isIncrease;
|
|
21941
|
+
const multiplyParams = isIncrease ? params.increaseParams : params.decreaseParams;
|
|
21942
|
+
if (!multiplyParams) {
|
|
21943
|
+
throw new Error("Multiply params are not provided");
|
|
21944
|
+
}
|
|
21945
|
+
const multiplyContract = new Contract8({ abi: vesu_multiple_abi_default, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21946
|
+
const call = multiplyContract.populate("modify_lever", {
|
|
21947
|
+
modify_lever_params: getVesuMultiplyParams(isIncrease, {
|
|
21948
|
+
...multiplyParams,
|
|
21949
|
+
user: this.config.vaultAllocator,
|
|
21950
|
+
pool_id: this.config.poolId,
|
|
21951
|
+
collateral_asset: this.config.collateral.address,
|
|
21952
|
+
debt_asset: this.config.debt.address,
|
|
21953
|
+
recipient: this.config.vaultAllocator
|
|
21954
|
+
})
|
|
21955
|
+
});
|
|
21956
|
+
return {
|
|
21957
|
+
sanitizer: SIMPLE_SANITIZER_V2,
|
|
21958
|
+
call: {
|
|
21959
|
+
contractAddress: this.VESU_MULTIPLY,
|
|
21960
|
+
selector: hash3.getSelectorFromName("modify_lever"),
|
|
21961
|
+
calldata: [
|
|
21962
|
+
...call.calldata
|
|
21963
|
+
]
|
|
21964
|
+
}
|
|
21965
|
+
};
|
|
21966
|
+
};
|
|
21967
|
+
this.getVesuModifyDelegationAdapter = (id) => {
|
|
21968
|
+
return () => {
|
|
21969
|
+
const packedArguments = [
|
|
21970
|
+
toBigInt(this.config.poolId.toString()),
|
|
21971
|
+
// pool id
|
|
21972
|
+
toBigInt(this.VESU_MULTIPLY.toString())
|
|
21973
|
+
// vault allocator
|
|
21974
|
+
];
|
|
21975
|
+
const output = this.constructSimpleLeafData({
|
|
21976
|
+
id,
|
|
21977
|
+
target: this.VESU_SINGLETON,
|
|
21978
|
+
method: "modify_delegation",
|
|
21979
|
+
packedArguments
|
|
21980
|
+
}, SIMPLE_SANITIZER_V2);
|
|
21981
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
21982
|
+
};
|
|
21983
|
+
};
|
|
21984
|
+
this.getVesuModifyDelegationCall = (params) => {
|
|
21985
|
+
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
21986
|
+
const call = singletonContract.populate("modify_delegation", {
|
|
21987
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
21988
|
+
delegatee: this.VESU_MULTIPLY.toBigInt(),
|
|
21989
|
+
delegation: params.delegation
|
|
21990
|
+
});
|
|
21991
|
+
return {
|
|
21992
|
+
sanitizer: SIMPLE_SANITIZER_V2,
|
|
21993
|
+
call: {
|
|
21994
|
+
contractAddress: this.VESU_SINGLETON,
|
|
21995
|
+
selector: hash3.getSelectorFromName("modify_delegation"),
|
|
21996
|
+
calldata: [
|
|
21997
|
+
...call.calldata
|
|
21998
|
+
]
|
|
21999
|
+
}
|
|
22000
|
+
};
|
|
22001
|
+
};
|
|
22002
|
+
this.getDefispringRewardsAdapter = (id) => {
|
|
22003
|
+
return () => {
|
|
22004
|
+
const packedArguments = [];
|
|
22005
|
+
const output = {
|
|
22006
|
+
id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
|
|
22007
|
+
readableId: id,
|
|
22008
|
+
data: [
|
|
22009
|
+
SIMPLE_SANITIZER.toBigInt(),
|
|
22010
|
+
// sanitizer address
|
|
22011
|
+
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
22012
|
+
// contract
|
|
22013
|
+
toBigInt(hash3.getSelectorFromName("claim")),
|
|
22014
|
+
// method name
|
|
22015
|
+
BigInt(packedArguments.length),
|
|
22016
|
+
...packedArguments
|
|
22017
|
+
]
|
|
22018
|
+
};
|
|
22019
|
+
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
22020
|
+
};
|
|
22021
|
+
};
|
|
22022
|
+
this.getDefiSpringClaimCall = () => {
|
|
22023
|
+
return (params) => ({
|
|
22024
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
22025
|
+
call: {
|
|
22026
|
+
contractAddress: VESU_REWARDS_CONTRACT,
|
|
22027
|
+
selector: hash3.getSelectorFromName("claim"),
|
|
22028
|
+
calldata: [
|
|
22029
|
+
BigInt(params.amount.toWei()),
|
|
22030
|
+
BigInt(params.proofs.length),
|
|
22031
|
+
...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
|
|
22032
|
+
]
|
|
22033
|
+
}
|
|
22034
|
+
});
|
|
22035
|
+
};
|
|
22036
|
+
this.config = config;
|
|
22037
|
+
}
|
|
22038
|
+
static getDefaultModifyPositionCallParams(params) {
|
|
22039
|
+
return {
|
|
22040
|
+
collateralAmount: {
|
|
22041
|
+
amount_type: 0 /* Delta */,
|
|
22042
|
+
denomination: 1 /* Assets */,
|
|
22043
|
+
value: {
|
|
22044
|
+
abs: params.collateralAmount,
|
|
22045
|
+
is_negative: !params.isAddCollateral
|
|
22046
|
+
}
|
|
22047
|
+
},
|
|
22048
|
+
debtAmount: {
|
|
22049
|
+
amount_type: 0 /* Delta */,
|
|
22050
|
+
denomination: 1 /* Assets */,
|
|
22051
|
+
value: {
|
|
22052
|
+
abs: params.debtAmount,
|
|
22053
|
+
is_negative: !params.isBorrow
|
|
22054
|
+
}
|
|
22055
|
+
}
|
|
22056
|
+
};
|
|
22057
|
+
}
|
|
22058
|
+
formatAmountTypeEnum(amountType) {
|
|
22059
|
+
switch (amountType) {
|
|
22060
|
+
case 0 /* Delta */:
|
|
22061
|
+
return new CairoCustomEnum2({ Delta: {} });
|
|
22062
|
+
case 1 /* Target */:
|
|
22063
|
+
return new CairoCustomEnum2({ Target: {} });
|
|
22064
|
+
}
|
|
22065
|
+
throw new Error(`Unknown VesuAmountType: ${amountType}`);
|
|
22066
|
+
}
|
|
22067
|
+
formatAmountDenominationEnum(denomination) {
|
|
22068
|
+
switch (denomination) {
|
|
22069
|
+
case 0 /* Native */:
|
|
22070
|
+
return new CairoCustomEnum2({ Native: {} });
|
|
22071
|
+
case 1 /* Assets */:
|
|
22072
|
+
return new CairoCustomEnum2({ Assets: {} });
|
|
22073
|
+
}
|
|
22074
|
+
throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
|
|
22075
|
+
}
|
|
22076
|
+
getVesuSingletonContract(config) {
|
|
22077
|
+
return new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider });
|
|
22078
|
+
}
|
|
22079
|
+
async getLTVConfig(config) {
|
|
22080
|
+
const CACHE_KEY = "ltv_config";
|
|
22081
|
+
const cacheData = this.getCache(CACHE_KEY);
|
|
22082
|
+
if (cacheData) {
|
|
22083
|
+
return cacheData;
|
|
22084
|
+
}
|
|
22085
|
+
const output = await this.getVesuSingletonContract(config).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
|
|
21347
22086
|
this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 3e5);
|
|
21348
22087
|
return this.getCache(CACHE_KEY);
|
|
21349
22088
|
}
|
|
@@ -23683,10 +24422,10 @@ var vault_manager_abi_default = [
|
|
|
23683
24422
|
|
|
23684
24423
|
// src/strategies/universal-strategy.tsx
|
|
23685
24424
|
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
23686
|
-
var AUMTypes = /* @__PURE__ */ ((
|
|
23687
|
-
|
|
23688
|
-
|
|
23689
|
-
return
|
|
24425
|
+
var AUMTypes = /* @__PURE__ */ ((AUMTypes3) => {
|
|
24426
|
+
AUMTypes3["FINALISED"] = "finalised";
|
|
24427
|
+
AUMTypes3["DEFISPRING"] = "defispring";
|
|
24428
|
+
return AUMTypes3;
|
|
23690
24429
|
})(AUMTypes || {});
|
|
23691
24430
|
var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
23692
24431
|
constructor(config, pricer, metadata) {
|
|
@@ -23814,24 +24553,33 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23814
24553
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
23815
24554
|
*/
|
|
23816
24555
|
async netAPY() {
|
|
23817
|
-
const
|
|
23818
|
-
const
|
|
23819
|
-
const
|
|
23820
|
-
const
|
|
23821
|
-
|
|
24556
|
+
const prevAUM = await this.getPrevAUM();
|
|
24557
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24558
|
+
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
24559
|
+
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
24560
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num9.getHexString(p.id)));
|
|
24561
|
+
});
|
|
24562
|
+
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
24563
|
+
if (pools.some((p) => !p)) {
|
|
23822
24564
|
throw new Error("Pool not found");
|
|
23823
24565
|
}
|
|
23824
24566
|
;
|
|
23825
|
-
const
|
|
23826
|
-
const debtAsset1 = pool1.assets.find((a) => a.symbol === vesuAdapter1.config.debt.symbol)?.stats;
|
|
23827
|
-
const collateralAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.collateral.symbol)?.stats;
|
|
23828
|
-
const debtAsset2 = pool2.assets.find((a) => a.symbol === vesuAdapter2.config.debt.symbol)?.stats;
|
|
23829
|
-
const collateral1APY = Number(collateralAsset1.supplyApy.value) / 1e18;
|
|
23830
|
-
const debt1APY = Number(debtAsset1.borrowApr.value) / 1e18;
|
|
23831
|
-
const collateral2APY = Number(collateralAsset2.supplyApy.value) / 1e18;
|
|
23832
|
-
const debt2APY = Number(debtAsset2.borrowApr.value) / 1e18;
|
|
23833
|
-
const positions = await this.getVaultPositions();
|
|
24567
|
+
const positions = await this.getVesuPositions();
|
|
23834
24568
|
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
24569
|
+
const baseAPYs = [];
|
|
24570
|
+
const rewardAPYs = [];
|
|
24571
|
+
for (const [index, pool] of pools.entries()) {
|
|
24572
|
+
const vesuAdapter = vesuAdapters[index];
|
|
24573
|
+
const collateralAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.collateral.symbol)?.stats;
|
|
24574
|
+
const debtAsset = pool.assets.find((a) => a.symbol === vesuAdapter.config.debt.symbol)?.stats;
|
|
24575
|
+
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
24576
|
+
const lstAPY = Number(collateralAsset.lstApr?.value || 0) / 1e18;
|
|
24577
|
+
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
24578
|
+
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr.value || "0") / 1e18, 0]);
|
|
24579
|
+
}
|
|
24580
|
+
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
24581
|
+
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
24582
|
+
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
23835
24583
|
if (positions.every((p) => p.amount.isZero())) {
|
|
23836
24584
|
return { net: 0, splits: [{
|
|
23837
24585
|
apy: 0,
|
|
@@ -23842,11 +24590,10 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23842
24590
|
}] };
|
|
23843
24591
|
}
|
|
23844
24592
|
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
23845
|
-
const
|
|
23846
|
-
|
|
23847
|
-
const
|
|
23848
|
-
const
|
|
23849
|
-
const rewardAPY = this.computeAPY(rewardAPYs, weights);
|
|
24593
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
24594
|
+
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
24595
|
+
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
24596
|
+
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
23850
24597
|
const netAPY = baseAPY + rewardAPY;
|
|
23851
24598
|
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
23852
24599
|
return { net: netAPY, splits: [{
|
|
@@ -23857,11 +24604,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23857
24604
|
id: "defispring"
|
|
23858
24605
|
}] };
|
|
23859
24606
|
}
|
|
23860
|
-
computeAPY(apys, weights) {
|
|
24607
|
+
computeAPY(apys, weights, currentAUM) {
|
|
23861
24608
|
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
23862
24609
|
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
23863
|
-
|
|
23864
|
-
return weightedSum /
|
|
24610
|
+
logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
|
|
24611
|
+
return weightedSum / currentAUM.toNumber();
|
|
23865
24612
|
}
|
|
23866
24613
|
/**
|
|
23867
24614
|
* Calculates the total TVL of the strategy.
|
|
@@ -23893,24 +24640,48 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23893
24640
|
usdValue
|
|
23894
24641
|
};
|
|
23895
24642
|
}
|
|
23896
|
-
async
|
|
24643
|
+
async getVesuAUM(adapter) {
|
|
24644
|
+
const legAUM = await adapter.getPositions(this.config);
|
|
24645
|
+
const underlying = this.asset();
|
|
24646
|
+
let vesuAum = Web3Number.fromWei("0", underlying.decimals);
|
|
24647
|
+
if (legAUM[0].token.address.eq(underlying.address)) {
|
|
24648
|
+
vesuAum = vesuAum.plus(legAUM[0].amount);
|
|
24649
|
+
} else {
|
|
24650
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24651
|
+
vesuAum = vesuAum.plus(legAUM[1].usdValue / tokenPrice.price);
|
|
24652
|
+
}
|
|
24653
|
+
if (legAUM[1].token.address.eq(underlying.address)) {
|
|
24654
|
+
vesuAum = vesuAum.minus(legAUM[1].amount);
|
|
24655
|
+
} else {
|
|
24656
|
+
const tokenPrice = await this.pricer.getPrice(legAUM[1].token.symbol);
|
|
24657
|
+
vesuAum = vesuAum.minus(legAUM[1].usdValue / tokenPrice.price);
|
|
24658
|
+
}
|
|
24659
|
+
;
|
|
24660
|
+
logger.verbose(`${this.getTag()} Vesu AUM: ${vesuAum}, legCollateral: ${legAUM[0].amount.toNumber()}, legDebt: ${legAUM[1].amount.toNumber()}`);
|
|
24661
|
+
return vesuAum;
|
|
24662
|
+
}
|
|
24663
|
+
async getPrevAUM() {
|
|
23897
24664
|
const currentAUM = await this.contract.call("aum", []);
|
|
23898
|
-
const
|
|
24665
|
+
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
24666
|
+
logger.verbose(`${this.getTag()} Prev AUM: ${prevAum}`);
|
|
24667
|
+
return prevAum;
|
|
24668
|
+
}
|
|
24669
|
+
async getAUM() {
|
|
24670
|
+
const prevAum = await this.getPrevAUM();
|
|
23899
24671
|
const token1Price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
23900
|
-
const
|
|
23901
|
-
|
|
23902
|
-
const
|
|
24672
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
24673
|
+
let vesuAum = Web3Number.fromWei("0", this.asset().decimals);
|
|
24674
|
+
for (const adapter of vesuAdapters) {
|
|
24675
|
+
vesuAum = vesuAum.plus(await this.getVesuAUM(adapter));
|
|
24676
|
+
}
|
|
23903
24677
|
const balance = await this.getUnusedBalance();
|
|
23904
24678
|
logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
|
|
23905
|
-
const vesuAum = leg1AUM[0].amount.plus(leg2AUM[0].usdValue / token1Price.price).minus(leg1AUM[1].usdValue / token1Price.price).minus(leg2AUM[1].amount);
|
|
23906
|
-
logger.verbose(`${this.getTag()} Vesu AUM: leg1: ${leg1AUM[0].amount.toNumber()}, ${leg1AUM[1].amount.toNumber()}, leg2: ${leg2AUM[0].amount.toNumber()}, ${leg2AUM[1].amount.toNumber()}`);
|
|
23907
24679
|
const zeroAmt = Web3Number.fromWei("0", this.asset().decimals);
|
|
23908
24680
|
const net = {
|
|
23909
24681
|
tokenInfo: this.asset(),
|
|
23910
24682
|
amount: zeroAmt,
|
|
23911
24683
|
usdValue: 0
|
|
23912
24684
|
};
|
|
23913
|
-
const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
|
|
23914
24685
|
if (vesuAum.isZero()) {
|
|
23915
24686
|
return { net, splits: [{
|
|
23916
24687
|
aum: zeroAmt,
|
|
@@ -23922,16 +24693,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23922
24693
|
}
|
|
23923
24694
|
const aumToken = vesuAum.plus(balance.amount);
|
|
23924
24695
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
23925
|
-
const
|
|
23926
|
-
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
23927
|
-
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
23928
|
-
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
23929
|
-
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
23930
|
-
const rewardAssets = prevAum.multipliedBy(growthRate);
|
|
23931
|
-
logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
|
|
23932
|
-
logger.verbose(`${this.getTag()} Current AUM: ${currentAUM}`);
|
|
23933
|
-
logger.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
|
|
23934
|
-
logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
|
|
24696
|
+
const rewardAssets = await this.getRewardsAUM(prevAum);
|
|
23935
24697
|
const newAUM = aumToken.plus(rewardAssets);
|
|
23936
24698
|
logger.verbose(`${this.getTag()} New AUM: ${newAUM}`);
|
|
23937
24699
|
net.amount = newAUM;
|
|
@@ -23945,6 +24707,21 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23945
24707
|
}];
|
|
23946
24708
|
return { net, splits, prevAum };
|
|
23947
24709
|
}
|
|
24710
|
+
// account for future rewards (e.g. defispring rewards)
|
|
24711
|
+
async getRewardsAUM(prevAum) {
|
|
24712
|
+
const lastReportTime = await this.contract.call("last_report_timestamp", []);
|
|
24713
|
+
const netAPY = await this.netAPY();
|
|
24714
|
+
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
24715
|
+
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
24716
|
+
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
24717
|
+
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
24718
|
+
const rewardAssets = prevAum.multipliedBy(growthRate);
|
|
24719
|
+
logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
|
|
24720
|
+
logger.verbose(`${this.getTag()} Current AUM: ${prevAum.toString()}`);
|
|
24721
|
+
logger.verbose(`${this.getTag()} Net APY: ${JSON.stringify(netAPY)}`);
|
|
24722
|
+
logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
|
|
24723
|
+
return rewardAssets;
|
|
24724
|
+
}
|
|
23948
24725
|
getVesuAdapters() {
|
|
23949
24726
|
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
23950
24727
|
const vesuAdapter2 = this.getAdapter("vesu_leg2_adapter" /* VESU_LEG2 */);
|
|
@@ -23954,11 +24731,23 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23954
24731
|
vesuAdapter2.networkConfig = this.config;
|
|
23955
24732
|
return [vesuAdapter1, vesuAdapter2];
|
|
23956
24733
|
}
|
|
24734
|
+
async getVesuPositions() {
|
|
24735
|
+
const adapters = this.getVesuAdapters();
|
|
24736
|
+
const positions = [];
|
|
24737
|
+
for (const adapter of adapters) {
|
|
24738
|
+
positions.push(...await adapter.getPositions(this.config));
|
|
24739
|
+
}
|
|
24740
|
+
return positions;
|
|
24741
|
+
}
|
|
23957
24742
|
async getVaultPositions() {
|
|
23958
|
-
const
|
|
23959
|
-
const
|
|
23960
|
-
|
|
23961
|
-
|
|
24743
|
+
const vesuPositions = await this.getVesuPositions();
|
|
24744
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
24745
|
+
return [...vesuPositions, {
|
|
24746
|
+
amount: unusedBalance.amount,
|
|
24747
|
+
usdValue: unusedBalance.usdValue,
|
|
24748
|
+
token: this.asset(),
|
|
24749
|
+
remarks: "Unused Balance"
|
|
24750
|
+
}];
|
|
23962
24751
|
}
|
|
23963
24752
|
getSetManagerCall(strategist, root = this.getMerkleRoot()) {
|
|
23964
24753
|
return this.managerContract.populate("set_manage_root", [strategist.address, num9.getHexString(root)]);
|
|
@@ -24096,7 +24885,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
24096
24885
|
return new Web3Number(newAmount.toFixed(8), debtTokenAmount.decimals);
|
|
24097
24886
|
}
|
|
24098
24887
|
}
|
|
24099
|
-
async
|
|
24888
|
+
async getVesuModifyPositionCall(params) {
|
|
24100
24889
|
const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
|
|
24101
24890
|
const leg1LTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
24102
24891
|
const leg2LTV = await vesuAdapter2.getLTVConfig(this.config);
|
|
@@ -24596,6 +25385,336 @@ var UniversalStrategies = [
|
|
|
24596
25385
|
investmentSteps
|
|
24597
25386
|
}
|
|
24598
25387
|
];
|
|
25388
|
+
|
|
25389
|
+
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
25390
|
+
import { Contract as Contract10, uint256 as uint2569 } from "starknet";
|
|
25391
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
25392
|
+
var UniversalLstMultiplierStrategy = class extends UniversalStrategy {
|
|
25393
|
+
constructor(config, pricer, metadata) {
|
|
25394
|
+
super(config, pricer, metadata);
|
|
25395
|
+
this.quoteAmountToFetchPrice = new Web3Number(1, 18);
|
|
25396
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25397
|
+
const underlyingToken = this.getLSTUnderlyingTokenInfo();
|
|
25398
|
+
if (underlyingToken.address.eq(STRKToken.address)) {
|
|
25399
|
+
this.quoteAmountToFetchPrice = new Web3Number(100, 18);
|
|
25400
|
+
} else {
|
|
25401
|
+
this.quoteAmountToFetchPrice = new Web3Number(0.01, this.asset().decimals);
|
|
25402
|
+
}
|
|
25403
|
+
}
|
|
25404
|
+
// only one leg is used
|
|
25405
|
+
// todo support lending assets of underlying as well
|
|
25406
|
+
getVesuAdapters() {
|
|
25407
|
+
const vesuAdapter1 = this.getAdapter("vesu_leg1_adapter" /* VESU_LEG1 */);
|
|
25408
|
+
vesuAdapter1.pricer = this.pricer;
|
|
25409
|
+
vesuAdapter1.networkConfig = this.config;
|
|
25410
|
+
return [vesuAdapter1];
|
|
25411
|
+
}
|
|
25412
|
+
// not applicable for this strategy
|
|
25413
|
+
// No rewards on collateral or borrowing of LST assets
|
|
25414
|
+
async getRewardsAUM(prevAum) {
|
|
25415
|
+
return Web3Number.fromWei("0", this.asset().decimals);
|
|
25416
|
+
}
|
|
25417
|
+
async getLSTDexPrice() {
|
|
25418
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25419
|
+
const lstTokenInfo = this.asset();
|
|
25420
|
+
const lstUnderlyingTokenInfo = this.getLSTUnderlyingTokenInfo();
|
|
25421
|
+
const quote = await ekuboQuoter.getQuote(
|
|
25422
|
+
lstTokenInfo.address.address,
|
|
25423
|
+
lstUnderlyingTokenInfo.address.address,
|
|
25424
|
+
this.quoteAmountToFetchPrice
|
|
25425
|
+
);
|
|
25426
|
+
const outputAmount = Web3Number.fromWei(quote.total_calculated, lstUnderlyingTokenInfo.decimals);
|
|
25427
|
+
const price = outputAmount.toNumber() / this.quoteAmountToFetchPrice.toNumber();
|
|
25428
|
+
logger.verbose(`${this.getTag()}:: LST Dex Price: ${price}`);
|
|
25429
|
+
return price;
|
|
25430
|
+
}
|
|
25431
|
+
/**
|
|
25432
|
+
* Uses vesu's multiple call to create leverage on LST
|
|
25433
|
+
* Deposit amount is in LST
|
|
25434
|
+
* @param params
|
|
25435
|
+
*/
|
|
25436
|
+
async getVesuMultiplyCall(params) {
|
|
25437
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25438
|
+
const legLTV = await vesuAdapter1.getLTVConfig(this.config);
|
|
25439
|
+
const existingPositions = await vesuAdapter1.getPositions(this.config);
|
|
25440
|
+
const collateralisation = await vesuAdapter1.getCollateralization(this.config);
|
|
25441
|
+
const existingCollateralInfo = existingPositions[0];
|
|
25442
|
+
const existingDebtInfo = existingPositions[1];
|
|
25443
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall existingCollateralInfo: ${JSON.stringify(existingCollateralInfo)},
|
|
25444
|
+
existingDebtInfo: ${JSON.stringify(existingDebtInfo)}, collateralisation: ${JSON.stringify(collateralisation)}`);
|
|
25445
|
+
const collateralPrice = collateralisation[0].usdValue > 0 ? collateralisation[0].usdValue / existingCollateralInfo.amount.toNumber() : 1;
|
|
25446
|
+
const debtPrice = collateralisation[1].usdValue > 0 ? collateralisation[1].usdValue / existingDebtInfo.amount.toNumber() : 1;
|
|
25447
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall collateralPrice: ${collateralPrice}, debtPrice: ${debtPrice}`);
|
|
25448
|
+
const addedCollateral = params.leg1DepositAmount.multipliedBy(params.isDeposit ? 1 : -1);
|
|
25449
|
+
const DEXPrice = await this.getLSTDexPrice();
|
|
25450
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall addedCollateral: ${addedCollateral}`);
|
|
25451
|
+
const numeratorPart1 = existingCollateralInfo.amount.plus(addedCollateral).multipliedBy(collateralPrice).multipliedBy(legLTV);
|
|
25452
|
+
const numeratorPart2 = existingDebtInfo.amount.multipliedBy(debtPrice).multipliedBy(this.metadata.additionalInfo.targetHealthFactor);
|
|
25453
|
+
const denominatorPart = this.metadata.additionalInfo.targetHealthFactor - legLTV / DEXPrice;
|
|
25454
|
+
const x_debt_usd = numeratorPart1.minus(numeratorPart2).dividedBy(denominatorPart);
|
|
25455
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall x_debt_usd: ${x_debt_usd}`);
|
|
25456
|
+
logger.debug(`${this.getTag()}::getVesuMultiplyCall numeratorPart1: ${numeratorPart1}, numeratorPart2: ${numeratorPart2}, denominatorPart: ${denominatorPart}`);
|
|
25457
|
+
const debtAmount = x_debt_usd.dividedBy(debtPrice);
|
|
25458
|
+
const marginAmount = addedCollateral;
|
|
25459
|
+
logger.verbose(`${this.getTag()}::getVesuMultiplyCall debtAmount: ${debtAmount}, marginAmount: ${marginAmount}`);
|
|
25460
|
+
return this.getModifyLeverCall({
|
|
25461
|
+
marginAmount,
|
|
25462
|
+
debtAmount,
|
|
25463
|
+
isIncrease: debtAmount.greaterThan(0)
|
|
25464
|
+
});
|
|
25465
|
+
}
|
|
25466
|
+
getLSTUnderlyingTokenInfo() {
|
|
25467
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25468
|
+
return vesuAdapter1.config.debt;
|
|
25469
|
+
}
|
|
25470
|
+
async getLSTExchangeRate() {
|
|
25471
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25472
|
+
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
25473
|
+
const lstABI = new Contract10({
|
|
25474
|
+
abi: erc4626_abi_default,
|
|
25475
|
+
address: lstTokenInfo.address.address,
|
|
25476
|
+
providerOrAccount: this.config.provider
|
|
25477
|
+
});
|
|
25478
|
+
const price = await lstABI.call("convert_to_assets", [uint2569.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
25479
|
+
const exchangeRate = Number(uint2569.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
25480
|
+
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
25481
|
+
return exchangeRate;
|
|
25482
|
+
}
|
|
25483
|
+
/**
|
|
25484
|
+
*
|
|
25485
|
+
* @param params marginAmount is in LST, debtAmount is in underlying
|
|
25486
|
+
*/
|
|
25487
|
+
async getModifyLeverCall(params) {
|
|
25488
|
+
assert(!params.marginAmount.isZero() || !params.debtAmount.isZero(), "Deposit/debt must be non-0");
|
|
25489
|
+
const [vesuAdapter1] = this.getVesuAdapters();
|
|
25490
|
+
const lstTokenInfo = this.asset();
|
|
25491
|
+
const lstUnderlyingTokenInfo = vesuAdapter1.config.debt;
|
|
25492
|
+
const proofsIDs = [];
|
|
25493
|
+
const manageCalls = [];
|
|
25494
|
+
if (params.marginAmount.greaterThan(0)) {
|
|
25495
|
+
const STEP1_ID = "approve_token1" /* APPROVE_TOKEN1 */;
|
|
25496
|
+
const manage1Info = this.getProofs(STEP1_ID);
|
|
25497
|
+
const depositAmount = params.marginAmount;
|
|
25498
|
+
const manageCall1 = manage1Info.callConstructor({
|
|
25499
|
+
amount: depositAmount
|
|
25500
|
+
});
|
|
25501
|
+
proofsIDs.push(STEP1_ID);
|
|
25502
|
+
manageCalls.push(manageCall1);
|
|
25503
|
+
}
|
|
25504
|
+
const ekuboQuoter = new EkuboQuoter(this.config);
|
|
25505
|
+
const lstPrice = await this.getLSTExchangeRate();
|
|
25506
|
+
const marginSwap = [];
|
|
25507
|
+
const MAX_SLIPPAGE = 0.01;
|
|
25508
|
+
const fromToken = params.isIncrease ? lstUnderlyingTokenInfo : lstTokenInfo;
|
|
25509
|
+
const toToken = params.isIncrease ? lstTokenInfo : lstUnderlyingTokenInfo;
|
|
25510
|
+
const leverSwapQuote = await ekuboQuoter.getQuote(
|
|
25511
|
+
fromToken.address.address,
|
|
25512
|
+
toToken.address.address,
|
|
25513
|
+
params.debtAmount
|
|
25514
|
+
// negative for exact amount out
|
|
25515
|
+
);
|
|
25516
|
+
assert(leverSwapQuote.price_impact < MAX_SLIPPAGE, "getIncreaseLeverCall: Price impact is too high [Debt swap]");
|
|
25517
|
+
const leverSwap = ekuboQuoter.getVesuMultiplyQuote(leverSwapQuote, fromToken, toToken);
|
|
25518
|
+
const minExpectedDebt = params.debtAmount.dividedBy(lstPrice).multipliedBy(1 - MAX_SLIPPAGE);
|
|
25519
|
+
const maxUsedCollateral = params.debtAmount.abs().dividedBy(lstPrice).multipliedBy(1 + MAX_SLIPPAGE);
|
|
25520
|
+
const STEP2_ID = "switch_delegation_on" /* SWITCH_DELEGATION_ON */;
|
|
25521
|
+
const manage2Info = this.getProofs(STEP2_ID);
|
|
25522
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
25523
|
+
delegation: true
|
|
25524
|
+
});
|
|
25525
|
+
const STEP3_ID = "multiply_vesu" /* MULTIPLY_VESU */;
|
|
25526
|
+
const manage3Info = this.getProofs(STEP3_ID);
|
|
25527
|
+
const multiplyParams = params.isIncrease ? {
|
|
25528
|
+
isIncrease: true,
|
|
25529
|
+
increaseParams: {
|
|
25530
|
+
add_margin: params.marginAmount,
|
|
25531
|
+
margin_swap: marginSwap,
|
|
25532
|
+
margin_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25533
|
+
lever_swap: leverSwap,
|
|
25534
|
+
lever_swap_limit_amount: minExpectedDebt
|
|
25535
|
+
}
|
|
25536
|
+
} : {
|
|
25537
|
+
isIncrease: false,
|
|
25538
|
+
decreaseParams: {
|
|
25539
|
+
sub_margin: params.marginAmount.multipliedBy(-1),
|
|
25540
|
+
lever_swap: leverSwap,
|
|
25541
|
+
lever_swap_limit_amount: maxUsedCollateral,
|
|
25542
|
+
// only required for close position
|
|
25543
|
+
lever_swap_weights: [],
|
|
25544
|
+
// no need to swap collateral to anything, and any residuals return our contract anyways.
|
|
25545
|
+
withdraw_swap: [],
|
|
25546
|
+
withdraw_swap_limit_amount: Web3Number.fromWei(0, this.asset().decimals),
|
|
25547
|
+
withdraw_swap_weights: [],
|
|
25548
|
+
close_position: false
|
|
25549
|
+
}
|
|
25550
|
+
};
|
|
25551
|
+
const manageCall3 = manage3Info.callConstructor(multiplyParams);
|
|
25552
|
+
const STEP4_ID = "switch_delegation_off" /* SWITCH_DELEGATION_OFF */;
|
|
25553
|
+
const manage4Info = this.getProofs(STEP4_ID);
|
|
25554
|
+
const manageCall4 = manage4Info.callConstructor({
|
|
25555
|
+
delegation: false
|
|
25556
|
+
});
|
|
25557
|
+
proofsIDs.push(STEP2_ID, STEP3_ID, STEP4_ID);
|
|
25558
|
+
manageCalls.push(manageCall2, manageCall3, manageCall4);
|
|
25559
|
+
return [this.getManageCall(proofsIDs, manageCalls)];
|
|
25560
|
+
}
|
|
25561
|
+
};
|
|
25562
|
+
function VaultDescription() {
|
|
25563
|
+
const containerStyle = {
|
|
25564
|
+
maxWidth: "800px",
|
|
25565
|
+
margin: "0 auto",
|
|
25566
|
+
backgroundColor: "#111",
|
|
25567
|
+
color: "#eee",
|
|
25568
|
+
fontFamily: "Arial, sans-serif",
|
|
25569
|
+
borderRadius: "12px"
|
|
25570
|
+
};
|
|
25571
|
+
return /* @__PURE__ */ jsxs4("div", { style: containerStyle, children: [
|
|
25572
|
+
/* @__PURE__ */ jsx5("h1", { style: { fontSize: "18px", marginBottom: "10px" }, children: "Meta Vault \u2014 Automated Yield Router" }),
|
|
25573
|
+
/* @__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." }),
|
|
25574
|
+
/* @__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: [
|
|
25575
|
+
/* @__PURE__ */ jsx5("strong", { children: "Withdrawals:" }),
|
|
25576
|
+
" Requests can take up to ",
|
|
25577
|
+
/* @__PURE__ */ jsx5("strong", { children: "1-2 hours" }),
|
|
25578
|
+
" to process as the vault unwinds and settles routing."
|
|
25579
|
+
] }) })
|
|
25580
|
+
] });
|
|
25581
|
+
}
|
|
25582
|
+
function getDescription2(tokenSymbol) {
|
|
25583
|
+
return VaultDescription();
|
|
25584
|
+
}
|
|
25585
|
+
function getLooperSettings2(lstSymbol, underlyingSymbol, vaultSettings, pool1) {
|
|
25586
|
+
vaultSettings.leafAdapters = [];
|
|
25587
|
+
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
25588
|
+
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
25589
|
+
const vesuAdapterLST = new VesuAdapter({
|
|
25590
|
+
poolId: pool1,
|
|
25591
|
+
collateral: lstToken,
|
|
25592
|
+
debt: underlyingToken,
|
|
25593
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
25594
|
+
id: "multiply_vesu" /* MULTIPLY_VESU */
|
|
25595
|
+
});
|
|
25596
|
+
const commonAdapter = new CommonAdapter({
|
|
25597
|
+
manager: vaultSettings.manager,
|
|
25598
|
+
asset: lstToken.address,
|
|
25599
|
+
id: "",
|
|
25600
|
+
vaultAddress: vaultSettings.vaultAddress,
|
|
25601
|
+
vaultAllocator: vaultSettings.vaultAllocator
|
|
25602
|
+
});
|
|
25603
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vesuAdapterLST.VESU_MULTIPLY, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
25604
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter.bind(vesuAdapterLST));
|
|
25605
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_on" /* SWITCH_DELEGATION_ON */).bind(vesuAdapterLST));
|
|
25606
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter("switch_delegation_off" /* SWITCH_DELEGATION_OFF */).bind(vesuAdapterLST));
|
|
25607
|
+
vaultSettings.adapters.push(...[{
|
|
25608
|
+
id: "vesu_leg1_adapter" /* VESU_LEG1 */,
|
|
25609
|
+
adapter: vesuAdapterLST
|
|
25610
|
+
}, {
|
|
25611
|
+
id: "common_adapter" /* COMMON */,
|
|
25612
|
+
adapter: commonAdapter
|
|
25613
|
+
}]);
|
|
25614
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25615
|
+
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
25616
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterLST));
|
|
25617
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
25618
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
25619
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, lstToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
|
|
25620
|
+
return vaultSettings;
|
|
25621
|
+
}
|
|
25622
|
+
function getFAQs2(lstSymbol, underlyingSymbol) {
|
|
25623
|
+
return [
|
|
25624
|
+
{
|
|
25625
|
+
question: `What is the Hyper ${lstSymbol} Vault?`,
|
|
25626
|
+
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.`
|
|
25627
|
+
},
|
|
25628
|
+
{
|
|
25629
|
+
question: "How does yield allocation work?",
|
|
25630
|
+
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.`
|
|
25631
|
+
},
|
|
25632
|
+
{
|
|
25633
|
+
question: "Which protocols/dApp are used??",
|
|
25634
|
+
answer: /* @__PURE__ */ jsxs4("span", { children: [
|
|
25635
|
+
"Currently, the LST is from ",
|
|
25636
|
+
/* @__PURE__ */ jsx5("strong", { children: "Endur" }),
|
|
25637
|
+
" while ",
|
|
25638
|
+
/* @__PURE__ */ jsx5("strong", { children: "Vesu" }),
|
|
25639
|
+
" is used to collateralize the looped position."
|
|
25640
|
+
] })
|
|
25641
|
+
},
|
|
25642
|
+
{
|
|
25643
|
+
question: "Can I get liquidated?",
|
|
25644
|
+
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."
|
|
25645
|
+
},
|
|
25646
|
+
{
|
|
25647
|
+
question: "What do I receive when I deposit?",
|
|
25648
|
+
answer: "Depositors receive vault tokens representing their proportional share of the vault. These tokens entitle holders to both the principal and accrued yield."
|
|
25649
|
+
},
|
|
25650
|
+
{
|
|
25651
|
+
question: "How long do withdrawals take?",
|
|
25652
|
+
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."
|
|
25653
|
+
},
|
|
25654
|
+
{
|
|
25655
|
+
question: "Is the Hyper xSTRK Vault non-custodial?",
|
|
25656
|
+
answer: "Yes. The Hyper xSTRK Vault operates entirely on-chain. Users always maintain control of their vault tokens, and the strategy is fully transparent."
|
|
25657
|
+
},
|
|
25658
|
+
{
|
|
25659
|
+
question: "Is the Vault audited?",
|
|
25660
|
+
answer: "Yes. The Hyper xSTRK Vault is audited by Zellic. Look for safety icon beside the strategy name for more details."
|
|
25661
|
+
},
|
|
25662
|
+
{
|
|
25663
|
+
question: "Are there any fees?",
|
|
25664
|
+
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."
|
|
25665
|
+
}
|
|
25666
|
+
];
|
|
25667
|
+
}
|
|
25668
|
+
var _riskFactor4 = [
|
|
25669
|
+
{ type: "Smart Contract Risk" /* SMART_CONTRACT_RISK */, value: 2 /* WELL_AUDITED */, weight: 25, reason: "Audited by Zellic" },
|
|
25670
|
+
{ type: "Liquidation Risk" /* LIQUIDATION_RISK */, value: 1 /* VERY_LOW_PROBABILITY */, weight: 50, reason: "The collateral and debt are highly correlated" },
|
|
25671
|
+
{ 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." }
|
|
25672
|
+
];
|
|
25673
|
+
var hyperxSTRK = {
|
|
25674
|
+
vaultAddress: ContractAddr.from("0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"),
|
|
25675
|
+
manager: ContractAddr.from("0x5d499cd333757f461a0bedaca3dfc4d77320c773037e0aa299f22a6dbfdc03a"),
|
|
25676
|
+
vaultAllocator: ContractAddr.from("0x511d07953a09bc7c505970891507c5a2486d2ea22752601a14db092186d7caa"),
|
|
25677
|
+
redeemRequestNFT: ContractAddr.from("0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"),
|
|
25678
|
+
aumOracle: ContractAddr.from("0x48cf709870a1a0d453d37de108e0c41b8b89819ef54f95abc0e2e1f98bbe937"),
|
|
25679
|
+
leafAdapters: [],
|
|
25680
|
+
adapters: [],
|
|
25681
|
+
targetHealthFactor: 1.1,
|
|
25682
|
+
minHealthFactor: 1.05
|
|
25683
|
+
};
|
|
25684
|
+
function getInvestmentSteps(lstSymbol, underlyingSymbol) {
|
|
25685
|
+
return [
|
|
25686
|
+
`Deposit ${underlyingSymbol} into the vault`,
|
|
25687
|
+
`The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
|
|
25688
|
+
`The vault manager collateralizes the ${lstSymbol} on Vesu`,
|
|
25689
|
+
`The vault manager borrows more ${underlyingSymbol} to loop further`,
|
|
25690
|
+
`Claim BTCFi STRK rewards weekly to swap to ${lstSymbol} and reinvest`,
|
|
25691
|
+
`If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
|
|
25692
|
+
];
|
|
25693
|
+
}
|
|
25694
|
+
function getStrategySettings(lstSymbol, underlyingSymbol, addresses) {
|
|
25695
|
+
return {
|
|
25696
|
+
name: `Hyper ${lstSymbol}`,
|
|
25697
|
+
description: getDescription2(lstSymbol),
|
|
25698
|
+
address: addresses.vaultAddress,
|
|
25699
|
+
launchBlock: 0,
|
|
25700
|
+
type: "Other",
|
|
25701
|
+
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
|
|
25702
|
+
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, addresses, VesuPools.Re7xSTRK),
|
|
25703
|
+
risk: {
|
|
25704
|
+
riskFactor: _riskFactor4,
|
|
25705
|
+
netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
|
|
25706
|
+
notARisks: getNoRiskTags(_riskFactor4)
|
|
25707
|
+
},
|
|
25708
|
+
protocols: [Protocols.ENDUR, Protocols.VESU],
|
|
25709
|
+
maxTVL: Web3Number.fromWei(0, 18),
|
|
25710
|
+
contractDetails: getContractDetails(addresses),
|
|
25711
|
+
faqs: getFAQs2(lstSymbol, underlyingSymbol),
|
|
25712
|
+
investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol)
|
|
25713
|
+
};
|
|
25714
|
+
}
|
|
25715
|
+
var HyperLSTStrategies = [
|
|
25716
|
+
getStrategySettings("xSTRK", "STRK", hyperxSTRK)
|
|
25717
|
+
];
|
|
24599
25718
|
export {
|
|
24600
25719
|
AUMTypes,
|
|
24601
25720
|
AutoCompounderSTRK,
|
|
@@ -24607,9 +25726,11 @@ export {
|
|
|
24607
25726
|
ERC20,
|
|
24608
25727
|
EkuboCLVault,
|
|
24609
25728
|
EkuboCLVaultStrategies,
|
|
25729
|
+
EkuboQuoter,
|
|
24610
25730
|
FatalError,
|
|
24611
25731
|
FlowChartColors,
|
|
24612
25732
|
Global,
|
|
25733
|
+
HyperLSTStrategies,
|
|
24613
25734
|
ILending,
|
|
24614
25735
|
Initializable,
|
|
24615
25736
|
MarginType,
|
|
@@ -24623,6 +25744,7 @@ export {
|
|
|
24623
25744
|
SenseiVault,
|
|
24624
25745
|
UNIVERSAL_ADAPTERS,
|
|
24625
25746
|
UNIVERSAL_MANAGE_IDS,
|
|
25747
|
+
UniversalLstMultiplierStrategy,
|
|
24626
25748
|
UniversalStrategies,
|
|
24627
25749
|
UniversalStrategy,
|
|
24628
25750
|
VesuAdapter,
|
|
@@ -24633,6 +25755,7 @@ export {
|
|
|
24633
25755
|
VesuRebalanceStrategies,
|
|
24634
25756
|
Web3Number,
|
|
24635
25757
|
ZkLend,
|
|
25758
|
+
getContractDetails,
|
|
24636
25759
|
getMainnetConfig,
|
|
24637
25760
|
getNoRiskTags,
|
|
24638
25761
|
getRiskColor,
|