@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
|
@@ -3926,8 +3926,8 @@ var strkfarm_risk_engine = (() => {
|
|
|
3926
3926
|
}
|
|
3927
3927
|
}
|
|
3928
3928
|
exports.output = output2;
|
|
3929
|
-
var
|
|
3930
|
-
exports.default =
|
|
3929
|
+
var assert6 = { number: number2, bool, bytes: bytes2, hash: hash3, exists: exists2, output: output2 };
|
|
3930
|
+
exports.default = assert6;
|
|
3931
3931
|
}
|
|
3932
3932
|
});
|
|
3933
3933
|
|
|
@@ -12885,8 +12885,8 @@ ${r2}}` : "}", l2;
|
|
|
12885
12885
|
}
|
|
12886
12886
|
}
|
|
12887
12887
|
exports.output = output2;
|
|
12888
|
-
var
|
|
12889
|
-
exports.default =
|
|
12888
|
+
var assert6 = { number: number2, bool, bytes: bytes2, hash: hash3, exists: exists2, output: output2 };
|
|
12889
|
+
exports.default = assert6;
|
|
12890
12890
|
}
|
|
12891
12891
|
});
|
|
12892
12892
|
|
|
@@ -17772,7 +17772,7 @@ ${r2}}` : "}", l2;
|
|
|
17772
17772
|
return BlockTag22;
|
|
17773
17773
|
})(BlockTag2 || {});
|
|
17774
17774
|
var import_starknet_types_07 = require_cjs();
|
|
17775
|
-
function
|
|
17775
|
+
function assert6(condition, message) {
|
|
17776
17776
|
if (!condition) {
|
|
17777
17777
|
throw new Error(message || "Assertion failure");
|
|
17778
17778
|
}
|
|
@@ -17800,7 +17800,7 @@ ${r2}}` : "}", l2;
|
|
|
17800
17800
|
toHexString: () => toHexString2,
|
|
17801
17801
|
toStorageKey: () => toStorageKey2
|
|
17802
17802
|
});
|
|
17803
|
-
var
|
|
17803
|
+
var import_utils164 = require_utils();
|
|
17804
17804
|
function isHex3(hex) {
|
|
17805
17805
|
return /^0x[0-9a-f]*$/i.test(hex);
|
|
17806
17806
|
}
|
|
@@ -17828,7 +17828,7 @@ ${r2}}` : "}", l2;
|
|
|
17828
17828
|
const inputBigInt = BigInt(input);
|
|
17829
17829
|
const lowerBoundBigInt = BigInt(lowerBound);
|
|
17830
17830
|
const upperBoundBigInt = BigInt(upperBound);
|
|
17831
|
-
|
|
17831
|
+
assert6(
|
|
17832
17832
|
inputBigInt >= lowerBoundBigInt && inputBigInt <= upperBoundBigInt,
|
|
17833
17833
|
`Message not signable, ${messageSuffix}.`
|
|
17834
17834
|
);
|
|
@@ -17873,7 +17873,7 @@ ${r2}}` : "}", l2;
|
|
|
17873
17873
|
if (adaptedValue.length % 2 !== 0) {
|
|
17874
17874
|
adaptedValue = `0${adaptedValue}`;
|
|
17875
17875
|
}
|
|
17876
|
-
return (0,
|
|
17876
|
+
return (0, import_utils164.hexToBytes)(adaptedValue);
|
|
17877
17877
|
}
|
|
17878
17878
|
function addPercent2(number22, percent) {
|
|
17879
17879
|
const bigIntNum = BigInt(number22);
|
|
@@ -17892,14 +17892,14 @@ ${r2}}` : "}", l2;
|
|
|
17892
17892
|
keccakBn: () => keccakBn2,
|
|
17893
17893
|
starknetKeccak: () => starknetKeccak2
|
|
17894
17894
|
});
|
|
17895
|
-
var
|
|
17895
|
+
var import_starknet42 = require_lib2();
|
|
17896
17896
|
function keccakBn2(value) {
|
|
17897
17897
|
const hexWithoutPrefix = removeHexPrefix2(toHex3(BigInt(value)));
|
|
17898
17898
|
const evenHex = hexWithoutPrefix.length % 2 === 0 ? hexWithoutPrefix : `0${hexWithoutPrefix}`;
|
|
17899
|
-
return addHexPrefix2((0,
|
|
17899
|
+
return addHexPrefix2((0, import_starknet42.keccak)(hexToBytes5(addHexPrefix2(evenHex))).toString(16));
|
|
17900
17900
|
}
|
|
17901
17901
|
function keccakHex2(str) {
|
|
17902
|
-
return addHexPrefix2((0,
|
|
17902
|
+
return addHexPrefix2((0, import_starknet42.keccak)(utf8ToArray2(str)).toString(16));
|
|
17903
17903
|
}
|
|
17904
17904
|
function starknetKeccak2(str) {
|
|
17905
17905
|
const hash3 = BigInt(keccakHex2(str));
|
|
@@ -19261,37 +19261,37 @@ ${r2}}` : "}", l2;
|
|
|
19261
19261
|
}
|
|
19262
19262
|
}
|
|
19263
19263
|
var validateFelt2 = (parameter, input) => {
|
|
19264
|
-
|
|
19264
|
+
assert6(
|
|
19265
19265
|
isString3(parameter) || isNumber4(parameter) || isBigInt2(parameter),
|
|
19266
19266
|
`Validate: arg ${input.name} should be a felt typed as (String, Number or BigInt)`
|
|
19267
19267
|
);
|
|
19268
19268
|
if (isString3(parameter) && !isHex3(parameter))
|
|
19269
19269
|
return;
|
|
19270
19270
|
const param = BigInt(parameter.toString(10));
|
|
19271
|
-
|
|
19271
|
+
assert6(
|
|
19272
19272
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1266
|
|
19273
19273
|
param >= 0n && param <= 2n ** 252n - 1n,
|
|
19274
19274
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
|
|
19275
19275
|
);
|
|
19276
19276
|
};
|
|
19277
19277
|
var validateBytes31 = (parameter, input) => {
|
|
19278
|
-
|
|
19279
|
-
|
|
19278
|
+
assert6(isString3(parameter), `Validate: arg ${input.name} should be a string.`);
|
|
19279
|
+
assert6(
|
|
19280
19280
|
parameter.length < 32,
|
|
19281
19281
|
`Validate: arg ${input.name} cairo typed ${input.type} should be a string of less than 32 characters.`
|
|
19282
19282
|
);
|
|
19283
19283
|
};
|
|
19284
19284
|
var validateByteArray = (parameter, input) => {
|
|
19285
|
-
|
|
19285
|
+
assert6(isString3(parameter), `Validate: arg ${input.name} should be a string.`);
|
|
19286
19286
|
};
|
|
19287
19287
|
var validateUint2 = (parameter, input) => {
|
|
19288
19288
|
if (isNumber4(parameter)) {
|
|
19289
|
-
|
|
19289
|
+
assert6(
|
|
19290
19290
|
parameter <= Number.MAX_SAFE_INTEGER,
|
|
19291
19291
|
`Validation: Parameter is to large to be typed as Number use (BigInt or String)`
|
|
19292
19292
|
);
|
|
19293
19293
|
}
|
|
19294
|
-
|
|
19294
|
+
assert6(
|
|
19295
19295
|
isString3(parameter) || isNumber4(parameter) || isBigInt2(parameter) || typeof parameter === "object" && "low" in parameter && "high" in parameter || typeof parameter === "object" && ["limb0", "limb1", "limb2", "limb3"].every((key) => key in parameter),
|
|
19296
19296
|
`Validate: arg ${input.name} of cairo type ${input.type} should be type (String, Number or BigInt), but is ${typeof parameter} ${parameter}.`
|
|
19297
19297
|
);
|
|
@@ -19308,60 +19308,60 @@ ${r2}}` : "}", l2;
|
|
|
19308
19308
|
}
|
|
19309
19309
|
switch (input.type) {
|
|
19310
19310
|
case "core::integer::u8":
|
|
19311
|
-
|
|
19311
|
+
assert6(
|
|
19312
19312
|
param >= 0n && param <= 255n,
|
|
19313
19313
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0 - 255]`
|
|
19314
19314
|
);
|
|
19315
19315
|
break;
|
|
19316
19316
|
case "core::integer::u16":
|
|
19317
|
-
|
|
19317
|
+
assert6(
|
|
19318
19318
|
param >= 0n && param <= 65535n,
|
|
19319
19319
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 65535]`
|
|
19320
19320
|
);
|
|
19321
19321
|
break;
|
|
19322
19322
|
case "core::integer::u32":
|
|
19323
|
-
|
|
19323
|
+
assert6(
|
|
19324
19324
|
param >= 0n && param <= 4294967295n,
|
|
19325
19325
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 4294967295]`
|
|
19326
19326
|
);
|
|
19327
19327
|
break;
|
|
19328
19328
|
case "core::integer::u64":
|
|
19329
|
-
|
|
19329
|
+
assert6(
|
|
19330
19330
|
param >= 0n && param <= 2n ** 64n - 1n,
|
|
19331
19331
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^64-1]`
|
|
19332
19332
|
);
|
|
19333
19333
|
break;
|
|
19334
19334
|
case "core::integer::u128":
|
|
19335
|
-
|
|
19335
|
+
assert6(
|
|
19336
19336
|
param >= 0n && param <= 2n ** 128n - 1n,
|
|
19337
19337
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^128-1]`
|
|
19338
19338
|
);
|
|
19339
19339
|
break;
|
|
19340
19340
|
case "core::integer::u256":
|
|
19341
|
-
|
|
19341
|
+
assert6(
|
|
19342
19342
|
param >= 0n && param <= 2n ** 256n - 1n,
|
|
19343
19343
|
`Validate: arg ${input.name} is ${input.type} 0 - 2^256-1`
|
|
19344
19344
|
);
|
|
19345
19345
|
break;
|
|
19346
19346
|
case "core::integer::u512":
|
|
19347
|
-
|
|
19347
|
+
assert6(CairoUint5122.is(param), `Validate: arg ${input.name} is ${input.type} 0 - 2^512-1`);
|
|
19348
19348
|
break;
|
|
19349
19349
|
case "core::starknet::class_hash::ClassHash":
|
|
19350
|
-
|
|
19350
|
+
assert6(
|
|
19351
19351
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1670
|
|
19352
19352
|
param >= 0n && param <= 2n ** 252n - 1n,
|
|
19353
19353
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
|
|
19354
19354
|
);
|
|
19355
19355
|
break;
|
|
19356
19356
|
case "core::starknet::contract_address::ContractAddress":
|
|
19357
|
-
|
|
19357
|
+
assert6(
|
|
19358
19358
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1245
|
|
19359
19359
|
param >= 0n && param <= 2n ** 252n - 1n,
|
|
19360
19360
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^252-1]`
|
|
19361
19361
|
);
|
|
19362
19362
|
break;
|
|
19363
19363
|
case "core::starknet::secp256k1::Secp256k1Point": {
|
|
19364
|
-
|
|
19364
|
+
assert6(
|
|
19365
19365
|
param >= 0n && param <= 2n ** 512n - 1n,
|
|
19366
19366
|
`Validate: arg ${input.name} must be ${input.type} : a 512 bits number.`
|
|
19367
19367
|
);
|
|
@@ -19372,7 +19372,7 @@ ${r2}}` : "}", l2;
|
|
|
19372
19372
|
}
|
|
19373
19373
|
};
|
|
19374
19374
|
var validateBool2 = (parameter, input) => {
|
|
19375
|
-
|
|
19375
|
+
assert6(
|
|
19376
19376
|
isBoolean3(parameter),
|
|
19377
19377
|
`Validate: arg ${input.name} of cairo type ${input.type} should be type (Boolean)`
|
|
19378
19378
|
);
|
|
@@ -19383,31 +19383,31 @@ ${r2}}` : "}", l2;
|
|
|
19383
19383
|
return;
|
|
19384
19384
|
}
|
|
19385
19385
|
if (input.type === "core::starknet::eth_address::EthAddress") {
|
|
19386
|
-
|
|
19386
|
+
assert6(
|
|
19387
19387
|
typeof parameter !== "object",
|
|
19388
19388
|
`EthAddress type is waiting a BigNumberish. Got ${parameter}`
|
|
19389
19389
|
);
|
|
19390
19390
|
const param = BigInt(parameter.toString(10));
|
|
19391
|
-
|
|
19391
|
+
assert6(
|
|
19392
19392
|
// from : https://github.com/starkware-libs/starknet-specs/blob/29bab650be6b1847c92d4461d4c33008b5e50b1a/api/starknet_api_openrpc.json#L1259
|
|
19393
19393
|
param >= 0n && param <= 2n ** 160n - 1n,
|
|
19394
19394
|
`Validate: arg ${input.name} cairo typed ${input.type} should be in range [0, 2^160-1]`
|
|
19395
19395
|
);
|
|
19396
19396
|
return;
|
|
19397
19397
|
}
|
|
19398
|
-
|
|
19398
|
+
assert6(
|
|
19399
19399
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
19400
19400
|
`Validate: arg ${input.name} is cairo type struct (${input.type}), and should be defined as js object (not array)`
|
|
19401
19401
|
);
|
|
19402
19402
|
structs[input.type].members.forEach(({ name }) => {
|
|
19403
|
-
|
|
19403
|
+
assert6(
|
|
19404
19404
|
Object.keys(parameter).includes(name),
|
|
19405
19405
|
`Validate: arg ${input.name} should have a property ${name}`
|
|
19406
19406
|
);
|
|
19407
19407
|
});
|
|
19408
19408
|
};
|
|
19409
19409
|
var validateEnum2 = (parameter, input) => {
|
|
19410
|
-
|
|
19410
|
+
assert6(
|
|
19411
19411
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
19412
19412
|
`Validate: arg ${input.name} is cairo type Enum (${input.type}), and should be defined as js object (not array)`
|
|
19413
19413
|
);
|
|
@@ -19427,7 +19427,7 @@ ${r2}}` : "}", l2;
|
|
|
19427
19427
|
);
|
|
19428
19428
|
};
|
|
19429
19429
|
var validateTuple2 = (parameter, input) => {
|
|
19430
|
-
|
|
19430
|
+
assert6(
|
|
19431
19431
|
typeof parameter === "object" && !Array.isArray(parameter),
|
|
19432
19432
|
`Validate: arg ${input.name} should be a tuple (defined as object)`
|
|
19433
19433
|
);
|
|
@@ -19437,7 +19437,7 @@ ${r2}}` : "}", l2;
|
|
|
19437
19437
|
if (isTypeFelt2(baseType) && isLongText2(parameter)) {
|
|
19438
19438
|
return;
|
|
19439
19439
|
}
|
|
19440
|
-
|
|
19440
|
+
assert6(Array.isArray(parameter), `Validate: arg ${input.name} should be an Array`);
|
|
19441
19441
|
switch (true) {
|
|
19442
19442
|
case isTypeFelt2(baseType):
|
|
19443
19443
|
parameter.forEach((param) => validateFelt2(param, input));
|
|
@@ -19472,14 +19472,14 @@ ${r2}}` : "}", l2;
|
|
|
19472
19472
|
};
|
|
19473
19473
|
var validateNonZero2 = (parameter, input) => {
|
|
19474
19474
|
const baseType = getArrayType2(input.type);
|
|
19475
|
-
|
|
19475
|
+
assert6(
|
|
19476
19476
|
isTypeUint2(baseType) && baseType !== CairoUint5122.abiSelector || isTypeFelt2(baseType),
|
|
19477
19477
|
`Validate: ${input.name} type is not authorized for NonZero type.`
|
|
19478
19478
|
);
|
|
19479
19479
|
switch (true) {
|
|
19480
19480
|
case isTypeFelt2(baseType):
|
|
19481
19481
|
validateFelt2(parameter, input);
|
|
19482
|
-
|
|
19482
|
+
assert6(
|
|
19483
19483
|
BigInt(parameter.toString(10)) > 0,
|
|
19484
19484
|
"Validate: value 0 is not authorized in NonZero felt252 type."
|
|
19485
19485
|
);
|
|
@@ -19488,13 +19488,13 @@ ${r2}}` : "}", l2;
|
|
|
19488
19488
|
validateUint2(parameter, { name: "", type: baseType });
|
|
19489
19489
|
switch (input.type) {
|
|
19490
19490
|
case "core::integer::u256":
|
|
19491
|
-
|
|
19491
|
+
assert6(
|
|
19492
19492
|
new CairoUint2562(parameter).toBigInt() > 0,
|
|
19493
19493
|
"Validate: value 0 is not authorized in NonZero uint256 type."
|
|
19494
19494
|
);
|
|
19495
19495
|
break;
|
|
19496
19496
|
default:
|
|
19497
|
-
|
|
19497
|
+
assert6(
|
|
19498
19498
|
toBigInt5(parameter) > 0,
|
|
19499
19499
|
"Validate: value 0 is not authorized in NonZero uint type."
|
|
19500
19500
|
);
|
|
@@ -19575,7 +19575,7 @@ ${r2}}` : "}", l2;
|
|
|
19575
19575
|
const isView = abi.stateMutability === "view" || abi.state_mutability === "view";
|
|
19576
19576
|
return type === "INVOKE" ? !isView : isView;
|
|
19577
19577
|
}).map((abi) => abi.name);
|
|
19578
|
-
|
|
19578
|
+
assert6(
|
|
19579
19579
|
invocableFunctionNames.includes(method),
|
|
19580
19580
|
`${type === "INVOKE" ? "invocable" : "viewable"} method not found in abi`
|
|
19581
19581
|
);
|
|
@@ -20272,7 +20272,7 @@ ${r2}}` : "}", l2;
|
|
|
20272
20272
|
toTransactionVersion: () => toTransactionVersion2,
|
|
20273
20273
|
v3Details: () => v3Details2
|
|
20274
20274
|
});
|
|
20275
|
-
var
|
|
20275
|
+
var import_starknet43 = require_lib2();
|
|
20276
20276
|
var import_pako2 = require_pako();
|
|
20277
20277
|
function compressProgram2(jsonProgram) {
|
|
20278
20278
|
const stringified = isString3(jsonProgram) ? jsonProgram : stringify22(jsonProgram);
|
|
@@ -20286,8 +20286,8 @@ ${r2}}` : "}", l2;
|
|
|
20286
20286
|
return parse22(decompressed);
|
|
20287
20287
|
}
|
|
20288
20288
|
function randomAddress2() {
|
|
20289
|
-
const randomKeyPair =
|
|
20290
|
-
return (0,
|
|
20289
|
+
const randomKeyPair = import_starknet43.utils.randomPrivateKey();
|
|
20290
|
+
return (0, import_starknet43.getStarkKey)(randomKeyPair);
|
|
20291
20291
|
}
|
|
20292
20292
|
function makeAddress(input) {
|
|
20293
20293
|
return addHexPrefix2(input).toLowerCase();
|
|
@@ -20419,7 +20419,7 @@ ${r2}}` : "}", l2;
|
|
|
20419
20419
|
function validateAndParseEthAddress2(address) {
|
|
20420
20420
|
assertInRange2(address, ZERO2, 2n ** 160n - 1n, "Ethereum Address ");
|
|
20421
20421
|
const result2 = addHexPrefix2(removeHexPrefix2(toHex3(address)).padStart(40, "0"));
|
|
20422
|
-
|
|
20422
|
+
assert6(Boolean(result2.match(/^(0x)?[0-9a-f]{40}$/)), "Invalid Ethereum Address Format");
|
|
20423
20423
|
return result2;
|
|
20424
20424
|
}
|
|
20425
20425
|
var import_fetch_cookie = __toESM2(require_cjs2());
|
|
@@ -21978,7 +21978,7 @@ ${r2}}` : "}", l2;
|
|
|
21978
21978
|
}
|
|
21979
21979
|
async getL1MessageHash(l2TxHash) {
|
|
21980
21980
|
const transaction2 = await this.channel.getTransactionByHash(l2TxHash);
|
|
21981
|
-
|
|
21981
|
+
assert6(transaction2.type === "L1_HANDLER", "This L2 transaction is not a L1 message.");
|
|
21982
21982
|
const { calldata, contract_address, entry_point_selector, nonce } = transaction2;
|
|
21983
21983
|
const params = [
|
|
21984
21984
|
calldata[0],
|
|
@@ -22773,7 +22773,7 @@ ${r2}}` : "}", l2;
|
|
|
22773
22773
|
};
|
|
22774
22774
|
function assertRange2(data, type, { min, max }) {
|
|
22775
22775
|
const value = BigInt(data);
|
|
22776
|
-
|
|
22776
|
+
assert6(value >= min && value <= max, `${value} (${type}) is out of bounds [${min}, ${max}]`);
|
|
22777
22777
|
}
|
|
22778
22778
|
function identifyRevision2({ types: types2, domain }) {
|
|
22779
22779
|
if (revisionConfiguration2[import_starknet_types_07.TypedDataRevision.ACTIVE].domain in types2 && domain.revision === import_starknet_types_07.TypedDataRevision.ACTIVE)
|
|
@@ -22968,7 +22968,7 @@ ${r2}}` : "}", l2;
|
|
|
22968
22968
|
}
|
|
22969
22969
|
case "bool": {
|
|
22970
22970
|
if (revision === import_starknet_types_07.TypedDataRevision.ACTIVE) {
|
|
22971
|
-
|
|
22971
|
+
assert6(typeof data === "boolean", `Type mismatch for ${type} ${data}`);
|
|
22972
22972
|
}
|
|
22973
22973
|
return [type, getHex2(data)];
|
|
22974
22974
|
}
|
|
@@ -23337,7 +23337,7 @@ ${r2}}` : "}", l2;
|
|
|
23337
23337
|
}
|
|
23338
23338
|
while (!abiEvent.name) {
|
|
23339
23339
|
const hashName = recEvent.keys.shift();
|
|
23340
|
-
|
|
23340
|
+
assert6(!!hashName, 'Not enough data in "key" property of this event.');
|
|
23341
23341
|
abiEvent = abiEvent[hashName];
|
|
23342
23342
|
}
|
|
23343
23343
|
const parsedEvent = {};
|
|
@@ -24349,7 +24349,7 @@ ${r2}}` : "}", l2;
|
|
|
24349
24349
|
formatResponse = void 0,
|
|
24350
24350
|
blockIdentifier = void 0
|
|
24351
24351
|
} = {}) {
|
|
24352
|
-
|
|
24352
|
+
assert6(this.address !== null, "contract is not connected to an address");
|
|
24353
24353
|
const calldata = getCalldata(args, () => {
|
|
24354
24354
|
if (parseRequest) {
|
|
24355
24355
|
this.callData.validate("CALL", method, args);
|
|
@@ -24376,7 +24376,7 @@ ${r2}}` : "}", l2;
|
|
|
24376
24376
|
});
|
|
24377
24377
|
}
|
|
24378
24378
|
invoke(method, args = [], { parseRequest = true, maxFee, nonce, signature } = {}) {
|
|
24379
|
-
|
|
24379
|
+
assert6(this.address !== null, "contract is not connected to an address");
|
|
24380
24380
|
const calldata = getCalldata(args, () => {
|
|
24381
24381
|
if (parseRequest) {
|
|
24382
24382
|
this.callData.validate("INVOKE", method, args);
|
|
@@ -24410,7 +24410,7 @@ ${r2}}` : "}", l2;
|
|
|
24410
24410
|
);
|
|
24411
24411
|
}
|
|
24412
24412
|
async estimate(method, args = []) {
|
|
24413
|
-
|
|
24413
|
+
assert6(this.address !== null, "contract is not connected to an address");
|
|
24414
24414
|
if (!getCalldata(args, () => false)) {
|
|
24415
24415
|
this.callData.validate("INVOKE", method, args);
|
|
24416
24416
|
}
|
|
@@ -24508,7 +24508,7 @@ ${r2}}` : "}", l2;
|
|
|
24508
24508
|
constructorCalldata,
|
|
24509
24509
|
salt: options.addressSalt
|
|
24510
24510
|
});
|
|
24511
|
-
|
|
24511
|
+
assert6(Boolean(contract_address), "Deployment of the contract failed");
|
|
24512
24512
|
const contractInstance = new Contract3(
|
|
24513
24513
|
this.compiledContract.abi,
|
|
24514
24514
|
contract_address,
|
|
@@ -28729,6 +28729,7 @@ ${r2}}` : "}", l2;
|
|
|
28729
28729
|
SIMPLE_SANITIZER: () => SIMPLE_SANITIZER,
|
|
28730
28730
|
SIMPLE_SANITIZER_V2: () => SIMPLE_SANITIZER_V2,
|
|
28731
28731
|
SIMPLE_SANITIZER_VESU_V1_DELEGATIONS: () => SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
|
|
28732
|
+
SVK_SIMPLE_SANITIZER: () => SVK_SIMPLE_SANITIZER,
|
|
28732
28733
|
SenseiStrategies: () => SenseiStrategies,
|
|
28733
28734
|
SenseiVault: () => SenseiVault,
|
|
28734
28735
|
SolveBudget: () => SolveBudget,
|
|
@@ -28745,6 +28746,8 @@ ${r2}}` : "}", l2;
|
|
|
28745
28746
|
TokenTransferAdapter: () => TokenTransferAdapter,
|
|
28746
28747
|
UNIVERSAL_ADAPTERS: () => UNIVERSAL_ADAPTERS,
|
|
28747
28748
|
UNIVERSAL_MANAGE_IDS: () => UNIVERSAL_MANAGE_IDS,
|
|
28749
|
+
USDCBoostedStrategies: () => USDCBoostedStrategies,
|
|
28750
|
+
USDCBoostedStrategy: () => USDCBoostedStrategy,
|
|
28748
28751
|
UniversalLstMultiplierStrategy: () => UniversalLstMultiplierStrategy,
|
|
28749
28752
|
UniversalStrategies: () => UniversalStrategies,
|
|
28750
28753
|
UniversalStrategy: () => UniversalStrategy,
|
|
@@ -109341,6 +109344,7 @@ spurious results.`);
|
|
|
109341
109344
|
|
|
109342
109345
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
109343
109346
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
109347
|
+
var SVK_SIMPLE_SANITIZER = ContractAddr.from("0x03dcde04343257c3ce14574676cb9c5b2eda16e332c1b8caf5dc4c95ac568d2f");
|
|
109344
109348
|
var EXTENDED_SANITIZER = ContractAddr.from("0x65891708362b24dcf4c40c8e218cce6e82d1d6b3a3404c9ab00a48f08e2c110");
|
|
109345
109349
|
var AVNU_LEGACY_SANITIZER = ContractAddr.from("0x0656fBE853f116DD53956176a553eDe8fE65632252f8aceB50C1B9B6c8237309");
|
|
109346
109350
|
var SIMPLE_SANITIZER_V2 = ContractAddr.from("0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2");
|
|
@@ -123194,7 +123198,14 @@ spurious results.`);
|
|
|
123194
123198
|
}
|
|
123195
123199
|
const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
|
|
123196
123200
|
helperOutput
|
|
123197
|
-
);
|
|
123201
|
+
).minus(state.currentDebt);
|
|
123202
|
+
if (normalizedDebtAmount.lessThan(0)) {
|
|
123203
|
+
logger2.warn(`VesuModifyPositionAdapter: deposit debt delta is negative (${normalizedDebtAmount.toNumber()}), clamping to zero`);
|
|
123204
|
+
return {
|
|
123205
|
+
collateral: this._toSigned(collateralToAdd, false),
|
|
123206
|
+
debt: this._toSigned(Web3Number.fromWei(0, this.config.debt.decimals), false)
|
|
123207
|
+
};
|
|
123208
|
+
}
|
|
123198
123209
|
return {
|
|
123199
123210
|
collateral: this._toSigned(collateralToAdd, false),
|
|
123200
123211
|
debt: this._toSigned(normalizedDebtAmount, false)
|
|
@@ -123212,8 +123223,8 @@ spurious results.`);
|
|
|
123212
123223
|
state.debtPrice,
|
|
123213
123224
|
this.config.debt
|
|
123214
123225
|
);
|
|
123215
|
-
if (!helperOutput || helperOutput.
|
|
123216
|
-
throw new Error(`Failed to calculate
|
|
123226
|
+
if (!helperOutput || helperOutput.lessThan(0)) {
|
|
123227
|
+
throw new Error(`Failed to calculate max debt amount for withdraw: ${helperOutput?.toNumber()}`);
|
|
123217
123228
|
}
|
|
123218
123229
|
const normalizedDebtAmount = this._normalizeDebtAmountFromHelper(
|
|
123219
123230
|
helperOutput
|
|
@@ -123410,6 +123421,24 @@ spurious results.`);
|
|
|
123410
123421
|
this._prepareVesuAdapter();
|
|
123411
123422
|
return this._vesuAdapter.getHealthFactor();
|
|
123412
123423
|
}
|
|
123424
|
+
/**
|
|
123425
|
+
* Simulates a deposit of `depositAmount` collateral and returns how much
|
|
123426
|
+
* debt (STRK) would be incrementally borrowed to reach the target LTV.
|
|
123427
|
+
* Used upstream to size the AVNU swap call in the same transaction batch.
|
|
123428
|
+
*/
|
|
123429
|
+
async getExpectedDepositDebtDelta(depositAmount) {
|
|
123430
|
+
const defaults2 = await this._buildDefaultDepositDeltas({ amount: depositAmount });
|
|
123431
|
+
return defaults2.debt.amount;
|
|
123432
|
+
}
|
|
123433
|
+
/**
|
|
123434
|
+
* Simulates a withdrawal of `withdrawAmount` collateral and returns the
|
|
123435
|
+
* incremental debt delta needed to keep the target health factor.
|
|
123436
|
+
* Positive means borrow, negative means repay.
|
|
123437
|
+
*/
|
|
123438
|
+
async getExpectedWithdrawDebtDelta(withdrawAmount) {
|
|
123439
|
+
const defaults2 = await this._buildDefaultWithdrawDeltas({ amount: withdrawAmount });
|
|
123440
|
+
return defaults2.debt.amount;
|
|
123441
|
+
}
|
|
123413
123442
|
};
|
|
123414
123443
|
|
|
123415
123444
|
// src/strategies/universal-adapters/extended-adapter.ts
|
|
@@ -123469,6 +123498,25 @@ spurious results.`);
|
|
|
123469
123498
|
return { success: false, data: [] };
|
|
123470
123499
|
}
|
|
123471
123500
|
}
|
|
123501
|
+
/** Account funding payment history via `GET /api/v1/account/funding-payments` (USDC amounts). */
|
|
123502
|
+
async getFundingPayments(side, startTime, limit) {
|
|
123503
|
+
try {
|
|
123504
|
+
const response = await this.client.getUserFundingPayments(
|
|
123505
|
+
this.config.extendedMarketName,
|
|
123506
|
+
side,
|
|
123507
|
+
startTime ?? Date.now() - 30 * 24 * 60 * 60 * 1e3,
|
|
123508
|
+
limit ?? 200
|
|
123509
|
+
);
|
|
123510
|
+
if (response.status !== "OK") {
|
|
123511
|
+
logger2.error("error getting funding payments", response.data);
|
|
123512
|
+
return { success: false, data: [] };
|
|
123513
|
+
}
|
|
123514
|
+
return { success: true, data: response.data ?? [] };
|
|
123515
|
+
} catch (err2) {
|
|
123516
|
+
logger2.error("error getting funding payments", err2);
|
|
123517
|
+
return { success: false, data: [] };
|
|
123518
|
+
}
|
|
123519
|
+
}
|
|
123472
123520
|
async getPosition(supportedPosition) {
|
|
123473
123521
|
const holdings = await this.getExtendedDepositAmount();
|
|
123474
123522
|
if (!holdings) {
|
|
@@ -126102,6 +126150,760 @@ spurious results.`);
|
|
|
126102
126150
|
}
|
|
126103
126151
|
];
|
|
126104
126152
|
|
|
126153
|
+
// src/data/redeem-request-nft.abi.json
|
|
126154
|
+
var redeem_request_nft_abi_default = [
|
|
126155
|
+
{
|
|
126156
|
+
type: "impl",
|
|
126157
|
+
name: "RedeemRequestImpl",
|
|
126158
|
+
interface_name: "vault::redeem_request::interface::IRedeemRequest"
|
|
126159
|
+
},
|
|
126160
|
+
{
|
|
126161
|
+
type: "struct",
|
|
126162
|
+
name: "core::integer::u256",
|
|
126163
|
+
members: [
|
|
126164
|
+
{
|
|
126165
|
+
name: "low",
|
|
126166
|
+
type: "core::integer::u128"
|
|
126167
|
+
},
|
|
126168
|
+
{
|
|
126169
|
+
name: "high",
|
|
126170
|
+
type: "core::integer::u128"
|
|
126171
|
+
}
|
|
126172
|
+
]
|
|
126173
|
+
},
|
|
126174
|
+
{
|
|
126175
|
+
type: "struct",
|
|
126176
|
+
name: "vault::redeem_request::interface::RedeemRequestInfo",
|
|
126177
|
+
members: [
|
|
126178
|
+
{
|
|
126179
|
+
name: "epoch",
|
|
126180
|
+
type: "core::integer::u256"
|
|
126181
|
+
},
|
|
126182
|
+
{
|
|
126183
|
+
name: "nominal",
|
|
126184
|
+
type: "core::integer::u256"
|
|
126185
|
+
}
|
|
126186
|
+
]
|
|
126187
|
+
},
|
|
126188
|
+
{
|
|
126189
|
+
type: "interface",
|
|
126190
|
+
name: "vault::redeem_request::interface::IRedeemRequest",
|
|
126191
|
+
items: [
|
|
126192
|
+
{
|
|
126193
|
+
type: "function",
|
|
126194
|
+
name: "vault",
|
|
126195
|
+
inputs: [],
|
|
126196
|
+
outputs: [
|
|
126197
|
+
{
|
|
126198
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126199
|
+
}
|
|
126200
|
+
],
|
|
126201
|
+
state_mutability: "view"
|
|
126202
|
+
},
|
|
126203
|
+
{
|
|
126204
|
+
type: "function",
|
|
126205
|
+
name: "id_to_info",
|
|
126206
|
+
inputs: [
|
|
126207
|
+
{
|
|
126208
|
+
name: "id",
|
|
126209
|
+
type: "core::integer::u256"
|
|
126210
|
+
}
|
|
126211
|
+
],
|
|
126212
|
+
outputs: [
|
|
126213
|
+
{
|
|
126214
|
+
type: "vault::redeem_request::interface::RedeemRequestInfo"
|
|
126215
|
+
}
|
|
126216
|
+
],
|
|
126217
|
+
state_mutability: "view"
|
|
126218
|
+
},
|
|
126219
|
+
{
|
|
126220
|
+
type: "function",
|
|
126221
|
+
name: "id_len",
|
|
126222
|
+
inputs: [],
|
|
126223
|
+
outputs: [
|
|
126224
|
+
{
|
|
126225
|
+
type: "core::integer::u256"
|
|
126226
|
+
}
|
|
126227
|
+
],
|
|
126228
|
+
state_mutability: "view"
|
|
126229
|
+
},
|
|
126230
|
+
{
|
|
126231
|
+
type: "function",
|
|
126232
|
+
name: "mint",
|
|
126233
|
+
inputs: [
|
|
126234
|
+
{
|
|
126235
|
+
name: "to",
|
|
126236
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126237
|
+
},
|
|
126238
|
+
{
|
|
126239
|
+
name: "redeem_request_info",
|
|
126240
|
+
type: "vault::redeem_request::interface::RedeemRequestInfo"
|
|
126241
|
+
}
|
|
126242
|
+
],
|
|
126243
|
+
outputs: [
|
|
126244
|
+
{
|
|
126245
|
+
type: "core::integer::u256"
|
|
126246
|
+
}
|
|
126247
|
+
],
|
|
126248
|
+
state_mutability: "external"
|
|
126249
|
+
},
|
|
126250
|
+
{
|
|
126251
|
+
type: "function",
|
|
126252
|
+
name: "burn",
|
|
126253
|
+
inputs: [
|
|
126254
|
+
{
|
|
126255
|
+
name: "id",
|
|
126256
|
+
type: "core::integer::u256"
|
|
126257
|
+
}
|
|
126258
|
+
],
|
|
126259
|
+
outputs: [],
|
|
126260
|
+
state_mutability: "external"
|
|
126261
|
+
}
|
|
126262
|
+
]
|
|
126263
|
+
},
|
|
126264
|
+
{
|
|
126265
|
+
type: "impl",
|
|
126266
|
+
name: "UpgradeableImpl",
|
|
126267
|
+
interface_name: "openzeppelin_interfaces::upgrades::IUpgradeable"
|
|
126268
|
+
},
|
|
126269
|
+
{
|
|
126270
|
+
type: "interface",
|
|
126271
|
+
name: "openzeppelin_interfaces::upgrades::IUpgradeable",
|
|
126272
|
+
items: [
|
|
126273
|
+
{
|
|
126274
|
+
type: "function",
|
|
126275
|
+
name: "upgrade",
|
|
126276
|
+
inputs: [
|
|
126277
|
+
{
|
|
126278
|
+
name: "new_class_hash",
|
|
126279
|
+
type: "core::starknet::class_hash::ClassHash"
|
|
126280
|
+
}
|
|
126281
|
+
],
|
|
126282
|
+
outputs: [],
|
|
126283
|
+
state_mutability: "external"
|
|
126284
|
+
}
|
|
126285
|
+
]
|
|
126286
|
+
},
|
|
126287
|
+
{
|
|
126288
|
+
type: "impl",
|
|
126289
|
+
name: "ERC721MixinImpl",
|
|
126290
|
+
interface_name: "openzeppelin_interfaces::token::erc721::ERC721ABI"
|
|
126291
|
+
},
|
|
126292
|
+
{
|
|
126293
|
+
type: "struct",
|
|
126294
|
+
name: "core::array::Span::<core::felt252>",
|
|
126295
|
+
members: [
|
|
126296
|
+
{
|
|
126297
|
+
name: "snapshot",
|
|
126298
|
+
type: "@core::array::Array::<core::felt252>"
|
|
126299
|
+
}
|
|
126300
|
+
]
|
|
126301
|
+
},
|
|
126302
|
+
{
|
|
126303
|
+
type: "enum",
|
|
126304
|
+
name: "core::bool",
|
|
126305
|
+
variants: [
|
|
126306
|
+
{
|
|
126307
|
+
name: "False",
|
|
126308
|
+
type: "()"
|
|
126309
|
+
},
|
|
126310
|
+
{
|
|
126311
|
+
name: "True",
|
|
126312
|
+
type: "()"
|
|
126313
|
+
}
|
|
126314
|
+
]
|
|
126315
|
+
},
|
|
126316
|
+
{
|
|
126317
|
+
type: "struct",
|
|
126318
|
+
name: "core::byte_array::ByteArray",
|
|
126319
|
+
members: [
|
|
126320
|
+
{
|
|
126321
|
+
name: "data",
|
|
126322
|
+
type: "core::array::Array::<core::bytes_31::bytes31>"
|
|
126323
|
+
},
|
|
126324
|
+
{
|
|
126325
|
+
name: "pending_word",
|
|
126326
|
+
type: "core::felt252"
|
|
126327
|
+
},
|
|
126328
|
+
{
|
|
126329
|
+
name: "pending_word_len",
|
|
126330
|
+
type: "core::integer::u32"
|
|
126331
|
+
}
|
|
126332
|
+
]
|
|
126333
|
+
},
|
|
126334
|
+
{
|
|
126335
|
+
type: "interface",
|
|
126336
|
+
name: "openzeppelin_interfaces::token::erc721::ERC721ABI",
|
|
126337
|
+
items: [
|
|
126338
|
+
{
|
|
126339
|
+
type: "function",
|
|
126340
|
+
name: "balance_of",
|
|
126341
|
+
inputs: [
|
|
126342
|
+
{
|
|
126343
|
+
name: "account",
|
|
126344
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126345
|
+
}
|
|
126346
|
+
],
|
|
126347
|
+
outputs: [
|
|
126348
|
+
{
|
|
126349
|
+
type: "core::integer::u256"
|
|
126350
|
+
}
|
|
126351
|
+
],
|
|
126352
|
+
state_mutability: "view"
|
|
126353
|
+
},
|
|
126354
|
+
{
|
|
126355
|
+
type: "function",
|
|
126356
|
+
name: "owner_of",
|
|
126357
|
+
inputs: [
|
|
126358
|
+
{
|
|
126359
|
+
name: "token_id",
|
|
126360
|
+
type: "core::integer::u256"
|
|
126361
|
+
}
|
|
126362
|
+
],
|
|
126363
|
+
outputs: [
|
|
126364
|
+
{
|
|
126365
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126366
|
+
}
|
|
126367
|
+
],
|
|
126368
|
+
state_mutability: "view"
|
|
126369
|
+
},
|
|
126370
|
+
{
|
|
126371
|
+
type: "function",
|
|
126372
|
+
name: "safe_transfer_from",
|
|
126373
|
+
inputs: [
|
|
126374
|
+
{
|
|
126375
|
+
name: "from",
|
|
126376
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126377
|
+
},
|
|
126378
|
+
{
|
|
126379
|
+
name: "to",
|
|
126380
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126381
|
+
},
|
|
126382
|
+
{
|
|
126383
|
+
name: "token_id",
|
|
126384
|
+
type: "core::integer::u256"
|
|
126385
|
+
},
|
|
126386
|
+
{
|
|
126387
|
+
name: "data",
|
|
126388
|
+
type: "core::array::Span::<core::felt252>"
|
|
126389
|
+
}
|
|
126390
|
+
],
|
|
126391
|
+
outputs: [],
|
|
126392
|
+
state_mutability: "external"
|
|
126393
|
+
},
|
|
126394
|
+
{
|
|
126395
|
+
type: "function",
|
|
126396
|
+
name: "transfer_from",
|
|
126397
|
+
inputs: [
|
|
126398
|
+
{
|
|
126399
|
+
name: "from",
|
|
126400
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126401
|
+
},
|
|
126402
|
+
{
|
|
126403
|
+
name: "to",
|
|
126404
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126405
|
+
},
|
|
126406
|
+
{
|
|
126407
|
+
name: "token_id",
|
|
126408
|
+
type: "core::integer::u256"
|
|
126409
|
+
}
|
|
126410
|
+
],
|
|
126411
|
+
outputs: [],
|
|
126412
|
+
state_mutability: "external"
|
|
126413
|
+
},
|
|
126414
|
+
{
|
|
126415
|
+
type: "function",
|
|
126416
|
+
name: "approve",
|
|
126417
|
+
inputs: [
|
|
126418
|
+
{
|
|
126419
|
+
name: "to",
|
|
126420
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126421
|
+
},
|
|
126422
|
+
{
|
|
126423
|
+
name: "token_id",
|
|
126424
|
+
type: "core::integer::u256"
|
|
126425
|
+
}
|
|
126426
|
+
],
|
|
126427
|
+
outputs: [],
|
|
126428
|
+
state_mutability: "external"
|
|
126429
|
+
},
|
|
126430
|
+
{
|
|
126431
|
+
type: "function",
|
|
126432
|
+
name: "set_approval_for_all",
|
|
126433
|
+
inputs: [
|
|
126434
|
+
{
|
|
126435
|
+
name: "operator",
|
|
126436
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126437
|
+
},
|
|
126438
|
+
{
|
|
126439
|
+
name: "approved",
|
|
126440
|
+
type: "core::bool"
|
|
126441
|
+
}
|
|
126442
|
+
],
|
|
126443
|
+
outputs: [],
|
|
126444
|
+
state_mutability: "external"
|
|
126445
|
+
},
|
|
126446
|
+
{
|
|
126447
|
+
type: "function",
|
|
126448
|
+
name: "get_approved",
|
|
126449
|
+
inputs: [
|
|
126450
|
+
{
|
|
126451
|
+
name: "token_id",
|
|
126452
|
+
type: "core::integer::u256"
|
|
126453
|
+
}
|
|
126454
|
+
],
|
|
126455
|
+
outputs: [
|
|
126456
|
+
{
|
|
126457
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126458
|
+
}
|
|
126459
|
+
],
|
|
126460
|
+
state_mutability: "view"
|
|
126461
|
+
},
|
|
126462
|
+
{
|
|
126463
|
+
type: "function",
|
|
126464
|
+
name: "is_approved_for_all",
|
|
126465
|
+
inputs: [
|
|
126466
|
+
{
|
|
126467
|
+
name: "owner",
|
|
126468
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126469
|
+
},
|
|
126470
|
+
{
|
|
126471
|
+
name: "operator",
|
|
126472
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126473
|
+
}
|
|
126474
|
+
],
|
|
126475
|
+
outputs: [
|
|
126476
|
+
{
|
|
126477
|
+
type: "core::bool"
|
|
126478
|
+
}
|
|
126479
|
+
],
|
|
126480
|
+
state_mutability: "view"
|
|
126481
|
+
},
|
|
126482
|
+
{
|
|
126483
|
+
type: "function",
|
|
126484
|
+
name: "supports_interface",
|
|
126485
|
+
inputs: [
|
|
126486
|
+
{
|
|
126487
|
+
name: "interface_id",
|
|
126488
|
+
type: "core::felt252"
|
|
126489
|
+
}
|
|
126490
|
+
],
|
|
126491
|
+
outputs: [
|
|
126492
|
+
{
|
|
126493
|
+
type: "core::bool"
|
|
126494
|
+
}
|
|
126495
|
+
],
|
|
126496
|
+
state_mutability: "view"
|
|
126497
|
+
},
|
|
126498
|
+
{
|
|
126499
|
+
type: "function",
|
|
126500
|
+
name: "name",
|
|
126501
|
+
inputs: [],
|
|
126502
|
+
outputs: [
|
|
126503
|
+
{
|
|
126504
|
+
type: "core::byte_array::ByteArray"
|
|
126505
|
+
}
|
|
126506
|
+
],
|
|
126507
|
+
state_mutability: "view"
|
|
126508
|
+
},
|
|
126509
|
+
{
|
|
126510
|
+
type: "function",
|
|
126511
|
+
name: "symbol",
|
|
126512
|
+
inputs: [],
|
|
126513
|
+
outputs: [
|
|
126514
|
+
{
|
|
126515
|
+
type: "core::byte_array::ByteArray"
|
|
126516
|
+
}
|
|
126517
|
+
],
|
|
126518
|
+
state_mutability: "view"
|
|
126519
|
+
},
|
|
126520
|
+
{
|
|
126521
|
+
type: "function",
|
|
126522
|
+
name: "token_uri",
|
|
126523
|
+
inputs: [
|
|
126524
|
+
{
|
|
126525
|
+
name: "token_id",
|
|
126526
|
+
type: "core::integer::u256"
|
|
126527
|
+
}
|
|
126528
|
+
],
|
|
126529
|
+
outputs: [
|
|
126530
|
+
{
|
|
126531
|
+
type: "core::byte_array::ByteArray"
|
|
126532
|
+
}
|
|
126533
|
+
],
|
|
126534
|
+
state_mutability: "view"
|
|
126535
|
+
},
|
|
126536
|
+
{
|
|
126537
|
+
type: "function",
|
|
126538
|
+
name: "balanceOf",
|
|
126539
|
+
inputs: [
|
|
126540
|
+
{
|
|
126541
|
+
name: "account",
|
|
126542
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126543
|
+
}
|
|
126544
|
+
],
|
|
126545
|
+
outputs: [
|
|
126546
|
+
{
|
|
126547
|
+
type: "core::integer::u256"
|
|
126548
|
+
}
|
|
126549
|
+
],
|
|
126550
|
+
state_mutability: "view"
|
|
126551
|
+
},
|
|
126552
|
+
{
|
|
126553
|
+
type: "function",
|
|
126554
|
+
name: "ownerOf",
|
|
126555
|
+
inputs: [
|
|
126556
|
+
{
|
|
126557
|
+
name: "tokenId",
|
|
126558
|
+
type: "core::integer::u256"
|
|
126559
|
+
}
|
|
126560
|
+
],
|
|
126561
|
+
outputs: [
|
|
126562
|
+
{
|
|
126563
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126564
|
+
}
|
|
126565
|
+
],
|
|
126566
|
+
state_mutability: "view"
|
|
126567
|
+
},
|
|
126568
|
+
{
|
|
126569
|
+
type: "function",
|
|
126570
|
+
name: "safeTransferFrom",
|
|
126571
|
+
inputs: [
|
|
126572
|
+
{
|
|
126573
|
+
name: "from",
|
|
126574
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126575
|
+
},
|
|
126576
|
+
{
|
|
126577
|
+
name: "to",
|
|
126578
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126579
|
+
},
|
|
126580
|
+
{
|
|
126581
|
+
name: "tokenId",
|
|
126582
|
+
type: "core::integer::u256"
|
|
126583
|
+
},
|
|
126584
|
+
{
|
|
126585
|
+
name: "data",
|
|
126586
|
+
type: "core::array::Span::<core::felt252>"
|
|
126587
|
+
}
|
|
126588
|
+
],
|
|
126589
|
+
outputs: [],
|
|
126590
|
+
state_mutability: "external"
|
|
126591
|
+
},
|
|
126592
|
+
{
|
|
126593
|
+
type: "function",
|
|
126594
|
+
name: "transferFrom",
|
|
126595
|
+
inputs: [
|
|
126596
|
+
{
|
|
126597
|
+
name: "from",
|
|
126598
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126599
|
+
},
|
|
126600
|
+
{
|
|
126601
|
+
name: "to",
|
|
126602
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126603
|
+
},
|
|
126604
|
+
{
|
|
126605
|
+
name: "tokenId",
|
|
126606
|
+
type: "core::integer::u256"
|
|
126607
|
+
}
|
|
126608
|
+
],
|
|
126609
|
+
outputs: [],
|
|
126610
|
+
state_mutability: "external"
|
|
126611
|
+
},
|
|
126612
|
+
{
|
|
126613
|
+
type: "function",
|
|
126614
|
+
name: "setApprovalForAll",
|
|
126615
|
+
inputs: [
|
|
126616
|
+
{
|
|
126617
|
+
name: "operator",
|
|
126618
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126619
|
+
},
|
|
126620
|
+
{
|
|
126621
|
+
name: "approved",
|
|
126622
|
+
type: "core::bool"
|
|
126623
|
+
}
|
|
126624
|
+
],
|
|
126625
|
+
outputs: [],
|
|
126626
|
+
state_mutability: "external"
|
|
126627
|
+
},
|
|
126628
|
+
{
|
|
126629
|
+
type: "function",
|
|
126630
|
+
name: "getApproved",
|
|
126631
|
+
inputs: [
|
|
126632
|
+
{
|
|
126633
|
+
name: "tokenId",
|
|
126634
|
+
type: "core::integer::u256"
|
|
126635
|
+
}
|
|
126636
|
+
],
|
|
126637
|
+
outputs: [
|
|
126638
|
+
{
|
|
126639
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126640
|
+
}
|
|
126641
|
+
],
|
|
126642
|
+
state_mutability: "view"
|
|
126643
|
+
},
|
|
126644
|
+
{
|
|
126645
|
+
type: "function",
|
|
126646
|
+
name: "isApprovedForAll",
|
|
126647
|
+
inputs: [
|
|
126648
|
+
{
|
|
126649
|
+
name: "owner",
|
|
126650
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126651
|
+
},
|
|
126652
|
+
{
|
|
126653
|
+
name: "operator",
|
|
126654
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126655
|
+
}
|
|
126656
|
+
],
|
|
126657
|
+
outputs: [
|
|
126658
|
+
{
|
|
126659
|
+
type: "core::bool"
|
|
126660
|
+
}
|
|
126661
|
+
],
|
|
126662
|
+
state_mutability: "view"
|
|
126663
|
+
},
|
|
126664
|
+
{
|
|
126665
|
+
type: "function",
|
|
126666
|
+
name: "tokenURI",
|
|
126667
|
+
inputs: [
|
|
126668
|
+
{
|
|
126669
|
+
name: "tokenId",
|
|
126670
|
+
type: "core::integer::u256"
|
|
126671
|
+
}
|
|
126672
|
+
],
|
|
126673
|
+
outputs: [
|
|
126674
|
+
{
|
|
126675
|
+
type: "core::byte_array::ByteArray"
|
|
126676
|
+
}
|
|
126677
|
+
],
|
|
126678
|
+
state_mutability: "view"
|
|
126679
|
+
}
|
|
126680
|
+
]
|
|
126681
|
+
},
|
|
126682
|
+
{
|
|
126683
|
+
type: "impl",
|
|
126684
|
+
name: "ERC721EnumerableImpl",
|
|
126685
|
+
interface_name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable"
|
|
126686
|
+
},
|
|
126687
|
+
{
|
|
126688
|
+
type: "interface",
|
|
126689
|
+
name: "openzeppelin_interfaces::token::erc721::IERC721Enumerable",
|
|
126690
|
+
items: [
|
|
126691
|
+
{
|
|
126692
|
+
type: "function",
|
|
126693
|
+
name: "total_supply",
|
|
126694
|
+
inputs: [],
|
|
126695
|
+
outputs: [
|
|
126696
|
+
{
|
|
126697
|
+
type: "core::integer::u256"
|
|
126698
|
+
}
|
|
126699
|
+
],
|
|
126700
|
+
state_mutability: "view"
|
|
126701
|
+
},
|
|
126702
|
+
{
|
|
126703
|
+
type: "function",
|
|
126704
|
+
name: "token_by_index",
|
|
126705
|
+
inputs: [
|
|
126706
|
+
{
|
|
126707
|
+
name: "index",
|
|
126708
|
+
type: "core::integer::u256"
|
|
126709
|
+
}
|
|
126710
|
+
],
|
|
126711
|
+
outputs: [
|
|
126712
|
+
{
|
|
126713
|
+
type: "core::integer::u256"
|
|
126714
|
+
}
|
|
126715
|
+
],
|
|
126716
|
+
state_mutability: "view"
|
|
126717
|
+
},
|
|
126718
|
+
{
|
|
126719
|
+
type: "function",
|
|
126720
|
+
name: "token_of_owner_by_index",
|
|
126721
|
+
inputs: [
|
|
126722
|
+
{
|
|
126723
|
+
name: "owner",
|
|
126724
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126725
|
+
},
|
|
126726
|
+
{
|
|
126727
|
+
name: "index",
|
|
126728
|
+
type: "core::integer::u256"
|
|
126729
|
+
}
|
|
126730
|
+
],
|
|
126731
|
+
outputs: [
|
|
126732
|
+
{
|
|
126733
|
+
type: "core::integer::u256"
|
|
126734
|
+
}
|
|
126735
|
+
],
|
|
126736
|
+
state_mutability: "view"
|
|
126737
|
+
}
|
|
126738
|
+
]
|
|
126739
|
+
},
|
|
126740
|
+
{
|
|
126741
|
+
type: "constructor",
|
|
126742
|
+
name: "constructor",
|
|
126743
|
+
inputs: [
|
|
126744
|
+
{
|
|
126745
|
+
name: "owner",
|
|
126746
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126747
|
+
},
|
|
126748
|
+
{
|
|
126749
|
+
name: "vault",
|
|
126750
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
126751
|
+
}
|
|
126752
|
+
]
|
|
126753
|
+
},
|
|
126754
|
+
{
|
|
126755
|
+
type: "event",
|
|
126756
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
|
|
126757
|
+
kind: "struct",
|
|
126758
|
+
members: [
|
|
126759
|
+
{
|
|
126760
|
+
name: "from",
|
|
126761
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126762
|
+
kind: "key"
|
|
126763
|
+
},
|
|
126764
|
+
{
|
|
126765
|
+
name: "to",
|
|
126766
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126767
|
+
kind: "key"
|
|
126768
|
+
},
|
|
126769
|
+
{
|
|
126770
|
+
name: "token_id",
|
|
126771
|
+
type: "core::integer::u256",
|
|
126772
|
+
kind: "key"
|
|
126773
|
+
}
|
|
126774
|
+
]
|
|
126775
|
+
},
|
|
126776
|
+
{
|
|
126777
|
+
type: "event",
|
|
126778
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
|
|
126779
|
+
kind: "struct",
|
|
126780
|
+
members: [
|
|
126781
|
+
{
|
|
126782
|
+
name: "owner",
|
|
126783
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126784
|
+
kind: "key"
|
|
126785
|
+
},
|
|
126786
|
+
{
|
|
126787
|
+
name: "approved",
|
|
126788
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126789
|
+
kind: "key"
|
|
126790
|
+
},
|
|
126791
|
+
{
|
|
126792
|
+
name: "token_id",
|
|
126793
|
+
type: "core::integer::u256",
|
|
126794
|
+
kind: "key"
|
|
126795
|
+
}
|
|
126796
|
+
]
|
|
126797
|
+
},
|
|
126798
|
+
{
|
|
126799
|
+
type: "event",
|
|
126800
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
|
|
126801
|
+
kind: "struct",
|
|
126802
|
+
members: [
|
|
126803
|
+
{
|
|
126804
|
+
name: "owner",
|
|
126805
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126806
|
+
kind: "key"
|
|
126807
|
+
},
|
|
126808
|
+
{
|
|
126809
|
+
name: "operator",
|
|
126810
|
+
type: "core::starknet::contract_address::ContractAddress",
|
|
126811
|
+
kind: "key"
|
|
126812
|
+
},
|
|
126813
|
+
{
|
|
126814
|
+
name: "approved",
|
|
126815
|
+
type: "core::bool",
|
|
126816
|
+
kind: "data"
|
|
126817
|
+
}
|
|
126818
|
+
]
|
|
126819
|
+
},
|
|
126820
|
+
{
|
|
126821
|
+
type: "event",
|
|
126822
|
+
name: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
|
|
126823
|
+
kind: "enum",
|
|
126824
|
+
variants: [
|
|
126825
|
+
{
|
|
126826
|
+
name: "Transfer",
|
|
126827
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Transfer",
|
|
126828
|
+
kind: "nested"
|
|
126829
|
+
},
|
|
126830
|
+
{
|
|
126831
|
+
name: "Approval",
|
|
126832
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Approval",
|
|
126833
|
+
kind: "nested"
|
|
126834
|
+
},
|
|
126835
|
+
{
|
|
126836
|
+
name: "ApprovalForAll",
|
|
126837
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll",
|
|
126838
|
+
kind: "nested"
|
|
126839
|
+
}
|
|
126840
|
+
]
|
|
126841
|
+
},
|
|
126842
|
+
{
|
|
126843
|
+
type: "event",
|
|
126844
|
+
name: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
|
|
126845
|
+
kind: "enum",
|
|
126846
|
+
variants: []
|
|
126847
|
+
},
|
|
126848
|
+
{
|
|
126849
|
+
type: "event",
|
|
126850
|
+
name: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
126851
|
+
kind: "enum",
|
|
126852
|
+
variants: []
|
|
126853
|
+
},
|
|
126854
|
+
{
|
|
126855
|
+
type: "event",
|
|
126856
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
126857
|
+
kind: "struct",
|
|
126858
|
+
members: [
|
|
126859
|
+
{
|
|
126860
|
+
name: "class_hash",
|
|
126861
|
+
type: "core::starknet::class_hash::ClassHash",
|
|
126862
|
+
kind: "data"
|
|
126863
|
+
}
|
|
126864
|
+
]
|
|
126865
|
+
},
|
|
126866
|
+
{
|
|
126867
|
+
type: "event",
|
|
126868
|
+
name: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
126869
|
+
kind: "enum",
|
|
126870
|
+
variants: [
|
|
126871
|
+
{
|
|
126872
|
+
name: "Upgraded",
|
|
126873
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Upgraded",
|
|
126874
|
+
kind: "nested"
|
|
126875
|
+
}
|
|
126876
|
+
]
|
|
126877
|
+
},
|
|
126878
|
+
{
|
|
126879
|
+
type: "event",
|
|
126880
|
+
name: "vault::redeem_request::redeem_request::RedeemRequest::Event",
|
|
126881
|
+
kind: "enum",
|
|
126882
|
+
variants: [
|
|
126883
|
+
{
|
|
126884
|
+
name: "ERC721Event",
|
|
126885
|
+
type: "openzeppelin_token::erc721::erc721::ERC721Component::Event",
|
|
126886
|
+
kind: "flat"
|
|
126887
|
+
},
|
|
126888
|
+
{
|
|
126889
|
+
name: "ERC721EnumerableEvent",
|
|
126890
|
+
type: "openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event",
|
|
126891
|
+
kind: "flat"
|
|
126892
|
+
},
|
|
126893
|
+
{
|
|
126894
|
+
name: "SRC5Event",
|
|
126895
|
+
type: "openzeppelin_introspection::src5::SRC5Component::Event",
|
|
126896
|
+
kind: "flat"
|
|
126897
|
+
},
|
|
126898
|
+
{
|
|
126899
|
+
name: "UpgradeableEvent",
|
|
126900
|
+
type: "openzeppelin_upgrades::upgradeable::UpgradeableComponent::Event",
|
|
126901
|
+
kind: "flat"
|
|
126902
|
+
}
|
|
126903
|
+
]
|
|
126904
|
+
}
|
|
126905
|
+
];
|
|
126906
|
+
|
|
126105
126907
|
// src/strategies/universal-adapters/svk-troves-adapter.ts
|
|
126106
126908
|
var DEFAULT_TROVES_STRATEGIES_API = "https://app.troves.fi/api/strategies";
|
|
126107
126909
|
function parseTrovesApyField(raw) {
|
|
@@ -126215,6 +127017,100 @@ spurious results.`);
|
|
|
126215
127017
|
throw error2;
|
|
126216
127018
|
}
|
|
126217
127019
|
}
|
|
127020
|
+
async getPendingAssetsFromOwner(owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
|
|
127021
|
+
const vault = new Contract({
|
|
127022
|
+
abi: universal_vault_abi_default,
|
|
127023
|
+
address: this.config.strategyVault.address,
|
|
127024
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
127025
|
+
});
|
|
127026
|
+
try {
|
|
127027
|
+
const dueRaw = await vault.call("due_assets_from_owner", [owner.address]);
|
|
127028
|
+
return Web3Number.fromWei(dueRaw.toString(), decimals);
|
|
127029
|
+
} catch (e) {
|
|
127030
|
+
logger2.warn(
|
|
127031
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwner: due_assets_from_owner failed (treating as 0): ${e.message}`
|
|
127032
|
+
);
|
|
127033
|
+
return Web3Number.fromWei("0", decimals);
|
|
127034
|
+
}
|
|
127035
|
+
}
|
|
127036
|
+
/**
|
|
127037
|
+
* Get pending assets from owner by scanning redeem request NFTs.
|
|
127038
|
+
* This method iterates backwards through NFT IDs to find all pending redemptions for a specific owner.
|
|
127039
|
+
*
|
|
127040
|
+
* @param redeemRequestNFT - The redeem request NFT contract address
|
|
127041
|
+
* @param owner - The owner address to check for pending redemptions (defaults to positionOwner)
|
|
127042
|
+
* @param decimals - Token decimals for conversion (defaults to baseToken decimals)
|
|
127043
|
+
* @returns Total pending assets from all NFTs owned by the specified address
|
|
127044
|
+
*/
|
|
127045
|
+
async getPendingAssetsFromOwnerNFTMethod(redeemRequestNFT, owner = this._positionOwner(), decimals = this.config.baseToken.decimals) {
|
|
127046
|
+
try {
|
|
127047
|
+
const nftContract = new Contract({
|
|
127048
|
+
abi: redeem_request_nft_abi_default,
|
|
127049
|
+
address: redeemRequestNFT.address,
|
|
127050
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
127051
|
+
});
|
|
127052
|
+
const idLenRaw = await nftContract.id_len();
|
|
127053
|
+
const latestId = BigInt(idLenRaw.toString());
|
|
127054
|
+
if (latestId === 0n) {
|
|
127055
|
+
logger2.info(
|
|
127056
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No NFTs minted yet`
|
|
127057
|
+
);
|
|
127058
|
+
return Web3Number.fromWei("0", decimals);
|
|
127059
|
+
}
|
|
127060
|
+
const matchingIds = [];
|
|
127061
|
+
let currentId = latestId - 1n;
|
|
127062
|
+
while (currentId >= 0n) {
|
|
127063
|
+
try {
|
|
127064
|
+
const idU256 = uint256_exports.bnToUint256(currentId);
|
|
127065
|
+
const ownerRaw = await nftContract.owner_of(idU256);
|
|
127066
|
+
const nftOwnerAddr = ContractAddr.from(ownerRaw.toString());
|
|
127067
|
+
if (nftOwnerAddr.eq(owner)) {
|
|
127068
|
+
matchingIds.push(currentId);
|
|
127069
|
+
logger2.debug(
|
|
127070
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found matching NFT ID ${currentId} for owner ${owner.address}`
|
|
127071
|
+
);
|
|
127072
|
+
}
|
|
127073
|
+
currentId--;
|
|
127074
|
+
} catch (e) {
|
|
127075
|
+
logger2.info(
|
|
127076
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Reached last pending NFT at id ${currentId}`
|
|
127077
|
+
);
|
|
127078
|
+
break;
|
|
127079
|
+
}
|
|
127080
|
+
}
|
|
127081
|
+
if (matchingIds.length === 0) {
|
|
127082
|
+
logger2.info(
|
|
127083
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: No matching NFTs found for owner ${owner.address}`
|
|
127084
|
+
);
|
|
127085
|
+
return Web3Number.fromWei("0", decimals);
|
|
127086
|
+
}
|
|
127087
|
+
let totalNominal = 0n;
|
|
127088
|
+
for (const nftId of matchingIds) {
|
|
127089
|
+
try {
|
|
127090
|
+
const idU256 = uint256_exports.bnToUint256(nftId);
|
|
127091
|
+
const infoRaw = await nftContract.id_to_info(idU256);
|
|
127092
|
+
const nominal = BigInt(infoRaw.nominal.toString());
|
|
127093
|
+
totalNominal += nominal;
|
|
127094
|
+
logger2.debug(
|
|
127095
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: NFT ID ${nftId} has nominal ${nominal}`
|
|
127096
|
+
);
|
|
127097
|
+
} catch (e) {
|
|
127098
|
+
logger2.warn(
|
|
127099
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Failed to get info for NFT ID ${nftId}: ${e.message}`
|
|
127100
|
+
);
|
|
127101
|
+
}
|
|
127102
|
+
}
|
|
127103
|
+
logger2.info(
|
|
127104
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: Found ${matchingIds.length} NFTs with total nominal ${totalNominal}`
|
|
127105
|
+
);
|
|
127106
|
+
return Web3Number.fromWei(totalNominal.toString(), decimals);
|
|
127107
|
+
} catch (error2) {
|
|
127108
|
+
logger2.error(
|
|
127109
|
+
`${_SvkTrovesAdapter.name}::getPendingAssetsFromOwnerNFTMethod: ${error2.message}`
|
|
127110
|
+
);
|
|
127111
|
+
return Web3Number.fromWei("0", decimals);
|
|
127112
|
+
}
|
|
127113
|
+
}
|
|
126218
127114
|
async maxDeposit(amount) {
|
|
126219
127115
|
const baseToken = this.config.baseToken;
|
|
126220
127116
|
if (!amount) {
|
|
@@ -126279,9 +127175,9 @@ spurious results.`);
|
|
|
126279
127175
|
return [
|
|
126280
127176
|
{
|
|
126281
127177
|
target: strategyVault,
|
|
126282
|
-
method: "
|
|
127178
|
+
method: "request_redeem",
|
|
126283
127179
|
packedArguments: [recv.toBigInt(), owner.toBigInt()],
|
|
126284
|
-
sanitizer:
|
|
127180
|
+
sanitizer: SVK_SIMPLE_SANITIZER,
|
|
126285
127181
|
id: this._withdrawCallProofReadableId()
|
|
126286
127182
|
}
|
|
126287
127183
|
];
|
|
@@ -126343,16 +127239,23 @@ spurious results.`);
|
|
|
126343
127239
|
const uint256Amount = uint256_exports.bnToUint256(amount.toWei());
|
|
126344
127240
|
const recv = this.config.vaultAllocator;
|
|
126345
127241
|
const owner = this.config.vaultAllocator;
|
|
127242
|
+
const vault = new Contract({
|
|
127243
|
+
abi: universal_vault_abi_default,
|
|
127244
|
+
address: strategyVault.address,
|
|
127245
|
+
providerOrAccount: this.config.networkConfig.provider
|
|
127246
|
+
});
|
|
127247
|
+
const sharesRaw = await vault.convert_to_shares(uint256Amount);
|
|
127248
|
+
const sharesU256 = uint256_exports.bnToUint256(sharesRaw.toString());
|
|
126346
127249
|
return [
|
|
126347
127250
|
{
|
|
126348
127251
|
proofReadableId: this._withdrawCallProofReadableId(),
|
|
126349
|
-
sanitizer:
|
|
127252
|
+
sanitizer: SVK_SIMPLE_SANITIZER,
|
|
126350
127253
|
call: {
|
|
126351
127254
|
contractAddress: strategyVault,
|
|
126352
|
-
selector: hash_exports.getSelectorFromName("
|
|
127255
|
+
selector: hash_exports.getSelectorFromName("request_redeem"),
|
|
126353
127256
|
calldata: [
|
|
126354
|
-
toBigInt3(
|
|
126355
|
-
toBigInt3(
|
|
127257
|
+
toBigInt3(sharesU256.low.toString()),
|
|
127258
|
+
toBigInt3(sharesU256.high.toString()),
|
|
126356
127259
|
recv.toBigInt(),
|
|
126357
127260
|
owner.toBigInt()
|
|
126358
127261
|
]
|
|
@@ -128133,9 +129036,9 @@ spurious results.`);
|
|
|
128133
129036
|
* Builds a manage call from an adapter's proof tree.
|
|
128134
129037
|
* DRY helper for the repeated getProofs → getManageCall pattern.
|
|
128135
129038
|
*/
|
|
128136
|
-
async buildManageCallFromAdapter(adapter2, isDeposit, amount) {
|
|
129039
|
+
async buildManageCallFromAdapter(adapter2, isDeposit, amount, additionalParams) {
|
|
128137
129040
|
const proofsInfo = adapter2.getProofs(isDeposit, this.getMerkleTree());
|
|
128138
|
-
const manageCalls = await proofsInfo.callConstructor({ amount });
|
|
129041
|
+
const manageCalls = await proofsInfo.callConstructor({ amount, ...additionalParams });
|
|
128139
129042
|
return this.getManageCall(
|
|
128140
129043
|
this.getProofGroupsForManageCalls(manageCalls),
|
|
128141
129044
|
manageCalls
|
|
@@ -129324,6 +130227,525 @@ spurious results.`);
|
|
|
129324
130227
|
getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
|
|
129325
130228
|
];
|
|
129326
130229
|
|
|
130230
|
+
// src/strategies/usdc-boosted-strategy.tsx
|
|
130231
|
+
var USDCBoostedStrategy = class _USDCBoostedStrategy extends SVKStrategy {
|
|
130232
|
+
constructor(config3, pricer, metadata) {
|
|
130233
|
+
super(config3, pricer, metadata);
|
|
130234
|
+
this.metadata.additionalInfo.adapters.forEach((adapter2) => {
|
|
130235
|
+
adapter2.adapter.config.networkConfig = this.config;
|
|
130236
|
+
adapter2.adapter.config.pricer = this.pricer;
|
|
130237
|
+
if (adapter2.adapter._vesuAdapter) {
|
|
130238
|
+
adapter2.adapter._vesuAdapter.networkConfig = this.config;
|
|
130239
|
+
adapter2.adapter._vesuAdapter.pricer = this.pricer;
|
|
130240
|
+
}
|
|
130241
|
+
});
|
|
130242
|
+
}
|
|
130243
|
+
getTag() {
|
|
130244
|
+
return `${_USDCBoostedStrategy.name}:${this.metadata.name}`;
|
|
130245
|
+
}
|
|
130246
|
+
getAdapterById(id2) {
|
|
130247
|
+
const entry = this.metadata.additionalInfo.adapters.find(
|
|
130248
|
+
(a) => a.id === id2
|
|
130249
|
+
);
|
|
130250
|
+
if (!entry) {
|
|
130251
|
+
throw new Error(
|
|
130252
|
+
`${this.getTag()}::getAdapterById: adapter not found for id "${id2}"`
|
|
130253
|
+
);
|
|
130254
|
+
}
|
|
130255
|
+
return entry.adapter;
|
|
130256
|
+
}
|
|
130257
|
+
async getVesuModifyPositionCall(params) {
|
|
130258
|
+
logger2.verbose(
|
|
130259
|
+
`${this.getTag()}::getVesuModifyPositionCall isDeposit=${params.isDeposit}, amount=${params.leg1DepositAmount}, debtAmount=${params.debtAmount?.toNumber()}`
|
|
130260
|
+
);
|
|
130261
|
+
return this.buildManageCallFromAdapter(
|
|
130262
|
+
this.getAdapterById("vesu_usdc_strk"),
|
|
130263
|
+
params.isDeposit,
|
|
130264
|
+
params.leg1DepositAmount,
|
|
130265
|
+
params.debtAmount ? { debtAmount: params.debtAmount } : void 0
|
|
130266
|
+
);
|
|
130267
|
+
}
|
|
130268
|
+
async getVesuPositions() {
|
|
130269
|
+
const positions = await this.getAdapterById(
|
|
130270
|
+
"vesu_usdc_strk"
|
|
130271
|
+
).getPositions();
|
|
130272
|
+
return positions.map((p) => ({
|
|
130273
|
+
amount: p.amount,
|
|
130274
|
+
usdValue: p.usdValue,
|
|
130275
|
+
remarks: p.remarks ?? "",
|
|
130276
|
+
token: p.tokenInfo,
|
|
130277
|
+
protocol: p.protocol
|
|
130278
|
+
}));
|
|
130279
|
+
}
|
|
130280
|
+
async getVesuHealthFactor(blockNumber = "latest") {
|
|
130281
|
+
const vesuAdapter = this.getAdapterById("vesu_usdc_strk");
|
|
130282
|
+
return await vesuAdapter._vesuAdapter.getHealthFactor(blockNumber);
|
|
130283
|
+
}
|
|
130284
|
+
// TODO: will have to still modify for instant withdrawals as of now
|
|
130285
|
+
async getModifyHyperPositionCall(params) {
|
|
130286
|
+
logger2.verbose(
|
|
130287
|
+
`${this.getTag()}::getModifyHyperPositionCall isDeposit=${params.isDeposit}, amount=${params.amount}`
|
|
130288
|
+
);
|
|
130289
|
+
return this.buildManageCallFromAdapter(
|
|
130290
|
+
this.getAdapterById("hyper_xstrk"),
|
|
130291
|
+
params.isDeposit,
|
|
130292
|
+
params.amount
|
|
130293
|
+
);
|
|
130294
|
+
}
|
|
130295
|
+
async getAvnuSwapCall(params) {
|
|
130296
|
+
logger2.verbose(
|
|
130297
|
+
`${this.getTag()}::getAvnuSwapCall isDeposit=${params.isDeposit}, amount=${params.amount}`
|
|
130298
|
+
);
|
|
130299
|
+
return this.buildManageCallFromAdapter(
|
|
130300
|
+
this.getAdapterById("avnu_strk_xstrk"),
|
|
130301
|
+
params.isDeposit,
|
|
130302
|
+
params.amount
|
|
130303
|
+
);
|
|
130304
|
+
}
|
|
130305
|
+
/**
|
|
130306
|
+
* Returns the USDC balance sitting idle inside the vault contract itself.
|
|
130307
|
+
* This balance can offset the required liquidity during withdrawal processing.
|
|
130308
|
+
*/
|
|
130309
|
+
async getUnusedBalanceVault() {
|
|
130310
|
+
const collateralToken = this.metadata.additionalInfo.collateralToken;
|
|
130311
|
+
return new ERC20(this.config).balanceOf(
|
|
130312
|
+
collateralToken.address,
|
|
130313
|
+
this.metadata.additionalInfo.vaultAddress,
|
|
130314
|
+
collateralToken.decimals
|
|
130315
|
+
);
|
|
130316
|
+
}
|
|
130317
|
+
/**
|
|
130318
|
+
* Returns the current STRK balance sitting unused in the vault allocator.
|
|
130319
|
+
* This covers STRK from prior borrow cycles that hasn't been swapped yet.
|
|
130320
|
+
*/
|
|
130321
|
+
// Technically we can use this or we can even use the avnu-adapter to get the unused debt
|
|
130322
|
+
async getUnusedDebt() {
|
|
130323
|
+
const debtToken = this.metadata.additionalInfo.debtToken;
|
|
130324
|
+
return new ERC20(this.config).balanceOf(
|
|
130325
|
+
debtToken.address,
|
|
130326
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
130327
|
+
debtToken.decimals
|
|
130328
|
+
);
|
|
130329
|
+
}
|
|
130330
|
+
/**
|
|
130331
|
+
* Returns the xSTRK balance sitting in the vault allocator.
|
|
130332
|
+
* This is non-zero when the previous cycle's request_redeem on the HyperPosition
|
|
130333
|
+
* has been settled — the redeemed xSTRK lands here and is ready to be swapped.
|
|
130334
|
+
*/
|
|
130335
|
+
async getxSTRKInVault() {
|
|
130336
|
+
const xstrkToken = Global.getDefaultTokens().find(
|
|
130337
|
+
(t) => t.symbol === "xSTRK"
|
|
130338
|
+
);
|
|
130339
|
+
if (!xstrkToken) {
|
|
130340
|
+
throw new Error(`${this.getTag()}:: xSTRK token not found`);
|
|
130341
|
+
}
|
|
130342
|
+
return new ERC20(this.config).balanceOf(
|
|
130343
|
+
xstrkToken.address.address,
|
|
130344
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
130345
|
+
xstrkToken.decimals
|
|
130346
|
+
);
|
|
130347
|
+
}
|
|
130348
|
+
/**
|
|
130349
|
+
* Simulates depositing `depositAmount` USDC on Vesu and returns the
|
|
130350
|
+
* incremental STRK that would be borrowed. Needed to size the AVNU swap
|
|
130351
|
+
* call that is batched together with the Vesu call in the same transaction.
|
|
130352
|
+
*/
|
|
130353
|
+
async computeVesuDepositBorrowAmount(depositAmount) {
|
|
130354
|
+
return this.getAdapterById(
|
|
130355
|
+
"vesu_usdc_strk"
|
|
130356
|
+
).getExpectedDepositDebtDelta(depositAmount);
|
|
130357
|
+
}
|
|
130358
|
+
async computeVesuWithdrawDebtDelta(withdrawAmount) {
|
|
130359
|
+
return this.getAdapterById(
|
|
130360
|
+
"vesu_usdc_strk"
|
|
130361
|
+
).getExpectedWithdrawDebtDelta(withdrawAmount);
|
|
130362
|
+
}
|
|
130363
|
+
async getPendingHyperAssets() {
|
|
130364
|
+
const xstrkToken = Global.getDefaultTokens().find(
|
|
130365
|
+
(t) => t.symbol === "xSTRK"
|
|
130366
|
+
);
|
|
130367
|
+
const hyperXstrkRedeemNFT = ContractAddr.from(
|
|
130368
|
+
"0x51e40b839dc0c2feca923f863072673b94abfa2483345be3b30b457a90d095"
|
|
130369
|
+
);
|
|
130370
|
+
return this.getAdapterById(
|
|
130371
|
+
"hyper_xstrk"
|
|
130372
|
+
).getPendingAssetsFromOwnerNFTMethod(
|
|
130373
|
+
hyperXstrkRedeemNFT,
|
|
130374
|
+
this.metadata.additionalInfo.vaultAllocator,
|
|
130375
|
+
xstrkToken.decimals
|
|
130376
|
+
);
|
|
130377
|
+
}
|
|
130378
|
+
// TODO: rn we are just making these functions in the strategy itself but
|
|
130379
|
+
// later on we will move them to the SVKStrategy for generalization
|
|
130380
|
+
async getUserTVL(user, blockIdentifier = "latest") {
|
|
130381
|
+
const shares = await this.contract.call("balanceOf", [user.address], {
|
|
130382
|
+
blockIdentifier
|
|
130383
|
+
});
|
|
130384
|
+
const assets = await this.contract.call(
|
|
130385
|
+
"convert_to_assets",
|
|
130386
|
+
[uint256_exports.bnToUint256(shares)],
|
|
130387
|
+
{ blockIdentifier }
|
|
130388
|
+
);
|
|
130389
|
+
const amount = Web3Number.fromWei(
|
|
130390
|
+
assets.toString(),
|
|
130391
|
+
this.metadata.depositTokens[0].decimals
|
|
130392
|
+
);
|
|
130393
|
+
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
130394
|
+
const price = await this.pricer.getPrice(
|
|
130395
|
+
this.metadata.depositTokens[0].symbol,
|
|
130396
|
+
blockNumber
|
|
130397
|
+
);
|
|
130398
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
130399
|
+
return {
|
|
130400
|
+
tokenInfo: this.asset(),
|
|
130401
|
+
amount,
|
|
130402
|
+
usdValue
|
|
130403
|
+
};
|
|
130404
|
+
}
|
|
130405
|
+
async getTVL() {
|
|
130406
|
+
const assets = await this.contract.total_assets();
|
|
130407
|
+
const amount = Web3Number.fromWei(
|
|
130408
|
+
assets.toString(),
|
|
130409
|
+
this.metadata.depositTokens[0].decimals
|
|
130410
|
+
);
|
|
130411
|
+
const price = await this.pricer.getPrice(
|
|
130412
|
+
this.metadata.depositTokens[0].symbol
|
|
130413
|
+
);
|
|
130414
|
+
const usdValue = Number(amount.toFixed(6)) * price.price;
|
|
130415
|
+
return {
|
|
130416
|
+
tokenInfo: this.asset(),
|
|
130417
|
+
amount,
|
|
130418
|
+
usdValue
|
|
130419
|
+
};
|
|
130420
|
+
}
|
|
130421
|
+
async getAUM() {
|
|
130422
|
+
const underlying = this.asset();
|
|
130423
|
+
const usdcPrice = await this.pricer.getPrice(underlying.symbol);
|
|
130424
|
+
const allPositions = [];
|
|
130425
|
+
for (const adapter2 of this.metadata.additionalInfo.adapters) {
|
|
130426
|
+
const positions = await adapter2.adapter.getPositions();
|
|
130427
|
+
allPositions.push(...positions);
|
|
130428
|
+
}
|
|
130429
|
+
let netAUM = new Web3Number(0, underlying.decimals);
|
|
130430
|
+
for (const position of allPositions) {
|
|
130431
|
+
if (position.tokenInfo.address.eq(underlying.address)) {
|
|
130432
|
+
netAUM = netAUM.plus(position.amount);
|
|
130433
|
+
} else {
|
|
130434
|
+
const valueInUSDC = position.usdValue;
|
|
130435
|
+
netAUM = netAUM.plus(valueInUSDC);
|
|
130436
|
+
}
|
|
130437
|
+
}
|
|
130438
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
130439
|
+
logger2.verbose(
|
|
130440
|
+
`${this.getTag()} unused balance: ${unusedBalance.amount.toNumber()}`
|
|
130441
|
+
);
|
|
130442
|
+
netAUM = netAUM.plus(unusedBalance.amount);
|
|
130443
|
+
const prevAum = await this.getPrevAUM();
|
|
130444
|
+
logger2.verbose(`${this.getTag()} AUM: ${netAUM}`);
|
|
130445
|
+
const realAUM = {
|
|
130446
|
+
tokenInfo: underlying,
|
|
130447
|
+
amount: netAUM,
|
|
130448
|
+
usdValue: netAUM.toNumber() * usdcPrice.price,
|
|
130449
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
130450
|
+
remarks: "finalised" /* FINALISED */,
|
|
130451
|
+
protocol: Protocols.NONE
|
|
130452
|
+
};
|
|
130453
|
+
const estimatedAUMDelta = {
|
|
130454
|
+
tokenInfo: underlying,
|
|
130455
|
+
amount: Web3Number.fromWei("0", underlying.decimals),
|
|
130456
|
+
usdValue: 0,
|
|
130457
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
130458
|
+
remarks: "defispring" /* DEFISPRING */,
|
|
130459
|
+
protocol: Protocols.NONE
|
|
130460
|
+
};
|
|
130461
|
+
return {
|
|
130462
|
+
net: {
|
|
130463
|
+
tokenInfo: underlying,
|
|
130464
|
+
amount: netAUM,
|
|
130465
|
+
usdValue: netAUM.toNumber() * usdcPrice.price
|
|
130466
|
+
},
|
|
130467
|
+
prevAum,
|
|
130468
|
+
splits: [realAUM, estimatedAUMDelta]
|
|
130469
|
+
};
|
|
130470
|
+
}
|
|
130471
|
+
// TODO: can refactor later but seems redundant since not being used ANYWHERE
|
|
130472
|
+
// Most of the fund management done through adapters only
|
|
130473
|
+
async getFundManagementCall(params) {
|
|
130474
|
+
logger2.verbose(
|
|
130475
|
+
`${this.getTag()}::getFundManagementCall params: ${JSON.stringify(params)}`
|
|
130476
|
+
);
|
|
130477
|
+
const allAdapters = this.metadata.additionalInfo.adapters.map(
|
|
130478
|
+
(a) => a.adapter
|
|
130479
|
+
);
|
|
130480
|
+
if (!params.isDeposit) {
|
|
130481
|
+
const unusedBalance = await this.getUnusedBalance();
|
|
130482
|
+
logger2.verbose(
|
|
130483
|
+
`${this.getTag()}::getFundManagementCall unusedBalance: ${unusedBalance.amount}, required: ${params.leg1DepositAmount}`
|
|
130484
|
+
);
|
|
130485
|
+
if (unusedBalance.amount.gte(params.leg1DepositAmount)) {
|
|
130486
|
+
return null;
|
|
130487
|
+
}
|
|
130488
|
+
const adapters2 = await AdapterOptimizer.getAdapterToUse(
|
|
130489
|
+
allAdapters,
|
|
130490
|
+
false,
|
|
130491
|
+
params.leg1DepositAmount
|
|
130492
|
+
);
|
|
130493
|
+
if (adapters2.length > 0) {
|
|
130494
|
+
const proofsInfo = adapters2.map(
|
|
130495
|
+
(adapter2) => adapter2.getProofs(false, this.getMerkleTree())
|
|
130496
|
+
);
|
|
130497
|
+
const calls = [];
|
|
130498
|
+
for (const info of proofsInfo) {
|
|
130499
|
+
const manageCalls = await info.callConstructor({
|
|
130500
|
+
amount: params.leg1DepositAmount
|
|
130501
|
+
});
|
|
130502
|
+
const call = this.getManageCall(
|
|
130503
|
+
this.getProofGroupsForManageCalls(manageCalls),
|
|
130504
|
+
manageCalls
|
|
130505
|
+
);
|
|
130506
|
+
calls.push(call);
|
|
130507
|
+
}
|
|
130508
|
+
return calls;
|
|
130509
|
+
}
|
|
130510
|
+
throw new Error(
|
|
130511
|
+
`${this.getTag()}::getFundManagementCall: no adapters for withdraw: ${unusedBalance.amount}`
|
|
130512
|
+
);
|
|
130513
|
+
}
|
|
130514
|
+
const adapters = await AdapterOptimizer.getAdapterToUse(
|
|
130515
|
+
allAdapters,
|
|
130516
|
+
true,
|
|
130517
|
+
params.leg1DepositAmount
|
|
130518
|
+
);
|
|
130519
|
+
if (adapters.length > 0) {
|
|
130520
|
+
const proofsInfo = adapters.map(
|
|
130521
|
+
(adapter2) => adapter2.getProofs(true, this.getMerkleTree())
|
|
130522
|
+
);
|
|
130523
|
+
const calls = [];
|
|
130524
|
+
for (const info of proofsInfo) {
|
|
130525
|
+
const manageCalls = await info.callConstructor({
|
|
130526
|
+
amount: params.leg1DepositAmount
|
|
130527
|
+
});
|
|
130528
|
+
const call = this.getManageCall(
|
|
130529
|
+
this.getProofGroupsForManageCalls(manageCalls),
|
|
130530
|
+
manageCalls
|
|
130531
|
+
);
|
|
130532
|
+
calls.push(call);
|
|
130533
|
+
}
|
|
130534
|
+
return calls;
|
|
130535
|
+
}
|
|
130536
|
+
throw new Error(
|
|
130537
|
+
`${this.getTag()}::getFundManagementCall: no adapters for deposit: ${params.leg1DepositAmount}`
|
|
130538
|
+
);
|
|
130539
|
+
}
|
|
130540
|
+
};
|
|
130541
|
+
function getUSDCBoostedSettings(vaultSettings) {
|
|
130542
|
+
vaultSettings.leafAdapters = [];
|
|
130543
|
+
const xSTRKToken = Global.getDefaultTokens().find(
|
|
130544
|
+
(t) => t.symbol === "xSTRK"
|
|
130545
|
+
);
|
|
130546
|
+
const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
|
|
130547
|
+
const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
130548
|
+
const baseAdapterConfig = {
|
|
130549
|
+
baseToken: USDCToken,
|
|
130550
|
+
supportedPositions: [{ asset: USDCToken, isDebt: false }],
|
|
130551
|
+
networkConfig: getMainnetConfig(),
|
|
130552
|
+
pricer: new PricerFromApi(getMainnetConfig(), Global.getDefaultTokens()),
|
|
130553
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
130554
|
+
vaultAddress: vaultSettings.vaultAddress
|
|
130555
|
+
};
|
|
130556
|
+
const vesuModifyPositionAdapter = new VesuModifyPositionAdapter({
|
|
130557
|
+
poolId: vaultSettings.vesuPoolId,
|
|
130558
|
+
collateral: vaultSettings.collateralToken,
|
|
130559
|
+
debt: vaultSettings.debtToken,
|
|
130560
|
+
targetLtv: vaultSettings.targetLTV,
|
|
130561
|
+
maxLtv: vaultSettings.maxLTV,
|
|
130562
|
+
...baseAdapterConfig,
|
|
130563
|
+
supportedPositions: [
|
|
130564
|
+
{ asset: USDCToken, isDebt: false },
|
|
130565
|
+
{ asset: STRKToken, isDebt: true }
|
|
130566
|
+
]
|
|
130567
|
+
});
|
|
130568
|
+
const avnuAdapter = new AvnuAdapter({
|
|
130569
|
+
baseUrl: AVNU_QUOTE_URL,
|
|
130570
|
+
avnuContract: AVNU_EXCHANGE,
|
|
130571
|
+
slippage: 0.01,
|
|
130572
|
+
minimumExtendedPriceDifferenceForSwapOpen: 0,
|
|
130573
|
+
maximumExtendedPriceDifferenceForSwapClosing: 0,
|
|
130574
|
+
...baseAdapterConfig,
|
|
130575
|
+
baseToken: STRKToken,
|
|
130576
|
+
supportedPositions: [
|
|
130577
|
+
{ asset: STRKToken, isDebt: false },
|
|
130578
|
+
{ asset: xSTRKToken, isDebt: false }
|
|
130579
|
+
]
|
|
130580
|
+
});
|
|
130581
|
+
const svkTrovesAdapter = new SvkTrovesAdapter({
|
|
130582
|
+
...baseAdapterConfig,
|
|
130583
|
+
baseToken: xSTRKToken,
|
|
130584
|
+
supportedPositions: [{ asset: xSTRKToken, isDebt: false }],
|
|
130585
|
+
strategyVault: vaultSettings.hyperxSTRKVaultAddress,
|
|
130586
|
+
trovesStrategyId: "hyper_xstrk"
|
|
130587
|
+
});
|
|
130588
|
+
const usdcTransferAdapter = new TokenTransferAdapter({
|
|
130589
|
+
...baseAdapterConfig,
|
|
130590
|
+
fromAddress: vaultSettings.vaultAllocator,
|
|
130591
|
+
toAddress: vaultSettings.vaultAddress
|
|
130592
|
+
});
|
|
130593
|
+
const commonAdapter = new CommonAdapter({
|
|
130594
|
+
id: "flash_loan_init" /* FLASH_LOAN */,
|
|
130595
|
+
vaultAddress: vaultSettings.vaultAddress,
|
|
130596
|
+
vaultAllocator: vaultSettings.vaultAllocator,
|
|
130597
|
+
manager: vaultSettings.manager,
|
|
130598
|
+
asset: USDCToken.address
|
|
130599
|
+
});
|
|
130600
|
+
vaultSettings.adapters.push(
|
|
130601
|
+
// TODO: generalize the ids
|
|
130602
|
+
{ id: "vesu_usdc_strk", adapter: vesuModifyPositionAdapter },
|
|
130603
|
+
// Used to track swapped funds in vaultAllocator
|
|
130604
|
+
{ id: "avnu_strk_xstrk", adapter: avnuAdapter },
|
|
130605
|
+
{ id: "hyper_xstrk", adapter: svkTrovesAdapter },
|
|
130606
|
+
{ id: "usdc_transfer", adapter: usdcTransferAdapter }
|
|
130607
|
+
);
|
|
130608
|
+
vaultSettings.leafAdapters.push(
|
|
130609
|
+
() => vesuModifyPositionAdapter.getDepositLeaf()
|
|
130610
|
+
);
|
|
130611
|
+
vaultSettings.leafAdapters.push(
|
|
130612
|
+
() => vesuModifyPositionAdapter.getWithdrawLeaf()
|
|
130613
|
+
);
|
|
130614
|
+
vaultSettings.leafAdapters.push(() => avnuAdapter.getDepositLeaf());
|
|
130615
|
+
vaultSettings.leafAdapters.push(() => avnuAdapter.getWithdrawLeaf());
|
|
130616
|
+
vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getDepositLeaf());
|
|
130617
|
+
vaultSettings.leafAdapters.push(() => svkTrovesAdapter.getWithdrawLeaf());
|
|
130618
|
+
vaultSettings.leafAdapters.push(
|
|
130619
|
+
commonAdapter.getApproveAdapter(
|
|
130620
|
+
USDCToken.address,
|
|
130621
|
+
vaultSettings.vaultAddress,
|
|
130622
|
+
"approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */
|
|
130623
|
+
).bind(commonAdapter)
|
|
130624
|
+
);
|
|
130625
|
+
vaultSettings.leafAdapters.push(
|
|
130626
|
+
commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter)
|
|
130627
|
+
);
|
|
130628
|
+
return vaultSettings;
|
|
130629
|
+
}
|
|
130630
|
+
var usdcBoostedSettings = {
|
|
130631
|
+
vaultAddress: ContractAddr.from(
|
|
130632
|
+
"0xcdb0e3b2e076a2cdc4ee958b726b47c066239ef91c5ac80c94cf814147b84"
|
|
130633
|
+
),
|
|
130634
|
+
manager: ContractAddr.from(
|
|
130635
|
+
"0x72eea9bac9fa8cfffda637d3b990851446860c6fd8987d6cb50e659b01ee50f"
|
|
130636
|
+
),
|
|
130637
|
+
vaultAllocator: ContractAddr.from(
|
|
130638
|
+
"0x6d3101cff7f821412a99ebe23bb31a1950f93276285102eb4313e3601f5f927"
|
|
130639
|
+
),
|
|
130640
|
+
redeemRequestNFT: ContractAddr.from(
|
|
130641
|
+
"0x47dcc6889ca8db4e9eea8f55421e10f8ce7e356ccb45260a1c49a76f733c309"
|
|
130642
|
+
),
|
|
130643
|
+
// TODO: not applicable in our case -> remove later ( make it optional if needed)
|
|
130644
|
+
aumOracle: ContractAddr.from("0x0"),
|
|
130645
|
+
leafAdapters: [],
|
|
130646
|
+
adapters: [],
|
|
130647
|
+
// Calc using the maxLTV / targetLTV (0.5)
|
|
130648
|
+
targetHealthFactor: 1.32,
|
|
130649
|
+
// Calc using the maxLTV / maxAcceptableLTV (0.55)
|
|
130650
|
+
minHealthFactor: 1.2,
|
|
130651
|
+
vesuPoolId: VesuPools.Prime,
|
|
130652
|
+
collateralToken: Global.getDefaultTokens().find((t) => t.symbol === "USDC"),
|
|
130653
|
+
debtToken: Global.getDefaultTokens().find((t) => t.symbol === "STRK"),
|
|
130654
|
+
maxLTV: 0.66,
|
|
130655
|
+
targetLTV: 0.5,
|
|
130656
|
+
hyperxSTRKVaultAddress: ContractAddr.from(
|
|
130657
|
+
"0x46c7a54c82b1fe374353859f554a40b8bd31d3e30f742901579e7b57b1b5960"
|
|
130658
|
+
)
|
|
130659
|
+
};
|
|
130660
|
+
function getStrategySettings2(settings2) {
|
|
130661
|
+
const USDCToken = Global.getDefaultTokens().find((t) => t.symbol === "USDC");
|
|
130662
|
+
const STRKToken = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
130663
|
+
return {
|
|
130664
|
+
id: "usdc_boosted",
|
|
130665
|
+
name: "USDC Boosted",
|
|
130666
|
+
description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield",
|
|
130667
|
+
address: settings2.vaultAddress,
|
|
130668
|
+
launchBlock: 8742931,
|
|
130669
|
+
type: "ERC4626",
|
|
130670
|
+
vaultType: {
|
|
130671
|
+
// TODO: can change as per need
|
|
130672
|
+
type: "Meta Vault" /* META_VAULT */,
|
|
130673
|
+
description: "Deposits USDC as collateral on Vesu, borrows STRK, swaps to xSTRK, and deposits into Hyper-xSTRK for boosted yield"
|
|
130674
|
+
},
|
|
130675
|
+
depositTokens: [USDCToken],
|
|
130676
|
+
additionalInfo: getUSDCBoostedSettings(settings2),
|
|
130677
|
+
// TODO: config lateron
|
|
130678
|
+
risk: {
|
|
130679
|
+
riskFactor: [],
|
|
130680
|
+
netRisk: 0,
|
|
130681
|
+
notARisks: []
|
|
130682
|
+
},
|
|
130683
|
+
protocols: [Protocols.VESU, Protocols.TROVES],
|
|
130684
|
+
curator: {
|
|
130685
|
+
name: "Unwrap Labs",
|
|
130686
|
+
logo: "https://assets.troves.fi/integrations/unwraplabs/white.png"
|
|
130687
|
+
},
|
|
130688
|
+
settings: {
|
|
130689
|
+
maxTVL: Web3Number.fromWei(0, USDCToken.decimals),
|
|
130690
|
+
isPaused: false,
|
|
130691
|
+
isAudited: false,
|
|
130692
|
+
isInstantWithdrawal: false,
|
|
130693
|
+
hideHarvestInfo: true,
|
|
130694
|
+
quoteToken: USDCToken,
|
|
130695
|
+
alerts: [
|
|
130696
|
+
{
|
|
130697
|
+
tab: "withdraw",
|
|
130698
|
+
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.",
|
|
130699
|
+
type: "info"
|
|
130700
|
+
}
|
|
130701
|
+
]
|
|
130702
|
+
},
|
|
130703
|
+
contractDetails: getContractDetails(settings2),
|
|
130704
|
+
// TODO: config later
|
|
130705
|
+
faqs: [],
|
|
130706
|
+
investmentSteps: [
|
|
130707
|
+
"Deposit USDC into the vault",
|
|
130708
|
+
"USDC is supplied as collateral on Vesu, STRK is borrowed",
|
|
130709
|
+
"Borrowed STRK is swapped to xSTRK via Avnu",
|
|
130710
|
+
"xSTRK is deposited into the Hyper-xSTRK vault for additional yield",
|
|
130711
|
+
"On withdrawal, the pipeline reverses to return USDC"
|
|
130712
|
+
],
|
|
130713
|
+
// TODO: config later
|
|
130714
|
+
tags: ["Meta Vaults" /* META_VAULT */],
|
|
130715
|
+
security: {
|
|
130716
|
+
auditStatus: "Audited" /* AUDITED */,
|
|
130717
|
+
sourceCode: {
|
|
130718
|
+
type: "Closed Source" /* CLOSED_SOURCE */,
|
|
130719
|
+
contractLink: "https://github.com/trovesfi/troves-contracts"
|
|
130720
|
+
},
|
|
130721
|
+
accessControl: {
|
|
130722
|
+
type: "Standard Account" /* STANDARD_ACCOUNT */,
|
|
130723
|
+
addresses: [ContractAddr.from("0x0")],
|
|
130724
|
+
timeLock: "2 Days"
|
|
130725
|
+
}
|
|
130726
|
+
},
|
|
130727
|
+
redemptionInfo: {
|
|
130728
|
+
instantWithdrawalVault: "No" /* NO */,
|
|
130729
|
+
redemptionsInfo: [
|
|
130730
|
+
{
|
|
130731
|
+
title: "Typical Duration",
|
|
130732
|
+
description: "1-2 hours"
|
|
130733
|
+
}
|
|
130734
|
+
],
|
|
130735
|
+
alerts: [
|
|
130736
|
+
{
|
|
130737
|
+
type: "info",
|
|
130738
|
+
text: "Redemption times are estimates and may vary based on network conditions and liquidity requirements.",
|
|
130739
|
+
tab: "withdraw"
|
|
130740
|
+
}
|
|
130741
|
+
]
|
|
130742
|
+
},
|
|
130743
|
+
usualTimeToEarnings: null,
|
|
130744
|
+
usualTimeToEarningsDescription: null
|
|
130745
|
+
};
|
|
130746
|
+
}
|
|
130747
|
+
var USDCBoostedStrategies = [getStrategySettings2(usdcBoostedSettings)];
|
|
130748
|
+
|
|
129327
130749
|
// src/strategies/vesu-extended-strategy/services/ltv-imbalance-rebalance-math.ts
|
|
129328
130750
|
function ceilBtc(v, precision) {
|
|
129329
130751
|
const f2 = 10 ** precision;
|