@strkfarm/sdk 2.0.0-staging.18 → 2.0.0-staging.19
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 +143 -125
- package/dist/index.browser.mjs +115 -98
- package/dist/index.d.ts +15 -4
- package/dist/index.js +201 -184
- package/dist/index.mjs +115 -98
- package/package.json +1 -1
- package/src/dataTypes/_bignumber.ts +5 -0
- package/src/strategies/ekubo-cl-vault.tsx +15 -3
- package/src/strategies/universal-adapters/vesu-adapter.ts +25 -23
- package/src/strategies/universal-lst-muliplier-strategy.tsx +4 -3
package/dist/index.js
CHANGED
|
@@ -143,6 +143,7 @@ var import_util = __toESM(require("util"));
|
|
|
143
143
|
|
|
144
144
|
// src/dataTypes/_bignumber.ts
|
|
145
145
|
var import_bignumber = __toESM(require("bignumber.js"));
|
|
146
|
+
var import_starknet = require("starknet");
|
|
146
147
|
var _Web3Number = class extends import_bignumber.default {
|
|
147
148
|
constructor(value, decimals) {
|
|
148
149
|
super(value);
|
|
@@ -217,6 +218,9 @@ var _Web3Number = class extends import_bignumber.default {
|
|
|
217
218
|
sign
|
|
218
219
|
};
|
|
219
220
|
}
|
|
221
|
+
toUint256() {
|
|
222
|
+
return import_starknet.uint256.bnToUint256(this.toWei());
|
|
223
|
+
}
|
|
220
224
|
};
|
|
221
225
|
import_bignumber.default.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: import_bignumber.default.ROUND_DOWN });
|
|
222
226
|
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: import_bignumber.default.ROUND_DOWN });
|
|
@@ -239,7 +243,7 @@ var Web3Number = class _Web3Number2 extends _Web3Number {
|
|
|
239
243
|
};
|
|
240
244
|
|
|
241
245
|
// src/dataTypes/address.ts
|
|
242
|
-
var
|
|
246
|
+
var import_starknet2 = require("starknet");
|
|
243
247
|
var ContractAddr = class _ContractAddr {
|
|
244
248
|
constructor(address) {
|
|
245
249
|
this.address = _ContractAddr.standardise(address);
|
|
@@ -258,7 +262,7 @@ var ContractAddr = class _ContractAddr {
|
|
|
258
262
|
if (!address) {
|
|
259
263
|
_a = "0";
|
|
260
264
|
}
|
|
261
|
-
const a =
|
|
265
|
+
const a = import_starknet2.num.getHexString(import_starknet2.num.getDecimalString(_a.toString()));
|
|
262
266
|
return a;
|
|
263
267
|
}
|
|
264
268
|
static eqString(a, b) {
|
|
@@ -268,7 +272,7 @@ var ContractAddr = class _ContractAddr {
|
|
|
268
272
|
return this.address;
|
|
269
273
|
}
|
|
270
274
|
toBigInt() {
|
|
271
|
-
return
|
|
275
|
+
return import_starknet2.num.toBigInt(this.address);
|
|
272
276
|
}
|
|
273
277
|
};
|
|
274
278
|
|
|
@@ -700,7 +704,7 @@ var PricerBase = class {
|
|
|
700
704
|
};
|
|
701
705
|
|
|
702
706
|
// src/modules/avnu.ts
|
|
703
|
-
var
|
|
707
|
+
var import_starknet5 = require("starknet");
|
|
704
708
|
var import_avnu_sdk = require("@avnu/avnu-sdk");
|
|
705
709
|
|
|
706
710
|
// src/utils/oz-merkle.ts
|
|
@@ -708,8 +712,8 @@ var import_bytes = require("@ericnordelo/strk-merkle-tree/dist/bytes");
|
|
|
708
712
|
var import_core = require("@ericnordelo/strk-merkle-tree/dist/core");
|
|
709
713
|
var import_hashes = require("@ericnordelo/strk-merkle-tree/dist/hashes");
|
|
710
714
|
var import_merkletree = require("@ericnordelo/strk-merkle-tree/dist/merkletree");
|
|
711
|
-
var
|
|
712
|
-
var
|
|
715
|
+
var import_starknet3 = require("starknet");
|
|
716
|
+
var import_starknet4 = require("@scure/starknet");
|
|
713
717
|
function hash_leaf(leaf) {
|
|
714
718
|
if (leaf.data.length < 1) {
|
|
715
719
|
throw new Error("Invalid leaf data");
|
|
@@ -719,10 +723,10 @@ function hash_leaf(leaf) {
|
|
|
719
723
|
for (let i = 1; i < leaf.data.length; i++) {
|
|
720
724
|
value = pedersen_hash(value, leaf.data[i]);
|
|
721
725
|
}
|
|
722
|
-
return `0x${
|
|
726
|
+
return `0x${import_starknet3.num.toHexString(value).replace(/^0x/, "").padStart(64, "0")}`;
|
|
723
727
|
}
|
|
724
728
|
function pedersen_hash(a, b) {
|
|
725
|
-
return BigInt((0,
|
|
729
|
+
return BigInt((0, import_starknet4.pedersen)(a, b).toString());
|
|
726
730
|
}
|
|
727
731
|
var StandardMerkleTree = class _StandardMerkleTree extends import_merkletree.MerkleTreeImpl {
|
|
728
732
|
constructor(tree, values, leafEncoding) {
|
|
@@ -845,10 +849,10 @@ var AvnuWrapper = class {
|
|
|
845
849
|
const _minAmount = minAmount || (quote.buyAmount * 95n / 100n).toString();
|
|
846
850
|
const swapInfo = {
|
|
847
851
|
token_from_address: quote.sellTokenAddress,
|
|
848
|
-
token_from_amount:
|
|
852
|
+
token_from_amount: import_starknet5.uint256.bnToUint256(quote.sellAmount),
|
|
849
853
|
token_to_address: quote.buyTokenAddress,
|
|
850
|
-
token_to_amount:
|
|
851
|
-
token_to_min_amount:
|
|
854
|
+
token_to_amount: import_starknet5.uint256.bnToUint256(_minAmount),
|
|
855
|
+
token_to_min_amount: import_starknet5.uint256.bnToUint256(_minAmount),
|
|
852
856
|
beneficiary: taker,
|
|
853
857
|
integrator_fee_amount_bps: integratorFeeBps,
|
|
854
858
|
integrator_fee_recipient: integratorFeeRecipient,
|
|
@@ -859,10 +863,10 @@ var AvnuWrapper = class {
|
|
|
859
863
|
static buildZeroSwap(tokenToSell, beneficiary, tokenToBuy = tokenToSell) {
|
|
860
864
|
return {
|
|
861
865
|
token_from_address: tokenToSell.address,
|
|
862
|
-
token_from_amount:
|
|
866
|
+
token_from_amount: import_starknet5.uint256.bnToUint256(0),
|
|
863
867
|
token_to_address: tokenToBuy.address,
|
|
864
|
-
token_to_amount:
|
|
865
|
-
token_to_min_amount:
|
|
868
|
+
token_to_amount: import_starknet5.uint256.bnToUint256(0),
|
|
869
|
+
token_to_min_amount: import_starknet5.uint256.bnToUint256(0),
|
|
866
870
|
beneficiary,
|
|
867
871
|
integrator_fee_amount_bps: 0,
|
|
868
872
|
integrator_fee_recipient: beneficiary,
|
|
@@ -1080,7 +1084,7 @@ var Pricer = class extends PricerBase {
|
|
|
1080
1084
|
};
|
|
1081
1085
|
|
|
1082
1086
|
// src/modules/pragma.ts
|
|
1083
|
-
var
|
|
1087
|
+
var import_starknet6 = require("starknet");
|
|
1084
1088
|
|
|
1085
1089
|
// src/data/pragma.abi.json
|
|
1086
1090
|
var pragma_abi_default = [
|
|
@@ -1185,7 +1189,7 @@ var Pragma = class extends PricerBase {
|
|
|
1185
1189
|
constructor(config, tokens2) {
|
|
1186
1190
|
super(config, tokens2);
|
|
1187
1191
|
this.contractAddr = "0x023fb3afbff2c0e3399f896dcf7400acf1a161941cfb386e34a123f228c62832";
|
|
1188
|
-
this.contract = new
|
|
1192
|
+
this.contract = new import_starknet6.Contract({
|
|
1189
1193
|
abi: pragma_abi_default,
|
|
1190
1194
|
address: this.contractAddr,
|
|
1191
1195
|
providerOrAccount: config.provider
|
|
@@ -1407,7 +1411,7 @@ var apolloClient = new import_client.ApolloClient({
|
|
|
1407
1411
|
var import_client2 = require("@apollo/client");
|
|
1408
1412
|
|
|
1409
1413
|
// src/modules/ekubo-pricer.ts
|
|
1410
|
-
var
|
|
1414
|
+
var import_starknet7 = require("starknet");
|
|
1411
1415
|
|
|
1412
1416
|
// src/data/ekubo-price-fethcer.abi.json
|
|
1413
1417
|
var ekubo_price_fethcer_abi_default = [
|
|
@@ -1683,7 +1687,7 @@ var EkuboPricer = class extends PricerBase {
|
|
|
1683
1687
|
this.EKUBO_PRICE_FETCHER_ADDRESS = "0x04946fb4ad5237d97bbb1256eba2080c4fe1de156da6a7f83e3b4823bb6d7da1";
|
|
1684
1688
|
this.USDC_ADDRESS = "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8";
|
|
1685
1689
|
this.USDC_DECIMALS = 6;
|
|
1686
|
-
this.contract = new
|
|
1690
|
+
this.contract = new import_starknet7.Contract({
|
|
1687
1691
|
abi: ekubo_price_fethcer_abi_default,
|
|
1688
1692
|
address: this.EKUBO_PRICE_FETCHER_ADDRESS,
|
|
1689
1693
|
providerOrAccount: config.provider
|
|
@@ -1894,7 +1898,7 @@ var PricerFromApi = class extends PricerBase {
|
|
|
1894
1898
|
};
|
|
1895
1899
|
|
|
1896
1900
|
// src/modules/erc20.ts
|
|
1897
|
-
var
|
|
1901
|
+
var import_starknet8 = require("starknet");
|
|
1898
1902
|
|
|
1899
1903
|
// src/data/erc20.abi.json
|
|
1900
1904
|
var erc20_abi_default = [
|
|
@@ -3027,7 +3031,7 @@ var ERC20 = class {
|
|
|
3027
3031
|
}
|
|
3028
3032
|
contract(addr) {
|
|
3029
3033
|
const _addr = typeof addr === "string" ? addr : addr.address;
|
|
3030
|
-
return new
|
|
3034
|
+
return new import_starknet8.Contract({ abi: erc20_abi_default, address: _addr, providerOrAccount: this.config.provider });
|
|
3031
3035
|
}
|
|
3032
3036
|
async balanceOf(token, address, tokenDecimals) {
|
|
3033
3037
|
const contract = this.contract(token);
|
|
@@ -3106,7 +3110,7 @@ var EkuboQuoter = class {
|
|
|
3106
3110
|
};
|
|
3107
3111
|
|
|
3108
3112
|
// src/interfaces/common.tsx
|
|
3109
|
-
var
|
|
3113
|
+
var import_starknet9 = require("starknet");
|
|
3110
3114
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
3111
3115
|
var RiskType = /* @__PURE__ */ ((RiskType2) => {
|
|
3112
3116
|
RiskType2["MARKET_RISK"] = "Market Risk";
|
|
@@ -3175,9 +3179,9 @@ var StrategyLiveStatus = /* @__PURE__ */ ((StrategyLiveStatus2) => {
|
|
|
3175
3179
|
StrategyLiveStatus2["HOT"] = "Hot & New \u{1F525}";
|
|
3176
3180
|
return StrategyLiveStatus2;
|
|
3177
3181
|
})(StrategyLiveStatus || {});
|
|
3178
|
-
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier =
|
|
3182
|
+
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = import_starknet9.BlockTag.LATEST) {
|
|
3179
3183
|
return {
|
|
3180
|
-
provider: new
|
|
3184
|
+
provider: new import_starknet9.RpcProvider({
|
|
3181
3185
|
nodeUrl: rpcUrl,
|
|
3182
3186
|
blockIdentifier
|
|
3183
3187
|
// specVersion
|
|
@@ -3286,7 +3290,7 @@ var Initializable = class {
|
|
|
3286
3290
|
};
|
|
3287
3291
|
|
|
3288
3292
|
// src/strategies/autoCompounderStrk.ts
|
|
3289
|
-
var
|
|
3293
|
+
var import_starknet10 = require("starknet");
|
|
3290
3294
|
var AutoCompounderSTRK = class {
|
|
3291
3295
|
constructor(config, pricer) {
|
|
3292
3296
|
this.addr = ContractAddr.from("0x541681b9ad63dff1b35f79c78d8477f64857de29a27902f7298f7b620838ea");
|
|
@@ -3309,7 +3313,7 @@ var AutoCompounderSTRK = class {
|
|
|
3309
3313
|
async init() {
|
|
3310
3314
|
const provider2 = this.config.provider;
|
|
3311
3315
|
const cls = await provider2.getClassAt(this.addr.address);
|
|
3312
|
-
this.contract = new
|
|
3316
|
+
this.contract = new import_starknet10.Contract({ abi: cls.abi, address: this.addr.address, providerOrAccount: provider2 });
|
|
3313
3317
|
this.initialized = true;
|
|
3314
3318
|
}
|
|
3315
3319
|
async waitForInitilisation() {
|
|
@@ -3330,7 +3334,7 @@ var AutoCompounderSTRK = class {
|
|
|
3330
3334
|
/** Returns underlying assets of user */
|
|
3331
3335
|
async balanceOfUnderlying(user) {
|
|
3332
3336
|
const balanceShares = await this.balanceOf(user);
|
|
3333
|
-
const assets = await this.contract.convert_to_assets(
|
|
3337
|
+
const assets = await this.contract.convert_to_assets(import_starknet10.uint256.bnToUint256(balanceShares.toWei()));
|
|
3334
3338
|
return Web3Number.fromWei(assets.toString(), this.metadata.decimals);
|
|
3335
3339
|
}
|
|
3336
3340
|
/** Returns usd value of assets */
|
|
@@ -3346,7 +3350,7 @@ var AutoCompounderSTRK = class {
|
|
|
3346
3350
|
};
|
|
3347
3351
|
|
|
3348
3352
|
// src/strategies/vesu-rebalance.tsx
|
|
3349
|
-
var
|
|
3353
|
+
var import_starknet12 = require("starknet");
|
|
3350
3354
|
|
|
3351
3355
|
// src/data/vesu-rebalance.abi.json
|
|
3352
3356
|
var vesu_rebalance_abi_default = [
|
|
@@ -4888,7 +4892,7 @@ async function getAPIUsingHeadlessBrowser(url) {
|
|
|
4888
4892
|
}
|
|
4889
4893
|
|
|
4890
4894
|
// src/modules/harvests.ts
|
|
4891
|
-
var
|
|
4895
|
+
var import_starknet11 = require("starknet");
|
|
4892
4896
|
var Harvests = class _Harvests {
|
|
4893
4897
|
constructor(config) {
|
|
4894
4898
|
this.config = config;
|
|
@@ -4908,7 +4912,7 @@ var Harvests = class _Harvests {
|
|
|
4908
4912
|
}
|
|
4909
4913
|
const cls = await this.config.provider.getClassAt(sortedRewards[0].rewardsContract.address);
|
|
4910
4914
|
for (const reward of sortedRewards) {
|
|
4911
|
-
const contract = new
|
|
4915
|
+
const contract = new import_starknet11.Contract({ abi: cls.abi, address: reward.rewardsContract.address, providerOrAccount: this.config.provider });
|
|
4912
4916
|
const isClaimed = await contract.call("is_claimed", [reward.claim.id]);
|
|
4913
4917
|
logger.verbose(`${_Harvests.name}: isClaimed: ${isClaimed}, claim id: ${reward.claim.id}, address: ${reward.rewardsContract.address}`);
|
|
4914
4918
|
if (isClaimed) {
|
|
@@ -4962,7 +4966,7 @@ var VesuHarvests = class _VesuHarvests extends Harvests {
|
|
|
4962
4966
|
const _data = await result.json();
|
|
4963
4967
|
const rewardsContract = VESU_REWARDS_CONTRACT;
|
|
4964
4968
|
const cls = await this.config.provider.getClassAt(rewardsContract.address);
|
|
4965
|
-
const contract = new
|
|
4969
|
+
const contract = new import_starknet11.Contract({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
|
|
4966
4970
|
const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
|
|
4967
4971
|
const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
|
|
4968
4972
|
logger.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
|
|
@@ -4980,7 +4984,7 @@ var VesuHarvests = class _VesuHarvests extends Harvests {
|
|
|
4980
4984
|
endDate: /* @__PURE__ */ new Date(0),
|
|
4981
4985
|
claim: {
|
|
4982
4986
|
id: 0,
|
|
4983
|
-
amount: Web3Number.fromWei(
|
|
4987
|
+
amount: Web3Number.fromWei(import_starknet11.num.getDecimalString(data.amount), 18),
|
|
4984
4988
|
claimee: addr
|
|
4985
4989
|
},
|
|
4986
4990
|
actualReward,
|
|
@@ -10473,7 +10477,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10473
10477
|
);
|
|
10474
10478
|
this.metadata = metadata;
|
|
10475
10479
|
this.address = metadata.address;
|
|
10476
|
-
this.contract = new
|
|
10480
|
+
this.contract = new import_starknet12.Contract({
|
|
10477
10481
|
abi: vesu_rebalance_abi_default,
|
|
10478
10482
|
address: this.address.address,
|
|
10479
10483
|
providerOrAccount: this.config.provider
|
|
@@ -10490,17 +10494,17 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10490
10494
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
10491
10495
|
"Deposit token mismatch"
|
|
10492
10496
|
);
|
|
10493
|
-
const assetContract = new
|
|
10497
|
+
const assetContract = new import_starknet12.Contract({
|
|
10494
10498
|
abi: vesu_rebalance_abi_default,
|
|
10495
10499
|
address: this.asset().address.address,
|
|
10496
10500
|
providerOrAccount: this.config.provider
|
|
10497
10501
|
});
|
|
10498
10502
|
const call1 = assetContract.populate("approve", [
|
|
10499
10503
|
this.address.address,
|
|
10500
|
-
|
|
10504
|
+
import_starknet12.uint256.bnToUint256(amountInfo.amount.toWei())
|
|
10501
10505
|
]);
|
|
10502
10506
|
const call2 = this.contract.populate("deposit", [
|
|
10503
|
-
|
|
10507
|
+
import_starknet12.uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
10504
10508
|
receiver.address
|
|
10505
10509
|
]);
|
|
10506
10510
|
return [call1, call2];
|
|
@@ -10515,7 +10519,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10515
10519
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
10516
10520
|
return [
|
|
10517
10521
|
this.contract.populate("withdraw", [
|
|
10518
|
-
|
|
10522
|
+
import_starknet12.uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
10519
10523
|
receiver.address,
|
|
10520
10524
|
owner.address
|
|
10521
10525
|
])
|
|
@@ -10539,7 +10543,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10539
10543
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
10540
10544
|
const assets = await this.contract.call(
|
|
10541
10545
|
"convert_to_assets",
|
|
10542
|
-
[
|
|
10546
|
+
[import_starknet12.uint256.bnToUint256(shares)],
|
|
10543
10547
|
{ blockIdentifier }
|
|
10544
10548
|
);
|
|
10545
10549
|
const amount = Web3Number.fromWei(
|
|
@@ -10665,7 +10669,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10665
10669
|
);
|
|
10666
10670
|
const _pool = pools.find((d) => {
|
|
10667
10671
|
logger.verbose(
|
|
10668
|
-
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${
|
|
10672
|
+
`pool check: ${ContractAddr.from(d.id).eq(p.pool_id)}, id: ${d.id}, pool_id: ${import_starknet12.num.getDecimalString(
|
|
10669
10673
|
p.pool_id.address.toString()
|
|
10670
10674
|
)}`
|
|
10671
10675
|
);
|
|
@@ -10690,14 +10694,14 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10690
10694
|
`Asset ${this.asset().address.toString()} not found in pool ${p.pool_id.address.toString()}`
|
|
10691
10695
|
);
|
|
10692
10696
|
}
|
|
10693
|
-
let vTokenContract = new
|
|
10697
|
+
let vTokenContract = new import_starknet12.Contract({
|
|
10694
10698
|
abi: vesu_rebalance_abi_default,
|
|
10695
10699
|
address: p.v_token.address,
|
|
10696
10700
|
providerOrAccount: this.config.provider
|
|
10697
10701
|
});
|
|
10698
10702
|
const bal = await vTokenContract.balanceOf(this.address.address);
|
|
10699
10703
|
const assets = await vTokenContract.convert_to_assets(
|
|
10700
|
-
|
|
10704
|
+
import_starknet12.uint256.bnToUint256(bal.toString())
|
|
10701
10705
|
);
|
|
10702
10706
|
logger.verbose(`Collateral: ${JSON.stringify(vesuPosition?.collateral)}`);
|
|
10703
10707
|
logger.verbose(`supplyApy: ${JSON.stringify(assetInfo?.stats.supplyApy)}`);
|
|
@@ -10999,11 +11003,11 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10999
11003
|
if (p.changeAmt.eq(0)) return null;
|
|
11000
11004
|
actions.push({
|
|
11001
11005
|
pool_id: p.pool_id.address,
|
|
11002
|
-
feature: new
|
|
11006
|
+
feature: new import_starknet12.CairoCustomEnum(
|
|
11003
11007
|
p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }
|
|
11004
11008
|
),
|
|
11005
11009
|
token: this.asset().address.address,
|
|
11006
|
-
amount:
|
|
11010
|
+
amount: import_starknet12.uint256.bnToUint256(
|
|
11007
11011
|
p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei()
|
|
11008
11012
|
)
|
|
11009
11013
|
});
|
|
@@ -11062,10 +11066,10 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
11062
11066
|
const avnu = new AvnuWrapper();
|
|
11063
11067
|
let swapInfo = {
|
|
11064
11068
|
token_from_address: harvest.token.address,
|
|
11065
|
-
token_from_amount:
|
|
11069
|
+
token_from_amount: import_starknet12.uint256.bnToUint256(harvest.actualReward.toWei()),
|
|
11066
11070
|
token_to_address: this.asset().address.address,
|
|
11067
|
-
token_to_amount:
|
|
11068
|
-
token_to_min_amount:
|
|
11071
|
+
token_to_amount: import_starknet12.uint256.bnToUint256(0),
|
|
11072
|
+
token_to_min_amount: import_starknet12.uint256.bnToUint256(0),
|
|
11069
11073
|
beneficiary: this.address.address,
|
|
11070
11074
|
integrator_fee_amount_bps: 0,
|
|
11071
11075
|
integrator_fee_recipient: this.address.address,
|
|
@@ -11334,7 +11338,7 @@ VesuRebalanceStrategies.forEach((s) => {
|
|
|
11334
11338
|
});
|
|
11335
11339
|
|
|
11336
11340
|
// src/strategies/ekubo-cl-vault.tsx
|
|
11337
|
-
var
|
|
11341
|
+
var import_starknet13 = require("starknet");
|
|
11338
11342
|
|
|
11339
11343
|
// src/data/cl-vault.abi.json
|
|
11340
11344
|
var cl_vault_abi_default = [
|
|
@@ -16351,13 +16355,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16351
16355
|
);
|
|
16352
16356
|
this.metadata = metadata;
|
|
16353
16357
|
this.address = metadata.address;
|
|
16354
|
-
this.contract = new
|
|
16358
|
+
this.contract = new import_starknet13.Contract({
|
|
16355
16359
|
abi: cl_vault_abi_default,
|
|
16356
16360
|
address: this.address.address,
|
|
16357
16361
|
providerOrAccount: this.config.provider
|
|
16358
16362
|
});
|
|
16359
16363
|
if (this.metadata.additionalInfo.lstContract) {
|
|
16360
|
-
this.lstContract = new
|
|
16364
|
+
this.lstContract = new import_starknet13.Contract({
|
|
16361
16365
|
abi: erc4626_abi_default,
|
|
16362
16366
|
address: this.metadata.additionalInfo.lstContract.address,
|
|
16363
16367
|
providerOrAccount: this.config.provider
|
|
@@ -16366,13 +16370,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16366
16370
|
this.lstContract = null;
|
|
16367
16371
|
}
|
|
16368
16372
|
const EKUBO_POSITION = "0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067";
|
|
16369
|
-
this.ekuboPositionsContract = new
|
|
16373
|
+
this.ekuboPositionsContract = new import_starknet13.Contract({
|
|
16370
16374
|
abi: ekubo_positions_abi_default,
|
|
16371
16375
|
address: EKUBO_POSITION,
|
|
16372
16376
|
providerOrAccount: this.config.provider
|
|
16373
16377
|
});
|
|
16374
16378
|
const EKUBO_MATH = "0x04a72e9e166f6c0e9d800af4dc40f6b6fb4404b735d3f528d9250808b2481995";
|
|
16375
|
-
this.ekuboMathContract = new
|
|
16379
|
+
this.ekuboMathContract = new import_starknet13.Contract({
|
|
16376
16380
|
abi: ekubo_math_abi_default,
|
|
16377
16381
|
address: EKUBO_MATH,
|
|
16378
16382
|
providerOrAccount: this.config.provider
|
|
@@ -16403,7 +16407,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16403
16407
|
const shares = await this.tokensToShares(amountInfo);
|
|
16404
16408
|
const { amount0, amount1 } = await this.contract.call(
|
|
16405
16409
|
"convert_to_assets",
|
|
16406
|
-
[
|
|
16410
|
+
[import_starknet13.uint256.bnToUint256(shares.toWei())]
|
|
16407
16411
|
);
|
|
16408
16412
|
return {
|
|
16409
16413
|
token0: {
|
|
@@ -16424,27 +16428,27 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16424
16428
|
}
|
|
16425
16429
|
async depositCall(amountInfo, receiver) {
|
|
16426
16430
|
const updateAmountInfo = await this.getMinDepositAmounts(amountInfo);
|
|
16427
|
-
const token0Contract = new
|
|
16431
|
+
const token0Contract = new import_starknet13.Contract({
|
|
16428
16432
|
abi: erc4626_abi_default,
|
|
16429
16433
|
address: amountInfo.token0.tokenInfo.address.address,
|
|
16430
16434
|
providerOrAccount: this.config.provider
|
|
16431
16435
|
});
|
|
16432
|
-
const token1Contract = new
|
|
16436
|
+
const token1Contract = new import_starknet13.Contract({
|
|
16433
16437
|
abi: erc4626_abi_default,
|
|
16434
16438
|
address: amountInfo.token1.tokenInfo.address.address,
|
|
16435
16439
|
providerOrAccount: this.config.provider
|
|
16436
16440
|
});
|
|
16437
16441
|
const call1 = token0Contract.populate("approve", [
|
|
16438
16442
|
this.address.address,
|
|
16439
|
-
|
|
16443
|
+
import_starknet13.uint256.bnToUint256(updateAmountInfo.token0.amount.toWei())
|
|
16440
16444
|
]);
|
|
16441
16445
|
const call2 = token1Contract.populate("approve", [
|
|
16442
16446
|
this.address.address,
|
|
16443
|
-
|
|
16447
|
+
import_starknet13.uint256.bnToUint256(updateAmountInfo.token1.amount.toWei())
|
|
16444
16448
|
]);
|
|
16445
16449
|
const call3 = this.contract.populate("deposit", [
|
|
16446
|
-
|
|
16447
|
-
|
|
16450
|
+
import_starknet13.uint256.bnToUint256(updateAmountInfo.token0.amount.toWei()),
|
|
16451
|
+
import_starknet13.uint256.bnToUint256(updateAmountInfo.token1.amount.toWei()),
|
|
16448
16452
|
receiver.address
|
|
16449
16453
|
]);
|
|
16450
16454
|
const calls = [];
|
|
@@ -16454,8 +16458,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16454
16458
|
}
|
|
16455
16459
|
async tokensToShares(amountInfo) {
|
|
16456
16460
|
const shares = await this.contract.call("convert_to_shares", [
|
|
16457
|
-
|
|
16458
|
-
|
|
16461
|
+
import_starknet13.uint256.bnToUint256(amountInfo.token0.amount.toWei()),
|
|
16462
|
+
import_starknet13.uint256.bnToUint256(amountInfo.token1.amount.toWei())
|
|
16459
16463
|
]);
|
|
16460
16464
|
return Web3Number.fromWei(shares.toString(), 18);
|
|
16461
16465
|
}
|
|
@@ -16466,7 +16470,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16466
16470
|
);
|
|
16467
16471
|
return [
|
|
16468
16472
|
this.contract.populate("withdraw", [
|
|
16469
|
-
|
|
16473
|
+
import_starknet13.uint256.bnToUint256(shares.toWei()),
|
|
16470
16474
|
receiver.address
|
|
16471
16475
|
])
|
|
16472
16476
|
];
|
|
@@ -16488,14 +16492,21 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16488
16492
|
handleFeesCall() {
|
|
16489
16493
|
return [this.contract.populate("handle_fees", [])];
|
|
16490
16494
|
}
|
|
16491
|
-
async getFeeHistory(timePeriod = "24h") {
|
|
16495
|
+
async getFeeHistory(timePeriod = "24h", range) {
|
|
16492
16496
|
const { data } = await apollo_client_default.query({
|
|
16493
16497
|
query: import_client4.gql`
|
|
16494
16498
|
query ContractFeeEarnings(
|
|
16495
16499
|
$timeframe: String!
|
|
16496
16500
|
$contract: String!
|
|
16501
|
+
$startTimestamp: Float
|
|
16502
|
+
$endTimestamp: Float
|
|
16497
16503
|
) {
|
|
16498
|
-
contractFeeEarnings(
|
|
16504
|
+
contractFeeEarnings(
|
|
16505
|
+
timeframe: $timeframe
|
|
16506
|
+
contract: $contract
|
|
16507
|
+
startTimestamp: $startTimestamp
|
|
16508
|
+
endTimestamp: $endTimestamp
|
|
16509
|
+
) {
|
|
16499
16510
|
contract
|
|
16500
16511
|
dailyEarnings {
|
|
16501
16512
|
date
|
|
@@ -16508,7 +16519,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16508
16519
|
`,
|
|
16509
16520
|
variables: {
|
|
16510
16521
|
timeframe: timePeriod,
|
|
16511
|
-
contract: this.address.address
|
|
16522
|
+
contract: this.address.address,
|
|
16523
|
+
startTimestamp: range?.startTimestamp,
|
|
16524
|
+
endTimestamp: range?.endTimestamp
|
|
16512
16525
|
},
|
|
16513
16526
|
fetchPolicy: "no-cache"
|
|
16514
16527
|
});
|
|
@@ -16680,7 +16693,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16680
16693
|
let bal = await this.balanceOf(user, blockIdentifier);
|
|
16681
16694
|
const assets = await this.contract.call(
|
|
16682
16695
|
"convert_to_assets",
|
|
16683
|
-
[
|
|
16696
|
+
[import_starknet13.uint256.bnToUint256(bal.toWei())],
|
|
16684
16697
|
{
|
|
16685
16698
|
blockIdentifier
|
|
16686
16699
|
}
|
|
@@ -16826,7 +16839,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16826
16839
|
return this.metadata.additionalInfo.truePrice;
|
|
16827
16840
|
} else if (this.lstContract) {
|
|
16828
16841
|
const result = await this.lstContract.call("convert_to_assets", [
|
|
16829
|
-
|
|
16842
|
+
import_starknet13.uint256.bnToUint256(BigInt(1e18).toString())
|
|
16830
16843
|
]);
|
|
16831
16844
|
const truePrice = Number(BigInt(result.toString()) * BigInt(1e9) / BigInt(1e18)) / 1e9;
|
|
16832
16845
|
return truePrice;
|
|
@@ -17327,7 +17340,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17327
17340
|
logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17328
17341
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17329
17342
|
}
|
|
17330
|
-
const fromAmount =
|
|
17343
|
+
const fromAmount = import_starknet13.uint256.uint256ToBN(swapInfo.token_from_amount);
|
|
17331
17344
|
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
17332
17345
|
logger.verbose(
|
|
17333
17346
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
@@ -17356,7 +17369,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17356
17369
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17357
17370
|
throw err;
|
|
17358
17371
|
}
|
|
17359
|
-
newSwapInfo.token_from_amount =
|
|
17372
|
+
newSwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(nextAmount);
|
|
17360
17373
|
} else {
|
|
17361
17374
|
logger.verbose("Increasing swap amount - deficit token0");
|
|
17362
17375
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17368,7 +17381,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17368
17381
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17369
17382
|
throw err;
|
|
17370
17383
|
}
|
|
17371
|
-
newSwapInfo.token_from_amount =
|
|
17384
|
+
newSwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(nextAmount);
|
|
17372
17385
|
}
|
|
17373
17386
|
} else if (err.message.includes("invalid token1 amount") || err.message.includes("invalid token1 balance")) {
|
|
17374
17387
|
if (isSellTokenToken0) {
|
|
@@ -17379,7 +17392,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17379
17392
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17380
17393
|
throw err;
|
|
17381
17394
|
}
|
|
17382
|
-
newSwapInfo.token_from_amount =
|
|
17395
|
+
newSwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(nextAmount);
|
|
17383
17396
|
} else {
|
|
17384
17397
|
logger.verbose("Increasing swap amount - deficit token1");
|
|
17385
17398
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17391,7 +17404,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17391
17404
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17392
17405
|
throw err;
|
|
17393
17406
|
}
|
|
17394
|
-
newSwapInfo.token_from_amount =
|
|
17407
|
+
newSwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(nextAmount);
|
|
17395
17408
|
}
|
|
17396
17409
|
} else if (err.message.includes("Residual tokens")) {
|
|
17397
17410
|
logger.error("Residual tokens");
|
|
@@ -17421,7 +17434,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17421
17434
|
logger.error("Unexpected error:", err);
|
|
17422
17435
|
throw err;
|
|
17423
17436
|
}
|
|
17424
|
-
newSwapInfo.token_to_min_amount =
|
|
17437
|
+
newSwapInfo.token_to_min_amount = import_starknet13.uint256.bnToUint256("0");
|
|
17425
17438
|
return this.rebalanceIter(
|
|
17426
17439
|
newSwapInfo,
|
|
17427
17440
|
acc,
|
|
@@ -17472,15 +17485,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17472
17485
|
const result = await this.ekuboMathContract.call(
|
|
17473
17486
|
"liquidity_delta_to_amount_delta",
|
|
17474
17487
|
[
|
|
17475
|
-
|
|
17488
|
+
import_starknet13.uint256.bnToUint256(currentPrice.sqrtRatio),
|
|
17476
17489
|
{
|
|
17477
17490
|
mag: liquidity.toWei(),
|
|
17478
17491
|
sign: 0
|
|
17479
17492
|
},
|
|
17480
|
-
|
|
17493
|
+
import_starknet13.uint256.bnToUint256(
|
|
17481
17494
|
_EkuboCLVault.priceToSqrtRatio(lowerPrice).toString()
|
|
17482
17495
|
),
|
|
17483
|
-
|
|
17496
|
+
import_starknet13.uint256.bnToUint256(
|
|
17484
17497
|
_EkuboCLVault.priceToSqrtRatio(upperPrice).toString()
|
|
17485
17498
|
)
|
|
17486
17499
|
],
|
|
@@ -17583,7 +17596,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17583
17596
|
const claimTokenInfo = await Global.getTokenInfoFromAddr(claim.token);
|
|
17584
17597
|
const harvestEstimateCall = async (baseSwapInfo2) => {
|
|
17585
17598
|
let baseSwapAmount = Web3Number.fromWei(
|
|
17586
|
-
|
|
17599
|
+
import_starknet13.uint256.uint256ToBN(baseSwapInfo2.token_from_amount).toString(),
|
|
17587
17600
|
claimTokenInfo.decimals
|
|
17588
17601
|
).minimum(
|
|
17589
17602
|
postFeeAmount.toFixed(claimTokenInfo.decimals)
|
|
@@ -17591,7 +17604,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17591
17604
|
if (baseSwapAmount.lt(1e-4)) {
|
|
17592
17605
|
baseSwapAmount = new Web3Number(0, claimTokenInfo.decimals);
|
|
17593
17606
|
}
|
|
17594
|
-
baseSwapInfo2.token_from_amount =
|
|
17607
|
+
baseSwapInfo2.token_from_amount = import_starknet13.uint256.bnToUint256(baseSwapAmount.toWei());
|
|
17595
17608
|
const isToken0ClaimToken2 = claim.token.eq(poolKey.token0);
|
|
17596
17609
|
logger.verbose(
|
|
17597
17610
|
`${_EkuboCLVault.name}: harvest => isToken0ClaimToken: ${isToken0ClaimToken2}, baseSwapAmount: ${baseSwapAmount}`
|
|
@@ -17601,7 +17614,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17601
17614
|
`${_EkuboCLVault.name}: harvest => remainingAmount: ${remainingAmount}`
|
|
17602
17615
|
);
|
|
17603
17616
|
let dummySwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, claim.token);
|
|
17604
|
-
dummySwapInfo.token_from_amount =
|
|
17617
|
+
dummySwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(remainingAmount.toWei());
|
|
17605
17618
|
logger.verbose(
|
|
17606
17619
|
`${_EkuboCLVault.name}: harvest => dummySwapInfo: ${JSON.stringify(
|
|
17607
17620
|
dummySwapInfo
|
|
@@ -17619,7 +17632,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17619
17632
|
amount: claim.claim.amount.toWei(),
|
|
17620
17633
|
claimee: claim.claim.claimee.address
|
|
17621
17634
|
},
|
|
17622
|
-
claim.proof.map((p) =>
|
|
17635
|
+
claim.proof.map((p) => import_starknet13.num.getDecimalString(p)),
|
|
17623
17636
|
isToken0ClaimToken2 ? dummySwapInfo : baseSwapInfo2,
|
|
17624
17637
|
// is token0 claim token, its just dummy swap
|
|
17625
17638
|
isToken0ClaimToken2 ? baseSwapInfo2 : dummySwapInfo
|
|
@@ -17628,7 +17641,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17628
17641
|
};
|
|
17629
17642
|
const isToken0ClaimToken = claim.token.eq(poolKey.token0);
|
|
17630
17643
|
let baseSwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, isToken0ClaimToken ? token1Info.address : token0Info.address);
|
|
17631
|
-
baseSwapInfo.token_from_amount =
|
|
17644
|
+
baseSwapInfo.token_from_amount = import_starknet13.uint256.bnToUint256(postFeeAmount.toWei());
|
|
17632
17645
|
if (postFeeAmount.greaterThan(0) && !isToken0ClaimToken) {
|
|
17633
17646
|
const avnuWrapper = new AvnuWrapper();
|
|
17634
17647
|
const quote = await avnuWrapper.getQuotes(
|
|
@@ -17737,7 +17750,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17737
17750
|
amount: claim.claim.amount.toWei(),
|
|
17738
17751
|
claimee: claim.claim.claimee.address
|
|
17739
17752
|
},
|
|
17740
|
-
claim.proof.map((p) =>
|
|
17753
|
+
claim.proof.map((p) => import_starknet13.num.getDecimalString(p)),
|
|
17741
17754
|
swapInfo1,
|
|
17742
17755
|
swapInfo2
|
|
17743
17756
|
];
|
|
@@ -18428,7 +18441,7 @@ EkuboCLVaultStrategies.forEach((s) => {
|
|
|
18428
18441
|
});
|
|
18429
18442
|
|
|
18430
18443
|
// src/strategies/sensei.ts
|
|
18431
|
-
var
|
|
18444
|
+
var import_starknet16 = require("starknet");
|
|
18432
18445
|
|
|
18433
18446
|
// src/data/sensei.abi.json
|
|
18434
18447
|
var sensei_abi_default = [
|
|
@@ -20192,7 +20205,7 @@ var sensei_abi_default = [
|
|
|
20192
20205
|
];
|
|
20193
20206
|
|
|
20194
20207
|
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
20195
|
-
var
|
|
20208
|
+
var import_starknet15 = require("starknet");
|
|
20196
20209
|
|
|
20197
20210
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
20198
20211
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
@@ -20214,7 +20227,7 @@ function toBigInt(value) {
|
|
|
20214
20227
|
}
|
|
20215
20228
|
|
|
20216
20229
|
// src/strategies/universal-adapters/baseAdapter.ts
|
|
20217
|
-
var
|
|
20230
|
+
var import_starknet14 = require("starknet");
|
|
20218
20231
|
var APYType = /* @__PURE__ */ ((APYType2) => {
|
|
20219
20232
|
APYType2["BASE"] = "base";
|
|
20220
20233
|
APYType2["REWARD"] = "reward";
|
|
@@ -20270,14 +20283,14 @@ var BaseAdapter = class extends CacheClass {
|
|
|
20270
20283
|
constructSimpleLeafData(params, sanitizer = SIMPLE_SANITIZER) {
|
|
20271
20284
|
const { id, target, method, packedArguments } = params;
|
|
20272
20285
|
return {
|
|
20273
|
-
id: BigInt(
|
|
20286
|
+
id: BigInt(import_starknet14.num.getDecimalString(import_starknet14.shortString.encodeShortString(id))),
|
|
20274
20287
|
readableId: id,
|
|
20275
20288
|
data: [
|
|
20276
20289
|
sanitizer.toBigInt(),
|
|
20277
20290
|
// sanitizer address
|
|
20278
20291
|
target.toBigInt(),
|
|
20279
20292
|
// contract
|
|
20280
|
-
toBigInt(
|
|
20293
|
+
toBigInt(import_starknet14.hash.getSelectorFromName(method)),
|
|
20281
20294
|
// method name
|
|
20282
20295
|
BigInt(packedArguments.length),
|
|
20283
20296
|
...packedArguments
|
|
@@ -27417,7 +27430,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27417
27430
|
if (isIncrease) {
|
|
27418
27431
|
const _params2 = params;
|
|
27419
27432
|
return {
|
|
27420
|
-
action: new
|
|
27433
|
+
action: new import_starknet15.CairoCustomEnum({ IncreaseLever: {
|
|
27421
27434
|
pool_id: _params2.pool_id.toBigInt(),
|
|
27422
27435
|
collateral_asset: _params2.collateral_asset.toBigInt(),
|
|
27423
27436
|
debt_asset: _params2.debt_asset.toBigInt(),
|
|
@@ -27430,9 +27443,9 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27430
27443
|
token1: route.pool_key.token1.toBigInt(),
|
|
27431
27444
|
fee: route.pool_key.fee,
|
|
27432
27445
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27433
|
-
extension: BigInt(
|
|
27446
|
+
extension: BigInt(import_starknet15.num.hexToDecimalString(route.pool_key.extension))
|
|
27434
27447
|
},
|
|
27435
|
-
sqrt_ratio_limit:
|
|
27448
|
+
sqrt_ratio_limit: import_starknet15.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27436
27449
|
skip_ahead: BigInt(100)
|
|
27437
27450
|
})),
|
|
27438
27451
|
token_amount: {
|
|
@@ -27448,9 +27461,9 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27448
27461
|
token1: route.pool_key.token1.toBigInt(),
|
|
27449
27462
|
fee: route.pool_key.fee,
|
|
27450
27463
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27451
|
-
extension: BigInt(
|
|
27464
|
+
extension: BigInt(import_starknet15.num.hexToDecimalString(route.pool_key.extension))
|
|
27452
27465
|
},
|
|
27453
|
-
sqrt_ratio_limit:
|
|
27466
|
+
sqrt_ratio_limit: import_starknet15.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27454
27467
|
skip_ahead: BigInt(100)
|
|
27455
27468
|
})),
|
|
27456
27469
|
token_amount: {
|
|
@@ -27464,7 +27477,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27464
27477
|
}
|
|
27465
27478
|
const _params = params;
|
|
27466
27479
|
return {
|
|
27467
|
-
action: new
|
|
27480
|
+
action: new import_starknet15.CairoCustomEnum({ DecreaseLever: {
|
|
27468
27481
|
pool_id: _params.pool_id.toBigInt(),
|
|
27469
27482
|
collateral_asset: _params.collateral_asset.toBigInt(),
|
|
27470
27483
|
debt_asset: _params.debt_asset.toBigInt(),
|
|
@@ -27480,7 +27493,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27480
27493
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27481
27494
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27482
27495
|
},
|
|
27483
|
-
sqrt_ratio_limit:
|
|
27496
|
+
sqrt_ratio_limit: import_starknet15.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27484
27497
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27485
27498
|
})),
|
|
27486
27499
|
token_amount: {
|
|
@@ -27499,7 +27512,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27499
27512
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27500
27513
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27501
27514
|
},
|
|
27502
|
-
sqrt_ratio_limit:
|
|
27515
|
+
sqrt_ratio_limit: import_starknet15.uint256.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27503
27516
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27504
27517
|
})),
|
|
27505
27518
|
token_amount: {
|
|
@@ -27583,7 +27596,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27583
27596
|
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
27584
27597
|
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
27585
27598
|
value: {
|
|
27586
|
-
abs:
|
|
27599
|
+
abs: import_starknet15.uint256.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
27587
27600
|
is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
|
|
27588
27601
|
}
|
|
27589
27602
|
};
|
|
@@ -27592,7 +27605,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27592
27605
|
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
27593
27606
|
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
27594
27607
|
value: {
|
|
27595
|
-
abs:
|
|
27608
|
+
abs: import_starknet15.uint256.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
27596
27609
|
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
27597
27610
|
}
|
|
27598
27611
|
};
|
|
@@ -27619,7 +27632,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27619
27632
|
sanitizer: isV2 ? VESU_V2_MODIFY_POSITION_SANITIZER : SIMPLE_SANITIZER,
|
|
27620
27633
|
call: {
|
|
27621
27634
|
contractAddress: ContractAddr.from(contract.address),
|
|
27622
|
-
selector:
|
|
27635
|
+
selector: import_starknet15.hash.getSelectorFromName("modify_position"),
|
|
27623
27636
|
calldata: [
|
|
27624
27637
|
...call.calldata
|
|
27625
27638
|
]
|
|
@@ -27656,7 +27669,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27656
27669
|
}
|
|
27657
27670
|
const { isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
27658
27671
|
const VESU_MULTIPLY = isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1;
|
|
27659
|
-
const multiplyContract = new
|
|
27672
|
+
const multiplyContract = new import_starknet15.Contract({ abi: vesu_multiple_abi_default, address: VESU_MULTIPLY.toString(), providerOrAccount: new import_starknet15.RpcProvider({ nodeUrl: "" }) });
|
|
27660
27673
|
const call = multiplyContract.populate("modify_lever", {
|
|
27661
27674
|
modify_lever_params: getVesuMultiplyParams(isIncrease, {
|
|
27662
27675
|
...multiplyParams,
|
|
@@ -27671,22 +27684,22 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27671
27684
|
sanitizer: SIMPLE_SANITIZER_V2,
|
|
27672
27685
|
call: {
|
|
27673
27686
|
contractAddress: VESU_MULTIPLY,
|
|
27674
|
-
selector:
|
|
27687
|
+
selector: import_starknet15.hash.getSelectorFromName("modify_lever"),
|
|
27675
27688
|
calldata: [
|
|
27676
27689
|
...call.calldata
|
|
27677
27690
|
]
|
|
27678
27691
|
}
|
|
27679
27692
|
};
|
|
27680
27693
|
};
|
|
27681
|
-
this.getVesuModifyDelegationAdapter = (id) => {
|
|
27694
|
+
this.getVesuModifyDelegationAdapter = (id, delegatee) => {
|
|
27682
27695
|
return () => {
|
|
27683
27696
|
const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
27684
27697
|
const packedArguments = isV2 ? [
|
|
27685
|
-
toBigInt(
|
|
27698
|
+
toBigInt(delegatee.toString())
|
|
27686
27699
|
// v2
|
|
27687
27700
|
] : [
|
|
27688
27701
|
this.config.poolId.toBigInt(),
|
|
27689
|
-
toBigInt(
|
|
27702
|
+
toBigInt(delegatee.toString())
|
|
27690
27703
|
// v1
|
|
27691
27704
|
];
|
|
27692
27705
|
const output = this.constructSimpleLeafData({
|
|
@@ -27695,43 +27708,45 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27695
27708
|
method: "modify_delegation",
|
|
27696
27709
|
packedArguments
|
|
27697
27710
|
}, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
|
|
27698
|
-
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
27711
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall(delegatee).bind(this) };
|
|
27699
27712
|
};
|
|
27700
27713
|
};
|
|
27701
|
-
this.getVesuModifyDelegationCall = (
|
|
27702
|
-
|
|
27703
|
-
|
|
27704
|
-
|
|
27705
|
-
|
|
27706
|
-
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
|
|
27710
|
-
|
|
27711
|
-
|
|
27712
|
-
|
|
27713
|
-
|
|
27714
|
-
|
|
27715
|
-
|
|
27716
|
-
|
|
27717
|
-
|
|
27718
|
-
|
|
27719
|
-
|
|
27720
|
-
|
|
27714
|
+
this.getVesuModifyDelegationCall = (delegatee) => {
|
|
27715
|
+
return (params) => {
|
|
27716
|
+
const VESU_SINGLETON2 = getVesuSingletonAddress(this.config.poolId).addr;
|
|
27717
|
+
const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
|
|
27718
|
+
const call = contract.populate("modify_delegation", isV2 ? {
|
|
27719
|
+
delegatee: delegatee.toBigInt(),
|
|
27720
|
+
delegation: params.delegation
|
|
27721
|
+
} : {
|
|
27722
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
27723
|
+
delegatee: delegatee.toBigInt(),
|
|
27724
|
+
delegation: params.delegation
|
|
27725
|
+
});
|
|
27726
|
+
return {
|
|
27727
|
+
sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
|
|
27728
|
+
call: {
|
|
27729
|
+
contractAddress: VESU_SINGLETON2,
|
|
27730
|
+
selector: import_starknet15.hash.getSelectorFromName("modify_delegation"),
|
|
27731
|
+
calldata: [
|
|
27732
|
+
...call.calldata
|
|
27733
|
+
]
|
|
27734
|
+
}
|
|
27735
|
+
};
|
|
27721
27736
|
};
|
|
27722
27737
|
};
|
|
27723
27738
|
this.getDefispringRewardsAdapter = (id) => {
|
|
27724
27739
|
return () => {
|
|
27725
27740
|
const packedArguments = [];
|
|
27726
27741
|
const output = {
|
|
27727
|
-
id: BigInt(
|
|
27742
|
+
id: BigInt(import_starknet15.num.getDecimalString(import_starknet15.shortString.encodeShortString(id))),
|
|
27728
27743
|
readableId: id,
|
|
27729
27744
|
data: [
|
|
27730
27745
|
SIMPLE_SANITIZER.toBigInt(),
|
|
27731
27746
|
// sanitizer address
|
|
27732
27747
|
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
27733
27748
|
// contract
|
|
27734
|
-
toBigInt(
|
|
27749
|
+
toBigInt(import_starknet15.hash.getSelectorFromName("claim")),
|
|
27735
27750
|
// method name
|
|
27736
27751
|
BigInt(packedArguments.length),
|
|
27737
27752
|
...packedArguments
|
|
@@ -27745,11 +27760,11 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27745
27760
|
sanitizer: SIMPLE_SANITIZER,
|
|
27746
27761
|
call: {
|
|
27747
27762
|
contractAddress: VESU_REWARDS_CONTRACT,
|
|
27748
|
-
selector:
|
|
27763
|
+
selector: import_starknet15.hash.getSelectorFromName("claim"),
|
|
27749
27764
|
calldata: [
|
|
27750
27765
|
BigInt(params.amount.toWei()),
|
|
27751
27766
|
BigInt(params.proofs.length),
|
|
27752
|
-
...params.proofs.map((proof) => BigInt(
|
|
27767
|
+
...params.proofs.map((proof) => BigInt(import_starknet15.num.hexToDecimalString(proof)))
|
|
27753
27768
|
]
|
|
27754
27769
|
}
|
|
27755
27770
|
});
|
|
@@ -27779,18 +27794,18 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27779
27794
|
formatAmountTypeEnum(amountType) {
|
|
27780
27795
|
switch (amountType) {
|
|
27781
27796
|
case 0 /* Delta */:
|
|
27782
|
-
return new
|
|
27797
|
+
return new import_starknet15.CairoCustomEnum({ Delta: {} });
|
|
27783
27798
|
case 1 /* Target */:
|
|
27784
|
-
return new
|
|
27799
|
+
return new import_starknet15.CairoCustomEnum({ Target: {} });
|
|
27785
27800
|
}
|
|
27786
27801
|
throw new Error(`Unknown VesuAmountType: ${amountType}`);
|
|
27787
27802
|
}
|
|
27788
27803
|
formatAmountDenominationEnum(denomination) {
|
|
27789
27804
|
switch (denomination) {
|
|
27790
27805
|
case 0 /* Native */:
|
|
27791
|
-
return new
|
|
27806
|
+
return new import_starknet15.CairoCustomEnum({ Native: {} });
|
|
27792
27807
|
case 1 /* Assets */:
|
|
27793
|
-
return new
|
|
27808
|
+
return new import_starknet15.CairoCustomEnum({ Assets: {} });
|
|
27794
27809
|
}
|
|
27795
27810
|
throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
|
|
27796
27811
|
}
|
|
@@ -27798,7 +27813,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27798
27813
|
const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(poolId);
|
|
27799
27814
|
const ABI = isV2 ? vesu_pool_v2_abi_default : vesu_singleton_abi_default;
|
|
27800
27815
|
return {
|
|
27801
|
-
contract: new
|
|
27816
|
+
contract: new import_starknet15.Contract({ abi: ABI, address: VESU_SINGLETON2.address, providerOrAccount: config.provider }),
|
|
27802
27817
|
isV2
|
|
27803
27818
|
};
|
|
27804
27819
|
}
|
|
@@ -27809,7 +27824,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27809
27824
|
if (!extensionAddr) {
|
|
27810
27825
|
throw new Error("Extension address not found");
|
|
27811
27826
|
}
|
|
27812
|
-
const extensionContract = new
|
|
27827
|
+
const extensionContract = new import_starknet15.Contract({ abi: vesu_extension_abi_default, address: extensionAddr.address, providerOrAccount: config.provider });
|
|
27813
27828
|
const output2 = await extensionContract.call("debt_caps", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
|
|
27814
27829
|
logger.verbose(`${this.config.debt.symbol}::VesuAdapter::getDebtCap debt_cap: ${output2.toString()}`);
|
|
27815
27830
|
return Web3Number.fromWei(output2.toString(), this.config.debt.decimals);
|
|
@@ -27839,7 +27854,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27839
27854
|
if (!extensionAddr) {
|
|
27840
27855
|
throw new Error("Extension address not found");
|
|
27841
27856
|
}
|
|
27842
|
-
interestRateConfigContract = new
|
|
27857
|
+
interestRateConfigContract = new import_starknet15.Contract({ abi: vesu_extension_abi_default, address: extensionAddr.address, providerOrAccount: config.provider });
|
|
27843
27858
|
}
|
|
27844
27859
|
const _interestRateConfig = await interestRateConfigContract.call(
|
|
27845
27860
|
"interest_rate_config",
|
|
@@ -28212,7 +28227,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28212
28227
|
this.address = metadata.address;
|
|
28213
28228
|
this.pricer = pricer;
|
|
28214
28229
|
this.metadata = metadata;
|
|
28215
|
-
this.contract = new
|
|
28230
|
+
this.contract = new import_starknet16.Contract({ abi: sensei_abi_default, address: this.address.address, providerOrAccount: this.config.provider });
|
|
28216
28231
|
if (metadata.depositTokens.length === 0) {
|
|
28217
28232
|
throw new Error("Deposit tokens are not defined in metadata");
|
|
28218
28233
|
}
|
|
@@ -28226,7 +28241,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28226
28241
|
}
|
|
28227
28242
|
);
|
|
28228
28243
|
const amount = Web3Number.fromWei(
|
|
28229
|
-
|
|
28244
|
+
import_starknet16.uint256.uint256ToBN(result[1].estimated_size).toString(),
|
|
28230
28245
|
this.metadata.depositTokens[0].decimals
|
|
28231
28246
|
);
|
|
28232
28247
|
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
@@ -28269,17 +28284,17 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28269
28284
|
}
|
|
28270
28285
|
}
|
|
28271
28286
|
async depositCall(amountInfo, receiver) {
|
|
28272
|
-
const mainTokenContract = new
|
|
28287
|
+
const mainTokenContract = new import_starknet16.Contract({
|
|
28273
28288
|
abi: erc20_abi_default,
|
|
28274
28289
|
address: this.metadata.depositTokens[0].address.address,
|
|
28275
28290
|
providerOrAccount: this.config.provider
|
|
28276
28291
|
});
|
|
28277
28292
|
const call1 = mainTokenContract.populate("approve", [
|
|
28278
28293
|
this.address.address,
|
|
28279
|
-
|
|
28294
|
+
import_starknet16.uint256.bnToUint256(amountInfo.amount.toWei())
|
|
28280
28295
|
]);
|
|
28281
28296
|
const call2 = this.contract.populate("deposit", [
|
|
28282
|
-
|
|
28297
|
+
import_starknet16.uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
28283
28298
|
receiver.address
|
|
28284
28299
|
]);
|
|
28285
28300
|
const calls = [call1, call2];
|
|
@@ -28287,7 +28302,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28287
28302
|
}
|
|
28288
28303
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
28289
28304
|
const call = this.contract.populate("withdraw", [
|
|
28290
|
-
|
|
28305
|
+
import_starknet16.uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
28291
28306
|
receiver.address,
|
|
28292
28307
|
300
|
|
28293
28308
|
// 3% max slippage
|
|
@@ -28375,7 +28390,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28375
28390
|
const { pools } = await VesuAdapter.getVesuPools();
|
|
28376
28391
|
const re7PoolId = VesuPools.Re7xSTRK;
|
|
28377
28392
|
const pool = pools.find(
|
|
28378
|
-
(p) => ContractAddr.from(
|
|
28393
|
+
(p) => ContractAddr.from(import_starknet16.num.getHexString(p.id)).eq(re7PoolId)
|
|
28379
28394
|
);
|
|
28380
28395
|
if (!pool) {
|
|
28381
28396
|
logger.warn(`${_SenseiVault.name}::netAPY - Re7 xSTRK pool not found`);
|
|
@@ -28607,7 +28622,7 @@ var SenseiStrategies = [
|
|
|
28607
28622
|
];
|
|
28608
28623
|
|
|
28609
28624
|
// src/strategies/universal-adapters/common-adapter.ts
|
|
28610
|
-
var
|
|
28625
|
+
var import_starknet17 = require("starknet");
|
|
28611
28626
|
var CommonAdapter = class extends BaseAdapter {
|
|
28612
28627
|
constructor(config) {
|
|
28613
28628
|
super();
|
|
@@ -28632,12 +28647,12 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28632
28647
|
return { leaf, callConstructor: this.getFlashloanCall.bind(this) };
|
|
28633
28648
|
}
|
|
28634
28649
|
getFlashloanCall(params) {
|
|
28635
|
-
const uint256Amount =
|
|
28650
|
+
const uint256Amount = import_starknet17.uint256.bnToUint256(params.amount.toWei());
|
|
28636
28651
|
return {
|
|
28637
28652
|
sanitizer: SIMPLE_SANITIZER,
|
|
28638
28653
|
call: {
|
|
28639
28654
|
contractAddress: this.config.manager,
|
|
28640
|
-
selector:
|
|
28655
|
+
selector: import_starknet17.hash.getSelectorFromName("flash_loan"),
|
|
28641
28656
|
calldata: [
|
|
28642
28657
|
this.config.manager.toBigInt(),
|
|
28643
28658
|
// receiver
|
|
@@ -28671,12 +28686,12 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28671
28686
|
}
|
|
28672
28687
|
getApproveCall(token, spender) {
|
|
28673
28688
|
return (params) => {
|
|
28674
|
-
const uint256Amount =
|
|
28689
|
+
const uint256Amount = import_starknet17.uint256.bnToUint256(params.amount.toWei());
|
|
28675
28690
|
return {
|
|
28676
28691
|
sanitizer: SIMPLE_SANITIZER,
|
|
28677
28692
|
call: {
|
|
28678
28693
|
contractAddress: token,
|
|
28679
|
-
selector:
|
|
28694
|
+
selector: import_starknet17.hash.getSelectorFromName("approve"),
|
|
28680
28695
|
calldata: [
|
|
28681
28696
|
spender.toBigInt(),
|
|
28682
28697
|
// spender
|
|
@@ -28702,12 +28717,12 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28702
28717
|
}
|
|
28703
28718
|
getBringLiquidityCall() {
|
|
28704
28719
|
return (params) => {
|
|
28705
|
-
const uint256Amount =
|
|
28720
|
+
const uint256Amount = import_starknet17.uint256.bnToUint256(params.amount.toWei());
|
|
28706
28721
|
return {
|
|
28707
28722
|
sanitizer: SIMPLE_SANITIZER,
|
|
28708
28723
|
call: {
|
|
28709
28724
|
contractAddress: this.config.vaultAddress,
|
|
28710
|
-
selector:
|
|
28725
|
+
selector: import_starknet17.hash.getSelectorFromName("bring_liquidity"),
|
|
28711
28726
|
calldata: [
|
|
28712
28727
|
toBigInt(uint256Amount.low.toString()),
|
|
28713
28728
|
// amount low
|
|
@@ -28739,7 +28754,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28739
28754
|
sanitizer: SIMPLE_SANITIZER,
|
|
28740
28755
|
call: {
|
|
28741
28756
|
contractAddress: isMiddleware ? AVNU_MIDDLEWARE : AVNU_EXCHANGE,
|
|
28742
|
-
selector:
|
|
28757
|
+
selector: import_starknet17.hash.getSelectorFromName("multi_route_swap"),
|
|
28743
28758
|
calldata: [
|
|
28744
28759
|
fromToken.toBigInt(),
|
|
28745
28760
|
// sell_token_address
|
|
@@ -28766,12 +28781,12 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28766
28781
|
// unpack routes
|
|
28767
28782
|
BigInt(params.props.routes.length),
|
|
28768
28783
|
...params.props.routes.map((r) => [
|
|
28769
|
-
BigInt(
|
|
28770
|
-
BigInt(
|
|
28771
|
-
BigInt(
|
|
28784
|
+
BigInt(import_starknet17.num.hexToDecimalString(r.token_from)),
|
|
28785
|
+
BigInt(import_starknet17.num.hexToDecimalString(r.token_to)),
|
|
28786
|
+
BigInt(import_starknet17.num.hexToDecimalString(r.exchange_address)),
|
|
28772
28787
|
BigInt(r.percent),
|
|
28773
28788
|
BigInt(r.additional_swap_params.length),
|
|
28774
|
-
...r.additional_swap_params.map((p) => BigInt(
|
|
28789
|
+
...r.additional_swap_params.map((p) => BigInt(import_starknet17.num.hexToDecimalString(p)))
|
|
28775
28790
|
]).flat()
|
|
28776
28791
|
]
|
|
28777
28792
|
}
|
|
@@ -28781,7 +28796,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28781
28796
|
};
|
|
28782
28797
|
|
|
28783
28798
|
// src/strategies/universal-strategy.tsx
|
|
28784
|
-
var
|
|
28799
|
+
var import_starknet18 = require("starknet");
|
|
28785
28800
|
|
|
28786
28801
|
// src/data/universal-vault.abi.json
|
|
28787
28802
|
var universal_vault_abi_default = [
|
|
@@ -31003,12 +31018,12 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31003
31018
|
);
|
|
31004
31019
|
this.metadata = metadata;
|
|
31005
31020
|
this.address = metadata.address;
|
|
31006
|
-
this.contract = new
|
|
31021
|
+
this.contract = new import_starknet18.Contract({
|
|
31007
31022
|
abi: universal_vault_abi_default,
|
|
31008
31023
|
address: this.address.address,
|
|
31009
31024
|
providerOrAccount: this.config.provider
|
|
31010
31025
|
});
|
|
31011
|
-
this.managerContract = new
|
|
31026
|
+
this.managerContract = new import_starknet18.Contract({
|
|
31012
31027
|
abi: vault_manager_abi_default,
|
|
31013
31028
|
address: this.metadata.additionalInfo.manager.address,
|
|
31014
31029
|
providerOrAccount: this.config.provider
|
|
@@ -31062,17 +31077,17 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31062
31077
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
31063
31078
|
"Deposit token mismatch"
|
|
31064
31079
|
);
|
|
31065
|
-
const assetContract = new
|
|
31080
|
+
const assetContract = new import_starknet18.Contract({
|
|
31066
31081
|
abi: universal_vault_abi_default,
|
|
31067
31082
|
address: this.asset().address.address,
|
|
31068
31083
|
providerOrAccount: this.config.provider
|
|
31069
31084
|
});
|
|
31070
31085
|
const call1 = assetContract.populate("approve", [
|
|
31071
31086
|
this.address.address,
|
|
31072
|
-
|
|
31087
|
+
import_starknet18.uint256.bnToUint256(amountInfo.amount.toWei())
|
|
31073
31088
|
]);
|
|
31074
31089
|
const call2 = this.contract.populate("deposit", [
|
|
31075
|
-
|
|
31090
|
+
import_starknet18.uint256.bnToUint256(amountInfo.amount.toWei()),
|
|
31076
31091
|
receiver.address
|
|
31077
31092
|
]);
|
|
31078
31093
|
return [call1, call2];
|
|
@@ -31082,9 +31097,9 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31082
31097
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
31083
31098
|
"Withdraw token mismatch"
|
|
31084
31099
|
);
|
|
31085
|
-
const shares = await this.contract.call("convert_to_shares", [
|
|
31100
|
+
const shares = await this.contract.call("convert_to_shares", [import_starknet18.uint256.bnToUint256(amountInfo.amount.toWei())]);
|
|
31086
31101
|
const call = this.contract.populate("request_redeem", [
|
|
31087
|
-
|
|
31102
|
+
import_starknet18.uint256.bnToUint256(shares.toString()),
|
|
31088
31103
|
receiver.address,
|
|
31089
31104
|
owner.address
|
|
31090
31105
|
]);
|
|
@@ -31094,7 +31109,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31094
31109
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
31095
31110
|
const assets = await this.contract.call(
|
|
31096
31111
|
"convert_to_assets",
|
|
31097
|
-
[
|
|
31112
|
+
[import_starknet18.uint256.bnToUint256(shares)],
|
|
31098
31113
|
{ blockIdentifier }
|
|
31099
31114
|
);
|
|
31100
31115
|
const amount = Web3Number.fromWei(
|
|
@@ -31117,7 +31132,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31117
31132
|
const vesuAdapters = this.getVesuAdapters();
|
|
31118
31133
|
const allVesuPools = await VesuAdapter.getVesuPools();
|
|
31119
31134
|
const pools = vesuAdapters.map((vesuAdapter) => {
|
|
31120
|
-
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(
|
|
31135
|
+
return allVesuPools.pools.find((p) => vesuAdapter.config.poolId.eqString(import_starknet18.num.getHexString(p.id)));
|
|
31121
31136
|
});
|
|
31122
31137
|
logger.verbose(`${this.metadata.name}::netAPY: vesu-pools: ${JSON.stringify(pools)}`);
|
|
31123
31138
|
if (pools.some((p) => !p)) {
|
|
@@ -31403,7 +31418,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31403
31418
|
}];
|
|
31404
31419
|
}
|
|
31405
31420
|
getSetManagerCall(strategist, root = this.getMerkleRoot()) {
|
|
31406
|
-
return this.managerContract.populate("set_manage_root", [strategist.address,
|
|
31421
|
+
return this.managerContract.populate("set_manage_root", [strategist.address, import_starknet18.num.getHexString(root)]);
|
|
31407
31422
|
}
|
|
31408
31423
|
getManageCall(proofIds, manageCalls) {
|
|
31409
31424
|
assert(proofIds.length == manageCalls.length, "Proof IDs and Manage Calls length mismatch");
|
|
@@ -31587,7 +31602,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
31587
31602
|
callSet1 = [...temp];
|
|
31588
31603
|
}
|
|
31589
31604
|
const allActions = [...callSet1.map((i) => i.manageCall), ...callSet2.map((i) => i.manageCall)];
|
|
31590
|
-
const flashloanCalldata =
|
|
31605
|
+
const flashloanCalldata = import_starknet18.CallData.compile([
|
|
31591
31606
|
[...callSet1.map((i) => i.proofs), ...callSet2.map((i) => i.proofs)],
|
|
31592
31607
|
allActions.map((i) => i.sanitizer.address),
|
|
31593
31608
|
allActions.map((i) => i.call.contractAddress.address),
|
|
@@ -32095,7 +32110,7 @@ var UniversalStrategies = [
|
|
|
32095
32110
|
];
|
|
32096
32111
|
|
|
32097
32112
|
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
32098
|
-
var
|
|
32113
|
+
var import_starknet19 = require("starknet");
|
|
32099
32114
|
|
|
32100
32115
|
// src/utils/health-factor-math.ts
|
|
32101
32116
|
var HealthFactorMath = class {
|
|
@@ -32628,13 +32643,13 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32628
32643
|
async getLSTExchangeRate() {
|
|
32629
32644
|
const vesuAdapter1 = this.getVesuSameTokenAdapter(this.metadata.additionalInfo.defaultPoolId);
|
|
32630
32645
|
const lstTokenInfo = vesuAdapter1.config.collateral;
|
|
32631
|
-
const lstABI = new
|
|
32646
|
+
const lstABI = new import_starknet19.Contract({
|
|
32632
32647
|
abi: erc4626_abi_default,
|
|
32633
32648
|
address: lstTokenInfo.address.address,
|
|
32634
32649
|
providerOrAccount: this.config.provider
|
|
32635
32650
|
});
|
|
32636
|
-
const price = await lstABI.call("convert_to_assets", [
|
|
32637
|
-
const exchangeRate = Number(
|
|
32651
|
+
const price = await lstABI.call("convert_to_assets", [import_starknet19.uint256.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
32652
|
+
const exchangeRate = Number(import_starknet19.uint256.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
32638
32653
|
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
32639
32654
|
return exchangeRate;
|
|
32640
32655
|
}
|
|
@@ -32805,9 +32820,9 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
32805
32820
|
const leafIdApprove = getVesuGenericLegId(poolId.toString(), "multiple_approve" /* MULTIPLE_APPROVE */);
|
|
32806
32821
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
|
|
32807
32822
|
const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), "switch_delegation_on" /* SWITCH_DELEGATION_ON */);
|
|
32808
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
|
|
32823
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32809
32824
|
const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), "switch_delegation_off" /* SWITCH_DELEGATION_OFF */);
|
|
32810
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
|
|
32825
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32811
32826
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
32812
32827
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
32813
32828
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
@@ -32924,7 +32939,9 @@ var hyperxSTRK = {
|
|
|
32924
32939
|
minHealthFactor: 1.05,
|
|
32925
32940
|
borrowable_assets: [
|
|
32926
32941
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
32927
|
-
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime }))
|
|
32942
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
32943
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
32944
|
+
// v2, new alt for Re7xSTRK
|
|
32928
32945
|
],
|
|
32929
32946
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
32930
32947
|
defaultPoolId: VesuPools.Re7xSTRK
|
|
@@ -33606,12 +33623,12 @@ var PricerRedis = class extends Pricer {
|
|
|
33606
33623
|
|
|
33607
33624
|
// src/node/deployer.ts
|
|
33608
33625
|
var import_assert = __toESM(require("assert"));
|
|
33609
|
-
var
|
|
33626
|
+
var import_starknet21 = require("starknet");
|
|
33610
33627
|
var import_fs2 = require("fs");
|
|
33611
33628
|
|
|
33612
33629
|
// src/utils/store.ts
|
|
33613
33630
|
var import_fs = __toESM(require("fs"));
|
|
33614
|
-
var
|
|
33631
|
+
var import_starknet20 = require("starknet");
|
|
33615
33632
|
var crypto2 = __toESM(require("crypto"));
|
|
33616
33633
|
|
|
33617
33634
|
// src/utils/encrypt.ts
|
|
@@ -33705,7 +33722,7 @@ var Store = class _Store {
|
|
|
33705
33722
|
}
|
|
33706
33723
|
logger.verbose(`Account loaded: ${accountKey} from network: ${this.config.network}`);
|
|
33707
33724
|
logger.verbose(`Address: ${data.address}`);
|
|
33708
|
-
const acc = new
|
|
33725
|
+
const acc = new import_starknet20.Account({
|
|
33709
33726
|
provider: this.config.provider,
|
|
33710
33727
|
address: data.address,
|
|
33711
33728
|
signer: data.pk,
|
|
@@ -33800,10 +33817,10 @@ function getAccount(accountKey, config, password = process.env.ACCOUNT_SECURE_PA
|
|
|
33800
33817
|
}
|
|
33801
33818
|
async function myDeclare(contract_name, package_name = "strkfarm", config, acc) {
|
|
33802
33819
|
const provider2 = config.provider;
|
|
33803
|
-
const compiledSierra =
|
|
33820
|
+
const compiledSierra = import_starknet21.json.parse(
|
|
33804
33821
|
(0, import_fs2.readFileSync)(`./target/release/${package_name}_${contract_name}.contract_class.json`).toString("ascii")
|
|
33805
33822
|
);
|
|
33806
|
-
const compiledCasm =
|
|
33823
|
+
const compiledCasm = import_starknet21.json.parse(
|
|
33807
33824
|
(0, import_fs2.readFileSync)(`./target/release/${package_name}_${contract_name}.compiled_contract_class.json`).toString("ascii")
|
|
33808
33825
|
);
|
|
33809
33826
|
const contracts = getContracts();
|
|
@@ -33811,7 +33828,7 @@ async function myDeclare(contract_name, package_name = "strkfarm", config, acc)
|
|
|
33811
33828
|
contract: compiledSierra,
|
|
33812
33829
|
casm: compiledCasm
|
|
33813
33830
|
};
|
|
33814
|
-
const result = (0,
|
|
33831
|
+
const result = (0, import_starknet21.extractContractHashes)(payload);
|
|
33815
33832
|
console.log("classhash:", result.classHash);
|
|
33816
33833
|
try {
|
|
33817
33834
|
const cls = await provider2.getClassByHash(result.classHash);
|
|
@@ -33829,7 +33846,7 @@ async function myDeclare(contract_name, package_name = "strkfarm", config, acc)
|
|
|
33829
33846
|
const tx = await acc.declareIfNot(payload);
|
|
33830
33847
|
console.log(`Declaring: ${contract_name}, tx:`, tx.transaction_hash);
|
|
33831
33848
|
await provider2.waitForTransaction(tx.transaction_hash, {
|
|
33832
|
-
successStates: [
|
|
33849
|
+
successStates: [import_starknet21.TransactionExecutionStatus.SUCCEEDED]
|
|
33833
33850
|
});
|
|
33834
33851
|
if (!contracts.class_hashes) {
|
|
33835
33852
|
contracts["class_hashes"] = {};
|
|
@@ -33853,7 +33870,7 @@ async function deployContract(contract_name, classHash, constructorData, config,
|
|
|
33853
33870
|
});
|
|
33854
33871
|
console.log("Deploy tx: ", tx.transaction_hash);
|
|
33855
33872
|
await provider2.waitForTransaction(tx.transaction_hash, {
|
|
33856
|
-
successStates: [
|
|
33873
|
+
successStates: [import_starknet21.TransactionExecutionStatus.SUCCEEDED]
|
|
33857
33874
|
});
|
|
33858
33875
|
const contracts = getContracts();
|
|
33859
33876
|
if (!contracts.contracts) {
|
|
@@ -33870,7 +33887,7 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
|
|
|
33870
33887
|
for (const { contract_name, package_name, constructorData } of contracts) {
|
|
33871
33888
|
const declaredInfo = await myDeclare(contract_name, package_name, config, acc);
|
|
33872
33889
|
const classHash = declaredInfo.class_hash;
|
|
33873
|
-
const { calls, addresses } = new
|
|
33890
|
+
const { calls, addresses } = new import_starknet21.Deployer().buildDeployerCall({
|
|
33874
33891
|
classHash,
|
|
33875
33892
|
constructorCalldata: constructorData
|
|
33876
33893
|
}, acc.address);
|
|
@@ -33888,7 +33905,7 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
|
|
|
33888
33905
|
}
|
|
33889
33906
|
async function executeDeployCalls(contractsInfo, acc, provider2) {
|
|
33890
33907
|
for (let contractInfo of contractsInfo) {
|
|
33891
|
-
(0, import_assert.default)(
|
|
33908
|
+
(0, import_assert.default)(import_starknet21.num.toHexString(contractInfo.call.contractAddress) == import_starknet21.num.toHexString(import_starknet21.constants.UDC.ADDRESS), "Must be pointed at UDC address");
|
|
33892
33909
|
}
|
|
33893
33910
|
const allCalls = contractsInfo.map((info) => info.call);
|
|
33894
33911
|
await executeTransactions(allCalls, acc, provider2, `Deploying contracts: ${contractsInfo.map((info) => info.contract_name).join(", ")}`);
|
|
@@ -33912,7 +33929,7 @@ async function executeTransactions(calls, acc, provider2, remarks) {
|
|
|
33912
33929
|
if (remarks)
|
|
33913
33930
|
console.log(`Remarks: ${remarks}`);
|
|
33914
33931
|
await provider2.waitForTransaction(tx.transaction_hash, {
|
|
33915
|
-
successStates: [
|
|
33932
|
+
successStates: [import_starknet21.TransactionExecutionStatus.SUCCEEDED]
|
|
33916
33933
|
});
|
|
33917
33934
|
console.log(`Transaction confirmed: ${tx.transaction_hash}`);
|
|
33918
33935
|
return tx;
|
|
@@ -33923,10 +33940,10 @@ async function myWaitForTransaction(transaction_hash, provider2, retry = 0) {
|
|
|
33923
33940
|
try {
|
|
33924
33941
|
const status = await provider2.getTransactionStatus(transaction_hash);
|
|
33925
33942
|
logger.verbose(`Transaction status: ${JSON.stringify(status.execution_status)}`);
|
|
33926
|
-
if (status.execution_status ==
|
|
33943
|
+
if (status.execution_status == import_starknet21.TransactionExecutionStatus.SUCCEEDED) {
|
|
33927
33944
|
return true;
|
|
33928
33945
|
}
|
|
33929
|
-
if (status.execution_status ==
|
|
33946
|
+
if (status.execution_status == import_starknet21.TransactionExecutionStatus.REVERTED) {
|
|
33930
33947
|
throw new Error(`Transaction reverted: ${transaction_hash}`);
|
|
33931
33948
|
}
|
|
33932
33949
|
if (retry > MAX_RETRIES) {
|