@strkfarm/sdk 2.0.0-dev.34 → 2.0.0-dev.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.global.js +1486 -64
- package/dist/index.browser.mjs +2433 -1010
- package/dist/index.d.ts +104 -2
- package/dist/index.js +1452 -26
- package/dist/index.mjs +2437 -1014
- package/package.json +1 -1
- package/src/data/redeem-request-nft.abi.json +752 -0
- package/src/strategies/index.ts +1 -0
- package/src/strategies/svk-strategy.ts +3 -2
- package/src/strategies/universal-adapters/adapter-utils.ts +2 -0
- package/src/strategies/universal-adapters/avnu-adapter.ts +3 -2
- package/src/strategies/universal-adapters/extended-adapter.ts +25 -0
- package/src/strategies/universal-adapters/svk-troves-adapter.ts +141 -7
- package/src/strategies/universal-adapters/vesu-modify-position-adapter.ts +69 -39
- package/src/strategies/usdc-boosted-strategy.tsx +693 -0
- package/src/strategies/vesu-extended-strategy/services/executionService.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -21734,6 +21734,7 @@ import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract10, hash as ha
|
|
|
21734
21734
|
|
|
21735
21735
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
21736
21736
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
21737
|
+
var SVK_SIMPLE_SANITIZER = ContractAddr.from("0x03dcde04343257c3ce14574676cb9c5b2eda16e332c1b8caf5dc4c95ac568d2f");
|
|
21737
21738
|
var EXTENDED_SANITIZER = ContractAddr.from("0x65891708362b24dcf4c40c8e218cce6e82d1d6b3a3404c9ab00a48f08e2c110");
|
|
21738
21739
|
var AVNU_LEGACY_SANITIZER = ContractAddr.from("0x0656fBE853f116DD53956176a553eDe8fE65632252f8aceB50C1B9B6c8237309");
|
|
21739
21740
|
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
|
|
@@ -35597,7 +35598,14 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
|
|
|
35597
35598
|
}
|
|
35598
35599
|
const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
|
|
35599
35600
|
helperOutput
|
|
35600
|
-
);
|
|
35601
|
+
).minus(state.currentDebt);
|
|
35602
|
+
if (normalizedDebtAmount.lessThan(0)) {
|
|
35603
|
+
logger.warn(`VesuModifyPositionAdapter: deposit debt delta is negative (${normalizedDebtAmount.toNumber()}), clamping to zero`);
|
|
35604
|
+
return {
|
|
35605
|
+
collateral: this._toSigned(collateralToAdd, false),
|
|
35606
|
+
debt: this._toSigned(Web3Number.fromWei(0, this.config.debt.decimals), false)
|
|
35607
|
+
};
|
|
35608
|
+
}
|
|
35601
35609
|
return {
|
|
35602
35610
|
collateral: this._toSigned(collateralToAdd, false),
|
|
35603
35611
|
debt: this._toSigned(normalizedDebtAmount, false)
|
|
@@ -35615,8 +35623,8 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
|
|
|
35615
35623
|
state.debtPrice,
|
|
35616
35624
|
this.config.debt
|
|
35617
35625
|
);
|
|
35618
|
-
if (!helperOutput || helperOutput.
|
|
35619
|
-
throw new Error(`Failed to calculate
|
|
35626
|
+
if (!helperOutput || helperOutput.lessThan(0)) {
|
|
35627
|
+
throw new Error(`Failed to calculate max debt amount for withdraw: ${helperOutput?.toNumber()}`);
|
|
35620
35628
|
}
|
|
35621
35629
|
const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
|
|
35622
35630
|
helperOutput
|
|
@@ -35813,6 +35821,24 @@ var VesuModifyPositionAdapter = class _VesuModifyPositionAdapter extends BaseAda
|
|
|
35813
35821
|
this._prepareVesuAdapter();
|
|
35814
35822
|
return this._vesuAdapter.getHealthFactor();
|
|
35815
35823
|
}
|
|
35824
|
+
/**
|
|
35825
|
+
* Simulates a deposit of `depositAmount` collateral and returns how much
|
|
35826
|
+
* debt (STRK) would be incrementally borrowed to reach the target LTV.
|
|
35827
|
+
* Used upstream to size the AVNU swap call in the same transaction batch.
|
|
35828
|
+
*/
|
|
35829
|
+
async getExpectedDepositDebtDelta(depositAmount) {
|
|
35830
|
+
const defaults = await this._buildDefaultDepositDeltas({ amount: depositAmount });
|
|
35831
|
+
return defaults.debt.amount;
|
|
35832
|
+
}
|
|
35833
|
+
/**
|
|
35834
|
+
* Simulates a withdrawal of `withdrawAmount` collateral and returns the
|
|
35835
|
+
* incremental debt delta needed to keep the target health factor.
|
|
35836
|
+
* Positive means borrow, negative means repay.
|
|
35837
|
+
*/
|
|
35838
|
+
async getExpectedWithdrawDebtDelta(withdrawAmount) {
|
|
35839
|
+
const defaults = await this._buildDefaultWithdrawDeltas({ amount: withdrawAmount });
|
|
35840
|
+
return defaults.debt.amount;
|
|
35841
|
+
}
|
|
35816
35842
|
};
|
|
35817
35843
|
|
|
35818
35844
|
// src/strategies/universal-adapters/extended-adapter.ts
|
|
@@ -36370,6 +36396,25 @@ var ExtendedAdapter = class _ExtendedAdapter extends BaseAdapter {
|
|
|
36370
36396
|
return { success: false, data: [] };
|
|
36371
36397
|
}
|
|
36372
36398
|
}
|
|
36399
|
+
/** Account funding payment history via `GET /api/v1/account/funding-payments` (USDC amounts). */
|
|
36400
|
+
async getFundingPayments(side, startTime, limit) {
|
|
36401
|
+
try {
|
|
36402
|
+
const response = await this.client.getUserFundingPayments(
|
|
36403
|
+
this.config.extendedMarketName,
|
|
36404
|
+
side,
|
|
36405
|
+
startTime ?? Date.now() - 30 * 24 * 60 * 60 * 1e3,
|
|
36406
|
+
limit ?? 200
|
|
36407
|
+
);
|
|
36408
|
+
if (response.status !== "OK") {
|
|
36409
|
+
logger.error("error getting funding payments", response.data);
|
|
36410
|
+
return { success: false, data: [] };
|
|
36411
|
+
}
|
|
36412
|
+
return { success: true, data: response.data ?? [] };
|
|
36413
|
+
} catch (err) {
|
|
36414
|
+
logger.error("error getting funding payments", err);
|
|
36415
|
+
return { success: false, data: [] };
|
|
36416
|
+
}
|
|
36417
|
+
}
|
|
36373
36418
|
async getPosition(supportedPosition) {
|
|
36374
36419
|
const holdings = await this.getExtendedDepositAmount();
|
|
36375
36420
|
if (!holdings) {
|
|
@@ -39009,349 +39054,110 @@ var universal_vault_abi_default = [
|
|
|
39009
39054
|
}
|
|
39010
39055
|
];
|
|
39011
39056
|
|
|
39012
|
-
// src/
|
|
39013
|
-
var
|
|
39014
|
-
|
|
39015
|
-
|
|
39016
|
-
|
|
39017
|
-
|
|
39018
|
-
|
|
39019
|
-
|
|
39020
|
-
|
|
39021
|
-
|
|
39022
|
-
|
|
39023
|
-
}
|
|
39024
|
-
return 0;
|
|
39025
|
-
}
|
|
39026
|
-
var SvkTrovesAdapter = class _SvkTrovesAdapter extends BaseAdapter {
|
|
39027
|
-
constructor(config) {
|
|
39028
|
-
super(config, _SvkTrovesAdapter.name, Protocols.TROVES);
|
|
39029
|
-
this.config = config;
|
|
39030
|
-
}
|
|
39031
|
-
/** Owner used for share balance + `due_assets_from_owner`. */
|
|
39032
|
-
_positionOwner() {
|
|
39033
|
-
return this.config.positionOwner ?? this.config.vaultAllocator;
|
|
39034
|
-
}
|
|
39035
|
-
/**
|
|
39036
|
-
* Proof readable IDs must stay ≤ 31 chars (Cairo short string). We derive a short ASCII suffix from
|
|
39037
|
-
* `strategyVault` address so multiple SVK adapters in one tree stay distinct.
|
|
39038
|
-
*/
|
|
39039
|
-
_proofSuffix() {
|
|
39040
|
-
return this.config.strategyVault.address.replace(/^0x/, "").slice(-6);
|
|
39041
|
-
}
|
|
39042
|
-
_depositApproveProofReadableId() {
|
|
39043
|
-
return `appr_dep_svk_${this._proofSuffix()}`;
|
|
39044
|
-
}
|
|
39045
|
-
_depositCallProofReadableId() {
|
|
39046
|
-
return `dep_svk_${this._proofSuffix()}`;
|
|
39047
|
-
}
|
|
39048
|
-
_withdrawCallProofReadableId() {
|
|
39049
|
-
return `wtdrw_svk_${this._proofSuffix()}`;
|
|
39050
|
-
}
|
|
39051
|
-
async getAPY(supportedPosition) {
|
|
39052
|
-
const CACHE_KEY = `svk_apy_${this.config.trovesStrategyId}`;
|
|
39053
|
-
const cached = this.getCache(CACHE_KEY);
|
|
39054
|
-
if (cached) {
|
|
39055
|
-
return cached;
|
|
39056
|
-
}
|
|
39057
|
-
const url = this.config.trovesStrategiesApiUrl ?? DEFAULT_TROVES_STRATEGIES_API;
|
|
39058
|
-
try {
|
|
39059
|
-
const res = await fetch(url);
|
|
39060
|
-
if (!res.ok) {
|
|
39061
|
-
logger.warn(`${_SvkTrovesAdapter.name}::getAPY: HTTP ${res.status} from ${url}`);
|
|
39062
|
-
const fallback = { apy: 0, type: "base" /* BASE */ };
|
|
39063
|
-
this.setCache(CACHE_KEY, fallback, 3e5);
|
|
39064
|
-
return fallback;
|
|
39065
|
-
}
|
|
39066
|
-
const body = await res.json();
|
|
39067
|
-
const row = body.strategies?.find((s) => s.id === this.config.trovesStrategyId);
|
|
39068
|
-
if (!row) {
|
|
39069
|
-
logger.warn(
|
|
39070
|
-
`${_SvkTrovesAdapter.name}::getAPY: strategy id not found: ${this.config.trovesStrategyId}`
|
|
39071
|
-
);
|
|
39072
|
-
const fallback = { apy: 0, type: "base" /* BASE */ };
|
|
39073
|
-
this.setCache(CACHE_KEY, fallback, 3e5);
|
|
39074
|
-
return fallback;
|
|
39075
|
-
}
|
|
39076
|
-
const apy = parseTrovesApyField(row.apy);
|
|
39077
|
-
const result = { apy, type: "base" /* BASE */ };
|
|
39078
|
-
this.setCache(CACHE_KEY, result, 3e5);
|
|
39079
|
-
return result;
|
|
39080
|
-
} catch (error) {
|
|
39081
|
-
logger.error(`${_SvkTrovesAdapter.name}::getAPY:`, error);
|
|
39082
|
-
throw error;
|
|
39083
|
-
}
|
|
39084
|
-
}
|
|
39085
|
-
async getPosition(supportedPosition) {
|
|
39086
|
-
const CACHE_KEY = `svk_pos_${this.config.strategyVault.address}_${this._positionOwner().address}`;
|
|
39087
|
-
const cached = this.getCache(CACHE_KEY);
|
|
39088
|
-
if (cached) {
|
|
39089
|
-
return cached;
|
|
39090
|
-
}
|
|
39091
|
-
try {
|
|
39092
|
-
const vault = new Contract14({
|
|
39093
|
-
abi: universal_vault_abi_default,
|
|
39094
|
-
address: this.config.strategyVault.address,
|
|
39095
|
-
providerOrAccount: this.config.networkConfig.provider
|
|
39096
|
-
});
|
|
39097
|
-
const owner = this._positionOwner();
|
|
39098
|
-
const decimals = supportedPosition.asset.decimals;
|
|
39099
|
-
const shares = await vault.balance_of(owner.address);
|
|
39100
|
-
const shareU256 = uint25619.bnToUint256(shares);
|
|
39101
|
-
const liquidAssetsRaw = await vault.convert_to_assets(shareU256);
|
|
39102
|
-
const liquid = Web3Number.fromWei(liquidAssetsRaw.toString(), decimals);
|
|
39103
|
-
let pending = Web3Number.fromWei("0", decimals);
|
|
39104
|
-
try {
|
|
39105
|
-
const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
|
|
39106
|
-
pending = Web3Number.fromWei(dueRaw.toString(), decimals);
|
|
39107
|
-
} catch (e) {
|
|
39108
|
-
logger.warn(
|
|
39109
|
-
`${_SvkTrovesAdapter.name}::getPosition: due_assets_from_owner failed (treating as 0): ${e.message}`
|
|
39110
|
-
);
|
|
39111
|
-
}
|
|
39112
|
-
const total = liquid.plus(pending);
|
|
39113
|
-
const remarks = `Troves ${this.config.trovesStrategyId} holdings`;
|
|
39114
|
-
const result = {
|
|
39115
|
-
amount: total,
|
|
39116
|
-
remarks
|
|
39117
|
-
};
|
|
39118
|
-
this.setCache(CACHE_KEY, result, 6e4);
|
|
39119
|
-
return result;
|
|
39120
|
-
} catch (error) {
|
|
39121
|
-
logger.error(`${_SvkTrovesAdapter.name}::getPosition:`, error);
|
|
39122
|
-
throw error;
|
|
39123
|
-
}
|
|
39124
|
-
}
|
|
39125
|
-
async maxDeposit(amount) {
|
|
39126
|
-
const baseToken = this.config.baseToken;
|
|
39127
|
-
if (!amount) {
|
|
39128
|
-
return {
|
|
39129
|
-
tokenInfo: baseToken,
|
|
39130
|
-
amount: new Web3Number("999999999999999999999999999", baseToken.decimals),
|
|
39131
|
-
usdValue: 1e27,
|
|
39132
|
-
remarks: "Max deposit (unbounded placeholder)",
|
|
39133
|
-
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
39134
|
-
protocol: this.protocol
|
|
39135
|
-
};
|
|
39136
|
-
}
|
|
39137
|
-
const usdValue = await this.getUSDValue(baseToken, amount);
|
|
39138
|
-
return {
|
|
39139
|
-
tokenInfo: baseToken,
|
|
39140
|
-
amount,
|
|
39141
|
-
usdValue,
|
|
39142
|
-
remarks: "Deposit amount",
|
|
39143
|
-
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
39144
|
-
protocol: this.protocol
|
|
39145
|
-
};
|
|
39146
|
-
}
|
|
39147
|
-
async maxWithdraw() {
|
|
39148
|
-
const baseToken = this.config.baseToken;
|
|
39149
|
-
const current = await this.getPosition({ asset: baseToken, isDebt: false });
|
|
39150
|
-
const pos = current ?? { amount: new Web3Number("0", baseToken.decimals), remarks: "" };
|
|
39151
|
-
const usdValue = await this.getUSDValue(baseToken, pos.amount);
|
|
39152
|
-
return {
|
|
39153
|
-
tokenInfo: baseToken,
|
|
39154
|
-
amount: pos.amount,
|
|
39155
|
-
usdValue,
|
|
39156
|
-
remarks: "Max withdraw (liquid + pending redemption, underlying units)",
|
|
39157
|
-
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
39158
|
-
protocol: this.protocol
|
|
39159
|
-
};
|
|
39160
|
-
}
|
|
39161
|
-
_getDepositLeaf() {
|
|
39162
|
-
const baseToken = this.config.baseToken;
|
|
39163
|
-
const strategyVault = this.config.strategyVault;
|
|
39164
|
-
const receiver = this.config.vaultAllocator;
|
|
39165
|
-
return [
|
|
39057
|
+
// src/data/redeem-request-nft.abi.json
|
|
39058
|
+
var redeem_request_nft_abi_default = [
|
|
39059
|
+
{
|
|
39060
|
+
type: "impl",
|
|
39061
|
+
name: "RedeemRequestImpl",
|
|
39062
|
+
interface_name: "vault::redeem_request::interface::IRedeemRequest"
|
|
39063
|
+
},
|
|
39064
|
+
{
|
|
39065
|
+
type: "struct",
|
|
39066
|
+
name: "core::integer::u256",
|
|
39067
|
+
members: [
|
|
39166
39068
|
{
|
|
39167
|
-
|
|
39168
|
-
|
|
39169
|
-
packedArguments: [strategyVault.toBigInt()],
|
|
39170
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
39171
|
-
id: this._depositApproveProofReadableId()
|
|
39069
|
+
name: "low",
|
|
39070
|
+
type: "core::integer::u128"
|
|
39172
39071
|
},
|
|
39173
39072
|
{
|
|
39174
|
-
|
|
39175
|
-
|
|
39176
|
-
packedArguments: [receiver.toBigInt()],
|
|
39177
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
39178
|
-
id: this._depositCallProofReadableId()
|
|
39179
|
-
}
|
|
39180
|
-
];
|
|
39181
|
-
}
|
|
39182
|
-
_getWithdrawLeaf() {
|
|
39183
|
-
const strategyVault = this.config.strategyVault;
|
|
39184
|
-
const recv = this.config.vaultAllocator;
|
|
39185
|
-
const owner = this.config.vaultAllocator;
|
|
39186
|
-
return [
|
|
39187
|
-
{
|
|
39188
|
-
target: strategyVault,
|
|
39189
|
-
method: "withdraw",
|
|
39190
|
-
packedArguments: [recv.toBigInt(), owner.toBigInt()],
|
|
39191
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
39192
|
-
id: this._withdrawCallProofReadableId()
|
|
39073
|
+
name: "high",
|
|
39074
|
+
type: "core::integer::u128"
|
|
39193
39075
|
}
|
|
39194
|
-
]
|
|
39195
|
-
}
|
|
39196
|
-
|
|
39197
|
-
|
|
39198
|
-
|
|
39199
|
-
|
|
39200
|
-
return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
|
|
39201
|
-
});
|
|
39202
|
-
return { leaves, callConstructor: this.getDepositCall.bind(this) };
|
|
39203
|
-
}
|
|
39204
|
-
getWithdrawAdapter() {
|
|
39205
|
-
const leafConfigs = this._getWithdrawLeaf();
|
|
39206
|
-
const leaves = leafConfigs.map((config) => {
|
|
39207
|
-
const { target, method, packedArguments, sanitizer, id } = config;
|
|
39208
|
-
return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
|
|
39209
|
-
});
|
|
39210
|
-
return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
|
|
39211
|
-
}
|
|
39212
|
-
async getDepositCall(params) {
|
|
39213
|
-
const baseToken = this.config.baseToken;
|
|
39214
|
-
const strategyVault = this.config.strategyVault;
|
|
39215
|
-
const amount = params.amount;
|
|
39216
|
-
const uint256Amount = uint25619.bnToUint256(amount.toWei());
|
|
39217
|
-
const receiver = this.config.vaultAllocator;
|
|
39218
|
-
return [
|
|
39076
|
+
]
|
|
39077
|
+
},
|
|
39078
|
+
{
|
|
39079
|
+
type: "struct",
|
|
39080
|
+
name: "vault::redeem_request::interface::RedeemRequestInfo",
|
|
39081
|
+
members: [
|
|
39219
39082
|
{
|
|
39220
|
-
|
|
39221
|
-
|
|
39222
|
-
call: {
|
|
39223
|
-
contractAddress: baseToken.address,
|
|
39224
|
-
selector: hash11.getSelectorFromName("approve"),
|
|
39225
|
-
calldata: [
|
|
39226
|
-
strategyVault.toBigInt(),
|
|
39227
|
-
toBigInt(uint256Amount.low.toString()),
|
|
39228
|
-
toBigInt(uint256Amount.high.toString())
|
|
39229
|
-
]
|
|
39230
|
-
}
|
|
39083
|
+
name: "epoch",
|
|
39084
|
+
type: "core::integer::u256"
|
|
39231
39085
|
},
|
|
39232
39086
|
{
|
|
39233
|
-
|
|
39234
|
-
|
|
39235
|
-
call: {
|
|
39236
|
-
contractAddress: strategyVault,
|
|
39237
|
-
selector: hash11.getSelectorFromName("deposit"),
|
|
39238
|
-
calldata: [
|
|
39239
|
-
toBigInt(uint256Amount.low.toString()),
|
|
39240
|
-
toBigInt(uint256Amount.high.toString()),
|
|
39241
|
-
receiver.toBigInt()
|
|
39242
|
-
]
|
|
39243
|
-
}
|
|
39244
|
-
}
|
|
39245
|
-
];
|
|
39246
|
-
}
|
|
39247
|
-
async getWithdrawCall(params) {
|
|
39248
|
-
const strategyVault = this.config.strategyVault;
|
|
39249
|
-
const amount = params.amount;
|
|
39250
|
-
const uint256Amount = uint25619.bnToUint256(amount.toWei());
|
|
39251
|
-
const recv = this.config.vaultAllocator;
|
|
39252
|
-
const owner = this.config.vaultAllocator;
|
|
39253
|
-
return [
|
|
39254
|
-
{
|
|
39255
|
-
proofReadableId: this._withdrawCallProofReadableId(),
|
|
39256
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
39257
|
-
call: {
|
|
39258
|
-
contractAddress: strategyVault,
|
|
39259
|
-
selector: hash11.getSelectorFromName("withdraw"),
|
|
39260
|
-
calldata: [
|
|
39261
|
-
toBigInt(uint256Amount.low.toString()),
|
|
39262
|
-
toBigInt(uint256Amount.high.toString()),
|
|
39263
|
-
recv.toBigInt(),
|
|
39264
|
-
owner.toBigInt()
|
|
39265
|
-
]
|
|
39266
|
-
}
|
|
39087
|
+
name: "nominal",
|
|
39088
|
+
type: "core::integer::u256"
|
|
39267
39089
|
}
|
|
39268
|
-
]
|
|
39269
|
-
}
|
|
39270
|
-
getHealthFactor() {
|
|
39271
|
-
return Promise.resolve(10);
|
|
39272
|
-
}
|
|
39273
|
-
};
|
|
39274
|
-
|
|
39275
|
-
// src/strategies/universal-strategy.tsx
|
|
39276
|
-
import { CallData, Contract as Contract15, num as num12, uint256 as uint25620 } from "starknet";
|
|
39277
|
-
|
|
39278
|
-
// src/data/vault-manager.abi.json
|
|
39279
|
-
var vault_manager_abi_default = [
|
|
39280
|
-
{
|
|
39281
|
-
type: "impl",
|
|
39282
|
-
name: "UpgradeableImpl",
|
|
39283
|
-
interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
|
|
39090
|
+
]
|
|
39284
39091
|
},
|
|
39285
39092
|
{
|
|
39286
39093
|
type: "interface",
|
|
39287
|
-
name: "
|
|
39094
|
+
name: "vault::redeem_request::interface::IRedeemRequest",
|
|
39288
39095
|
items: [
|
|
39289
39096
|
{
|
|
39290
39097
|
type: "function",
|
|
39291
|
-
name: "
|
|
39292
|
-
inputs: [
|
|
39098
|
+
name: "vault",
|
|
39099
|
+
inputs: [],
|
|
39100
|
+
outputs: [
|
|
39293
39101
|
{
|
|
39294
|
-
|
|
39295
|
-
type: "core::starknet::class_hash::ClassHash"
|
|
39102
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39296
39103
|
}
|
|
39297
39104
|
],
|
|
39298
|
-
|
|
39299
|
-
state_mutability: "external"
|
|
39300
|
-
}
|
|
39301
|
-
]
|
|
39302
|
-
},
|
|
39303
|
-
{
|
|
39304
|
-
type: "impl",
|
|
39305
|
-
name: "ManagerFlashloanReceiverImpl",
|
|
39306
|
-
interface_name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver"
|
|
39307
|
-
},
|
|
39308
|
-
{
|
|
39309
|
-
type: "struct",
|
|
39310
|
-
name: "core::integer::u256",
|
|
39311
|
-
members: [
|
|
39312
|
-
{
|
|
39313
|
-
name: "low",
|
|
39314
|
-
type: "core::integer::u128"
|
|
39105
|
+
state_mutability: "view"
|
|
39315
39106
|
},
|
|
39316
39107
|
{
|
|
39317
|
-
|
|
39318
|
-
|
|
39319
|
-
|
|
39320
|
-
|
|
39321
|
-
|
|
39322
|
-
|
|
39323
|
-
|
|
39324
|
-
|
|
39325
|
-
|
|
39108
|
+
type: "function",
|
|
39109
|
+
name: "id_to_info",
|
|
39110
|
+
inputs: [
|
|
39111
|
+
{
|
|
39112
|
+
name: "id",
|
|
39113
|
+
type: "core::integer::u256"
|
|
39114
|
+
}
|
|
39115
|
+
],
|
|
39116
|
+
outputs: [
|
|
39117
|
+
{
|
|
39118
|
+
type: "vault::redeem_request::interface::RedeemRequestInfo"
|
|
39119
|
+
}
|
|
39120
|
+
],
|
|
39121
|
+
state_mutability: "view"
|
|
39122
|
+
},
|
|
39326
39123
|
{
|
|
39327
|
-
|
|
39328
|
-
|
|
39329
|
-
|
|
39330
|
-
|
|
39331
|
-
|
|
39332
|
-
|
|
39333
|
-
|
|
39334
|
-
|
|
39335
|
-
|
|
39124
|
+
type: "function",
|
|
39125
|
+
name: "id_len",
|
|
39126
|
+
inputs: [],
|
|
39127
|
+
outputs: [
|
|
39128
|
+
{
|
|
39129
|
+
type: "core::integer::u256"
|
|
39130
|
+
}
|
|
39131
|
+
],
|
|
39132
|
+
state_mutability: "view"
|
|
39133
|
+
},
|
|
39336
39134
|
{
|
|
39337
39135
|
type: "function",
|
|
39338
|
-
name: "
|
|
39136
|
+
name: "mint",
|
|
39339
39137
|
inputs: [
|
|
39340
39138
|
{
|
|
39341
|
-
name: "
|
|
39139
|
+
name: "to",
|
|
39342
39140
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39343
39141
|
},
|
|
39344
39142
|
{
|
|
39345
|
-
name: "
|
|
39346
|
-
type: "
|
|
39347
|
-
}
|
|
39143
|
+
name: "redeem_request_info",
|
|
39144
|
+
type: "vault::redeem_request::interface::RedeemRequestInfo"
|
|
39145
|
+
}
|
|
39146
|
+
],
|
|
39147
|
+
outputs: [
|
|
39348
39148
|
{
|
|
39349
|
-
name: "amount",
|
|
39350
39149
|
type: "core::integer::u256"
|
|
39351
|
-
}
|
|
39150
|
+
}
|
|
39151
|
+
],
|
|
39152
|
+
state_mutability: "external"
|
|
39153
|
+
},
|
|
39154
|
+
{
|
|
39155
|
+
type: "function",
|
|
39156
|
+
name: "burn",
|
|
39157
|
+
inputs: [
|
|
39352
39158
|
{
|
|
39353
|
-
name: "
|
|
39354
|
-
type: "core::
|
|
39159
|
+
name: "id",
|
|
39160
|
+
type: "core::integer::u256"
|
|
39355
39161
|
}
|
|
39356
39162
|
],
|
|
39357
39163
|
outputs: [],
|
|
@@ -39361,26 +39167,39 @@ var vault_manager_abi_default = [
|
|
|
39361
39167
|
},
|
|
39362
39168
|
{
|
|
39363
39169
|
type: "impl",
|
|
39364
|
-
name: "
|
|
39365
|
-
interface_name: "
|
|
39170
|
+
name: "UpgradeableImpl",
|
|
39171
|
+
interface_name: "openzeppelin_interfaces::upgrades::IUpgradeable"
|
|
39366
39172
|
},
|
|
39367
39173
|
{
|
|
39368
|
-
type: "
|
|
39369
|
-
name: "
|
|
39370
|
-
|
|
39174
|
+
type: "interface",
|
|
39175
|
+
name: "openzeppelin_interfaces::upgrades::IUpgradeable",
|
|
39176
|
+
items: [
|
|
39371
39177
|
{
|
|
39372
|
-
|
|
39373
|
-
|
|
39178
|
+
type: "function",
|
|
39179
|
+
name: "upgrade",
|
|
39180
|
+
inputs: [
|
|
39181
|
+
{
|
|
39182
|
+
name: "new_class_hash",
|
|
39183
|
+
type: "core::starknet::class_hash::ClassHash"
|
|
39184
|
+
}
|
|
39185
|
+
],
|
|
39186
|
+
outputs: [],
|
|
39187
|
+
state_mutability: "external"
|
|
39374
39188
|
}
|
|
39375
39189
|
]
|
|
39376
39190
|
},
|
|
39191
|
+
{
|
|
39192
|
+
type: "impl",
|
|
39193
|
+
name: "ERC721MixinImpl",
|
|
39194
|
+
interface_name: "openzeppelin_interfaces::token::erc721::ERC721ABI"
|
|
39195
|
+
},
|
|
39377
39196
|
{
|
|
39378
39197
|
type: "struct",
|
|
39379
|
-
name: "core::array::Span::<core::
|
|
39198
|
+
name: "core::array::Span::<core::felt252>",
|
|
39380
39199
|
members: [
|
|
39381
39200
|
{
|
|
39382
39201
|
name: "snapshot",
|
|
39383
|
-
type: "@core::array::Array::<core::
|
|
39202
|
+
type: "@core::array::Array::<core::felt252>"
|
|
39384
39203
|
}
|
|
39385
39204
|
]
|
|
39386
39205
|
},
|
|
@@ -39398,25 +39217,53 @@ var vault_manager_abi_default = [
|
|
|
39398
39217
|
}
|
|
39399
39218
|
]
|
|
39400
39219
|
},
|
|
39220
|
+
{
|
|
39221
|
+
type: "struct",
|
|
39222
|
+
name: "core::byte_array::ByteArray",
|
|
39223
|
+
members: [
|
|
39224
|
+
{
|
|
39225
|
+
name: "data",
|
|
39226
|
+
type: "core::array::Array::<core::bytes_31::bytes31>"
|
|
39227
|
+
},
|
|
39228
|
+
{
|
|
39229
|
+
name: "pending_word",
|
|
39230
|
+
type: "core::felt252"
|
|
39231
|
+
},
|
|
39232
|
+
{
|
|
39233
|
+
name: "pending_word_len",
|
|
39234
|
+
type: "core::integer::u32"
|
|
39235
|
+
}
|
|
39236
|
+
]
|
|
39237
|
+
},
|
|
39401
39238
|
{
|
|
39402
39239
|
type: "interface",
|
|
39403
|
-
name: "
|
|
39240
|
+
name: "openzeppelin_interfaces::token::erc721::ERC721ABI",
|
|
39404
39241
|
items: [
|
|
39405
39242
|
{
|
|
39406
39243
|
type: "function",
|
|
39407
|
-
name: "
|
|
39408
|
-
inputs: [
|
|
39409
|
-
outputs: [
|
|
39244
|
+
name: "balance_of",
|
|
39245
|
+
inputs: [
|
|
39410
39246
|
{
|
|
39247
|
+
name: "account",
|
|
39411
39248
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39412
39249
|
}
|
|
39413
39250
|
],
|
|
39251
|
+
outputs: [
|
|
39252
|
+
{
|
|
39253
|
+
type: "core::integer::u256"
|
|
39254
|
+
}
|
|
39255
|
+
],
|
|
39414
39256
|
state_mutability: "view"
|
|
39415
39257
|
},
|
|
39416
39258
|
{
|
|
39417
39259
|
type: "function",
|
|
39418
|
-
name: "
|
|
39419
|
-
inputs: [
|
|
39260
|
+
name: "owner_of",
|
|
39261
|
+
inputs: [
|
|
39262
|
+
{
|
|
39263
|
+
name: "token_id",
|
|
39264
|
+
type: "core::integer::u256"
|
|
39265
|
+
}
|
|
39266
|
+
],
|
|
39420
39267
|
outputs: [
|
|
39421
39268
|
{
|
|
39422
39269
|
type: "core::starknet::contract_address::ContractAddress"
|
|
@@ -39426,15 +39273,23 @@ var vault_manager_abi_default = [
|
|
|
39426
39273
|
},
|
|
39427
39274
|
{
|
|
39428
39275
|
type: "function",
|
|
39429
|
-
name: "
|
|
39276
|
+
name: "safe_transfer_from",
|
|
39430
39277
|
inputs: [
|
|
39431
39278
|
{
|
|
39432
|
-
name: "
|
|
39279
|
+
name: "from",
|
|
39433
39280
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39434
39281
|
},
|
|
39435
39282
|
{
|
|
39436
|
-
name: "
|
|
39437
|
-
type: "core::
|
|
39283
|
+
name: "to",
|
|
39284
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39285
|
+
},
|
|
39286
|
+
{
|
|
39287
|
+
name: "token_id",
|
|
39288
|
+
type: "core::integer::u256"
|
|
39289
|
+
},
|
|
39290
|
+
{
|
|
39291
|
+
name: "data",
|
|
39292
|
+
type: "core::array::Span::<core::felt252>"
|
|
39438
39293
|
}
|
|
39439
39294
|
],
|
|
39440
39295
|
outputs: [],
|
|
@@ -39442,137 +39297,150 @@ var vault_manager_abi_default = [
|
|
|
39442
39297
|
},
|
|
39443
39298
|
{
|
|
39444
39299
|
type: "function",
|
|
39445
|
-
name: "
|
|
39300
|
+
name: "transfer_from",
|
|
39446
39301
|
inputs: [
|
|
39447
39302
|
{
|
|
39448
|
-
name: "
|
|
39303
|
+
name: "from",
|
|
39449
39304
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39450
|
-
}
|
|
39451
|
-
],
|
|
39452
|
-
outputs: [
|
|
39305
|
+
},
|
|
39453
39306
|
{
|
|
39454
|
-
|
|
39307
|
+
name: "to",
|
|
39308
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39309
|
+
},
|
|
39310
|
+
{
|
|
39311
|
+
name: "token_id",
|
|
39312
|
+
type: "core::integer::u256"
|
|
39455
39313
|
}
|
|
39456
39314
|
],
|
|
39457
|
-
|
|
39315
|
+
outputs: [],
|
|
39316
|
+
state_mutability: "external"
|
|
39458
39317
|
},
|
|
39459
39318
|
{
|
|
39460
39319
|
type: "function",
|
|
39461
|
-
name: "
|
|
39462
|
-
inputs: [
|
|
39320
|
+
name: "approve",
|
|
39321
|
+
inputs: [
|
|
39322
|
+
{
|
|
39323
|
+
name: "to",
|
|
39324
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39325
|
+
},
|
|
39326
|
+
{
|
|
39327
|
+
name: "token_id",
|
|
39328
|
+
type: "core::integer::u256"
|
|
39329
|
+
}
|
|
39330
|
+
],
|
|
39463
39331
|
outputs: [],
|
|
39464
39332
|
state_mutability: "external"
|
|
39465
39333
|
},
|
|
39466
39334
|
{
|
|
39467
39335
|
type: "function",
|
|
39468
|
-
name: "
|
|
39469
|
-
inputs: [
|
|
39336
|
+
name: "set_approval_for_all",
|
|
39337
|
+
inputs: [
|
|
39338
|
+
{
|
|
39339
|
+
name: "operator",
|
|
39340
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39341
|
+
},
|
|
39342
|
+
{
|
|
39343
|
+
name: "approved",
|
|
39344
|
+
type: "core::bool"
|
|
39345
|
+
}
|
|
39346
|
+
],
|
|
39470
39347
|
outputs: [],
|
|
39471
39348
|
state_mutability: "external"
|
|
39472
39349
|
},
|
|
39473
39350
|
{
|
|
39474
39351
|
type: "function",
|
|
39475
|
-
name: "
|
|
39352
|
+
name: "get_approved",
|
|
39476
39353
|
inputs: [
|
|
39477
39354
|
{
|
|
39478
|
-
name: "
|
|
39479
|
-
type: "core::
|
|
39480
|
-
}
|
|
39481
|
-
|
|
39482
|
-
|
|
39483
|
-
type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
|
|
39484
|
-
},
|
|
39485
|
-
{
|
|
39486
|
-
name: "targets",
|
|
39487
|
-
type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
|
|
39488
|
-
},
|
|
39489
|
-
{
|
|
39490
|
-
name: "selectors",
|
|
39491
|
-
type: "core::array::Span::<core::felt252>"
|
|
39492
|
-
},
|
|
39355
|
+
name: "token_id",
|
|
39356
|
+
type: "core::integer::u256"
|
|
39357
|
+
}
|
|
39358
|
+
],
|
|
39359
|
+
outputs: [
|
|
39493
39360
|
{
|
|
39494
|
-
|
|
39495
|
-
type: "core::array::Span::<core::array::Span::<core::felt252>>"
|
|
39361
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39496
39362
|
}
|
|
39497
39363
|
],
|
|
39498
|
-
|
|
39499
|
-
state_mutability: "external"
|
|
39364
|
+
state_mutability: "view"
|
|
39500
39365
|
},
|
|
39501
39366
|
{
|
|
39502
39367
|
type: "function",
|
|
39503
|
-
name: "
|
|
39368
|
+
name: "is_approved_for_all",
|
|
39504
39369
|
inputs: [
|
|
39505
39370
|
{
|
|
39506
|
-
name: "
|
|
39371
|
+
name: "owner",
|
|
39507
39372
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39508
39373
|
},
|
|
39509
39374
|
{
|
|
39510
|
-
name: "
|
|
39375
|
+
name: "operator",
|
|
39511
39376
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39512
|
-
}
|
|
39513
|
-
|
|
39514
|
-
|
|
39515
|
-
type: "core::integer::u256"
|
|
39516
|
-
},
|
|
39377
|
+
}
|
|
39378
|
+
],
|
|
39379
|
+
outputs: [
|
|
39517
39380
|
{
|
|
39518
|
-
name: "is_legacy",
|
|
39519
39381
|
type: "core::bool"
|
|
39520
|
-
},
|
|
39521
|
-
{
|
|
39522
|
-
name: "data",
|
|
39523
|
-
type: "core::array::Span::<core::felt252>"
|
|
39524
39382
|
}
|
|
39525
39383
|
],
|
|
39526
|
-
|
|
39527
|
-
state_mutability: "external"
|
|
39384
|
+
state_mutability: "view"
|
|
39528
39385
|
},
|
|
39529
39386
|
{
|
|
39530
39387
|
type: "function",
|
|
39531
|
-
name: "
|
|
39388
|
+
name: "supports_interface",
|
|
39532
39389
|
inputs: [
|
|
39533
39390
|
{
|
|
39534
|
-
name: "
|
|
39535
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39536
|
-
},
|
|
39537
|
-
{
|
|
39538
|
-
name: "target",
|
|
39539
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39540
|
-
},
|
|
39541
|
-
{
|
|
39542
|
-
name: "selector",
|
|
39391
|
+
name: "interface_id",
|
|
39543
39392
|
type: "core::felt252"
|
|
39544
|
-
}
|
|
39393
|
+
}
|
|
39394
|
+
],
|
|
39395
|
+
outputs: [
|
|
39545
39396
|
{
|
|
39546
|
-
|
|
39547
|
-
type: "core::array::Span::<core::felt252>"
|
|
39397
|
+
type: "core::bool"
|
|
39548
39398
|
}
|
|
39549
39399
|
],
|
|
39400
|
+
state_mutability: "view"
|
|
39401
|
+
},
|
|
39402
|
+
{
|
|
39403
|
+
type: "function",
|
|
39404
|
+
name: "name",
|
|
39405
|
+
inputs: [],
|
|
39550
39406
|
outputs: [
|
|
39551
39407
|
{
|
|
39552
|
-
type: "core::
|
|
39408
|
+
type: "core::byte_array::ByteArray"
|
|
39553
39409
|
}
|
|
39554
39410
|
],
|
|
39555
39411
|
state_mutability: "view"
|
|
39556
|
-
}
|
|
39557
|
-
]
|
|
39558
|
-
},
|
|
39559
|
-
{
|
|
39560
|
-
type: "impl",
|
|
39561
|
-
name: "AccessControlImpl",
|
|
39562
|
-
interface_name: "openzeppelin_access::accesscontrol::interface::IAccessControl"
|
|
39563
|
-
},
|
|
39564
|
-
{
|
|
39565
|
-
type: "interface",
|
|
39566
|
-
name: "openzeppelin_access::accesscontrol::interface::IAccessControl",
|
|
39567
|
-
items: [
|
|
39412
|
+
},
|
|
39568
39413
|
{
|
|
39569
39414
|
type: "function",
|
|
39570
|
-
name: "
|
|
39415
|
+
name: "symbol",
|
|
39416
|
+
inputs: [],
|
|
39417
|
+
outputs: [
|
|
39418
|
+
{
|
|
39419
|
+
type: "core::byte_array::ByteArray"
|
|
39420
|
+
}
|
|
39421
|
+
],
|
|
39422
|
+
state_mutability: "view"
|
|
39423
|
+
},
|
|
39424
|
+
{
|
|
39425
|
+
type: "function",
|
|
39426
|
+
name: "token_uri",
|
|
39571
39427
|
inputs: [
|
|
39572
39428
|
{
|
|
39573
|
-
name: "
|
|
39574
|
-
type: "core::
|
|
39575
|
-
}
|
|
39429
|
+
name: "token_id",
|
|
39430
|
+
type: "core::integer::u256"
|
|
39431
|
+
}
|
|
39432
|
+
],
|
|
39433
|
+
outputs: [
|
|
39434
|
+
{
|
|
39435
|
+
type: "core::byte_array::ByteArray"
|
|
39436
|
+
}
|
|
39437
|
+
],
|
|
39438
|
+
state_mutability: "view"
|
|
39439
|
+
},
|
|
39440
|
+
{
|
|
39441
|
+
type: "function",
|
|
39442
|
+
name: "balanceOf",
|
|
39443
|
+
inputs: [
|
|
39576
39444
|
{
|
|
39577
39445
|
name: "account",
|
|
39578
39446
|
type: "core::starknet::contract_address::ContractAddress"
|
|
@@ -39580,38 +39448,46 @@ var vault_manager_abi_default = [
|
|
|
39580
39448
|
],
|
|
39581
39449
|
outputs: [
|
|
39582
39450
|
{
|
|
39583
|
-
type: "core::
|
|
39451
|
+
type: "core::integer::u256"
|
|
39584
39452
|
}
|
|
39585
39453
|
],
|
|
39586
39454
|
state_mutability: "view"
|
|
39587
39455
|
},
|
|
39588
39456
|
{
|
|
39589
39457
|
type: "function",
|
|
39590
|
-
name: "
|
|
39458
|
+
name: "ownerOf",
|
|
39591
39459
|
inputs: [
|
|
39592
39460
|
{
|
|
39593
|
-
name: "
|
|
39594
|
-
type: "core::
|
|
39461
|
+
name: "tokenId",
|
|
39462
|
+
type: "core::integer::u256"
|
|
39595
39463
|
}
|
|
39596
39464
|
],
|
|
39597
39465
|
outputs: [
|
|
39598
39466
|
{
|
|
39599
|
-
type: "core::
|
|
39467
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39600
39468
|
}
|
|
39601
39469
|
],
|
|
39602
39470
|
state_mutability: "view"
|
|
39603
39471
|
},
|
|
39604
39472
|
{
|
|
39605
39473
|
type: "function",
|
|
39606
|
-
name: "
|
|
39474
|
+
name: "safeTransferFrom",
|
|
39607
39475
|
inputs: [
|
|
39608
39476
|
{
|
|
39609
|
-
name: "
|
|
39610
|
-
type: "core::
|
|
39477
|
+
name: "from",
|
|
39478
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39611
39479
|
},
|
|
39612
39480
|
{
|
|
39613
|
-
name: "
|
|
39481
|
+
name: "to",
|
|
39614
39482
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39483
|
+
},
|
|
39484
|
+
{
|
|
39485
|
+
name: "tokenId",
|
|
39486
|
+
type: "core::integer::u256"
|
|
39487
|
+
},
|
|
39488
|
+
{
|
|
39489
|
+
name: "data",
|
|
39490
|
+
type: "core::array::Span::<core::felt252>"
|
|
39615
39491
|
}
|
|
39616
39492
|
],
|
|
39617
39493
|
outputs: [],
|
|
@@ -39619,15 +39495,19 @@ var vault_manager_abi_default = [
|
|
|
39619
39495
|
},
|
|
39620
39496
|
{
|
|
39621
39497
|
type: "function",
|
|
39622
|
-
name: "
|
|
39498
|
+
name: "transferFrom",
|
|
39623
39499
|
inputs: [
|
|
39624
39500
|
{
|
|
39625
|
-
name: "
|
|
39626
|
-
type: "core::
|
|
39501
|
+
name: "from",
|
|
39502
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39627
39503
|
},
|
|
39628
39504
|
{
|
|
39629
|
-
name: "
|
|
39505
|
+
name: "to",
|
|
39630
39506
|
type: "core::starknet::contract_address::ContractAddress"
|
|
39507
|
+
},
|
|
39508
|
+
{
|
|
39509
|
+
name: "tokenId",
|
|
39510
|
+
type: "core::integer::u256"
|
|
39631
39511
|
}
|
|
39632
39512
|
],
|
|
39633
39513
|
outputs: [],
|
|
@@ -39635,188 +39515,246 @@ var vault_manager_abi_default = [
|
|
|
39635
39515
|
},
|
|
39636
39516
|
{
|
|
39637
39517
|
type: "function",
|
|
39638
|
-
name: "
|
|
39518
|
+
name: "setApprovalForAll",
|
|
39639
39519
|
inputs: [
|
|
39640
39520
|
{
|
|
39641
|
-
name: "
|
|
39642
|
-
type: "core::
|
|
39521
|
+
name: "operator",
|
|
39522
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39643
39523
|
},
|
|
39644
39524
|
{
|
|
39645
|
-
name: "
|
|
39646
|
-
type: "core::
|
|
39525
|
+
name: "approved",
|
|
39526
|
+
type: "core::bool"
|
|
39647
39527
|
}
|
|
39648
39528
|
],
|
|
39649
39529
|
outputs: [],
|
|
39650
39530
|
state_mutability: "external"
|
|
39531
|
+
},
|
|
39532
|
+
{
|
|
39533
|
+
type: "function",
|
|
39534
|
+
name: "getApproved",
|
|
39535
|
+
inputs: [
|
|
39536
|
+
{
|
|
39537
|
+
name: "tokenId",
|
|
39538
|
+
type: "core::integer::u256"
|
|
39539
|
+
}
|
|
39540
|
+
],
|
|
39541
|
+
outputs: [
|
|
39542
|
+
{
|
|
39543
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39544
|
+
}
|
|
39545
|
+
],
|
|
39546
|
+
state_mutability: "view"
|
|
39547
|
+
},
|
|
39548
|
+
{
|
|
39549
|
+
type: "function",
|
|
39550
|
+
name: "isApprovedForAll",
|
|
39551
|
+
inputs: [
|
|
39552
|
+
{
|
|
39553
|
+
name: "owner",
|
|
39554
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39555
|
+
},
|
|
39556
|
+
{
|
|
39557
|
+
name: "operator",
|
|
39558
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39559
|
+
}
|
|
39560
|
+
],
|
|
39561
|
+
outputs: [
|
|
39562
|
+
{
|
|
39563
|
+
type: "core::bool"
|
|
39564
|
+
}
|
|
39565
|
+
],
|
|
39566
|
+
state_mutability: "view"
|
|
39567
|
+
},
|
|
39568
|
+
{
|
|
39569
|
+
type: "function",
|
|
39570
|
+
name: "tokenURI",
|
|
39571
|
+
inputs: [
|
|
39572
|
+
{
|
|
39573
|
+
name: "tokenId",
|
|
39574
|
+
type: "core::integer::u256"
|
|
39575
|
+
}
|
|
39576
|
+
],
|
|
39577
|
+
outputs: [
|
|
39578
|
+
{
|
|
39579
|
+
type: "core::byte_array::ByteArray"
|
|
39580
|
+
}
|
|
39581
|
+
],
|
|
39582
|
+
state_mutability: "view"
|
|
39651
39583
|
}
|
|
39652
39584
|
]
|
|
39653
39585
|
},
|
|
39654
39586
|
{
|
|
39655
39587
|
type: "impl",
|
|
39656
|
-
name: "
|
|
39657
|
-
interface_name: "
|
|
39588
|
+
name: "ERC721EnumerableImpl",
|
|
39589
|
+
interface_name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable"
|
|
39658
39590
|
},
|
|
39659
39591
|
{
|
|
39660
39592
|
type: "interface",
|
|
39661
|
-
name: "
|
|
39593
|
+
name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable",
|
|
39662
39594
|
items: [
|
|
39663
39595
|
{
|
|
39664
39596
|
type: "function",
|
|
39665
|
-
name: "
|
|
39597
|
+
name: "total_supply",
|
|
39666
39598
|
inputs: [],
|
|
39667
39599
|
outputs: [
|
|
39668
39600
|
{
|
|
39669
|
-
type: "core::
|
|
39601
|
+
type: "core::integer::u256"
|
|
39670
39602
|
}
|
|
39671
39603
|
],
|
|
39672
39604
|
state_mutability: "view"
|
|
39673
|
-
}
|
|
39674
|
-
]
|
|
39675
|
-
},
|
|
39676
|
-
{
|
|
39677
|
-
type: "constructor",
|
|
39678
|
-
name: "constructor",
|
|
39679
|
-
inputs: [
|
|
39680
|
-
{
|
|
39681
|
-
name: "owner",
|
|
39682
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39683
|
-
},
|
|
39684
|
-
{
|
|
39685
|
-
name: "vault_allocator",
|
|
39686
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39687
39605
|
},
|
|
39688
39606
|
{
|
|
39689
|
-
|
|
39690
|
-
|
|
39607
|
+
type: "function",
|
|
39608
|
+
name: "token_by_index",
|
|
39609
|
+
inputs: [
|
|
39610
|
+
{
|
|
39611
|
+
name: "index",
|
|
39612
|
+
type: "core::integer::u256"
|
|
39613
|
+
}
|
|
39614
|
+
],
|
|
39615
|
+
outputs: [
|
|
39616
|
+
{
|
|
39617
|
+
type: "core::integer::u256"
|
|
39618
|
+
}
|
|
39619
|
+
],
|
|
39620
|
+
state_mutability: "view"
|
|
39621
|
+
},
|
|
39622
|
+
{
|
|
39623
|
+
type: "function",
|
|
39624
|
+
name: "token_of_owner_by_index",
|
|
39625
|
+
inputs: [
|
|
39626
|
+
{
|
|
39627
|
+
name: "owner",
|
|
39628
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39629
|
+
},
|
|
39630
|
+
{
|
|
39631
|
+
name: "index",
|
|
39632
|
+
type: "core::integer::u256"
|
|
39633
|
+
}
|
|
39634
|
+
],
|
|
39635
|
+
outputs: [
|
|
39636
|
+
{
|
|
39637
|
+
type: "core::integer::u256"
|
|
39638
|
+
}
|
|
39639
|
+
],
|
|
39640
|
+
state_mutability: "view"
|
|
39691
39641
|
}
|
|
39692
39642
|
]
|
|
39693
39643
|
},
|
|
39694
39644
|
{
|
|
39695
|
-
type: "
|
|
39696
|
-
name: "
|
|
39697
|
-
|
|
39698
|
-
variants: []
|
|
39699
|
-
},
|
|
39700
|
-
{
|
|
39701
|
-
type: "event",
|
|
39702
|
-
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
|
|
39703
|
-
kind: "struct",
|
|
39704
|
-
members: [
|
|
39705
|
-
{
|
|
39706
|
-
name: "role",
|
|
39707
|
-
type: "core::felt252",
|
|
39708
|
-
kind: "data"
|
|
39709
|
-
},
|
|
39645
|
+
type: "constructor",
|
|
39646
|
+
name: "constructor",
|
|
39647
|
+
inputs: [
|
|
39710
39648
|
{
|
|
39711
|
-
name: "
|
|
39712
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39713
|
-
kind: "data"
|
|
39649
|
+
name: "owner",
|
|
39650
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39714
39651
|
},
|
|
39715
39652
|
{
|
|
39716
|
-
name: "
|
|
39717
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
39718
|
-
kind: "data"
|
|
39653
|
+
name: "vault",
|
|
39654
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
39719
39655
|
}
|
|
39720
39656
|
]
|
|
39721
39657
|
},
|
|
39722
39658
|
{
|
|
39723
39659
|
type: "event",
|
|
39724
|
-
name: "
|
|
39660
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
|
|
39725
39661
|
kind: "struct",
|
|
39726
39662
|
members: [
|
|
39727
39663
|
{
|
|
39728
|
-
name: "
|
|
39729
|
-
type: "core::felt252",
|
|
39730
|
-
kind: "data"
|
|
39731
|
-
},
|
|
39732
|
-
{
|
|
39733
|
-
name: "account",
|
|
39664
|
+
name: "from",
|
|
39734
39665
|
type: "core::starknet::contract_address::ContractAddress",
|
|
39735
|
-
kind: "
|
|
39666
|
+
kind: "key"
|
|
39736
39667
|
},
|
|
39737
39668
|
{
|
|
39738
|
-
name: "
|
|
39669
|
+
name: "to",
|
|
39739
39670
|
type: "core::starknet::contract_address::ContractAddress",
|
|
39740
|
-
kind: "
|
|
39671
|
+
kind: "key"
|
|
39741
39672
|
},
|
|
39742
39673
|
{
|
|
39743
|
-
name: "
|
|
39744
|
-
type: "core::integer::
|
|
39745
|
-
kind: "
|
|
39674
|
+
name: "token_id",
|
|
39675
|
+
type: "core::integer::u256",
|
|
39676
|
+
kind: "key"
|
|
39746
39677
|
}
|
|
39747
39678
|
]
|
|
39748
39679
|
},
|
|
39749
39680
|
{
|
|
39750
39681
|
type: "event",
|
|
39751
|
-
name: "
|
|
39682
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
|
|
39752
39683
|
kind: "struct",
|
|
39753
39684
|
members: [
|
|
39754
39685
|
{
|
|
39755
|
-
name: "
|
|
39756
|
-
type: "core::
|
|
39757
|
-
kind: "
|
|
39686
|
+
name: "owner",
|
|
39687
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
39688
|
+
kind: "key"
|
|
39758
39689
|
},
|
|
39759
39690
|
{
|
|
39760
|
-
name: "
|
|
39691
|
+
name: "approved",
|
|
39761
39692
|
type: "core::starknet::contract_address::ContractAddress",
|
|
39762
|
-
kind: "
|
|
39693
|
+
kind: "key"
|
|
39763
39694
|
},
|
|
39764
39695
|
{
|
|
39765
|
-
name: "
|
|
39766
|
-
type: "core::
|
|
39767
|
-
kind: "
|
|
39696
|
+
name: "token_id",
|
|
39697
|
+
type: "core::integer::u256",
|
|
39698
|
+
kind: "key"
|
|
39768
39699
|
}
|
|
39769
39700
|
]
|
|
39770
39701
|
},
|
|
39771
39702
|
{
|
|
39772
39703
|
type: "event",
|
|
39773
|
-
name: "
|
|
39704
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
|
|
39774
39705
|
kind: "struct",
|
|
39775
39706
|
members: [
|
|
39776
39707
|
{
|
|
39777
|
-
name: "
|
|
39778
|
-
type: "core::
|
|
39779
|
-
kind: "
|
|
39708
|
+
name: "owner",
|
|
39709
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
39710
|
+
kind: "key"
|
|
39780
39711
|
},
|
|
39781
39712
|
{
|
|
39782
|
-
name: "
|
|
39783
|
-
type: "core::
|
|
39784
|
-
kind: "
|
|
39713
|
+
name: "operator",
|
|
39714
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
39715
|
+
kind: "key"
|
|
39785
39716
|
},
|
|
39786
39717
|
{
|
|
39787
|
-
name: "
|
|
39788
|
-
type: "core::
|
|
39718
|
+
name: "approved",
|
|
39719
|
+
type: "core::bool",
|
|
39789
39720
|
kind: "data"
|
|
39790
39721
|
}
|
|
39791
39722
|
]
|
|
39792
39723
|
},
|
|
39793
39724
|
{
|
|
39794
39725
|
type: "event",
|
|
39795
|
-
name: "
|
|
39726
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
|
|
39796
39727
|
kind: "enum",
|
|
39797
39728
|
variants: [
|
|
39798
39729
|
{
|
|
39799
|
-
name: "
|
|
39800
|
-
type: "
|
|
39801
|
-
kind: "nested"
|
|
39802
|
-
},
|
|
39803
|
-
{
|
|
39804
|
-
name: "RoleGrantedWithDelay",
|
|
39805
|
-
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
|
|
39730
|
+
name: "Transfer",
|
|
39731
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
|
|
39806
39732
|
kind: "nested"
|
|
39807
39733
|
},
|
|
39808
39734
|
{
|
|
39809
|
-
name: "
|
|
39810
|
-
type: "
|
|
39735
|
+
name: "Approval",
|
|
39736
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
|
|
39811
39737
|
kind: "nested"
|
|
39812
39738
|
},
|
|
39813
39739
|
{
|
|
39814
|
-
name: "
|
|
39815
|
-
type: "
|
|
39740
|
+
name: "ApprovalForAll",
|
|
39741
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
|
|
39816
39742
|
kind: "nested"
|
|
39817
39743
|
}
|
|
39818
39744
|
]
|
|
39819
39745
|
},
|
|
39746
|
+
{
|
|
39747
|
+
type: "event",
|
|
39748
|
+
name: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
|
|
39749
|
+
kind: "enum",
|
|
39750
|
+
variants: []
|
|
39751
|
+
},
|
|
39752
|
+
{
|
|
39753
|
+
type: "event",
|
|
39754
|
+
name: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
39755
|
+
kind: "enum",
|
|
39756
|
+
variants: []
|
|
39757
|
+
},
|
|
39820
39758
|
{
|
|
39821
39759
|
type: "event",
|
|
39822
39760
|
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
@@ -39843,390 +39781,1352 @@ var vault_manager_abi_default = [
|
|
|
39843
39781
|
},
|
|
39844
39782
|
{
|
|
39845
39783
|
type: "event",
|
|
39846
|
-
name: "
|
|
39847
|
-
kind: "struct",
|
|
39848
|
-
members: [
|
|
39849
|
-
{
|
|
39850
|
-
name: "account",
|
|
39851
|
-
type: "core::starknet::contract_address::ContractAddress",
|
|
39852
|
-
kind: "data"
|
|
39853
|
-
}
|
|
39854
|
-
]
|
|
39855
|
-
},
|
|
39856
|
-
{
|
|
39857
|
-
type: "event",
|
|
39858
|
-
name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
39859
|
-
kind: "struct",
|
|
39860
|
-
members: [
|
|
39861
|
-
{
|
|
39862
|
-
name: "account",
|
|
39863
|
-
type: "core::starknet::contract_address::ContractAddress",
|
|
39864
|
-
kind: "data"
|
|
39865
|
-
}
|
|
39866
|
-
]
|
|
39867
|
-
},
|
|
39868
|
-
{
|
|
39869
|
-
type: "event",
|
|
39870
|
-
name: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
39784
|
+
name: "vault::redeem_request::redeem_request::RedeemRequest::Event",
|
|
39871
39785
|
kind: "enum",
|
|
39872
39786
|
variants: [
|
|
39873
39787
|
{
|
|
39874
|
-
name: "
|
|
39875
|
-
type: "
|
|
39876
|
-
kind: "
|
|
39788
|
+
name: "ERC721Event",
|
|
39789
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
|
|
39790
|
+
kind: "flat"
|
|
39877
39791
|
},
|
|
39878
39792
|
{
|
|
39879
|
-
name: "
|
|
39880
|
-
type: "
|
|
39881
|
-
kind: "
|
|
39882
|
-
}
|
|
39883
|
-
]
|
|
39884
|
-
},
|
|
39885
|
-
{
|
|
39886
|
-
type: "event",
|
|
39887
|
-
name: "vault_allocator::manager::manager::Manager::Event",
|
|
39888
|
-
kind: "enum",
|
|
39889
|
-
variants: [
|
|
39793
|
+
name: "ERC721EnumerableEvent",
|
|
39794
|
+
type: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
|
|
39795
|
+
kind: "flat"
|
|
39796
|
+
},
|
|
39890
39797
|
{
|
|
39891
39798
|
name: "SRC5Event",
|
|
39892
39799
|
type: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
39893
|
-
kind: "
|
|
39894
|
-
},
|
|
39895
|
-
{
|
|
39896
|
-
name: "AccessControlEvent",
|
|
39897
|
-
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
|
|
39898
|
-
kind: "nested"
|
|
39800
|
+
kind: "flat"
|
|
39899
39801
|
},
|
|
39900
39802
|
{
|
|
39901
39803
|
name: "UpgradeableEvent",
|
|
39902
39804
|
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
39903
|
-
kind: "
|
|
39904
|
-
},
|
|
39905
|
-
{
|
|
39906
|
-
name: "PausableEvent",
|
|
39907
|
-
type: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
39908
|
-
kind: "nested"
|
|
39805
|
+
kind: "flat"
|
|
39909
39806
|
}
|
|
39910
39807
|
]
|
|
39911
39808
|
}
|
|
39912
39809
|
];
|
|
39913
39810
|
|
|
39914
|
-
// src/strategies/
|
|
39915
|
-
var
|
|
39916
|
-
|
|
39917
|
-
|
|
39918
|
-
|
|
39919
|
-
})(LSTPriceType || {});
|
|
39920
|
-
|
|
39921
|
-
// src/strategies/universal-strategy.tsx
|
|
39922
|
-
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
39923
|
-
var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
|
|
39924
|
-
AUMTypes2["FINALISED"] = "finalised";
|
|
39925
|
-
AUMTypes2["DEFISPRING"] = "defispring";
|
|
39926
|
-
return AUMTypes2;
|
|
39927
|
-
})(AUMTypes || {});
|
|
39928
|
-
var PositionTypeAvnuExtended = /* @__PURE__ */ ((PositionTypeAvnuExtended2) => {
|
|
39929
|
-
PositionTypeAvnuExtended2["OPEN"] = "open";
|
|
39930
|
-
PositionTypeAvnuExtended2["CLOSE"] = "close";
|
|
39931
|
-
return PositionTypeAvnuExtended2;
|
|
39932
|
-
})(PositionTypeAvnuExtended || {});
|
|
39933
|
-
var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
39934
|
-
constructor(config, pricer, metadata) {
|
|
39935
|
-
super(config);
|
|
39936
|
-
this.pricer = pricer;
|
|
39937
|
-
assert(
|
|
39938
|
-
metadata.depositTokens.length === 1,
|
|
39939
|
-
"VesuRebalance only supports 1 deposit token"
|
|
39940
|
-
);
|
|
39941
|
-
this.metadata = metadata;
|
|
39942
|
-
this.address = metadata.address;
|
|
39943
|
-
this.contract = new Contract15({
|
|
39944
|
-
abi: universal_vault_abi_default,
|
|
39945
|
-
address: this.address.address,
|
|
39946
|
-
providerOrAccount: this.config.provider
|
|
39947
|
-
});
|
|
39948
|
-
this.managerContract = new Contract15({
|
|
39949
|
-
abi: vault_manager_abi_default,
|
|
39950
|
-
address: this.metadata.additionalInfo.manager.address,
|
|
39951
|
-
providerOrAccount: this.config.provider
|
|
39952
|
-
});
|
|
39811
|
+
// src/strategies/universal-adapters/svk-troves-adapter.ts
|
|
39812
|
+
var DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
|
|
39813
|
+
function parseTrovesApyField(raw) {
|
|
39814
|
+
if (typeof raw === "number" && Number.isFinite(raw)) {
|
|
39815
|
+
return raw;
|
|
39953
39816
|
}
|
|
39954
|
-
|
|
39955
|
-
|
|
39956
|
-
|
|
39957
|
-
return
|
|
39958
|
-
}
|
|
39959
|
-
const standardTree = StandardMerkleTree.of(leaves.flatMap((l) => l.leaves));
|
|
39960
|
-
this.merkleTree = standardTree;
|
|
39961
|
-
return standardTree;
|
|
39817
|
+
if (typeof raw === "string") {
|
|
39818
|
+
const n = Number.parseFloat(raw);
|
|
39819
|
+
if (Number.isFinite(n)) {
|
|
39820
|
+
return n;
|
|
39821
|
+
}
|
|
39962
39822
|
}
|
|
39963
|
-
|
|
39964
|
-
|
|
39823
|
+
return 0;
|
|
39824
|
+
}
|
|
39825
|
+
var SvkTrovesAdapter = class _SvkTrovesAdapter extends BaseAdapter {
|
|
39826
|
+
constructor(config) {
|
|
39827
|
+
super(config, _SvkTrovesAdapter.name, Protocols.TROVES);
|
|
39828
|
+
this.config = config;
|
|
39965
39829
|
}
|
|
39966
|
-
|
|
39967
|
-
|
|
39968
|
-
|
|
39969
|
-
|
|
39970
|
-
|
|
39971
|
-
|
|
39972
|
-
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39830
|
+
/** Owner used for share balance + `due_assets_from_owner`. */
|
|
39831
|
+
_positionOwner() {
|
|
39832
|
+
return this.config.positionOwner ?? this.config.vaultAllocator;
|
|
39833
|
+
}
|
|
39834
|
+
/**
|
|
39835
|
+
* Proof readable IDs must stay ≤ 31 chars (Cairo short string). We derive a short ASCII suffix from
|
|
39836
|
+
* `strategyVault` address so multiple SVK adapters in one tree stay distinct.
|
|
39837
|
+
*/
|
|
39838
|
+
_proofSuffix() {
|
|
39839
|
+
return this.config.strategyVault.address.replace(/^0x/, "").slice(-6);
|
|
39840
|
+
}
|
|
39841
|
+
_depositApproveProofReadableId() {
|
|
39842
|
+
return `appr_dep_svk_${this._proofSuffix()}`;
|
|
39843
|
+
}
|
|
39844
|
+
_depositCallProofReadableId() {
|
|
39845
|
+
return `dep_svk_${this._proofSuffix()}`;
|
|
39846
|
+
}
|
|
39847
|
+
_withdrawCallProofReadableId() {
|
|
39848
|
+
return `wtdrw_svk_${this._proofSuffix()}`;
|
|
39849
|
+
}
|
|
39850
|
+
async getAPY(supportedPosition) {
|
|
39851
|
+
const CACHE_KEY = `svk_apy_${this.config.trovesStrategyId}`;
|
|
39852
|
+
const cached = this.getCache(CACHE_KEY);
|
|
39853
|
+
if (cached) {
|
|
39854
|
+
return cached;
|
|
39976
39855
|
}
|
|
39977
|
-
const
|
|
39978
|
-
|
|
39979
|
-
|
|
39856
|
+
const url = this.config.trovesStrategiesApiUrl ?? DEFAULT_TROVES_STRATEGIES_API;
|
|
39857
|
+
try {
|
|
39858
|
+
const res = await fetch(url);
|
|
39859
|
+
if (!res.ok) {
|
|
39860
|
+
logger.warn(`${_SvkTrovesAdapter.name}::getAPY: HTTP ${res.status} from ${url}`);
|
|
39861
|
+
const fallback = { apy: 0, type: "base" /* BASE */ };
|
|
39862
|
+
this.setCache(CACHE_KEY, fallback, 3e5);
|
|
39863
|
+
return fallback;
|
|
39864
|
+
}
|
|
39865
|
+
const body = await res.json();
|
|
39866
|
+
const row = body.strategies?.find((s) => s.id === this.config.trovesStrategyId);
|
|
39867
|
+
if (!row) {
|
|
39868
|
+
logger.warn(
|
|
39869
|
+
`${_SvkTrovesAdapter.name}::getAPY: strategy id not found: ${this.config.trovesStrategyId}`
|
|
39870
|
+
);
|
|
39871
|
+
const fallback = { apy: 0, type: "base" /* BASE */ };
|
|
39872
|
+
this.setCache(CACHE_KEY, fallback, 3e5);
|
|
39873
|
+
return fallback;
|
|
39874
|
+
}
|
|
39875
|
+
const apy = parseTrovesApyField(row.apy);
|
|
39876
|
+
const result = { apy, type: "base" /* BASE */ };
|
|
39877
|
+
this.setCache(CACHE_KEY, result, 3e5);
|
|
39878
|
+
return result;
|
|
39879
|
+
} catch (error) {
|
|
39880
|
+
logger.error(`${_SvkTrovesAdapter.name}::getAPY:`, error);
|
|
39881
|
+
throw error;
|
|
39980
39882
|
}
|
|
39981
|
-
const leafInfo = leafAdapter();
|
|
39982
|
-
return {
|
|
39983
|
-
proofs,
|
|
39984
|
-
callConstructor: leafInfo.callConstructor.bind(leafInfo)
|
|
39985
|
-
};
|
|
39986
39883
|
}
|
|
39987
|
-
|
|
39988
|
-
const
|
|
39989
|
-
|
|
39990
|
-
|
|
39884
|
+
async getPosition(supportedPosition) {
|
|
39885
|
+
const CACHE_KEY = `svk_pos_${this.config.strategyVault.address}_${this._positionOwner().address}`;
|
|
39886
|
+
const cached = this.getCache(CACHE_KEY);
|
|
39887
|
+
if (cached) {
|
|
39888
|
+
return cached;
|
|
39889
|
+
}
|
|
39890
|
+
try {
|
|
39891
|
+
const vault = new Contract14({
|
|
39892
|
+
abi: universal_vault_abi_default,
|
|
39893
|
+
address: this.config.strategyVault.address,
|
|
39894
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
39895
|
+
});
|
|
39896
|
+
const owner = this._positionOwner();
|
|
39897
|
+
const decimals = supportedPosition.asset.decimals;
|
|
39898
|
+
const shares = await vault.balance_of(owner.address);
|
|
39899
|
+
const shareU256 = uint25619.bnToUint256(shares);
|
|
39900
|
+
const liquidAssetsRaw = await vault.convert_to_assets(shareU256);
|
|
39901
|
+
const liquid = Web3Number.fromWei(liquidAssetsRaw.toString(), decimals);
|
|
39902
|
+
let pending = Web3Number.fromWei("0", decimals);
|
|
39903
|
+
try {
|
|
39904
|
+
const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
|
|
39905
|
+
pending = Web3Number.fromWei(dueRaw.toString(), decimals);
|
|
39906
|
+
} catch (e) {
|
|
39907
|
+
logger.warn(
|
|
39908
|
+
`${_SvkTrovesAdapter.name}::getPosition: due_assets_from_owner failed (treating as 0): ${e.message}`
|
|
39909
|
+
);
|
|
39910
|
+
}
|
|
39911
|
+
const total = liquid.plus(pending);
|
|
39912
|
+
const remarks = `Troves ${this.config.trovesStrategyId} holdings`;
|
|
39913
|
+
const result = {
|
|
39914
|
+
amount: total,
|
|
39915
|
+
remarks
|
|
39916
|
+
};
|
|
39917
|
+
this.setCache(CACHE_KEY, result, 6e4);
|
|
39918
|
+
return result;
|
|
39919
|
+
} catch (error) {
|
|
39920
|
+
logger.error(`${_SvkTrovesAdapter.name}::getPosition:`, error);
|
|
39921
|
+
throw error;
|
|
39991
39922
|
}
|
|
39992
|
-
return adapter.adapter;
|
|
39993
|
-
}
|
|
39994
|
-
asset() {
|
|
39995
|
-
return this.metadata.depositTokens[0];
|
|
39996
39923
|
}
|
|
39997
|
-
async
|
|
39998
|
-
|
|
39999
|
-
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
40000
|
-
"Deposit token mismatch"
|
|
40001
|
-
);
|
|
40002
|
-
const assetContract = new Contract15({
|
|
39924
|
+
async getPendingAssetsFromOwner(owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
|
|
39925
|
+
const vault = new Contract14({
|
|
40003
39926
|
abi: universal_vault_abi_default,
|
|
40004
|
-
address: this.
|
|
40005
|
-
providerOrAccount: this.config.provider
|
|
39927
|
+
address: this.config.strategyVault.address,
|
|
39928
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
40006
39929
|
});
|
|
40007
|
-
|
|
40008
|
-
|
|
40009
|
-
|
|
40010
|
-
|
|
40011
|
-
|
|
40012
|
-
|
|
40013
|
-
|
|
40014
|
-
|
|
40015
|
-
|
|
39930
|
+
try {
|
|
39931
|
+
const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
|
|
39932
|
+
return Web3Number.fromWei(dueRaw.toString(), decimals);
|
|
39933
|
+
} catch (e) {
|
|
39934
|
+
logger.warn(
|
|
39935
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwner: due_assets_from_owner failed (treating as 0): ${e.message}`
|
|
39936
|
+
);
|
|
39937
|
+
return Web3Number.fromWei("0", decimals);
|
|
39938
|
+
}
|
|
40016
39939
|
}
|
|
40017
|
-
|
|
40018
|
-
|
|
40019
|
-
|
|
40020
|
-
|
|
40021
|
-
|
|
40022
|
-
|
|
40023
|
-
|
|
40024
|
-
|
|
40025
|
-
|
|
40026
|
-
|
|
40027
|
-
|
|
40028
|
-
|
|
39940
|
+
/**
|
|
39941
|
+
* Get pending assets from owner by scanning redeem request NFTs.
|
|
39942
|
+
* This method iterates backwards through NFT IDs to find all pending redemptions for a specific owner.
|
|
39943
|
+
*
|
|
39944
|
+
* @param redeemRequestNFT - The redeem request NFT contract address
|
|
39945
|
+
* @param owner - The owner address to check for pending redemptions (defaults to positionOwner)
|
|
39946
|
+
* @param decimals - Token decimals for conversion (defaults to baseToken decimals)
|
|
39947
|
+
* @returns Total pending assets from all NFTs owned by the specified address
|
|
39948
|
+
*/
|
|
39949
|
+
async getPendingAssetsFromOwnerNFTMethod(redeemRequestNFT, owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
|
|
39950
|
+
try {
|
|
39951
|
+
const nftContract = new Contract14({
|
|
39952
|
+
abi: redeem_request_nft_abi_default,
|
|
39953
|
+
address: redeemRequestNFT.address,
|
|
39954
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
39955
|
+
});
|
|
39956
|
+
const idLenRaw = await nftContract.id_len();
|
|
39957
|
+
const latestId = BigInt(idLenRaw.toString());
|
|
39958
|
+
if (latestId === 0n) {
|
|
39959
|
+
logger.info(
|
|
39960
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No NFTs minted yet`
|
|
39961
|
+
);
|
|
39962
|
+
return Web3Number.fromWei("0", decimals);
|
|
39963
|
+
}
|
|
39964
|
+
const matchingIds = [];
|
|
39965
|
+
let currentId = latestId - 1n;
|
|
39966
|
+
while (currentId >= 0n) {
|
|
39967
|
+
try {
|
|
39968
|
+
const idU256 = uint25619.bnToUint256(currentId);
|
|
39969
|
+
const ownerRaw = await nftContract.owner_of(idU256);
|
|
39970
|
+
const nftOwnerAddr = ContractAddr.from(ownerRaw.toString());
|
|
39971
|
+
if (nftOwnerAddr.eq(owner)) {
|
|
39972
|
+
matchingIds.push(currentId);
|
|
39973
|
+
logger.debug(
|
|
39974
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found matching NFT ID ${currentId} for owner ${owner.address}`
|
|
39975
|
+
);
|
|
39976
|
+
}
|
|
39977
|
+
currentId--;
|
|
39978
|
+
} catch (e) {
|
|
39979
|
+
logger.info(
|
|
39980
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Reached last pending NFT at id ${currentId}`
|
|
39981
|
+
);
|
|
39982
|
+
break;
|
|
39983
|
+
}
|
|
39984
|
+
}
|
|
39985
|
+
if (matchingIds.length === 0) {
|
|
39986
|
+
logger.info(
|
|
39987
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No matching NFTs found for owner ${owner.address}`
|
|
39988
|
+
);
|
|
39989
|
+
return Web3Number.fromWei("0", decimals);
|
|
39990
|
+
}
|
|
39991
|
+
let totalNominal = 0n;
|
|
39992
|
+
for (const nftId of matchingIds) {
|
|
39993
|
+
try {
|
|
39994
|
+
const idU256 = uint25619.bnToUint256(nftId);
|
|
39995
|
+
const infoRaw = await nftContract.id_to_info(idU256);
|
|
39996
|
+
const nominal = BigInt(infoRaw.nominal.toString());
|
|
39997
|
+
totalNominal += nominal;
|
|
39998
|
+
logger.debug(
|
|
39999
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: NFT ID ${nftId} has nominal ${nominal}`
|
|
40000
|
+
);
|
|
40001
|
+
} catch (e) {
|
|
40002
|
+
logger.warn(
|
|
40003
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Failed to get info for NFT ID ${nftId}: ${e.message}`
|
|
40004
|
+
);
|
|
40005
|
+
}
|
|
40006
|
+
}
|
|
40007
|
+
logger.info(
|
|
40008
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found ${matchingIds.length} NFTs with total nominal ${totalNominal}`
|
|
40009
|
+
);
|
|
40010
|
+
return Web3Number.fromWei(totalNominal.toString(), decimals);
|
|
40011
|
+
} catch (error) {
|
|
40012
|
+
logger.error(
|
|
40013
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: ${error.message}`
|
|
40014
|
+
);
|
|
40015
|
+
return Web3Number.fromWei("0", decimals);
|
|
40016
|
+
}
|
|
40029
40017
|
}
|
|
40030
|
-
async
|
|
40031
|
-
const
|
|
40032
|
-
|
|
40033
|
-
|
|
40034
|
-
|
|
40035
|
-
|
|
40036
|
-
|
|
40037
|
-
|
|
40038
|
-
|
|
40039
|
-
|
|
40040
|
-
|
|
40041
|
-
|
|
40042
|
-
|
|
40043
|
-
this.metadata.depositTokens[0].symbol,
|
|
40044
|
-
blockNumber
|
|
40045
|
-
);
|
|
40046
|
-
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
40018
|
+
async maxDeposit(amount) {
|
|
40019
|
+
const baseToken = this.config.baseToken;
|
|
40020
|
+
if (!amount) {
|
|
40021
|
+
return {
|
|
40022
|
+
tokenInfo: baseToken,
|
|
40023
|
+
amount: new Web3Number("999999999999999999999999999", baseToken.decimals),
|
|
40024
|
+
usdValue: 1e27,
|
|
40025
|
+
remarks: "Max deposit (unbounded placeholder)",
|
|
40026
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
40027
|
+
protocol: this.protocol
|
|
40028
|
+
};
|
|
40029
|
+
}
|
|
40030
|
+
const usdValue = await this.getUSDValue(baseToken, amount);
|
|
40047
40031
|
return {
|
|
40048
|
-
tokenInfo:
|
|
40032
|
+
tokenInfo: baseToken,
|
|
40049
40033
|
amount,
|
|
40050
|
-
usdValue
|
|
40034
|
+
usdValue,
|
|
40035
|
+
remarks: "Deposit amount",
|
|
40036
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
40037
|
+
protocol: this.protocol
|
|
40051
40038
|
};
|
|
40052
40039
|
}
|
|
40053
|
-
async
|
|
40054
|
-
const
|
|
40055
|
-
const
|
|
40056
|
-
const
|
|
40057
|
-
|
|
40058
|
-
});
|
|
40059
|
-
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
40060
|
-
if (pools.some((p) => !p)) {
|
|
40061
|
-
throw new Error("Pool not found");
|
|
40062
|
-
}
|
|
40063
|
-
;
|
|
40064
|
-
const positions = await this.getVesuPositions();
|
|
40065
|
-
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
40066
|
-
const baseAPYs = [];
|
|
40067
|
-
const rewardAPYs = [];
|
|
40068
|
-
for (const [index, pool] of pools.entries()) {
|
|
40069
|
-
const vesuAdapter = vesuAdapters[index];
|
|
40070
|
-
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
40071
|
-
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
40072
|
-
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
40073
|
-
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
40074
|
-
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
40075
|
-
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
40076
|
-
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
40077
|
-
}
|
|
40078
|
-
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
40079
|
-
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
40080
|
-
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
40040
|
+
async maxWithdraw() {
|
|
40041
|
+
const baseToken = this.config.baseToken;
|
|
40042
|
+
const current = await this.getPosition({ asset: baseToken, isDebt: false });
|
|
40043
|
+
const pos = current ?? { amount: new Web3Number("0", baseToken.decimals), remarks: "" };
|
|
40044
|
+
const usdValue = await this.getUSDValue(baseToken, pos.amount);
|
|
40081
40045
|
return {
|
|
40082
|
-
|
|
40083
|
-
|
|
40084
|
-
|
|
40046
|
+
tokenInfo: baseToken,
|
|
40047
|
+
amount: pos.amount,
|
|
40048
|
+
usdValue,
|
|
40049
|
+
remarks: "Max withdraw (liquid + pending redemption, underlying units)",
|
|
40050
|
+
apy: await this.getAPY({ asset: baseToken, isDebt: false }),
|
|
40051
|
+
protocol: this.protocol
|
|
40085
40052
|
};
|
|
40086
40053
|
}
|
|
40087
|
-
|
|
40088
|
-
|
|
40089
|
-
|
|
40090
|
-
|
|
40091
|
-
|
|
40092
|
-
|
|
40093
|
-
|
|
40094
|
-
|
|
40095
|
-
|
|
40096
|
-
|
|
40097
|
-
|
|
40098
|
-
|
|
40099
|
-
|
|
40100
|
-
|
|
40101
|
-
|
|
40102
|
-
|
|
40103
|
-
|
|
40104
|
-
|
|
40105
|
-
|
|
40106
|
-
|
|
40107
|
-
const prevAUM = await this.getPrevAUM();
|
|
40108
|
-
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
40109
|
-
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
40110
|
-
return this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
|
|
40111
|
-
}
|
|
40112
|
-
async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
|
|
40113
|
-
if (weights.every((p) => p == 0)) {
|
|
40114
|
-
return { net: 0, splits: [{
|
|
40115
|
-
apy: 0,
|
|
40116
|
-
id: "base"
|
|
40117
|
-
}, {
|
|
40118
|
-
apy: 0,
|
|
40119
|
-
id: "defispring"
|
|
40120
|
-
}] };
|
|
40121
|
-
}
|
|
40122
|
-
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
40123
|
-
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
40124
|
-
const netAPY = baseAPY + rewardAPY;
|
|
40125
|
-
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
40126
|
-
return { net: netAPY, splits: [{
|
|
40127
|
-
apy: baseAPY,
|
|
40128
|
-
id: "base"
|
|
40129
|
-
}, {
|
|
40130
|
-
apy: rewardAPY,
|
|
40131
|
-
id: "defispring"
|
|
40132
|
-
}] };
|
|
40054
|
+
_getDepositLeaf() {
|
|
40055
|
+
const baseToken = this.config.baseToken;
|
|
40056
|
+
const strategyVault = this.config.strategyVault;
|
|
40057
|
+
const receiver = this.config.vaultAllocator;
|
|
40058
|
+
return [
|
|
40059
|
+
{
|
|
40060
|
+
target: baseToken.address,
|
|
40061
|
+
method: "approve",
|
|
40062
|
+
packedArguments: [strategyVault.toBigInt()],
|
|
40063
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
40064
|
+
id: this._depositApproveProofReadableId()
|
|
40065
|
+
},
|
|
40066
|
+
{
|
|
40067
|
+
target: strategyVault,
|
|
40068
|
+
method: "deposit",
|
|
40069
|
+
packedArguments: [receiver.toBigInt()],
|
|
40070
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
40071
|
+
id: this._depositCallProofReadableId()
|
|
40072
|
+
}
|
|
40073
|
+
];
|
|
40133
40074
|
}
|
|
40134
|
-
|
|
40135
|
-
|
|
40136
|
-
|
|
40137
|
-
|
|
40138
|
-
|
|
40075
|
+
_getWithdrawLeaf() {
|
|
40076
|
+
const strategyVault = this.config.strategyVault;
|
|
40077
|
+
const recv = this.config.vaultAllocator;
|
|
40078
|
+
const owner = this.config.vaultAllocator;
|
|
40079
|
+
return [
|
|
40080
|
+
{
|
|
40081
|
+
target: strategyVault,
|
|
40082
|
+
method: "request_redeem",
|
|
40083
|
+
packedArguments: [recv.toBigInt(), owner.toBigInt()],
|
|
40084
|
+
sanitizer: SVK_SIMPLE_SANITIZER,
|
|
40085
|
+
id: this._withdrawCallProofReadableId()
|
|
40086
|
+
}
|
|
40087
|
+
];
|
|
40139
40088
|
}
|
|
40140
|
-
|
|
40141
|
-
|
|
40142
|
-
const
|
|
40143
|
-
|
|
40144
|
-
|
|
40089
|
+
getDepositAdapter() {
|
|
40090
|
+
const leafConfigs = this._getDepositLeaf();
|
|
40091
|
+
const leaves = leafConfigs.map((config) => {
|
|
40092
|
+
const { target, method, packedArguments, sanitizer, id } = config;
|
|
40093
|
+
return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
|
|
40094
|
+
});
|
|
40095
|
+
return { leaves, callConstructor: this.getDepositCall.bind(this) };
|
|
40145
40096
|
}
|
|
40146
|
-
|
|
40147
|
-
|
|
40148
|
-
|
|
40149
|
-
|
|
40150
|
-
|
|
40151
|
-
logger.verbose(
|
|
40152
|
-
`${this.getTag()}: getUserRealizedAPY => starting with blockIdentifier=${blockIdentifier}, sinceBlocks=${sinceBlocks}`
|
|
40153
|
-
);
|
|
40154
|
-
let blockNow = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : (await this.config.provider.getBlockLatestAccepted()).block_number;
|
|
40155
|
-
const blockNowTime = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
40156
|
-
const blockBefore = Math.max(
|
|
40157
|
-
blockNow - sinceBlocks,
|
|
40158
|
-
this.metadata.launchBlock
|
|
40159
|
-
);
|
|
40160
|
-
const assetsNowRaw = await this.contract.call("total_assets", [], {
|
|
40161
|
-
blockIdentifier
|
|
40097
|
+
getWithdrawAdapter() {
|
|
40098
|
+
const leafConfigs = this._getWithdrawLeaf();
|
|
40099
|
+
const leaves = leafConfigs.map((config) => {
|
|
40100
|
+
const { target, method, packedArguments, sanitizer, id } = config;
|
|
40101
|
+
return this.constructSimpleLeafData({ id, target, method, packedArguments }, sanitizer);
|
|
40162
40102
|
});
|
|
40163
|
-
|
|
40164
|
-
|
|
40165
|
-
|
|
40166
|
-
|
|
40167
|
-
const
|
|
40168
|
-
|
|
40103
|
+
return { leaves, callConstructor: this.getWithdrawCall.bind(this) };
|
|
40104
|
+
}
|
|
40105
|
+
async getDepositCall(params) {
|
|
40106
|
+
const baseToken = this.config.baseToken;
|
|
40107
|
+
const strategyVault = this.config.strategyVault;
|
|
40108
|
+
const amount = params.amount;
|
|
40109
|
+
const uint256Amount = uint25619.bnToUint256(amount.toWei());
|
|
40110
|
+
const receiver = this.config.vaultAllocator;
|
|
40111
|
+
return [
|
|
40112
|
+
{
|
|
40113
|
+
proofReadableId: this._depositApproveProofReadableId(),
|
|
40114
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
40115
|
+
call: {
|
|
40116
|
+
contractAddress: baseToken.address,
|
|
40117
|
+
selector: hash11.getSelectorFromName("approve"),
|
|
40118
|
+
calldata: [
|
|
40119
|
+
strategyVault.toBigInt(),
|
|
40120
|
+
toBigInt(uint256Amount.low.toString()),
|
|
40121
|
+
toBigInt(uint256Amount.high.toString())
|
|
40122
|
+
]
|
|
40123
|
+
}
|
|
40124
|
+
},
|
|
40125
|
+
{
|
|
40126
|
+
proofReadableId: this._depositCallProofReadableId(),
|
|
40127
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
40128
|
+
call: {
|
|
40129
|
+
contractAddress: strategyVault,
|
|
40130
|
+
selector: hash11.getSelectorFromName("deposit"),
|
|
40131
|
+
calldata: [
|
|
40132
|
+
toBigInt(uint256Amount.low.toString()),
|
|
40133
|
+
toBigInt(uint256Amount.high.toString()),
|
|
40134
|
+
receiver.toBigInt()
|
|
40135
|
+
]
|
|
40136
|
+
}
|
|
40137
|
+
}
|
|
40138
|
+
];
|
|
40139
|
+
}
|
|
40140
|
+
async getWithdrawCall(params) {
|
|
40141
|
+
const strategyVault = this.config.strategyVault;
|
|
40142
|
+
const amount = params.amount;
|
|
40143
|
+
const uint256Amount = uint25619.bnToUint256(amount.toWei());
|
|
40144
|
+
const recv = this.config.vaultAllocator;
|
|
40145
|
+
const owner = this.config.vaultAllocator;
|
|
40146
|
+
const vault = new Contract14({
|
|
40147
|
+
abi: universal_vault_abi_default,
|
|
40148
|
+
address: strategyVault.address,
|
|
40149
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
40169
40150
|
});
|
|
40170
|
-
const
|
|
40171
|
-
const
|
|
40172
|
-
|
|
40173
|
-
|
|
40174
|
-
|
|
40175
|
-
|
|
40176
|
-
|
|
40177
|
-
|
|
40178
|
-
|
|
40179
|
-
|
|
40180
|
-
|
|
40181
|
-
|
|
40182
|
-
|
|
40183
|
-
|
|
40184
|
-
|
|
40185
|
-
|
|
40186
|
-
|
|
40187
|
-
|
|
40188
|
-
);
|
|
40189
|
-
const assetsPerShareNow = amountNow.multipliedBy(1e18).dividedBy(supplyNow.toString());
|
|
40190
|
-
const assetsPerShareBf = amountBefore.multipliedBy(1e18).dividedBy(supplyBefore.toString());
|
|
40191
|
-
const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
|
|
40192
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsNow: ${amountNow.toString()}`);
|
|
40193
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsBefore: ${amountBefore.toString()}`);
|
|
40194
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareNow: ${assetsPerShareNow.toString()}`);
|
|
40195
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareBf: ${assetsPerShareBf.toString()}`);
|
|
40196
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply before: ${supplyBefore.toString()}`);
|
|
40197
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply now: ${supplyNow.toString()}`);
|
|
40198
|
-
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Time diff in seconds: ${timeDiffSeconds}`);
|
|
40199
|
-
const apyForGivenBlocks = Number(
|
|
40200
|
-
assetsPerShareNow.minus(assetsPerShareBf).multipliedBy(1e4).dividedBy(assetsPerShareBf)
|
|
40201
|
-
) / 1e4;
|
|
40202
|
-
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
40151
|
+
const sharesRaw = await vault.convert_to_shares(uint256Amount);
|
|
40152
|
+
const sharesU256 = uint25619.bnToUint256(sharesRaw.toString());
|
|
40153
|
+
return [
|
|
40154
|
+
{
|
|
40155
|
+
proofReadableId: this._withdrawCallProofReadableId(),
|
|
40156
|
+
sanitizer: SVK_SIMPLE_SANITIZER,
|
|
40157
|
+
call: {
|
|
40158
|
+
contractAddress: strategyVault,
|
|
40159
|
+
selector: hash11.getSelectorFromName("request_redeem"),
|
|
40160
|
+
calldata: [
|
|
40161
|
+
toBigInt(sharesU256.low.toString()),
|
|
40162
|
+
toBigInt(sharesU256.high.toString()),
|
|
40163
|
+
recv.toBigInt(),
|
|
40164
|
+
owner.toBigInt()
|
|
40165
|
+
]
|
|
40166
|
+
}
|
|
40167
|
+
}
|
|
40168
|
+
];
|
|
40203
40169
|
}
|
|
40204
|
-
|
|
40205
|
-
|
|
40206
|
-
* @returns Object containing the total amount in token units and USD value
|
|
40207
|
-
*/
|
|
40208
|
-
async getTVL() {
|
|
40209
|
-
const assets = await this.contract.total_assets();
|
|
40210
|
-
const amount = Web3Number.fromWei(
|
|
40211
|
-
assets.toString(),
|
|
40212
|
-
this.metadata.depositTokens[0].decimals
|
|
40213
|
-
);
|
|
40214
|
-
let price = await this.pricer.getPrice(
|
|
40215
|
-
this.metadata.depositTokens[0].symbol
|
|
40216
|
-
);
|
|
40217
|
-
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
40218
|
-
return {
|
|
40219
|
-
tokenInfo: this.asset(),
|
|
40220
|
-
amount,
|
|
40221
|
-
usdValue
|
|
40222
|
-
};
|
|
40170
|
+
getHealthFactor() {
|
|
40171
|
+
return Promise.resolve(10);
|
|
40223
40172
|
}
|
|
40224
|
-
|
|
40225
|
-
|
|
40226
|
-
|
|
40227
|
-
|
|
40228
|
-
|
|
40229
|
-
|
|
40173
|
+
};
|
|
40174
|
+
|
|
40175
|
+
// src/strategies/universal-strategy.tsx
|
|
40176
|
+
import { CallData, Contract as Contract15, num as num12, uint256 as uint25620 } from "starknet";
|
|
40177
|
+
|
|
40178
|
+
// src/data/vault-manager.abi.json
|
|
40179
|
+
var vault_manager_abi_default = [
|
|
40180
|
+
{
|
|
40181
|
+
type: "impl",
|
|
40182
|
+
name: "UpgradeableImpl",
|
|
40183
|
+
interface_name: "openzeppelin_upgrades::interface::IUpgradeable"
|
|
40184
|
+
},
|
|
40185
|
+
{
|
|
40186
|
+
type: "interface",
|
|
40187
|
+
name: "openzeppelin_upgrades::interface::IUpgradeable",
|
|
40188
|
+
items: [
|
|
40189
|
+
{
|
|
40190
|
+
type: "function",
|
|
40191
|
+
name: "upgrade",
|
|
40192
|
+
inputs: [
|
|
40193
|
+
{
|
|
40194
|
+
name: "new_class_hash",
|
|
40195
|
+
type: "core::starknet::class_hash::ClassHash"
|
|
40196
|
+
}
|
|
40197
|
+
],
|
|
40198
|
+
outputs: [],
|
|
40199
|
+
state_mutability: "external"
|
|
40200
|
+
}
|
|
40201
|
+
]
|
|
40202
|
+
},
|
|
40203
|
+
{
|
|
40204
|
+
type: "impl",
|
|
40205
|
+
name: "ManagerFlashloanReceiverImpl",
|
|
40206
|
+
interface_name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver"
|
|
40207
|
+
},
|
|
40208
|
+
{
|
|
40209
|
+
type: "struct",
|
|
40210
|
+
name: "core::integer::u256",
|
|
40211
|
+
members: [
|
|
40212
|
+
{
|
|
40213
|
+
name: "low",
|
|
40214
|
+
type: "core::integer::u128"
|
|
40215
|
+
},
|
|
40216
|
+
{
|
|
40217
|
+
name: "high",
|
|
40218
|
+
type: "core::integer::u128"
|
|
40219
|
+
}
|
|
40220
|
+
]
|
|
40221
|
+
},
|
|
40222
|
+
{
|
|
40223
|
+
type: "struct",
|
|
40224
|
+
name: "core::array::Span::<core::felt252>",
|
|
40225
|
+
members: [
|
|
40226
|
+
{
|
|
40227
|
+
name: "snapshot",
|
|
40228
|
+
type: "@core::array::Array::<core::felt252>"
|
|
40229
|
+
}
|
|
40230
|
+
]
|
|
40231
|
+
},
|
|
40232
|
+
{
|
|
40233
|
+
type: "interface",
|
|
40234
|
+
name: "vault_allocator::integration_interfaces::vesu::IFlashloanReceiver",
|
|
40235
|
+
items: [
|
|
40236
|
+
{
|
|
40237
|
+
type: "function",
|
|
40238
|
+
name: "on_flash_loan",
|
|
40239
|
+
inputs: [
|
|
40240
|
+
{
|
|
40241
|
+
name: "sender",
|
|
40242
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40243
|
+
},
|
|
40244
|
+
{
|
|
40245
|
+
name: "asset",
|
|
40246
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40247
|
+
},
|
|
40248
|
+
{
|
|
40249
|
+
name: "amount",
|
|
40250
|
+
type: "core::integer::u256"
|
|
40251
|
+
},
|
|
40252
|
+
{
|
|
40253
|
+
name: "data",
|
|
40254
|
+
type: "core::array::Span::<core::felt252>"
|
|
40255
|
+
}
|
|
40256
|
+
],
|
|
40257
|
+
outputs: [],
|
|
40258
|
+
state_mutability: "external"
|
|
40259
|
+
}
|
|
40260
|
+
]
|
|
40261
|
+
},
|
|
40262
|
+
{
|
|
40263
|
+
type: "impl",
|
|
40264
|
+
name: "ManagerImpl",
|
|
40265
|
+
interface_name: "vault_allocator::manager::interface::IManager"
|
|
40266
|
+
},
|
|
40267
|
+
{
|
|
40268
|
+
type: "struct",
|
|
40269
|
+
name: "core::array::Span::<core::array::Span::<core::felt252>>",
|
|
40270
|
+
members: [
|
|
40271
|
+
{
|
|
40272
|
+
name: "snapshot",
|
|
40273
|
+
type: "@core::array::Array::<core::array::Span::<core::felt252>>"
|
|
40274
|
+
}
|
|
40275
|
+
]
|
|
40276
|
+
},
|
|
40277
|
+
{
|
|
40278
|
+
type: "struct",
|
|
40279
|
+
name: "core::array::Span::<core::starknet::contract_address::ContractAddress>",
|
|
40280
|
+
members: [
|
|
40281
|
+
{
|
|
40282
|
+
name: "snapshot",
|
|
40283
|
+
type: "@core::array::Array::<core::starknet::contract_address::ContractAddress>"
|
|
40284
|
+
}
|
|
40285
|
+
]
|
|
40286
|
+
},
|
|
40287
|
+
{
|
|
40288
|
+
type: "enum",
|
|
40289
|
+
name: "core::bool",
|
|
40290
|
+
variants: [
|
|
40291
|
+
{
|
|
40292
|
+
name: "False",
|
|
40293
|
+
type: "()"
|
|
40294
|
+
},
|
|
40295
|
+
{
|
|
40296
|
+
name: "True",
|
|
40297
|
+
type: "()"
|
|
40298
|
+
}
|
|
40299
|
+
]
|
|
40300
|
+
},
|
|
40301
|
+
{
|
|
40302
|
+
type: "interface",
|
|
40303
|
+
name: "vault_allocator::manager::interface::IManager",
|
|
40304
|
+
items: [
|
|
40305
|
+
{
|
|
40306
|
+
type: "function",
|
|
40307
|
+
name: "vesu_singleton",
|
|
40308
|
+
inputs: [],
|
|
40309
|
+
outputs: [
|
|
40310
|
+
{
|
|
40311
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40312
|
+
}
|
|
40313
|
+
],
|
|
40314
|
+
state_mutability: "view"
|
|
40315
|
+
},
|
|
40316
|
+
{
|
|
40317
|
+
type: "function",
|
|
40318
|
+
name: "vault_allocator",
|
|
40319
|
+
inputs: [],
|
|
40320
|
+
outputs: [
|
|
40321
|
+
{
|
|
40322
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40323
|
+
}
|
|
40324
|
+
],
|
|
40325
|
+
state_mutability: "view"
|
|
40326
|
+
},
|
|
40327
|
+
{
|
|
40328
|
+
type: "function",
|
|
40329
|
+
name: "set_manage_root",
|
|
40330
|
+
inputs: [
|
|
40331
|
+
{
|
|
40332
|
+
name: "target",
|
|
40333
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40334
|
+
},
|
|
40335
|
+
{
|
|
40336
|
+
name: "root",
|
|
40337
|
+
type: "core::felt252"
|
|
40338
|
+
}
|
|
40339
|
+
],
|
|
40340
|
+
outputs: [],
|
|
40341
|
+
state_mutability: "external"
|
|
40342
|
+
},
|
|
40343
|
+
{
|
|
40344
|
+
type: "function",
|
|
40345
|
+
name: "manage_root",
|
|
40346
|
+
inputs: [
|
|
40347
|
+
{
|
|
40348
|
+
name: "target",
|
|
40349
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40350
|
+
}
|
|
40351
|
+
],
|
|
40352
|
+
outputs: [
|
|
40353
|
+
{
|
|
40354
|
+
type: "core::felt252"
|
|
40355
|
+
}
|
|
40356
|
+
],
|
|
40357
|
+
state_mutability: "view"
|
|
40358
|
+
},
|
|
40359
|
+
{
|
|
40360
|
+
type: "function",
|
|
40361
|
+
name: "pause",
|
|
40362
|
+
inputs: [],
|
|
40363
|
+
outputs: [],
|
|
40364
|
+
state_mutability: "external"
|
|
40365
|
+
},
|
|
40366
|
+
{
|
|
40367
|
+
type: "function",
|
|
40368
|
+
name: "unpause",
|
|
40369
|
+
inputs: [],
|
|
40370
|
+
outputs: [],
|
|
40371
|
+
state_mutability: "external"
|
|
40372
|
+
},
|
|
40373
|
+
{
|
|
40374
|
+
type: "function",
|
|
40375
|
+
name: "manage_vault_with_merkle_verification",
|
|
40376
|
+
inputs: [
|
|
40377
|
+
{
|
|
40378
|
+
name: "proofs",
|
|
40379
|
+
type: "core::array::Span::<core::array::Span::<core::felt252>>"
|
|
40380
|
+
},
|
|
40381
|
+
{
|
|
40382
|
+
name: "decoder_and_sanitizers",
|
|
40383
|
+
type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
|
|
40384
|
+
},
|
|
40385
|
+
{
|
|
40386
|
+
name: "targets",
|
|
40387
|
+
type: "core::array::Span::<core::starknet::contract_address::ContractAddress>"
|
|
40388
|
+
},
|
|
40389
|
+
{
|
|
40390
|
+
name: "selectors",
|
|
40391
|
+
type: "core::array::Span::<core::felt252>"
|
|
40392
|
+
},
|
|
40393
|
+
{
|
|
40394
|
+
name: "calldatas",
|
|
40395
|
+
type: "core::array::Span::<core::array::Span::<core::felt252>>"
|
|
40396
|
+
}
|
|
40397
|
+
],
|
|
40398
|
+
outputs: [],
|
|
40399
|
+
state_mutability: "external"
|
|
40400
|
+
},
|
|
40401
|
+
{
|
|
40402
|
+
type: "function",
|
|
40403
|
+
name: "flash_loan",
|
|
40404
|
+
inputs: [
|
|
40405
|
+
{
|
|
40406
|
+
name: "recipient",
|
|
40407
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40408
|
+
},
|
|
40409
|
+
{
|
|
40410
|
+
name: "asset",
|
|
40411
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40412
|
+
},
|
|
40413
|
+
{
|
|
40414
|
+
name: "amount",
|
|
40415
|
+
type: "core::integer::u256"
|
|
40416
|
+
},
|
|
40417
|
+
{
|
|
40418
|
+
name: "is_legacy",
|
|
40419
|
+
type: "core::bool"
|
|
40420
|
+
},
|
|
40421
|
+
{
|
|
40422
|
+
name: "data",
|
|
40423
|
+
type: "core::array::Span::<core::felt252>"
|
|
40424
|
+
}
|
|
40425
|
+
],
|
|
40426
|
+
outputs: [],
|
|
40427
|
+
state_mutability: "external"
|
|
40428
|
+
},
|
|
40429
|
+
{
|
|
40430
|
+
type: "function",
|
|
40431
|
+
name: "get_leaf_hash",
|
|
40432
|
+
inputs: [
|
|
40433
|
+
{
|
|
40434
|
+
name: "decoder_and_sanitizer",
|
|
40435
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40436
|
+
},
|
|
40437
|
+
{
|
|
40438
|
+
name: "target",
|
|
40439
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40440
|
+
},
|
|
40441
|
+
{
|
|
40442
|
+
name: "selector",
|
|
40443
|
+
type: "core::felt252"
|
|
40444
|
+
},
|
|
40445
|
+
{
|
|
40446
|
+
name: "packed_argument_addresses",
|
|
40447
|
+
type: "core::array::Span::<core::felt252>"
|
|
40448
|
+
}
|
|
40449
|
+
],
|
|
40450
|
+
outputs: [
|
|
40451
|
+
{
|
|
40452
|
+
type: "core::felt252"
|
|
40453
|
+
}
|
|
40454
|
+
],
|
|
40455
|
+
state_mutability: "view"
|
|
40456
|
+
}
|
|
40457
|
+
]
|
|
40458
|
+
},
|
|
40459
|
+
{
|
|
40460
|
+
type: "impl",
|
|
40461
|
+
name: "AccessControlImpl",
|
|
40462
|
+
interface_name: "openzeppelin_access::accesscontrol::interface::IAccessControl"
|
|
40463
|
+
},
|
|
40464
|
+
{
|
|
40465
|
+
type: "interface",
|
|
40466
|
+
name: "openzeppelin_access::accesscontrol::interface::IAccessControl",
|
|
40467
|
+
items: [
|
|
40468
|
+
{
|
|
40469
|
+
type: "function",
|
|
40470
|
+
name: "has_role",
|
|
40471
|
+
inputs: [
|
|
40472
|
+
{
|
|
40473
|
+
name: "role",
|
|
40474
|
+
type: "core::felt252"
|
|
40475
|
+
},
|
|
40476
|
+
{
|
|
40477
|
+
name: "account",
|
|
40478
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40479
|
+
}
|
|
40480
|
+
],
|
|
40481
|
+
outputs: [
|
|
40482
|
+
{
|
|
40483
|
+
type: "core::bool"
|
|
40484
|
+
}
|
|
40485
|
+
],
|
|
40486
|
+
state_mutability: "view"
|
|
40487
|
+
},
|
|
40488
|
+
{
|
|
40489
|
+
type: "function",
|
|
40490
|
+
name: "get_role_admin",
|
|
40491
|
+
inputs: [
|
|
40492
|
+
{
|
|
40493
|
+
name: "role",
|
|
40494
|
+
type: "core::felt252"
|
|
40495
|
+
}
|
|
40496
|
+
],
|
|
40497
|
+
outputs: [
|
|
40498
|
+
{
|
|
40499
|
+
type: "core::felt252"
|
|
40500
|
+
}
|
|
40501
|
+
],
|
|
40502
|
+
state_mutability: "view"
|
|
40503
|
+
},
|
|
40504
|
+
{
|
|
40505
|
+
type: "function",
|
|
40506
|
+
name: "grant_role",
|
|
40507
|
+
inputs: [
|
|
40508
|
+
{
|
|
40509
|
+
name: "role",
|
|
40510
|
+
type: "core::felt252"
|
|
40511
|
+
},
|
|
40512
|
+
{
|
|
40513
|
+
name: "account",
|
|
40514
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40515
|
+
}
|
|
40516
|
+
],
|
|
40517
|
+
outputs: [],
|
|
40518
|
+
state_mutability: "external"
|
|
40519
|
+
},
|
|
40520
|
+
{
|
|
40521
|
+
type: "function",
|
|
40522
|
+
name: "revoke_role",
|
|
40523
|
+
inputs: [
|
|
40524
|
+
{
|
|
40525
|
+
name: "role",
|
|
40526
|
+
type: "core::felt252"
|
|
40527
|
+
},
|
|
40528
|
+
{
|
|
40529
|
+
name: "account",
|
|
40530
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40531
|
+
}
|
|
40532
|
+
],
|
|
40533
|
+
outputs: [],
|
|
40534
|
+
state_mutability: "external"
|
|
40535
|
+
},
|
|
40536
|
+
{
|
|
40537
|
+
type: "function",
|
|
40538
|
+
name: "renounce_role",
|
|
40539
|
+
inputs: [
|
|
40540
|
+
{
|
|
40541
|
+
name: "role",
|
|
40542
|
+
type: "core::felt252"
|
|
40543
|
+
},
|
|
40544
|
+
{
|
|
40545
|
+
name: "account",
|
|
40546
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40547
|
+
}
|
|
40548
|
+
],
|
|
40549
|
+
outputs: [],
|
|
40550
|
+
state_mutability: "external"
|
|
40551
|
+
}
|
|
40552
|
+
]
|
|
40553
|
+
},
|
|
40554
|
+
{
|
|
40555
|
+
type: "impl",
|
|
40556
|
+
name: "PausableImpl",
|
|
40557
|
+
interface_name: "openzeppelin_security::interface::IPausable"
|
|
40558
|
+
},
|
|
40559
|
+
{
|
|
40560
|
+
type: "interface",
|
|
40561
|
+
name: "openzeppelin_security::interface::IPausable",
|
|
40562
|
+
items: [
|
|
40563
|
+
{
|
|
40564
|
+
type: "function",
|
|
40565
|
+
name: "is_paused",
|
|
40566
|
+
inputs: [],
|
|
40567
|
+
outputs: [
|
|
40568
|
+
{
|
|
40569
|
+
type: "core::bool"
|
|
40570
|
+
}
|
|
40571
|
+
],
|
|
40572
|
+
state_mutability: "view"
|
|
40573
|
+
}
|
|
40574
|
+
]
|
|
40575
|
+
},
|
|
40576
|
+
{
|
|
40577
|
+
type: "constructor",
|
|
40578
|
+
name: "constructor",
|
|
40579
|
+
inputs: [
|
|
40580
|
+
{
|
|
40581
|
+
name: "owner",
|
|
40582
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40583
|
+
},
|
|
40584
|
+
{
|
|
40585
|
+
name: "vault_allocator",
|
|
40586
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40587
|
+
},
|
|
40588
|
+
{
|
|
40589
|
+
name: "vesu_singleton",
|
|
40590
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
40591
|
+
}
|
|
40592
|
+
]
|
|
40593
|
+
},
|
|
40594
|
+
{
|
|
40595
|
+
type: "event",
|
|
40596
|
+
name: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
40597
|
+
kind: "enum",
|
|
40598
|
+
variants: []
|
|
40599
|
+
},
|
|
40600
|
+
{
|
|
40601
|
+
type: "event",
|
|
40602
|
+
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
|
|
40603
|
+
kind: "struct",
|
|
40604
|
+
members: [
|
|
40605
|
+
{
|
|
40606
|
+
name: "role",
|
|
40607
|
+
type: "core::felt252",
|
|
40608
|
+
kind: "data"
|
|
40609
|
+
},
|
|
40610
|
+
{
|
|
40611
|
+
name: "account",
|
|
40612
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40613
|
+
kind: "data"
|
|
40614
|
+
},
|
|
40615
|
+
{
|
|
40616
|
+
name: "sender",
|
|
40617
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40618
|
+
kind: "data"
|
|
40619
|
+
}
|
|
40620
|
+
]
|
|
40621
|
+
},
|
|
40622
|
+
{
|
|
40623
|
+
type: "event",
|
|
40624
|
+
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
|
|
40625
|
+
kind: "struct",
|
|
40626
|
+
members: [
|
|
40627
|
+
{
|
|
40628
|
+
name: "role",
|
|
40629
|
+
type: "core::felt252",
|
|
40630
|
+
kind: "data"
|
|
40631
|
+
},
|
|
40632
|
+
{
|
|
40633
|
+
name: "account",
|
|
40634
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40635
|
+
kind: "data"
|
|
40636
|
+
},
|
|
40637
|
+
{
|
|
40638
|
+
name: "sender",
|
|
40639
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40640
|
+
kind: "data"
|
|
40641
|
+
},
|
|
40642
|
+
{
|
|
40643
|
+
name: "delay",
|
|
40644
|
+
type: "core::integer::u64",
|
|
40645
|
+
kind: "data"
|
|
40646
|
+
}
|
|
40647
|
+
]
|
|
40648
|
+
},
|
|
40649
|
+
{
|
|
40650
|
+
type: "event",
|
|
40651
|
+
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
|
|
40652
|
+
kind: "struct",
|
|
40653
|
+
members: [
|
|
40654
|
+
{
|
|
40655
|
+
name: "role",
|
|
40656
|
+
type: "core::felt252",
|
|
40657
|
+
kind: "data"
|
|
40658
|
+
},
|
|
40659
|
+
{
|
|
40660
|
+
name: "account",
|
|
40661
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40662
|
+
kind: "data"
|
|
40663
|
+
},
|
|
40664
|
+
{
|
|
40665
|
+
name: "sender",
|
|
40666
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40667
|
+
kind: "data"
|
|
40668
|
+
}
|
|
40669
|
+
]
|
|
40670
|
+
},
|
|
40671
|
+
{
|
|
40672
|
+
type: "event",
|
|
40673
|
+
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
|
|
40674
|
+
kind: "struct",
|
|
40675
|
+
members: [
|
|
40676
|
+
{
|
|
40677
|
+
name: "role",
|
|
40678
|
+
type: "core::felt252",
|
|
40679
|
+
kind: "data"
|
|
40680
|
+
},
|
|
40681
|
+
{
|
|
40682
|
+
name: "previous_admin_role",
|
|
40683
|
+
type: "core::felt252",
|
|
40684
|
+
kind: "data"
|
|
40685
|
+
},
|
|
40686
|
+
{
|
|
40687
|
+
name: "new_admin_role",
|
|
40688
|
+
type: "core::felt252",
|
|
40689
|
+
kind: "data"
|
|
40690
|
+
}
|
|
40691
|
+
]
|
|
40692
|
+
},
|
|
40693
|
+
{
|
|
40694
|
+
type: "event",
|
|
40695
|
+
name: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
|
|
40696
|
+
kind: "enum",
|
|
40697
|
+
variants: [
|
|
40698
|
+
{
|
|
40699
|
+
name: "RoleGranted",
|
|
40700
|
+
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGranted",
|
|
40701
|
+
kind: "nested"
|
|
40702
|
+
},
|
|
40703
|
+
{
|
|
40704
|
+
name: "RoleGrantedWithDelay",
|
|
40705
|
+
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleGrantedWithDelay",
|
|
40706
|
+
kind: "nested"
|
|
40707
|
+
},
|
|
40708
|
+
{
|
|
40709
|
+
name: "RoleRevoked",
|
|
40710
|
+
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleRevoked",
|
|
40711
|
+
kind: "nested"
|
|
40712
|
+
},
|
|
40713
|
+
{
|
|
40714
|
+
name: "RoleAdminChanged",
|
|
40715
|
+
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::RoleAdminChanged",
|
|
40716
|
+
kind: "nested"
|
|
40717
|
+
}
|
|
40718
|
+
]
|
|
40719
|
+
},
|
|
40720
|
+
{
|
|
40721
|
+
type: "event",
|
|
40722
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
40723
|
+
kind: "struct",
|
|
40724
|
+
members: [
|
|
40725
|
+
{
|
|
40726
|
+
name: "class_hash",
|
|
40727
|
+
type: "core::starknet::class_hash::ClassHash",
|
|
40728
|
+
kind: "data"
|
|
40729
|
+
}
|
|
40730
|
+
]
|
|
40731
|
+
},
|
|
40732
|
+
{
|
|
40733
|
+
type: "event",
|
|
40734
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
40735
|
+
kind: "enum",
|
|
40736
|
+
variants: [
|
|
40737
|
+
{
|
|
40738
|
+
name: "Upgraded",
|
|
40739
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
40740
|
+
kind: "nested"
|
|
40741
|
+
}
|
|
40742
|
+
]
|
|
40743
|
+
},
|
|
40744
|
+
{
|
|
40745
|
+
type: "event",
|
|
40746
|
+
name: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
40747
|
+
kind: "struct",
|
|
40748
|
+
members: [
|
|
40749
|
+
{
|
|
40750
|
+
name: "account",
|
|
40751
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40752
|
+
kind: "data"
|
|
40753
|
+
}
|
|
40754
|
+
]
|
|
40755
|
+
},
|
|
40756
|
+
{
|
|
40757
|
+
type: "event",
|
|
40758
|
+
name: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
40759
|
+
kind: "struct",
|
|
40760
|
+
members: [
|
|
40761
|
+
{
|
|
40762
|
+
name: "account",
|
|
40763
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
40764
|
+
kind: "data"
|
|
40765
|
+
}
|
|
40766
|
+
]
|
|
40767
|
+
},
|
|
40768
|
+
{
|
|
40769
|
+
type: "event",
|
|
40770
|
+
name: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
40771
|
+
kind: "enum",
|
|
40772
|
+
variants: [
|
|
40773
|
+
{
|
|
40774
|
+
name: "Paused",
|
|
40775
|
+
type: "openzeppelin_security::pausable::PausableComponent::Paused",
|
|
40776
|
+
kind: "nested"
|
|
40777
|
+
},
|
|
40778
|
+
{
|
|
40779
|
+
name: "Unpaused",
|
|
40780
|
+
type: "openzeppelin_security::pausable::PausableComponent::Unpaused",
|
|
40781
|
+
kind: "nested"
|
|
40782
|
+
}
|
|
40783
|
+
]
|
|
40784
|
+
},
|
|
40785
|
+
{
|
|
40786
|
+
type: "event",
|
|
40787
|
+
name: "vault_allocator::manager::manager::Manager::Event",
|
|
40788
|
+
kind: "enum",
|
|
40789
|
+
variants: [
|
|
40790
|
+
{
|
|
40791
|
+
name: "SRC5Event",
|
|
40792
|
+
type: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
40793
|
+
kind: "nested"
|
|
40794
|
+
},
|
|
40795
|
+
{
|
|
40796
|
+
name: "AccessControlEvent",
|
|
40797
|
+
type: "openzeppelin_access::accesscontrol::accesscontrol::AccessControlComponent::Event",
|
|
40798
|
+
kind: "nested"
|
|
40799
|
+
},
|
|
40800
|
+
{
|
|
40801
|
+
name: "UpgradeableEvent",
|
|
40802
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
40803
|
+
kind: "nested"
|
|
40804
|
+
},
|
|
40805
|
+
{
|
|
40806
|
+
name: "PausableEvent",
|
|
40807
|
+
type: "openzeppelin_security::pausable::PausableComponent::Event",
|
|
40808
|
+
kind: "nested"
|
|
40809
|
+
}
|
|
40810
|
+
]
|
|
40811
|
+
}
|
|
40812
|
+
];
|
|
40813
|
+
|
|
40814
|
+
// src/strategies/types.ts
|
|
40815
|
+
var LSTPriceType = /* @__PURE__ */ ((LSTPriceType2) => {
|
|
40816
|
+
LSTPriceType2["ENDUR_PRICE"] = "ENDUR_PRICE";
|
|
40817
|
+
LSTPriceType2["AVNU_PRICE"] = "AVNU_PRICE";
|
|
40818
|
+
return LSTPriceType2;
|
|
40819
|
+
})(LSTPriceType || {});
|
|
40820
|
+
|
|
40821
|
+
// src/strategies/universal-strategy.tsx
|
|
40822
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
40823
|
+
var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
|
|
40824
|
+
AUMTypes2["FINALISED"] = "finalised";
|
|
40825
|
+
AUMTypes2["DEFISPRING"] = "defispring";
|
|
40826
|
+
return AUMTypes2;
|
|
40827
|
+
})(AUMTypes || {});
|
|
40828
|
+
var PositionTypeAvnuExtended = /* @__PURE__ */ ((PositionTypeAvnuExtended2) => {
|
|
40829
|
+
PositionTypeAvnuExtended2["OPEN"] = "open";
|
|
40830
|
+
PositionTypeAvnuExtended2["CLOSE"] = "close";
|
|
40831
|
+
return PositionTypeAvnuExtended2;
|
|
40832
|
+
})(PositionTypeAvnuExtended || {});
|
|
40833
|
+
var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
40834
|
+
constructor(config, pricer, metadata) {
|
|
40835
|
+
super(config);
|
|
40836
|
+
this.pricer = pricer;
|
|
40837
|
+
assert(
|
|
40838
|
+
metadata.depositTokens.length === 1,
|
|
40839
|
+
"VesuRebalance only supports 1 deposit token"
|
|
40840
|
+
);
|
|
40841
|
+
this.metadata = metadata;
|
|
40842
|
+
this.address = metadata.address;
|
|
40843
|
+
this.contract = new Contract15({
|
|
40844
|
+
abi: universal_vault_abi_default,
|
|
40845
|
+
address: this.address.address,
|
|
40846
|
+
providerOrAccount: this.config.provider
|
|
40847
|
+
});
|
|
40848
|
+
this.managerContract = new Contract15({
|
|
40849
|
+
abi: vault_manager_abi_default,
|
|
40850
|
+
address: this.metadata.additionalInfo.manager.address,
|
|
40851
|
+
providerOrAccount: this.config.provider
|
|
40852
|
+
});
|
|
40853
|
+
}
|
|
40854
|
+
getMerkleTree() {
|
|
40855
|
+
if (this.merkleTree) return this.merkleTree;
|
|
40856
|
+
const leaves = this.metadata.additionalInfo.leafAdapters.map((adapter, index) => {
|
|
40857
|
+
return adapter();
|
|
40858
|
+
});
|
|
40859
|
+
const standardTree = StandardMerkleTree.of(leaves.flatMap((l) => l.leaves));
|
|
40860
|
+
this.merkleTree = standardTree;
|
|
40861
|
+
return standardTree;
|
|
40862
|
+
}
|
|
40863
|
+
getMerkleRoot() {
|
|
40864
|
+
return this.getMerkleTree().root;
|
|
40865
|
+
}
|
|
40866
|
+
getProofs(id) {
|
|
40867
|
+
const tree = this.getMerkleTree();
|
|
40868
|
+
let proofs = [];
|
|
40869
|
+
for (const [i, v] of tree.entries()) {
|
|
40870
|
+
if (v.readableId == id) {
|
|
40871
|
+
proofs = tree.getProof(i);
|
|
40872
|
+
}
|
|
40873
|
+
}
|
|
40874
|
+
if (proofs.length === 0) {
|
|
40875
|
+
throw new Error(`Proof not found for ID: ${id}`);
|
|
40876
|
+
}
|
|
40877
|
+
const leafAdapter = this.metadata.additionalInfo.leafAdapters.find((adapter) => adapter().leaves[0]?.readableId === id);
|
|
40878
|
+
if (!leafAdapter) {
|
|
40879
|
+
throw new Error(`Leaf adapter not found for ID: ${id}`);
|
|
40880
|
+
}
|
|
40881
|
+
const leafInfo = leafAdapter();
|
|
40882
|
+
return {
|
|
40883
|
+
proofs,
|
|
40884
|
+
callConstructor: leafInfo.callConstructor.bind(leafInfo)
|
|
40885
|
+
};
|
|
40886
|
+
}
|
|
40887
|
+
getAdapter(id) {
|
|
40888
|
+
const adapter = this.metadata.additionalInfo.adapters.find((adapter2) => adapter2.id === id);
|
|
40889
|
+
if (!adapter) {
|
|
40890
|
+
throw new Error(`Adapter not found for ID: ${id}`);
|
|
40891
|
+
}
|
|
40892
|
+
return adapter.adapter;
|
|
40893
|
+
}
|
|
40894
|
+
asset() {
|
|
40895
|
+
return this.metadata.depositTokens[0];
|
|
40896
|
+
}
|
|
40897
|
+
async depositCall(amountInfo, receiver) {
|
|
40898
|
+
assert(
|
|
40899
|
+
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
40900
|
+
"Deposit token mismatch"
|
|
40901
|
+
);
|
|
40902
|
+
const assetContract = new Contract15({
|
|
40903
|
+
abi: universal_vault_abi_default,
|
|
40904
|
+
address: this.asset().address.address,
|
|
40905
|
+
providerOrAccount: this.config.provider
|
|
40906
|
+
});
|
|
40907
|
+
const call1 = assetContract.populate("approve", [
|
|
40908
|
+
this.address.address,
|
|
40909
|
+
uint25620.bnToUint256(amountInfo.amount.toWei())
|
|
40910
|
+
]);
|
|
40911
|
+
const call2 = this.contract.populate("deposit", [
|
|
40912
|
+
uint25620.bnToUint256(amountInfo.amount.toWei()),
|
|
40913
|
+
receiver.address
|
|
40914
|
+
]);
|
|
40915
|
+
return [call1, call2];
|
|
40916
|
+
}
|
|
40917
|
+
async withdrawCall(amountInfo, receiver, owner) {
|
|
40918
|
+
assert(
|
|
40919
|
+
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
40920
|
+
"Withdraw token mismatch"
|
|
40921
|
+
);
|
|
40922
|
+
const shares = await this.contract.call("convert_to_shares", [uint25620.bnToUint256(amountInfo.amount.toWei())]);
|
|
40923
|
+
const call = this.contract.populate("request_redeem", [
|
|
40924
|
+
uint25620.bnToUint256(shares.toString()),
|
|
40925
|
+
receiver.address,
|
|
40926
|
+
owner.address
|
|
40927
|
+
]);
|
|
40928
|
+
return [call];
|
|
40929
|
+
}
|
|
40930
|
+
async getUserTVL(user, blockIdentifier = "latest") {
|
|
40931
|
+
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
40932
|
+
const assets = await this.contract.call(
|
|
40933
|
+
"convert_to_assets",
|
|
40934
|
+
[uint25620.bnToUint256(shares)],
|
|
40935
|
+
{ blockIdentifier }
|
|
40936
|
+
);
|
|
40937
|
+
const amount = Web3Number.fromWei(
|
|
40938
|
+
assets.toString(),
|
|
40939
|
+
this.metadata.depositTokens[0].decimals
|
|
40940
|
+
);
|
|
40941
|
+
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
40942
|
+
let price = await this.pricer.getPrice(
|
|
40943
|
+
this.metadata.depositTokens[0].symbol,
|
|
40944
|
+
blockNumber
|
|
40945
|
+
);
|
|
40946
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
40947
|
+
return {
|
|
40948
|
+
tokenInfo: this.asset(),
|
|
40949
|
+
amount,
|
|
40950
|
+
usdValue
|
|
40951
|
+
};
|
|
40952
|
+
}
|
|
40953
|
+
async getVesuAPYs() {
|
|
40954
|
+
const vesuAdapters = this.getVesuAdapters();
|
|
40955
|
+
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
40956
|
+
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
40957
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(num12.getHexString(p.id)));
|
|
40958
|
+
});
|
|
40959
|
+
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
40960
|
+
if (pools.some((p) => !p)) {
|
|
40961
|
+
throw new Error("Pool not found");
|
|
40962
|
+
}
|
|
40963
|
+
;
|
|
40964
|
+
const positions = await this.getVesuPositions();
|
|
40965
|
+
logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
|
|
40966
|
+
const baseAPYs = [];
|
|
40967
|
+
const rewardAPYs = [];
|
|
40968
|
+
for (const [index, pool] of pools.entries()) {
|
|
40969
|
+
const vesuAdapter = vesuAdapters[index];
|
|
40970
|
+
const collateralAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.collateral.symbol.toLowerCase())?.stats;
|
|
40971
|
+
const debtAsset = pool.assets.find((a) => a.symbol.toLowerCase() === vesuAdapter.config.debt.symbol.toLowerCase())?.stats;
|
|
40972
|
+
const supplyApy = Number(collateralAsset.supplyApy.value || 0) / 1e18;
|
|
40973
|
+
const lstAPY = await this.getLSTAPR(vesuAdapter.config.collateral.address);
|
|
40974
|
+
logger.verbose(`${this.metadata.name}::netAPY: ${vesuAdapter.config.collateral.symbol} LST APR from Endur: ${lstAPY}`);
|
|
40975
|
+
baseAPYs.push(...[supplyApy + lstAPY, Number(debtAsset.borrowApr.value) / 1e18]);
|
|
40976
|
+
rewardAPYs.push(...[Number(collateralAsset.defiSpringSupplyApr?.value || "0") / 1e18, 0]);
|
|
40977
|
+
}
|
|
40978
|
+
logger.verbose(`${this.metadata.name}::netAPY: baseAPYs: ${JSON.stringify(baseAPYs)}`);
|
|
40979
|
+
logger.verbose(`${this.metadata.name}::netAPY: rewardAPYs: ${JSON.stringify(rewardAPYs)}`);
|
|
40980
|
+
assert(baseAPYs.length == positions.length, "APYs and positions length mismatch");
|
|
40981
|
+
return {
|
|
40982
|
+
baseAPYs,
|
|
40983
|
+
rewardAPYs,
|
|
40984
|
+
positions
|
|
40985
|
+
};
|
|
40986
|
+
}
|
|
40987
|
+
/**
|
|
40988
|
+
* Calculates the weighted average APY across all pools based on USD value.
|
|
40989
|
+
* @returns {Promise<number>} The weighted average APY across all pools
|
|
40990
|
+
*/
|
|
40991
|
+
async netAPY() {
|
|
40992
|
+
if (this.metadata.isPreview) {
|
|
40993
|
+
return { net: 0, splits: [{
|
|
40994
|
+
apy: 0,
|
|
40995
|
+
id: "base"
|
|
40996
|
+
}, {
|
|
40997
|
+
apy: 0,
|
|
40998
|
+
id: "defispring"
|
|
40999
|
+
}] };
|
|
41000
|
+
}
|
|
41001
|
+
const { positions, baseAPYs, rewardAPYs } = await this.getVesuAPYs();
|
|
41002
|
+
const unusedBalanceAPY = await this.getUnusedBalanceAPY();
|
|
41003
|
+
baseAPYs.push(...[unusedBalanceAPY.apy]);
|
|
41004
|
+
rewardAPYs.push(0);
|
|
41005
|
+
const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
|
|
41006
|
+
weights.push(unusedBalanceAPY.weight);
|
|
41007
|
+
const prevAUM = await this.getPrevAUM();
|
|
41008
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
41009
|
+
const prevAUMUSD = prevAUM.multipliedBy(price.price);
|
|
41010
|
+
return this.returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD);
|
|
41011
|
+
}
|
|
41012
|
+
async returnNetAPY(baseAPYs, rewardAPYs, weights, prevAUMUSD) {
|
|
41013
|
+
if (weights.every((p) => p == 0)) {
|
|
41014
|
+
return { net: 0, splits: [{
|
|
41015
|
+
apy: 0,
|
|
41016
|
+
id: "base"
|
|
41017
|
+
}, {
|
|
41018
|
+
apy: 0,
|
|
41019
|
+
id: "defispring"
|
|
41020
|
+
}] };
|
|
41021
|
+
}
|
|
41022
|
+
const baseAPY = this.computeAPY(baseAPYs, weights, prevAUMUSD);
|
|
41023
|
+
const rewardAPY = this.computeAPY(rewardAPYs, weights, prevAUMUSD);
|
|
41024
|
+
const netAPY = baseAPY + rewardAPY;
|
|
41025
|
+
logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
|
|
41026
|
+
return { net: netAPY, splits: [{
|
|
41027
|
+
apy: baseAPY,
|
|
41028
|
+
id: "base"
|
|
41029
|
+
}, {
|
|
41030
|
+
apy: rewardAPY,
|
|
41031
|
+
id: "defispring"
|
|
41032
|
+
}] };
|
|
41033
|
+
}
|
|
41034
|
+
async getUnusedBalanceAPY() {
|
|
41035
|
+
return {
|
|
41036
|
+
apy: 0,
|
|
41037
|
+
weight: 0
|
|
41038
|
+
};
|
|
41039
|
+
}
|
|
41040
|
+
computeAPY(apys, weights, currentAUM) {
|
|
41041
|
+
assert(apys.length === weights.length, "APYs and weights length mismatch");
|
|
41042
|
+
const weightedSum = apys.reduce((acc, apy, i) => acc + apy * weights[i], 0);
|
|
41043
|
+
logger.verbose(`${this.getTag()} computeAPY: apys: ${JSON.stringify(apys)}, weights: ${JSON.stringify(weights)}, weightedSum: ${weightedSum}, currentAUM: ${currentAUM}`);
|
|
41044
|
+
return weightedSum / currentAUM.toNumber();
|
|
41045
|
+
}
|
|
41046
|
+
/**
|
|
41047
|
+
* Calculates user realized APY based on trueSharesBasedAPY method.
|
|
41048
|
+
* Returns the APY as a number.
|
|
41049
|
+
*/
|
|
41050
|
+
async getUserRealizedAPY(blockIdentifier = "latest", sinceBlocks = 6e5) {
|
|
41051
|
+
logger.verbose(
|
|
41052
|
+
`${this.getTag()}: getUserRealizedAPY => starting with blockIdentifier=${blockIdentifier}, sinceBlocks=${sinceBlocks}`
|
|
41053
|
+
);
|
|
41054
|
+
let blockNow = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : (await this.config.provider.getBlockLatestAccepted()).block_number;
|
|
41055
|
+
const blockNowTime = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? (await this.config.provider.getBlockWithTxs(blockIdentifier)).timestamp : (/* @__PURE__ */ new Date()).getTime() / 1e3;
|
|
41056
|
+
const blockBefore = Math.max(
|
|
41057
|
+
blockNow - sinceBlocks,
|
|
41058
|
+
this.metadata.launchBlock
|
|
41059
|
+
);
|
|
41060
|
+
const assetsNowRaw = await this.contract.call("total_assets", [], {
|
|
41061
|
+
blockIdentifier
|
|
41062
|
+
});
|
|
41063
|
+
const amountNow = Web3Number.fromWei(
|
|
41064
|
+
assetsNowRaw.toString(),
|
|
41065
|
+
this.metadata.depositTokens[0].decimals
|
|
41066
|
+
);
|
|
41067
|
+
const supplyNowRaw = await this.contract.call("total_supply", [], {
|
|
41068
|
+
blockIdentifier
|
|
41069
|
+
});
|
|
41070
|
+
const supplyNow = Web3Number.fromWei(supplyNowRaw.toString(), 18);
|
|
41071
|
+
const assetsBeforeRaw = await this.contract.call(
|
|
41072
|
+
"total_assets",
|
|
41073
|
+
[],
|
|
41074
|
+
{ blockIdentifier: blockBefore }
|
|
41075
|
+
);
|
|
41076
|
+
const amountBefore = Web3Number.fromWei(
|
|
41077
|
+
assetsBeforeRaw.toString(),
|
|
41078
|
+
this.metadata.depositTokens[0].decimals
|
|
41079
|
+
);
|
|
41080
|
+
const supplyBeforeRaw = await this.contract.call(
|
|
41081
|
+
"total_supply",
|
|
41082
|
+
[],
|
|
41083
|
+
{ blockIdentifier: blockBefore }
|
|
41084
|
+
);
|
|
41085
|
+
const supplyBefore = Web3Number.fromWei(supplyBeforeRaw.toString(), 18);
|
|
41086
|
+
const blockBeforeInfo = await this.config.provider.getBlockWithTxs(
|
|
41087
|
+
blockBefore
|
|
41088
|
+
);
|
|
41089
|
+
const assetsPerShareNow = amountNow.multipliedBy(1e18).dividedBy(supplyNow.toString());
|
|
41090
|
+
const assetsPerShareBf = amountBefore.multipliedBy(1e18).dividedBy(supplyBefore.toString());
|
|
41091
|
+
const timeDiffSeconds = blockNowTime - blockBeforeInfo.timestamp;
|
|
41092
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsNow: ${amountNow.toString()}`);
|
|
41093
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsBefore: ${amountBefore.toString()}`);
|
|
41094
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareNow: ${assetsPerShareNow.toString()}`);
|
|
41095
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] assetsPerShareBf: ${assetsPerShareBf.toString()}`);
|
|
41096
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply before: ${supplyBefore.toString()}`);
|
|
41097
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Supply now: ${supplyNow.toString()}`);
|
|
41098
|
+
logger.verbose(`${this.getTag()} [getUserRealizedAPY] Time diff in seconds: ${timeDiffSeconds}`);
|
|
41099
|
+
const apyForGivenBlocks = Number(
|
|
41100
|
+
assetsPerShareNow.minus(assetsPerShareBf).multipliedBy(1e4).dividedBy(assetsPerShareBf)
|
|
41101
|
+
) / 1e4;
|
|
41102
|
+
return apyForGivenBlocks * (365 * 24 * 3600) / timeDiffSeconds;
|
|
41103
|
+
}
|
|
41104
|
+
/**
|
|
41105
|
+
* Calculates the total TVL of the strategy.
|
|
41106
|
+
* @returns Object containing the total amount in token units and USD value
|
|
41107
|
+
*/
|
|
41108
|
+
async getTVL() {
|
|
41109
|
+
const assets = await this.contract.total_assets();
|
|
41110
|
+
const amount = Web3Number.fromWei(
|
|
41111
|
+
assets.toString(),
|
|
41112
|
+
this.metadata.depositTokens[0].decimals
|
|
41113
|
+
);
|
|
41114
|
+
let price = await this.pricer.getPrice(
|
|
41115
|
+
this.metadata.depositTokens[0].symbol
|
|
41116
|
+
);
|
|
41117
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
41118
|
+
return {
|
|
41119
|
+
tokenInfo: this.asset(),
|
|
41120
|
+
amount,
|
|
41121
|
+
usdValue
|
|
41122
|
+
};
|
|
41123
|
+
}
|
|
41124
|
+
async getUnusedBalance() {
|
|
41125
|
+
const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
|
|
41126
|
+
const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
|
|
41127
|
+
const usdValue = Number(balance.toFixed(6)) * price.price;
|
|
41128
|
+
return {
|
|
41129
|
+
tokenInfo: this.asset(),
|
|
40230
41130
|
amount: balance,
|
|
40231
41131
|
usdValue
|
|
40232
41132
|
};
|
|
@@ -41044,9 +41944,9 @@ var SVKStrategy = class extends BaseStrategy {
|
|
|
41044
41944
|
* Builds a manage call from an adapter's proof tree.
|
|
41045
41945
|
* DRY helper for the repeated getProofs → getManageCall pattern.
|
|
41046
41946
|
*/
|
|
41047
|
-
async buildManageCallFromAdapter(adapter, isDeposit, amount) {
|
|
41947
|
+
async buildManageCallFromAdapter(adapter, isDeposit, amount, additionalParams) {
|
|
41048
41948
|
const proofsInfo = adapter.getProofs(isDeposit, this.getMerkleTree());
|
|
41049
|
-
const manageCalls = await proofsInfo.callConstructor({ amount });
|
|
41949
|
+
const manageCalls = await proofsInfo.callConstructor({ amount, ...additionalParams });
|
|
41050
41950
|
return this.getManageCall(
|
|
41051
41951
|
this.getProofGroupsForManageCalls(manageCalls),
|
|
41052
41952
|
manageCalls
|
|
@@ -42066,177 +42966,697 @@ var hyperxLBTC = {
|
|
|
42066
42966
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "LBTC"),
|
|
42067
42967
|
quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "LBTC").decimals)
|
|
42068
42968
|
};
|
|
42069
|
-
var hypermRe7BTC = {
|
|
42070
|
-
vaultAddress: ContractAddr.from("0x6c89b75d09de82477edb86b2c2918cfc1a5dc0177cfbdea46278386b6499645"),
|
|
42071
|
-
manager: ContractAddr.from("0x7bc2d0535e13352d3ab78ea047616a3162068294297304943d2302122a150a1"),
|
|
42072
|
-
vaultAllocator: ContractAddr.from("0x760f9cebca9d2ee624f4224591da6da8b3ea5fd2410590735709551bd4e7570"),
|
|
42073
|
-
redeemRequestNFT: ContractAddr.from("0x5e045ae0160f7650f8a4dd7c826f25630a89fe62434db4441e7e0075608180f"),
|
|
42074
|
-
aumOracle: ContractAddr.from("0x3958df341b838813c24efb9183c23bddd1c57d44b1b86c0dd57f67887b89fba"),
|
|
42075
|
-
leafAdapters: [],
|
|
42076
|
-
adapters: [],
|
|
42077
|
-
targetHealthFactor: 1.1,
|
|
42078
|
-
minHealthFactor: 1.05,
|
|
42079
|
-
borrowable_assets: borrowableAssets.map((asset) => Global.getDefaultTokens().find((token) => token.symbol === asset)),
|
|
42080
|
-
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
42081
|
-
quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
|
|
42969
|
+
var hypermRe7BTC = {
|
|
42970
|
+
vaultAddress: ContractAddr.from("0x6c89b75d09de82477edb86b2c2918cfc1a5dc0177cfbdea46278386b6499645"),
|
|
42971
|
+
manager: ContractAddr.from("0x7bc2d0535e13352d3ab78ea047616a3162068294297304943d2302122a150a1"),
|
|
42972
|
+
vaultAllocator: ContractAddr.from("0x760f9cebca9d2ee624f4224591da6da8b3ea5fd2410590735709551bd4e7570"),
|
|
42973
|
+
redeemRequestNFT: ContractAddr.from("0x5e045ae0160f7650f8a4dd7c826f25630a89fe62434db4441e7e0075608180f"),
|
|
42974
|
+
aumOracle: ContractAddr.from("0x3958df341b838813c24efb9183c23bddd1c57d44b1b86c0dd57f67887b89fba"),
|
|
42975
|
+
leafAdapters: [],
|
|
42976
|
+
adapters: [],
|
|
42977
|
+
targetHealthFactor: 1.1,
|
|
42978
|
+
minHealthFactor: 1.05,
|
|
42979
|
+
borrowable_assets: borrowableAssets.map((asset) => Global.getDefaultTokens().find((token) => token.symbol === asset)),
|
|
42980
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "WBTC"),
|
|
42981
|
+
quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
|
|
42982
|
+
};
|
|
42983
|
+
var hypermRe7YIELD = {
|
|
42984
|
+
vaultAddress: ContractAddr.from("0x42797ab4eb1f72787442e91a73d63a39e3a141c1106470a946ecc328db6896c"),
|
|
42985
|
+
manager: ContractAddr.from("0x435b45d40fbb406cf69ac84bb471e7b7a4ea2295d0893c05dd2db565295e77f"),
|
|
42986
|
+
vaultAllocator: ContractAddr.from("0x456c4c6afca90512aeb5c735d84405fea6e51ab06d1851ac8cdb0a235e14f15"),
|
|
42987
|
+
redeemRequestNFT: ContractAddr.from("0x4bbb25c2568af07967342833f7db1aece1be1be2330798dab4ee585aa6c2c72"),
|
|
42988
|
+
aumOracle: ContractAddr.from("0x3e1f2825158cafccc9b42a8165d17ceb6b8e966474d9c63587d338746888382"),
|
|
42989
|
+
leafAdapters: [],
|
|
42990
|
+
adapters: [],
|
|
42991
|
+
targetHealthFactor: 1.1,
|
|
42992
|
+
minHealthFactor: 1.05,
|
|
42993
|
+
borrowable_assets: [Global.getDefaultTokens().find((token) => token.symbol === "USDC")],
|
|
42994
|
+
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "USDC"),
|
|
42995
|
+
quoteAmountToFetchPrice: new Web3Number("0.001", Global.getDefaultTokens().find((token) => token.symbol === "mRe7BTC").decimals)
|
|
42996
|
+
};
|
|
42997
|
+
function getInvestmentSteps(lstSymbol, underlyingSymbol) {
|
|
42998
|
+
return [
|
|
42999
|
+
`Deposit ${lstSymbol} into the vault`,
|
|
43000
|
+
`The vault manager loops the ${underlyingSymbol} to buy ${lstSymbol}`,
|
|
43001
|
+
`The vault manager collateralizes the ${lstSymbol} on Vesu`,
|
|
43002
|
+
`The vault manager borrows more ${underlyingSymbol} to loop further`,
|
|
43003
|
+
`If required, adjust leverage or re-allocate assets within LST pool on Vesu to optimize yield`
|
|
43004
|
+
];
|
|
43005
|
+
}
|
|
43006
|
+
function getMaxTVL(lstSymbol) {
|
|
43007
|
+
const lstMaxTVLs = {
|
|
43008
|
+
xWBTC: 5,
|
|
43009
|
+
xLBTC: 5,
|
|
43010
|
+
xtBTC: 5,
|
|
43011
|
+
xsBTC: 5,
|
|
43012
|
+
xSTRK: 7e6
|
|
43013
|
+
};
|
|
43014
|
+
const maxTVLValue = lstMaxTVLs[lstSymbol] || 0;
|
|
43015
|
+
const token = Global.getDefaultTokens().find(
|
|
43016
|
+
(token2) => token2.symbol === lstSymbol
|
|
43017
|
+
);
|
|
43018
|
+
if (!token) {
|
|
43019
|
+
return Web3Number.fromWei(0, 18);
|
|
43020
|
+
}
|
|
43021
|
+
return Web3Number.fromWei(maxTVLValue, token.decimals);
|
|
43022
|
+
}
|
|
43023
|
+
function createHyperLSTSettings(lstSymbol, underlyingSymbol) {
|
|
43024
|
+
const depositToken = Global.getDefaultTokens().find(
|
|
43025
|
+
(token) => token.symbol === lstSymbol
|
|
43026
|
+
);
|
|
43027
|
+
return {
|
|
43028
|
+
maxTVL: getMaxTVL(lstSymbol),
|
|
43029
|
+
isPaused: false,
|
|
43030
|
+
liveStatus: "Hot & New \u{1F525}" /* HOT */,
|
|
43031
|
+
isAudited: true,
|
|
43032
|
+
isInstantWithdrawal: false,
|
|
43033
|
+
hideHarvestInfo: true,
|
|
43034
|
+
quoteToken: depositToken,
|
|
43035
|
+
showWithdrawalWarningModal: false,
|
|
43036
|
+
alerts: [
|
|
43037
|
+
{
|
|
43038
|
+
tab: "withdraw",
|
|
43039
|
+
text: "On withdrawal, you will receive an NFT representing your withdrawal request. The funds will be automatically sent to your wallet (NFT owner) in 24 hours (In this initial phase of Launch). You can monitor the status in transactions tab.",
|
|
43040
|
+
type: "info"
|
|
43041
|
+
},
|
|
43042
|
+
{
|
|
43043
|
+
tab: "deposit",
|
|
43044
|
+
text: /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
43045
|
+
"To acquire the LST, please visit",
|
|
43046
|
+
" ",
|
|
43047
|
+
/* @__PURE__ */ jsx5("a", { href: "https://app.endur.fi", target: "_blank", rel: "noopener noreferrer", children: "endur.fi" })
|
|
43048
|
+
] }),
|
|
43049
|
+
type: "info"
|
|
43050
|
+
},
|
|
43051
|
+
{
|
|
43052
|
+
tab: "deposit",
|
|
43053
|
+
text: "It may take up to one week for your deposit to appreciate in value. This delay occurs because the LST price is sourced from DEXes and liquidity is usually rebased once a week.",
|
|
43054
|
+
type: "info"
|
|
43055
|
+
}
|
|
43056
|
+
]
|
|
43057
|
+
};
|
|
43058
|
+
}
|
|
43059
|
+
var HYPER_LST_SECURITY = {
|
|
43060
|
+
auditStatus: "Audited" /* AUDITED */,
|
|
43061
|
+
sourceCode: {
|
|
43062
|
+
type: "Closed Source" /* CLOSED_SOURCE */,
|
|
43063
|
+
contractLink: "https://github.com/trovesfi/troves-contracts"
|
|
43064
|
+
},
|
|
43065
|
+
accessControl: {
|
|
43066
|
+
type: "Standard Account" /* STANDARD_ACCOUNT */,
|
|
43067
|
+
addresses: [ContractAddr.from("0x0")],
|
|
43068
|
+
timeLock: "2 Days"
|
|
43069
|
+
}
|
|
43070
|
+
};
|
|
43071
|
+
var HYPER_LST_REDEMPTION_INFO = {
|
|
43072
|
+
instantWithdrawalVault: "No" /* NO */,
|
|
43073
|
+
redemptionsInfo: [
|
|
43074
|
+
{
|
|
43075
|
+
title: "Typical Duration",
|
|
43076
|
+
description: "1-2 hours"
|
|
43077
|
+
}
|
|
43078
|
+
],
|
|
43079
|
+
alerts: [
|
|
43080
|
+
{
|
|
43081
|
+
type: "info",
|
|
43082
|
+
text: "In cases of low liquidity, high slippages, the redemptions can take longer time. Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
|
|
43083
|
+
tab: "withdraw"
|
|
43084
|
+
}
|
|
43085
|
+
]
|
|
42082
43086
|
};
|
|
42083
|
-
|
|
42084
|
-
|
|
42085
|
-
|
|
42086
|
-
|
|
42087
|
-
|
|
42088
|
-
|
|
42089
|
-
|
|
42090
|
-
|
|
42091
|
-
|
|
42092
|
-
|
|
42093
|
-
|
|
42094
|
-
|
|
42095
|
-
|
|
43087
|
+
function getStrategySettings(lstSymbol, underlyingSymbol, settings, isPreview = false, isLST) {
|
|
43088
|
+
return {
|
|
43089
|
+
id: `hyper_${lstSymbol.toLowerCase()}`,
|
|
43090
|
+
name: `Hyper ${lstSymbol}`,
|
|
43091
|
+
description: getDescription2(lstSymbol, underlyingSymbol),
|
|
43092
|
+
address: settings.vaultAddress,
|
|
43093
|
+
launchBlock: 0,
|
|
43094
|
+
type: "Other",
|
|
43095
|
+
vaultType: {
|
|
43096
|
+
type: "Looping" /* LOOPING */,
|
|
43097
|
+
description: `Creates leveraged looping position on ${lstSymbol} by borrowing ${underlyingSymbol} to increase yield`
|
|
43098
|
+
},
|
|
43099
|
+
depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === lstSymbol)],
|
|
43100
|
+
additionalInfo: getLooperSettings2(lstSymbol, underlyingSymbol, settings, lstSymbol === "xSTRK" ? VesuPools.Re7xSTRK : VesuPools.Re7xBTC),
|
|
43101
|
+
risk: {
|
|
43102
|
+
riskFactor: _riskFactor4,
|
|
43103
|
+
netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
|
|
43104
|
+
notARisks: getNoRiskTags(_riskFactor4)
|
|
43105
|
+
},
|
|
43106
|
+
auditUrl: AUDIT_URL4,
|
|
43107
|
+
protocols: [Protocols.ENDUR, Protocols.VESU],
|
|
43108
|
+
curator: {
|
|
43109
|
+
name: "Unwrap Labs",
|
|
43110
|
+
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
43111
|
+
},
|
|
43112
|
+
settings: createHyperLSTSettings(lstSymbol, underlyingSymbol),
|
|
43113
|
+
contractDetails: getContractDetails(settings),
|
|
43114
|
+
faqs: getFAQs2(lstSymbol, underlyingSymbol, isLST),
|
|
43115
|
+
investmentSteps: getInvestmentSteps(lstSymbol, underlyingSymbol),
|
|
43116
|
+
isPreview,
|
|
43117
|
+
apyMethodology: "Current annualized APY in terms of base asset of the LST. There is no additional fee taken by Troves on LST APY. We charge a 10% performance fee on the additional gain which is already accounted in the APY shown.",
|
|
43118
|
+
realizedAPYMethodology: "The realizedAPY is based on past 14 days performance by the vault",
|
|
43119
|
+
tags: lstSymbol.includes("BTC") ? ["BTC" /* BTC */, "Maxx" /* LEVERED */] : ["Maxx" /* LEVERED */],
|
|
43120
|
+
security: HYPER_LST_SECURITY,
|
|
43121
|
+
redemptionInfo: HYPER_LST_REDEMPTION_INFO,
|
|
43122
|
+
usualTimeToEarnings: "2 weeks",
|
|
43123
|
+
usualTimeToEarningsDescription: "Strategy returns depend on LST price on DEXes. Even though the true price of LST on Endur increases continuously, the DEX price may lag sometimes, and historically is seen to rebase at least once every 2 hours. This is when you realise your earnings.",
|
|
43124
|
+
points: lstSymbol === "xSTRK" ? [{
|
|
43125
|
+
multiplier: 4,
|
|
43126
|
+
logo: "https://endur.fi/favicon.ico",
|
|
43127
|
+
toolTip: "This strategy holds xSTRK. Earn 3-4x Endur points on your xSTRK due to the leverage. Points can be found on endur.fi."
|
|
43128
|
+
}] : void 0
|
|
43129
|
+
};
|
|
43130
|
+
}
|
|
43131
|
+
var HyperLSTStrategies = [
|
|
43132
|
+
getStrategySettings("xSTRK", "STRK", hyperxSTRK, false, true),
|
|
43133
|
+
getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false, false),
|
|
43134
|
+
getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false, false),
|
|
43135
|
+
getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false, false),
|
|
43136
|
+
getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false, false),
|
|
43137
|
+
getStrategySettings("mRe7BTC", "mRe7BTC", hypermRe7BTC, false, false),
|
|
43138
|
+
getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
|
|
43139
|
+
];
|
|
43140
|
+
|
|
43141
|
+
// src/strategies/usdc-boosted-strategy.tsx
|
|
43142
|
+
import { uint256 as uint25623 } from "starknet";
|
|
43143
|
+
var USDCBoostedStrategy = class _USDCBoostedStrategy extends SVKStrategy {
|
|
43144
|
+
constructor(config, pricer, metadata) {
|
|
43145
|
+
super(config, pricer, metadata);
|
|
43146
|
+
this.metadata.additionalInfo.adapters.forEach((adapter) => {
|
|
43147
|
+
adapter.adapter.config.networkConfig = this.config;
|
|
43148
|
+
adapter.adapter.config.pricer = this.pricer;
|
|
43149
|
+
if (adapter.adapter._vesuAdapter) {
|
|
43150
|
+
adapter.adapter._vesuAdapter.networkConfig = this.config;
|
|
43151
|
+
adapter.adapter._vesuAdapter.pricer = this.pricer;
|
|
43152
|
+
}
|
|
43153
|
+
});
|
|
43154
|
+
}
|
|
43155
|
+
getTag() {
|
|
43156
|
+
return `${_USDCBoostedStrategy.name}:${this.metadata.name}`;
|
|
43157
|
+
}
|
|
43158
|
+
getAdapterById(id) {
|
|
43159
|
+
const entry = this.metadata.additionalInfo.adapters.find(
|
|
43160
|
+
(a) => a.id === id
|
|
43161
|
+
);
|
|
43162
|
+
if (!entry) {
|
|
43163
|
+
throw new Error(
|
|
43164
|
+
`${this.getTag()}::getAdapterById: adapter not found for id "${id}"`
|
|
43165
|
+
);
|
|
43166
|
+
}
|
|
43167
|
+
return entry.adapter;
|
|
43168
|
+
}
|
|
43169
|
+
async getVesuModifyPositionCall(params) {
|
|
43170
|
+
logger.verbose(
|
|
43171
|
+
`${this.getTag()}::getVesuModifyPositionCall isDeposit=${params.isDeposit}, amount=${params.leg1DepositAmount}, debtAmount=${params.debtAmount?.toNumber()}`
|
|
43172
|
+
);
|
|
43173
|
+
return this.buildManageCallFromAdapter(
|
|
43174
|
+
this.getAdapterById("vesu_usdc_strk"),
|
|
43175
|
+
params.isDeposit,
|
|
43176
|
+
params.leg1DepositAmount,
|
|
43177
|
+
params.debtAmount ? { debtAmount: params.debtAmount } : void 0
|
|
43178
|
+
);
|
|
43179
|
+
}
|
|
43180
|
+
async getVesuPositions() {
|
|
43181
|
+
const positions = await this.getAdapterById(
|
|
43182
|
+
"vesu_usdc_strk"
|
|
43183
|
+
).getPositions();
|
|
43184
|
+
return positions.map((p) => ({
|
|
43185
|
+
amount: p.amount,
|
|
43186
|
+
usdValue: p.usdValue,
|
|
43187
|
+
remarks: p.remarks ?? "",
|
|
43188
|
+
token: p.tokenInfo,
|
|
43189
|
+
protocol: p.protocol
|
|
43190
|
+
}));
|
|
43191
|
+
}
|
|
43192
|
+
async getVesuHealthFactor(blockNumber = "latest") {
|
|
43193
|
+
const vesuAdapter = this.getAdapterById("vesu_usdc_strk");
|
|
43194
|
+
return await vesuAdapter._vesuAdapter.getHealthFactor(blockNumber);
|
|
43195
|
+
}
|
|
43196
|
+
// TODO: will have to still modify for instant withdrawals as of now
|
|
43197
|
+
async getModifyHyperPositionCall(params) {
|
|
43198
|
+
logger.verbose(
|
|
43199
|
+
`${this.getTag()}::getModifyHyperPositionCall isDeposit=${params.isDeposit}, amount=${params.amount}`
|
|
43200
|
+
);
|
|
43201
|
+
return this.buildManageCallFromAdapter(
|
|
43202
|
+
this.getAdapterById("hyper_xstrk"),
|
|
43203
|
+
params.isDeposit,
|
|
43204
|
+
params.amount
|
|
43205
|
+
);
|
|
43206
|
+
}
|
|
43207
|
+
async getAvnuSwapCall(params) {
|
|
43208
|
+
logger.verbose(
|
|
43209
|
+
`${this.getTag()}::getAvnuSwapCall isDeposit=${params.isDeposit}, amount=${params.amount}`
|
|
43210
|
+
);
|
|
43211
|
+
return this.buildManageCallFromAdapter(
|
|
43212
|
+
this.getAdapterById("avnu_strk_xstrk"),
|
|
43213
|
+
params.isDeposit,
|
|
43214
|
+
params.amount
|
|
43215
|
+
);
|
|
43216
|
+
}
|
|
43217
|
+
/**
|
|
43218
|
+
* Returns the USDC balance sitting idle inside the vault contract itself.
|
|
43219
|
+
* This balance can offset the required liquidity during withdrawal processing.
|
|
43220
|
+
*/
|
|
43221
|
+
async getUnusedBalanceVault() {
|
|
43222
|
+
const collateralToken = this.metadata.additionalInfo.collateralToken;
|
|
43223
|
+
return new ERC20(this.config).balanceOf(
|
|
43224
|
+
collateralToken.address,
|
|
43225
|
+
this.metadata.additionalInfo.vaultAddress,
|
|
43226
|
+
collateralToken.decimals
|
|
43227
|
+
);
|
|
43228
|
+
}
|
|
43229
|
+
/**
|
|
43230
|
+
* Returns the current STRK balance sitting unused in the vault allocator.
|
|
43231
|
+
* This covers STRK from prior borrow cycles that hasn't been swapped yet.
|
|
43232
|
+
*/
|
|
43233
|
+
// Technically we can use this or we can even use the avnu-adapter to get the unused debt
|
|
43234
|
+
async getUnusedDebt() {
|
|
43235
|
+
const debtToken = this.metadata.additionalInfo.debtToken;
|
|
43236
|
+
return new ERC20(this.config).balanceOf(
|
|
43237
|
+
debtToken.address,
|
|
43238
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
43239
|
+
debtToken.decimals
|
|
43240
|
+
);
|
|
43241
|
+
}
|
|
43242
|
+
/**
|
|
43243
|
+
* Returns the xSTRK balance sitting in the vault allocator.
|
|
43244
|
+
* This is non-zero when the previous cycle's request_redeem on the HyperPosition
|
|
43245
|
+
* has been settled — the redeemed xSTRK lands here and is ready to be swapped.
|
|
43246
|
+
*/
|
|
43247
|
+
async getxSTRKInVault() {
|
|
43248
|
+
const xstrkToken = Global.getDefaultTokens().find(
|
|
43249
|
+
(t) => t.symbol === "xSTRK"
|
|
43250
|
+
);
|
|
43251
|
+
if (!xstrkToken) {
|
|
43252
|
+
throw new Error(`${this.getTag()}:: xSTRK token not found`);
|
|
43253
|
+
}
|
|
43254
|
+
return new ERC20(this.config).balanceOf(
|
|
43255
|
+
xstrkToken.address.address,
|
|
43256
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
43257
|
+
xstrkToken.decimals
|
|
43258
|
+
);
|
|
43259
|
+
}
|
|
43260
|
+
/**
|
|
43261
|
+
* Simulates depositing `depositAmount` USDC on Vesu and returns the
|
|
43262
|
+
* incremental STRK that would be borrowed. Needed to size the AVNU swap
|
|
43263
|
+
* call that is batched together with the Vesu call in the same transaction.
|
|
43264
|
+
*/
|
|
43265
|
+
async computeVesuDepositBorrowAmount(depositAmount) {
|
|
43266
|
+
return this.getAdapterById(
|
|
43267
|
+
"vesu_usdc_strk"
|
|
43268
|
+
).getExpectedDepositDebtDelta(depositAmount);
|
|
43269
|
+
}
|
|
43270
|
+
async computeVesuWithdrawDebtDelta(withdrawAmount) {
|
|
43271
|
+
return this.getAdapterById(
|
|
43272
|
+
"vesu_usdc_strk"
|
|
43273
|
+
).getExpectedWithdrawDebtDelta(withdrawAmount);
|
|
43274
|
+
}
|
|
43275
|
+
async getPendingHyperAssets() {
|
|
43276
|
+
const xstrkToken = Global.getDefaultTokens().find(
|
|
43277
|
+
(t) => t.symbol === "xSTRK"
|
|
43278
|
+
);
|
|
43279
|
+
const hyperXstrkRedeemNFT = ContractAddr.from(
|
|
43280
|
+
"0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"
|
|
43281
|
+
);
|
|
43282
|
+
return this.getAdapterById(
|
|
43283
|
+
"hyper_xstrk"
|
|
43284
|
+
).getPendingAssetsFromOwnerNFTMethod(
|
|
43285
|
+
hyperXstrkRedeemNFT,
|
|
43286
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
43287
|
+
xstrkToken.decimals
|
|
43288
|
+
);
|
|
43289
|
+
}
|
|
43290
|
+
// TODO: rn we are just making these functions in the strategy itself but
|
|
43291
|
+
// later on we will move them to the SVKStrategy for generalization
|
|
43292
|
+
async getUserTVL(user, blockIdentifier = "latest") {
|
|
43293
|
+
const shares = await this.contract.call("balanceOf", [user.address], {
|
|
43294
|
+
blockIdentifier
|
|
43295
|
+
});
|
|
43296
|
+
const assets = await this.contract.call(
|
|
43297
|
+
"convert_to_assets",
|
|
43298
|
+
[uint25623.bnToUint256(shares)],
|
|
43299
|
+
{ blockIdentifier }
|
|
43300
|
+
);
|
|
43301
|
+
const amount = Web3Number.fromWei(
|
|
43302
|
+
assets.toString(),
|
|
43303
|
+
this.metadata.depositTokens[0].decimals
|
|
43304
|
+
);
|
|
43305
|
+
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
43306
|
+
const price = await this.pricer.getPrice(
|
|
43307
|
+
this.metadata.depositTokens[0].symbol,
|
|
43308
|
+
blockNumber
|
|
43309
|
+
);
|
|
43310
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
43311
|
+
return {
|
|
43312
|
+
tokenInfo: this.asset(),
|
|
43313
|
+
amount,
|
|
43314
|
+
usdValue
|
|
43315
|
+
};
|
|
43316
|
+
}
|
|
43317
|
+
async getTVL() {
|
|
43318
|
+
const assets = await this.contract.total_assets();
|
|
43319
|
+
const amount = Web3Number.fromWei(
|
|
43320
|
+
assets.toString(),
|
|
43321
|
+
this.metadata.depositTokens[0].decimals
|
|
43322
|
+
);
|
|
43323
|
+
const price = await this.pricer.getPrice(
|
|
43324
|
+
this.metadata.depositTokens[0].symbol
|
|
43325
|
+
);
|
|
43326
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
43327
|
+
return {
|
|
43328
|
+
tokenInfo: this.asset(),
|
|
43329
|
+
amount,
|
|
43330
|
+
usdValue
|
|
43331
|
+
};
|
|
43332
|
+
}
|
|
43333
|
+
async getAUM() {
|
|
43334
|
+
const underlying = this.asset();
|
|
43335
|
+
const usdcPrice = await this.pricer.getPrice(underlying.symbol);
|
|
43336
|
+
const allPositions = [];
|
|
43337
|
+
for (const adapter of this.metadata.additionalInfo.adapters) {
|
|
43338
|
+
const positions = await adapter.adapter.getPositions();
|
|
43339
|
+
allPositions.push(...positions);
|
|
43340
|
+
}
|
|
43341
|
+
let netAUM = new Web3Number(0, underlying.decimals);
|
|
43342
|
+
for (const position of allPositions) {
|
|
43343
|
+
if (position.tokenInfo.address.eq(underlying.address)) {
|
|
43344
|
+
netAUM = netAUM.plus(position.amount);
|
|
43345
|
+
} else {
|
|
43346
|
+
const valueInUSDC = position.usdValue;
|
|
43347
|
+
netAUM = netAUM.plus(valueInUSDC);
|
|
43348
|
+
}
|
|
43349
|
+
}
|
|
43350
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
43351
|
+
logger.verbose(
|
|
43352
|
+
`${this.getTag()} unused balance: ${unusedBalance.amount.toNumber()}`
|
|
43353
|
+
);
|
|
43354
|
+
netAUM = netAUM.plus(unusedBalance.amount);
|
|
43355
|
+
const prevAum = await this.getPrevAUM();
|
|
43356
|
+
logger.verbose(`${this.getTag()} AUM: ${netAUM}`);
|
|
43357
|
+
const realAUM = {
|
|
43358
|
+
tokenInfo: underlying,
|
|
43359
|
+
amount: netAUM,
|
|
43360
|
+
usdValue: netAUM.toNumber() * usdcPrice.price,
|
|
43361
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
43362
|
+
remarks: "finalised" /* FINALISED */,
|
|
43363
|
+
protocol: Protocols.NONE
|
|
43364
|
+
};
|
|
43365
|
+
const estimatedAUMDelta = {
|
|
43366
|
+
tokenInfo: underlying,
|
|
43367
|
+
amount: Web3Number.fromWei("0", underlying.decimals),
|
|
43368
|
+
usdValue: 0,
|
|
43369
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
43370
|
+
remarks: "defispring" /* DEFISPRING */,
|
|
43371
|
+
protocol: Protocols.NONE
|
|
43372
|
+
};
|
|
43373
|
+
return {
|
|
43374
|
+
net: {
|
|
43375
|
+
tokenInfo: underlying,
|
|
43376
|
+
amount: netAUM,
|
|
43377
|
+
usdValue: netAUM.toNumber() * usdcPrice.price
|
|
43378
|
+
},
|
|
43379
|
+
prevAum,
|
|
43380
|
+
splits: [realAUM, estimatedAUMDelta]
|
|
43381
|
+
};
|
|
43382
|
+
}
|
|
43383
|
+
// TODO: can refactor later but seems redundant since not being used ANYWHERE
|
|
43384
|
+
// Most of the fund management done through adapters only
|
|
43385
|
+
async getFundManagementCall(params) {
|
|
43386
|
+
logger.verbose(
|
|
43387
|
+
`${this.getTag()}::getFundManagementCall params: ${JSON.stringify(params)}`
|
|
43388
|
+
);
|
|
43389
|
+
const allAdapters = this.metadata.additionalInfo.adapters.map(
|
|
43390
|
+
(a) => a.adapter
|
|
43391
|
+
);
|
|
43392
|
+
if (!params.isDeposit) {
|
|
43393
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
43394
|
+
logger.verbose(
|
|
43395
|
+
`${this.getTag()}::getFundManagementCall unusedBalance: ${unusedBalance.amount}, required: ${params.leg1DepositAmount}`
|
|
43396
|
+
);
|
|
43397
|
+
if (unusedBalance.amount.gte(params.leg1DepositAmount)) {
|
|
43398
|
+
return null;
|
|
43399
|
+
}
|
|
43400
|
+
const adapters2 = await AdapterOptimizer.getAdapterToUse(
|
|
43401
|
+
allAdapters,
|
|
43402
|
+
false,
|
|
43403
|
+
params.leg1DepositAmount
|
|
43404
|
+
);
|
|
43405
|
+
if (adapters2.length > 0) {
|
|
43406
|
+
const proofsInfo = adapters2.map(
|
|
43407
|
+
(adapter) => adapter.getProofs(false, this.getMerkleTree())
|
|
43408
|
+
);
|
|
43409
|
+
const calls = [];
|
|
43410
|
+
for (const info of proofsInfo) {
|
|
43411
|
+
const manageCalls = await info.callConstructor({
|
|
43412
|
+
amount: params.leg1DepositAmount
|
|
43413
|
+
});
|
|
43414
|
+
const call = this.getManageCall(
|
|
43415
|
+
this.getProofGroupsForManageCalls(manageCalls),
|
|
43416
|
+
manageCalls
|
|
43417
|
+
);
|
|
43418
|
+
calls.push(call);
|
|
43419
|
+
}
|
|
43420
|
+
return calls;
|
|
43421
|
+
}
|
|
43422
|
+
throw new Error(
|
|
43423
|
+
`${this.getTag()}::getFundManagementCall: no adapters for withdraw: ${unusedBalance.amount}`
|
|
43424
|
+
);
|
|
43425
|
+
}
|
|
43426
|
+
const adapters = await AdapterOptimizer.getAdapterToUse(
|
|
43427
|
+
allAdapters,
|
|
43428
|
+
true,
|
|
43429
|
+
params.leg1DepositAmount
|
|
43430
|
+
);
|
|
43431
|
+
if (adapters.length > 0) {
|
|
43432
|
+
const proofsInfo = adapters.map(
|
|
43433
|
+
(adapter) => adapter.getProofs(true, this.getMerkleTree())
|
|
43434
|
+
);
|
|
43435
|
+
const calls = [];
|
|
43436
|
+
for (const info of proofsInfo) {
|
|
43437
|
+
const manageCalls = await info.callConstructor({
|
|
43438
|
+
amount: params.leg1DepositAmount
|
|
43439
|
+
});
|
|
43440
|
+
const call = this.getManageCall(
|
|
43441
|
+
this.getProofGroupsForManageCalls(manageCalls),
|
|
43442
|
+
manageCalls
|
|
43443
|
+
);
|
|
43444
|
+
calls.push(call);
|
|
43445
|
+
}
|
|
43446
|
+
return calls;
|
|
43447
|
+
}
|
|
43448
|
+
throw new Error(
|
|
43449
|
+
`${this.getTag()}::getFundManagementCall: no adapters for deposit: ${params.leg1DepositAmount}`
|
|
43450
|
+
);
|
|
43451
|
+
}
|
|
42096
43452
|
};
|
|
42097
|
-
function
|
|
42098
|
-
|
|
42099
|
-
|
|
42100
|
-
|
|
42101
|
-
|
|
42102
|
-
|
|
42103
|
-
|
|
42104
|
-
|
|
42105
|
-
|
|
42106
|
-
|
|
42107
|
-
|
|
42108
|
-
|
|
42109
|
-
|
|
42110
|
-
|
|
42111
|
-
xsBTC: 5,
|
|
42112
|
-
xSTRK: 7e6
|
|
43453
|
+
function getUSDCBoostedSettings(vaultSettings) {
|
|
43454
|
+
vaultSettings.leafAdapters = [];
|
|
43455
|
+
const xSTRKToken = Global.getDefaultTokens().find(
|
|
43456
|
+
(t) => t.symbol === "xSTRK"
|
|
43457
|
+
);
|
|
43458
|
+
const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
|
|
43459
|
+
const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
43460
|
+
const baseAdapterConfig = {
|
|
43461
|
+
baseToken: USDCToken,
|
|
43462
|
+
supportedPositions: [{ asset: USDCToken, isDebt: false }],
|
|
43463
|
+
networkConfig: getMainnetConfig(),
|
|
43464
|
+
pricer: new PricerFromApi(getMainnetConfig(), Global.getDefaultTokens()),
|
|
43465
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
43466
|
+
vaultAddress: vaultSettings.vaultAddress
|
|
42113
43467
|
};
|
|
42114
|
-
const
|
|
42115
|
-
|
|
42116
|
-
|
|
43468
|
+
const vesuModifyPositionAdapter = new VesuModifyPositionAdapter({
|
|
43469
|
+
poolId: vaultSettings.vesuPoolId,
|
|
43470
|
+
collateral: vaultSettings.collateralToken,
|
|
43471
|
+
debt: vaultSettings.debtToken,
|
|
43472
|
+
targetLtv: vaultSettings.targetLTV,
|
|
43473
|
+
maxLtv: vaultSettings.maxLTV,
|
|
43474
|
+
...baseAdapterConfig,
|
|
43475
|
+
supportedPositions: [
|
|
43476
|
+
{ asset: USDCToken, isDebt: false },
|
|
43477
|
+
{ asset: STRKToken, isDebt: true }
|
|
43478
|
+
]
|
|
43479
|
+
});
|
|
43480
|
+
const avnuAdapter = new AvnuAdapter({
|
|
43481
|
+
baseUrl: AVNU_QUOTE_URL,
|
|
43482
|
+
avnuContract: AVNU_EXCHANGE,
|
|
43483
|
+
slippage: 0.01,
|
|
43484
|
+
minimumExtendedPriceDifferenceForSwapOpen: 0,
|
|
43485
|
+
maximumExtendedPriceDifferenceForSwapClosing: 0,
|
|
43486
|
+
...baseAdapterConfig,
|
|
43487
|
+
baseToken: STRKToken,
|
|
43488
|
+
supportedPositions: [
|
|
43489
|
+
{ asset: STRKToken, isDebt: false },
|
|
43490
|
+
{ asset: xSTRKToken, isDebt: false }
|
|
43491
|
+
]
|
|
43492
|
+
});
|
|
43493
|
+
const svkTrovesAdapter = new SvkTrovesAdapter({
|
|
43494
|
+
...baseAdapterConfig,
|
|
43495
|
+
baseToken: xSTRKToken,
|
|
43496
|
+
supportedPositions: [{ asset: xSTRKToken, isDebt: false }],
|
|
43497
|
+
strategyVault: vaultSettings.hyperxSTRKVaultAddress,
|
|
43498
|
+
trovesStrategyId: "hyper_xstrk"
|
|
43499
|
+
});
|
|
43500
|
+
const usdcTransferAdapter = new TokenTransferAdapter({
|
|
43501
|
+
...baseAdapterConfig,
|
|
43502
|
+
fromAddress: vaultSettings.vaultAllocator,
|
|
43503
|
+
toAddress: vaultSettings.vaultAddress
|
|
43504
|
+
});
|
|
43505
|
+
const commonAdapter = new CommonAdapter({
|
|
43506
|
+
id: "flash_loan_init" /* FLASH_LOAN */,
|
|
43507
|
+
vaultAddress: vaultSettings.vaultAddress,
|
|
43508
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
43509
|
+
manager: vaultSettings.manager,
|
|
43510
|
+
asset: USDCToken.address
|
|
43511
|
+
});
|
|
43512
|
+
vaultSettings.adapters.push(
|
|
43513
|
+
// TODO: generalize the ids
|
|
43514
|
+
{ id: "vesu_usdc_strk", adapter: vesuModifyPositionAdapter },
|
|
43515
|
+
// Used to track swapped funds in vaultAllocator
|
|
43516
|
+
{ id: "avnu_strk_xstrk", adapter: avnuAdapter },
|
|
43517
|
+
{ id: "hyper_xstrk", adapter: svkTrovesAdapter },
|
|
43518
|
+
{ id: "usdc_transfer", adapter: usdcTransferAdapter }
|
|
42117
43519
|
);
|
|
42118
|
-
|
|
42119
|
-
|
|
42120
|
-
}
|
|
42121
|
-
return Web3Number.fromWei(maxTVLValue, token.decimals);
|
|
42122
|
-
}
|
|
42123
|
-
function createHyperLSTSettings(lstSymbol, underlyingSymbol) {
|
|
42124
|
-
const depositToken = Global.getDefaultTokens().find(
|
|
42125
|
-
(token) => token.symbol === lstSymbol
|
|
43520
|
+
vaultSettings.leafAdapters.push(
|
|
43521
|
+
() => vesuModifyPositionAdapter.getDepositLeaf()
|
|
42126
43522
|
);
|
|
42127
|
-
|
|
42128
|
-
|
|
42129
|
-
|
|
42130
|
-
|
|
42131
|
-
|
|
42132
|
-
|
|
42133
|
-
|
|
42134
|
-
|
|
42135
|
-
|
|
42136
|
-
|
|
42137
|
-
|
|
42138
|
-
|
|
42139
|
-
|
|
42140
|
-
|
|
42141
|
-
|
|
42142
|
-
|
|
42143
|
-
|
|
42144
|
-
|
|
42145
|
-
"To acquire the LST, please visit",
|
|
42146
|
-
" ",
|
|
42147
|
-
/* @__PURE__ */ jsx5("a", { href: "https://app.endur.fi", target: "_blank", rel: "noopener noreferrer", children: "endur.fi" })
|
|
42148
|
-
] }),
|
|
42149
|
-
type: "info"
|
|
42150
|
-
},
|
|
42151
|
-
{
|
|
42152
|
-
tab: "deposit",
|
|
42153
|
-
text: "It may take up to one week for your deposit to appreciate in value. This delay occurs because the LST price is sourced from DEXes and liquidity is usually rebased once a week.",
|
|
42154
|
-
type: "info"
|
|
42155
|
-
}
|
|
42156
|
-
]
|
|
42157
|
-
};
|
|
43523
|
+
vaultSettings.leafAdapters.push(
|
|
43524
|
+
() => vesuModifyPositionAdapter.getWithdrawLeaf()
|
|
43525
|
+
);
|
|
43526
|
+
vaultSettings.leafAdapters.push(() => avnuAdapter.getDepositLeaf());
|
|
43527
|
+
vaultSettings.leafAdapters.push(() => avnuAdapter.getWithdrawLeaf());
|
|
43528
|
+
vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getDepositLeaf());
|
|
43529
|
+
vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getWithdrawLeaf());
|
|
43530
|
+
vaultSettings.leafAdapters.push(
|
|
43531
|
+
commonAdapter.getApproveAdapter(
|
|
43532
|
+
USDCToken.address,
|
|
43533
|
+
vaultSettings.vaultAddress,
|
|
43534
|
+
"approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */
|
|
43535
|
+
).bind(commonAdapter)
|
|
43536
|
+
);
|
|
43537
|
+
vaultSettings.leafAdapters.push(
|
|
43538
|
+
commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter)
|
|
43539
|
+
);
|
|
43540
|
+
return vaultSettings;
|
|
42158
43541
|
}
|
|
42159
|
-
var
|
|
42160
|
-
|
|
42161
|
-
|
|
42162
|
-
|
|
42163
|
-
|
|
42164
|
-
|
|
42165
|
-
|
|
42166
|
-
|
|
42167
|
-
|
|
42168
|
-
|
|
42169
|
-
|
|
42170
|
-
|
|
42171
|
-
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
|
|
42176
|
-
|
|
42177
|
-
|
|
42178
|
-
|
|
42179
|
-
|
|
42180
|
-
|
|
42181
|
-
|
|
42182
|
-
|
|
42183
|
-
|
|
42184
|
-
|
|
42185
|
-
|
|
43542
|
+
var usdcBoostedSettings = {
|
|
43543
|
+
vaultAddress: ContractAddr.from(
|
|
43544
|
+
"0xcdb0e3b2e076a2cdc4ee958b726b47c066239ef91c5ac80c94cf814147b84"
|
|
43545
|
+
),
|
|
43546
|
+
manager: ContractAddr.from(
|
|
43547
|
+
"0x72eea9bac9fa8cfffda637d3b990851446860c6fd8987d6cb50e659b01ee50f"
|
|
43548
|
+
),
|
|
43549
|
+
vaultAllocator: ContractAddr.from(
|
|
43550
|
+
"0x6d3101cff7f821412a99ebe23bb31a1950f93276285102eb4313e3601f5f927"
|
|
43551
|
+
),
|
|
43552
|
+
redeemRequestNFT: ContractAddr.from(
|
|
43553
|
+
"0x47dcc6889ca8db4e9eea8f55421e10f8ce7e356ccb45260a1c49a76f733c309"
|
|
43554
|
+
),
|
|
43555
|
+
// TODO: not applicable in our case -> remove later ( make it optional if needed)
|
|
43556
|
+
aumOracle: ContractAddr.from("0x0"),
|
|
43557
|
+
leafAdapters: [],
|
|
43558
|
+
adapters: [],
|
|
43559
|
+
// Calc using the maxLTV / targetLTV (0.5)
|
|
43560
|
+
targetHealthFactor: 1.32,
|
|
43561
|
+
// Calc using the maxLTV / maxAcceptableLTV (0.55)
|
|
43562
|
+
minHealthFactor: 1.2,
|
|
43563
|
+
vesuPoolId: VesuPools.Prime,
|
|
43564
|
+
collateralToken: Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
43565
|
+
debtToken: Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
|
|
43566
|
+
maxLTV: 0.66,
|
|
43567
|
+
targetLTV: 0.5,
|
|
43568
|
+
hyperxSTRKVaultAddress: ContractAddr.from(
|
|
43569
|
+
"0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"
|
|
43570
|
+
)
|
|
42186
43571
|
};
|
|
42187
|
-
function
|
|
43572
|
+
function getStrategySettings2(settings) {
|
|
43573
|
+
const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
|
|
43574
|
+
const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
42188
43575
|
return {
|
|
42189
|
-
id:
|
|
42190
|
-
name:
|
|
42191
|
-
description:
|
|
43576
|
+
id: "usdc_boosted",
|
|
43577
|
+
name: "USDC Boosted",
|
|
43578
|
+
description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield",
|
|
42192
43579
|
address: settings.vaultAddress,
|
|
42193
|
-
launchBlock:
|
|
42194
|
-
type: "
|
|
43580
|
+
launchBlock: 8742931,
|
|
43581
|
+
type: "ERC4626",
|
|
42195
43582
|
vaultType: {
|
|
42196
|
-
|
|
42197
|
-
|
|
43583
|
+
// TODO: can change as per need
|
|
43584
|
+
type: "Meta Vault" /* META_VAULT */,
|
|
43585
|
+
description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield"
|
|
42198
43586
|
},
|
|
42199
|
-
depositTokens: [
|
|
42200
|
-
additionalInfo:
|
|
43587
|
+
depositTokens: [USDCToken],
|
|
43588
|
+
additionalInfo: getUSDCBoostedSettings(settings),
|
|
43589
|
+
// TODO: config lateron
|
|
42201
43590
|
risk: {
|
|
42202
|
-
riskFactor:
|
|
42203
|
-
netRisk:
|
|
42204
|
-
notARisks:
|
|
43591
|
+
riskFactor: [],
|
|
43592
|
+
netRisk: 0,
|
|
43593
|
+
notARisks: []
|
|
42205
43594
|
},
|
|
42206
|
-
|
|
42207
|
-
protocols: [Protocols.ENDUR, Protocols.VESU],
|
|
43595
|
+
protocols: [Protocols.VESU, Protocols.TROVES],
|
|
42208
43596
|
curator: {
|
|
42209
43597
|
name: "Unwrap Labs",
|
|
42210
43598
|
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
42211
43599
|
},
|
|
42212
|
-
settings:
|
|
43600
|
+
settings: {
|
|
43601
|
+
maxTVL: Web3Number.fromWei(0, USDCToken.decimals),
|
|
43602
|
+
isPaused: false,
|
|
43603
|
+
isAudited: false,
|
|
43604
|
+
isInstantWithdrawal: false,
|
|
43605
|
+
hideHarvestInfo: true,
|
|
43606
|
+
quoteToken: USDCToken,
|
|
43607
|
+
alerts: [
|
|
43608
|
+
{
|
|
43609
|
+
tab: "withdraw",
|
|
43610
|
+
text: "On withdrawal, you will receive an NFT representing your withdrawal request. The funds will be automatically sent to your wallet (NFT owner) in 1-2 hours. You can monitor the status in transactions tab.",
|
|
43611
|
+
type: "info"
|
|
43612
|
+
}
|
|
43613
|
+
]
|
|
43614
|
+
},
|
|
42213
43615
|
contractDetails: getContractDetails(settings),
|
|
42214
|
-
|
|
42215
|
-
|
|
42216
|
-
|
|
42217
|
-
|
|
42218
|
-
|
|
42219
|
-
|
|
42220
|
-
|
|
42221
|
-
|
|
42222
|
-
|
|
42223
|
-
|
|
42224
|
-
|
|
42225
|
-
|
|
42226
|
-
|
|
42227
|
-
|
|
42228
|
-
|
|
43616
|
+
// TODO: config later
|
|
43617
|
+
faqs: [],
|
|
43618
|
+
investmentSteps: [
|
|
43619
|
+
"Deposit USDC into the vault",
|
|
43620
|
+
"USDC is supplied as collateral on Vesu, STRK is borrowed",
|
|
43621
|
+
"Borrowed STRK is swapped to xSTRK via Avnu",
|
|
43622
|
+
"xSTRK is deposited into the Hyper-xSTRK vault for additional yield",
|
|
43623
|
+
"On withdrawal, the pipeline reverses to return USDC"
|
|
43624
|
+
],
|
|
43625
|
+
// TODO: config later
|
|
43626
|
+
tags: ["Meta Vaults" /* META_VAULT */],
|
|
43627
|
+
security: {
|
|
43628
|
+
auditStatus: "Audited" /* AUDITED */,
|
|
43629
|
+
sourceCode: {
|
|
43630
|
+
type: "Closed Source" /* CLOSED_SOURCE */,
|
|
43631
|
+
contractLink: "https://github.com/trovesfi/troves-contracts"
|
|
43632
|
+
},
|
|
43633
|
+
accessControl: {
|
|
43634
|
+
type: "Standard Account" /* STANDARD_ACCOUNT */,
|
|
43635
|
+
addresses: [ContractAddr.from("0x0")],
|
|
43636
|
+
timeLock: "2 Days"
|
|
43637
|
+
}
|
|
43638
|
+
},
|
|
43639
|
+
redemptionInfo: {
|
|
43640
|
+
instantWithdrawalVault: "No" /* NO */,
|
|
43641
|
+
redemptionsInfo: [
|
|
43642
|
+
{
|
|
43643
|
+
title: "Typical Duration",
|
|
43644
|
+
description: "1-2 hours"
|
|
43645
|
+
}
|
|
43646
|
+
],
|
|
43647
|
+
alerts: [
|
|
43648
|
+
{
|
|
43649
|
+
type: "info",
|
|
43650
|
+
text: "Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
|
|
43651
|
+
tab: "withdraw"
|
|
43652
|
+
}
|
|
43653
|
+
]
|
|
43654
|
+
},
|
|
43655
|
+
usualTimeToEarnings: null,
|
|
43656
|
+
usualTimeToEarningsDescription: null
|
|
42229
43657
|
};
|
|
42230
43658
|
}
|
|
42231
|
-
var
|
|
42232
|
-
getStrategySettings("xSTRK", "STRK", hyperxSTRK, false, true),
|
|
42233
|
-
getStrategySettings("xWBTC", "WBTC", hyperxWBTC, false, false),
|
|
42234
|
-
getStrategySettings("xtBTC", "tBTC", hyperxtBTC, false, false),
|
|
42235
|
-
getStrategySettings("xsBTC", "solvBTC", hyperxsBTC, false, false),
|
|
42236
|
-
getStrategySettings("xLBTC", "LBTC", hyperxLBTC, false, false),
|
|
42237
|
-
getStrategySettings("mRe7BTC", "mRe7BTC", hypermRe7BTC, false, false),
|
|
42238
|
-
getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
|
|
42239
|
-
];
|
|
43659
|
+
var USDCBoostedStrategies = [getStrategySettings2(usdcBoostedSettings)];
|
|
42240
43660
|
|
|
42241
43661
|
// src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts
|
|
42242
43662
|
function ceilBtc(v, precision) {
|
|
@@ -45621,7 +47041,7 @@ var ExtendedSVKVesuStateManager = class {
|
|
|
45621
47041
|
};
|
|
45622
47042
|
|
|
45623
47043
|
// src/strategies/vesu-extended-strategy/services/executionService.ts
|
|
45624
|
-
import { uint256 as
|
|
47044
|
+
import { uint256 as uint25624 } from "starknet";
|
|
45625
47045
|
|
|
45626
47046
|
// src/strategies/vesu-extended-strategy/types/transaction-metadata.ts
|
|
45627
47047
|
var CycleType = /* @__PURE__ */ ((CycleType2) => {
|
|
@@ -46553,7 +47973,7 @@ var _ExecutionService = class _ExecutionService {
|
|
|
46553
47973
|
const extendedContract = extendedAdapter.config.extendedContract;
|
|
46554
47974
|
const vaultId = extendedAdapter.config.vaultIdExtended;
|
|
46555
47975
|
const salt = Math.floor(Math.random() * 10 ** usdcToken.decimals);
|
|
46556
|
-
const uint256Amount =
|
|
47976
|
+
const uint256Amount = uint25624.bnToUint256(amount.toWei());
|
|
46557
47977
|
const approveCall = {
|
|
46558
47978
|
contractAddress: usdcToken.address.address,
|
|
46559
47979
|
entrypoint: "approve",
|
|
@@ -48509,7 +49929,7 @@ var PricerRedis = class extends Pricer {
|
|
|
48509
49929
|
};
|
|
48510
49930
|
|
|
48511
49931
|
// src/node/deployer.ts
|
|
48512
|
-
import
|
|
49932
|
+
import assert3 from "assert";
|
|
48513
49933
|
import { Deployer as SnDeployer, TransactionExecutionStatus, constants as constants3, extractContractHashes, json, num as num14 } from "starknet";
|
|
48514
49934
|
import { readFileSync as readFileSync2, existsSync, writeFileSync as writeFileSync2 } from "fs";
|
|
48515
49935
|
|
|
@@ -48778,8 +50198,8 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
|
|
|
48778
50198
|
classHash,
|
|
48779
50199
|
constructorCalldata: constructorData
|
|
48780
50200
|
}, acc.address);
|
|
48781
|
-
|
|
48782
|
-
|
|
50201
|
+
assert3(calls.length == 1, `Expected exactly one call, got ${calls.length}`);
|
|
50202
|
+
assert3(addresses.length == 1, `Expected exactly one address, got ${addresses.length}`);
|
|
48783
50203
|
result.push({
|
|
48784
50204
|
contract_name,
|
|
48785
50205
|
package_name,
|
|
@@ -48792,7 +50212,7 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
|
|
|
48792
50212
|
}
|
|
48793
50213
|
async function executeDeployCalls(contractsInfo, acc, provider2) {
|
|
48794
50214
|
for (let contractInfo of contractsInfo) {
|
|
48795
|
-
|
|
50215
|
+
assert3(num14.toHexString(contractInfo.call.contractAddress) == num14.toHexString(constants3.UDC.ADDRESS), "Must be pointed at UDC address");
|
|
48796
50216
|
}
|
|
48797
50217
|
const allCalls = contractsInfo.map((info) => info.call);
|
|
48798
50218
|
await executeTransactions(allCalls, acc, provider2, `Deploying contracts: ${contractsInfo.map((info) => info.contract_name).join(", ")}`);
|
|
@@ -48936,6 +50356,7 @@ export {
|
|
|
48936
50356
|
SIMPLE_SANITIZER,
|
|
48937
50357
|
SIMPLE_SANITIZER_V2,
|
|
48938
50358
|
SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
|
|
50359
|
+
SVK_SIMPLE_SANITIZER,
|
|
48939
50360
|
SenseiStrategies,
|
|
48940
50361
|
SenseiVault,
|
|
48941
50362
|
SolveBudget,
|
|
@@ -48955,6 +50376,8 @@ export {
|
|
|
48955
50376
|
TokenTransferAdapter,
|
|
48956
50377
|
UNIVERSAL_ADAPTERS,
|
|
48957
50378
|
UNIVERSAL_MANAGE_IDS,
|
|
50379
|
+
USDCBoostedStrategies,
|
|
50380
|
+
USDCBoostedStrategy,
|
|
48958
50381
|
UniversalLstMultiplierStrategy,
|
|
48959
50382
|
UniversalStrategies,
|
|
48960
50383
|
UniversalStrategy,
|