@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.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import util from "util";
|
|
|
9
9
|
|
|
10
10
|
// src/dataTypes/_bignumber.ts
|
|
11
11
|
import BigNumber from "bignumber.js";
|
|
12
|
+
import { uint256 } from "starknet";
|
|
12
13
|
var _Web3Number = class extends BigNumber {
|
|
13
14
|
constructor(value, decimals) {
|
|
14
15
|
super(value);
|
|
@@ -83,6 +84,9 @@ var _Web3Number = class extends BigNumber {
|
|
|
83
84
|
sign
|
|
84
85
|
};
|
|
85
86
|
}
|
|
87
|
+
toUint256() {
|
|
88
|
+
return uint256.bnToUint256(this.toWei());
|
|
89
|
+
}
|
|
86
90
|
};
|
|
87
91
|
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
88
92
|
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
@@ -566,7 +570,7 @@ var PricerBase = class {
|
|
|
566
570
|
};
|
|
567
571
|
|
|
568
572
|
// src/modules/avnu.ts
|
|
569
|
-
import { uint256 } from "starknet";
|
|
573
|
+
import { uint256 as uint2562 } from "starknet";
|
|
570
574
|
import { fetchBuildExecuteTransaction, fetchQuotes } from "@avnu/avnu-sdk";
|
|
571
575
|
|
|
572
576
|
// src/utils/oz-merkle.ts
|
|
@@ -711,10 +715,10 @@ var AvnuWrapper = class {
|
|
|
711
715
|
const _minAmount = minAmount || (quote.buyAmount * 95n / 100n).toString();
|
|
712
716
|
const swapInfo = {
|
|
713
717
|
token_from_address: quote.sellTokenAddress,
|
|
714
|
-
token_from_amount:
|
|
718
|
+
token_from_amount: uint2562.bnToUint256(quote.sellAmount),
|
|
715
719
|
token_to_address: quote.buyTokenAddress,
|
|
716
|
-
token_to_amount:
|
|
717
|
-
token_to_min_amount:
|
|
720
|
+
token_to_amount: uint2562.bnToUint256(_minAmount),
|
|
721
|
+
token_to_min_amount: uint2562.bnToUint256(_minAmount),
|
|
718
722
|
beneficiary: taker,
|
|
719
723
|
integrator_fee_amount_bps: integratorFeeBps,
|
|
720
724
|
integrator_fee_recipient: integratorFeeRecipient,
|
|
@@ -725,10 +729,10 @@ var AvnuWrapper = class {
|
|
|
725
729
|
static buildZeroSwap(tokenToSell, beneficiary, tokenToBuy = tokenToSell) {
|
|
726
730
|
return {
|
|
727
731
|
token_from_address: tokenToSell.address,
|
|
728
|
-
token_from_amount:
|
|
732
|
+
token_from_amount: uint2562.bnToUint256(0),
|
|
729
733
|
token_to_address: tokenToBuy.address,
|
|
730
|
-
token_to_amount:
|
|
731
|
-
token_to_min_amount:
|
|
734
|
+
token_to_amount: uint2562.bnToUint256(0),
|
|
735
|
+
token_to_min_amount: uint2562.bnToUint256(0),
|
|
732
736
|
beneficiary,
|
|
733
737
|
integrator_fee_amount_bps: 0,
|
|
734
738
|
integrator_fee_recipient: beneficiary,
|
|
@@ -3152,7 +3156,7 @@ var Initializable = class {
|
|
|
3152
3156
|
};
|
|
3153
3157
|
|
|
3154
3158
|
// src/strategies/autoCompounderStrk.ts
|
|
3155
|
-
import { Contract as Contract4, uint256 as
|
|
3159
|
+
import { Contract as Contract4, uint256 as uint2563 } from "starknet";
|
|
3156
3160
|
var AutoCompounderSTRK = class {
|
|
3157
3161
|
constructor(config, pricer) {
|
|
3158
3162
|
this.addr = ContractAddr.from("0x541681b9ad63dff1b35f79c78d8477f64857de29a27902f7298f7b620838ea");
|
|
@@ -3196,7 +3200,7 @@ var AutoCompounderSTRK = class {
|
|
|
3196
3200
|
/** Returns underlying assets of user */
|
|
3197
3201
|
async balanceOfUnderlying(user) {
|
|
3198
3202
|
const balanceShares = await this.balanceOf(user);
|
|
3199
|
-
const assets = await this.contract.convert_to_assets(
|
|
3203
|
+
const assets = await this.contract.convert_to_assets(uint2563.bnToUint256(balanceShares.toWei()));
|
|
3200
3204
|
return Web3Number.fromWei(assets.toString(), this.metadata.decimals);
|
|
3201
3205
|
}
|
|
3202
3206
|
/** Returns usd value of assets */
|
|
@@ -3212,7 +3216,7 @@ var AutoCompounderSTRK = class {
|
|
|
3212
3216
|
};
|
|
3213
3217
|
|
|
3214
3218
|
// src/strategies/vesu-rebalance.tsx
|
|
3215
|
-
import { CairoCustomEnum, Contract as Contract6, num as num4, uint256 as
|
|
3219
|
+
import { CairoCustomEnum, Contract as Contract6, num as num4, uint256 as uint2564 } from "starknet";
|
|
3216
3220
|
|
|
3217
3221
|
// src/data/vesu-rebalance.abi.json
|
|
3218
3222
|
var vesu_rebalance_abi_default = [
|
|
@@ -10363,10 +10367,10 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10363
10367
|
});
|
|
10364
10368
|
const call1 = assetContract.populate("approve", [
|
|
10365
10369
|
this.address.address,
|
|
10366
|
-
|
|
10370
|
+
uint2564.bnToUint256(amountInfo.amount.toWei())
|
|
10367
10371
|
]);
|
|
10368
10372
|
const call2 = this.contract.populate("deposit", [
|
|
10369
|
-
|
|
10373
|
+
uint2564.bnToUint256(amountInfo.amount.toWei()),
|
|
10370
10374
|
receiver.address
|
|
10371
10375
|
]);
|
|
10372
10376
|
return [call1, call2];
|
|
@@ -10381,7 +10385,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10381
10385
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
10382
10386
|
return [
|
|
10383
10387
|
this.contract.populate("withdraw", [
|
|
10384
|
-
|
|
10388
|
+
uint2564.bnToUint256(amountInfo.amount.toWei()),
|
|
10385
10389
|
receiver.address,
|
|
10386
10390
|
owner.address
|
|
10387
10391
|
])
|
|
@@ -10405,7 +10409,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10405
10409
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
10406
10410
|
const assets = await this.contract.call(
|
|
10407
10411
|
"convert_to_assets",
|
|
10408
|
-
[
|
|
10412
|
+
[uint2564.bnToUint256(shares)],
|
|
10409
10413
|
{ blockIdentifier }
|
|
10410
10414
|
);
|
|
10411
10415
|
const amount = Web3Number.fromWei(
|
|
@@ -10563,7 +10567,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10563
10567
|
});
|
|
10564
10568
|
const bal = await vTokenContract.balanceOf(this.address.address);
|
|
10565
10569
|
const assets = await vTokenContract.convert_to_assets(
|
|
10566
|
-
|
|
10570
|
+
uint2564.bnToUint256(bal.toString())
|
|
10567
10571
|
);
|
|
10568
10572
|
logger.verbose(`Collateral: ${JSON.stringify(vesuPosition?.collateral)}`);
|
|
10569
10573
|
logger.verbose(`supplyApy: ${JSON.stringify(assetInfo?.stats.supplyApy)}`);
|
|
@@ -10869,7 +10873,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10869
10873
|
p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }
|
|
10870
10874
|
),
|
|
10871
10875
|
token: this.asset().address.address,
|
|
10872
|
-
amount:
|
|
10876
|
+
amount: uint2564.bnToUint256(
|
|
10873
10877
|
p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei()
|
|
10874
10878
|
)
|
|
10875
10879
|
});
|
|
@@ -10928,10 +10932,10 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10928
10932
|
const avnu = new AvnuWrapper();
|
|
10929
10933
|
let swapInfo = {
|
|
10930
10934
|
token_from_address: harvest.token.address,
|
|
10931
|
-
token_from_amount:
|
|
10935
|
+
token_from_amount: uint2564.bnToUint256(harvest.actualReward.toWei()),
|
|
10932
10936
|
token_to_address: this.asset().address.address,
|
|
10933
|
-
token_to_amount:
|
|
10934
|
-
token_to_min_amount:
|
|
10937
|
+
token_to_amount: uint2564.bnToUint256(0),
|
|
10938
|
+
token_to_min_amount: uint2564.bnToUint256(0),
|
|
10935
10939
|
beneficiary: this.address.address,
|
|
10936
10940
|
integrator_fee_amount_bps: 0,
|
|
10937
10941
|
integrator_fee_recipient: this.address.address,
|
|
@@ -11203,7 +11207,7 @@ VesuRebalanceStrategies.forEach((s) => {
|
|
|
11203
11207
|
import {
|
|
11204
11208
|
Contract as Contract7,
|
|
11205
11209
|
num as num5,
|
|
11206
|
-
uint256 as
|
|
11210
|
+
uint256 as uint2565
|
|
11207
11211
|
} from "starknet";
|
|
11208
11212
|
|
|
11209
11213
|
// src/data/cl-vault.abi.json
|
|
@@ -16273,7 +16277,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16273
16277
|
const shares = await this.tokensToShares(amountInfo);
|
|
16274
16278
|
const { amount0, amount1 } = await this.contract.call(
|
|
16275
16279
|
"convert_to_assets",
|
|
16276
|
-
[
|
|
16280
|
+
[uint2565.bnToUint256(shares.toWei())]
|
|
16277
16281
|
);
|
|
16278
16282
|
return {
|
|
16279
16283
|
token0: {
|
|
@@ -16306,15 +16310,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16306
16310
|
});
|
|
16307
16311
|
const call1 = token0Contract.populate("approve", [
|
|
16308
16312
|
this.address.address,
|
|
16309
|
-
|
|
16313
|
+
uint2565.bnToUint256(updateAmountInfo.token0.amount.toWei())
|
|
16310
16314
|
]);
|
|
16311
16315
|
const call2 = token1Contract.populate("approve", [
|
|
16312
16316
|
this.address.address,
|
|
16313
|
-
|
|
16317
|
+
uint2565.bnToUint256(updateAmountInfo.token1.amount.toWei())
|
|
16314
16318
|
]);
|
|
16315
16319
|
const call3 = this.contract.populate("deposit", [
|
|
16316
|
-
|
|
16317
|
-
|
|
16320
|
+
uint2565.bnToUint256(updateAmountInfo.token0.amount.toWei()),
|
|
16321
|
+
uint2565.bnToUint256(updateAmountInfo.token1.amount.toWei()),
|
|
16318
16322
|
receiver.address
|
|
16319
16323
|
]);
|
|
16320
16324
|
const calls = [];
|
|
@@ -16324,8 +16328,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16324
16328
|
}
|
|
16325
16329
|
async tokensToShares(amountInfo) {
|
|
16326
16330
|
const shares = await this.contract.call("convert_to_shares", [
|
|
16327
|
-
|
|
16328
|
-
|
|
16331
|
+
uint2565.bnToUint256(amountInfo.token0.amount.toWei()),
|
|
16332
|
+
uint2565.bnToUint256(amountInfo.token1.amount.toWei())
|
|
16329
16333
|
]);
|
|
16330
16334
|
return Web3Number.fromWei(shares.toString(), 18);
|
|
16331
16335
|
}
|
|
@@ -16336,7 +16340,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16336
16340
|
);
|
|
16337
16341
|
return [
|
|
16338
16342
|
this.contract.populate("withdraw", [
|
|
16339
|
-
|
|
16343
|
+
uint2565.bnToUint256(shares.toWei()),
|
|
16340
16344
|
receiver.address
|
|
16341
16345
|
])
|
|
16342
16346
|
];
|
|
@@ -16358,14 +16362,21 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16358
16362
|
handleFeesCall() {
|
|
16359
16363
|
return [this.contract.populate("handle_fees", [])];
|
|
16360
16364
|
}
|
|
16361
|
-
async getFeeHistory(timePeriod = "24h") {
|
|
16365
|
+
async getFeeHistory(timePeriod = "24h", range) {
|
|
16362
16366
|
const { data } = await apollo_client_default.query({
|
|
16363
16367
|
query: gql2`
|
|
16364
16368
|
query ContractFeeEarnings(
|
|
16365
16369
|
$timeframe: String!
|
|
16366
16370
|
$contract: String!
|
|
16371
|
+
$startTimestamp: Float
|
|
16372
|
+
$endTimestamp: Float
|
|
16367
16373
|
) {
|
|
16368
|
-
contractFeeEarnings(
|
|
16374
|
+
contractFeeEarnings(
|
|
16375
|
+
timeframe: $timeframe
|
|
16376
|
+
contract: $contract
|
|
16377
|
+
startTimestamp: $startTimestamp
|
|
16378
|
+
endTimestamp: $endTimestamp
|
|
16379
|
+
) {
|
|
16369
16380
|
contract
|
|
16370
16381
|
dailyEarnings {
|
|
16371
16382
|
date
|
|
@@ -16378,7 +16389,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16378
16389
|
`,
|
|
16379
16390
|
variables: {
|
|
16380
16391
|
timeframe: timePeriod,
|
|
16381
|
-
contract: this.address.address
|
|
16392
|
+
contract: this.address.address,
|
|
16393
|
+
startTimestamp: range?.startTimestamp,
|
|
16394
|
+
endTimestamp: range?.endTimestamp
|
|
16382
16395
|
},
|
|
16383
16396
|
fetchPolicy: "no-cache"
|
|
16384
16397
|
});
|
|
@@ -16550,7 +16563,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16550
16563
|
let bal = await this.balanceOf(user, blockIdentifier);
|
|
16551
16564
|
const assets = await this.contract.call(
|
|
16552
16565
|
"convert_to_assets",
|
|
16553
|
-
[
|
|
16566
|
+
[uint2565.bnToUint256(bal.toWei())],
|
|
16554
16567
|
{
|
|
16555
16568
|
blockIdentifier
|
|
16556
16569
|
}
|
|
@@ -16696,7 +16709,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16696
16709
|
return this.metadata.additionalInfo.truePrice;
|
|
16697
16710
|
} else if (this.lstContract) {
|
|
16698
16711
|
const result = await this.lstContract.call("convert_to_assets", [
|
|
16699
|
-
|
|
16712
|
+
uint2565.bnToUint256(BigInt(1e18).toString())
|
|
16700
16713
|
]);
|
|
16701
16714
|
const truePrice = Number(BigInt(result.toString()) * BigInt(1e9) / BigInt(1e18)) / 1e9;
|
|
16702
16715
|
return truePrice;
|
|
@@ -17197,7 +17210,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17197
17210
|
logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17198
17211
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17199
17212
|
}
|
|
17200
|
-
const fromAmount =
|
|
17213
|
+
const fromAmount = uint2565.uint256ToBN(swapInfo.token_from_amount);
|
|
17201
17214
|
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
17202
17215
|
logger.verbose(
|
|
17203
17216
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
@@ -17226,7 +17239,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17226
17239
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17227
17240
|
throw err;
|
|
17228
17241
|
}
|
|
17229
|
-
newSwapInfo.token_from_amount =
|
|
17242
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17230
17243
|
} else {
|
|
17231
17244
|
logger.verbose("Increasing swap amount - deficit token0");
|
|
17232
17245
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17238,7 +17251,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17238
17251
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17239
17252
|
throw err;
|
|
17240
17253
|
}
|
|
17241
|
-
newSwapInfo.token_from_amount =
|
|
17254
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17242
17255
|
}
|
|
17243
17256
|
} else if (err.message.includes("invalid token1 amount") || err.message.includes("invalid token1 balance")) {
|
|
17244
17257
|
if (isSellTokenToken0) {
|
|
@@ -17249,7 +17262,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17249
17262
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17250
17263
|
throw err;
|
|
17251
17264
|
}
|
|
17252
|
-
newSwapInfo.token_from_amount =
|
|
17265
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17253
17266
|
} else {
|
|
17254
17267
|
logger.verbose("Increasing swap amount - deficit token1");
|
|
17255
17268
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17261,7 +17274,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17261
17274
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17262
17275
|
throw err;
|
|
17263
17276
|
}
|
|
17264
|
-
newSwapInfo.token_from_amount =
|
|
17277
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17265
17278
|
}
|
|
17266
17279
|
} else if (err.message.includes("Residual tokens")) {
|
|
17267
17280
|
logger.error("Residual tokens");
|
|
@@ -17291,7 +17304,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17291
17304
|
logger.error("Unexpected error:", err);
|
|
17292
17305
|
throw err;
|
|
17293
17306
|
}
|
|
17294
|
-
newSwapInfo.token_to_min_amount =
|
|
17307
|
+
newSwapInfo.token_to_min_amount = uint2565.bnToUint256("0");
|
|
17295
17308
|
return this.rebalanceIter(
|
|
17296
17309
|
newSwapInfo,
|
|
17297
17310
|
acc,
|
|
@@ -17342,15 +17355,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17342
17355
|
const result = await this.ekuboMathContract.call(
|
|
17343
17356
|
"liquidity_delta_to_amount_delta",
|
|
17344
17357
|
[
|
|
17345
|
-
|
|
17358
|
+
uint2565.bnToUint256(currentPrice.sqrtRatio),
|
|
17346
17359
|
{
|
|
17347
17360
|
mag: liquidity.toWei(),
|
|
17348
17361
|
sign: 0
|
|
17349
17362
|
},
|
|
17350
|
-
|
|
17363
|
+
uint2565.bnToUint256(
|
|
17351
17364
|
_EkuboCLVault.priceToSqrtRatio(lowerPrice).toString()
|
|
17352
17365
|
),
|
|
17353
|
-
|
|
17366
|
+
uint2565.bnToUint256(
|
|
17354
17367
|
_EkuboCLVault.priceToSqrtRatio(upperPrice).toString()
|
|
17355
17368
|
)
|
|
17356
17369
|
],
|
|
@@ -17453,7 +17466,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17453
17466
|
const claimTokenInfo = await Global.getTokenInfoFromAddr(claim.token);
|
|
17454
17467
|
const harvestEstimateCall = async (baseSwapInfo2) => {
|
|
17455
17468
|
let baseSwapAmount = Web3Number.fromWei(
|
|
17456
|
-
|
|
17469
|
+
uint2565.uint256ToBN(baseSwapInfo2.token_from_amount).toString(),
|
|
17457
17470
|
claimTokenInfo.decimals
|
|
17458
17471
|
).minimum(
|
|
17459
17472
|
postFeeAmount.toFixed(claimTokenInfo.decimals)
|
|
@@ -17461,7 +17474,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17461
17474
|
if (baseSwapAmount.lt(1e-4)) {
|
|
17462
17475
|
baseSwapAmount = new Web3Number(0, claimTokenInfo.decimals);
|
|
17463
17476
|
}
|
|
17464
|
-
baseSwapInfo2.token_from_amount =
|
|
17477
|
+
baseSwapInfo2.token_from_amount = uint2565.bnToUint256(baseSwapAmount.toWei());
|
|
17465
17478
|
const isToken0ClaimToken2 = claim.token.eq(poolKey.token0);
|
|
17466
17479
|
logger.verbose(
|
|
17467
17480
|
`${_EkuboCLVault.name}: harvest => isToken0ClaimToken: ${isToken0ClaimToken2}, baseSwapAmount: ${baseSwapAmount}`
|
|
@@ -17471,7 +17484,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17471
17484
|
`${_EkuboCLVault.name}: harvest => remainingAmount: ${remainingAmount}`
|
|
17472
17485
|
);
|
|
17473
17486
|
let dummySwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, claim.token);
|
|
17474
|
-
dummySwapInfo.token_from_amount =
|
|
17487
|
+
dummySwapInfo.token_from_amount = uint2565.bnToUint256(remainingAmount.toWei());
|
|
17475
17488
|
logger.verbose(
|
|
17476
17489
|
`${_EkuboCLVault.name}: harvest => dummySwapInfo: ${JSON.stringify(
|
|
17477
17490
|
dummySwapInfo
|
|
@@ -17498,7 +17511,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17498
17511
|
};
|
|
17499
17512
|
const isToken0ClaimToken = claim.token.eq(poolKey.token0);
|
|
17500
17513
|
let baseSwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, isToken0ClaimToken ? token1Info.address : token0Info.address);
|
|
17501
|
-
baseSwapInfo.token_from_amount =
|
|
17514
|
+
baseSwapInfo.token_from_amount = uint2565.bnToUint256(postFeeAmount.toWei());
|
|
17502
17515
|
if (postFeeAmount.greaterThan(0) && !isToken0ClaimToken) {
|
|
17503
17516
|
const avnuWrapper = new AvnuWrapper();
|
|
17504
17517
|
const quote = await avnuWrapper.getQuotes(
|
|
@@ -18298,7 +18311,7 @@ EkuboCLVaultStrategies.forEach((s) => {
|
|
|
18298
18311
|
});
|
|
18299
18312
|
|
|
18300
18313
|
// src/strategies/sensei.ts
|
|
18301
|
-
import { Contract as Contract9, num as num8, uint256 as
|
|
18314
|
+
import { Contract as Contract9, num as num8, uint256 as uint2567 } from "starknet";
|
|
18302
18315
|
|
|
18303
18316
|
// src/data/sensei.abi.json
|
|
18304
18317
|
var sensei_abi_default = [
|
|
@@ -20062,7 +20075,7 @@ var sensei_abi_default = [
|
|
|
20062
20075
|
];
|
|
20063
20076
|
|
|
20064
20077
|
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
20065
|
-
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash2, num as num7, RpcProvider as RpcProvider5, shortString as shortString2, uint256 as
|
|
20078
|
+
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash2, num as num7, RpcProvider as RpcProvider5, shortString as shortString2, uint256 as uint2566 } from "starknet";
|
|
20066
20079
|
|
|
20067
20080
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
20068
20081
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
@@ -27302,7 +27315,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27302
27315
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27303
27316
|
extension: BigInt(num7.hexToDecimalString(route.pool_key.extension))
|
|
27304
27317
|
},
|
|
27305
|
-
sqrt_ratio_limit:
|
|
27318
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27306
27319
|
skip_ahead: BigInt(100)
|
|
27307
27320
|
})),
|
|
27308
27321
|
token_amount: {
|
|
@@ -27320,7 +27333,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27320
27333
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27321
27334
|
extension: BigInt(num7.hexToDecimalString(route.pool_key.extension))
|
|
27322
27335
|
},
|
|
27323
|
-
sqrt_ratio_limit:
|
|
27336
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27324
27337
|
skip_ahead: BigInt(100)
|
|
27325
27338
|
})),
|
|
27326
27339
|
token_amount: {
|
|
@@ -27350,7 +27363,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27350
27363
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27351
27364
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27352
27365
|
},
|
|
27353
|
-
sqrt_ratio_limit:
|
|
27366
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27354
27367
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27355
27368
|
})),
|
|
27356
27369
|
token_amount: {
|
|
@@ -27369,7 +27382,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27369
27382
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27370
27383
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27371
27384
|
},
|
|
27372
|
-
sqrt_ratio_limit:
|
|
27385
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27373
27386
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27374
27387
|
})),
|
|
27375
27388
|
token_amount: {
|
|
@@ -27453,7 +27466,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27453
27466
|
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
27454
27467
|
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
27455
27468
|
value: {
|
|
27456
|
-
abs:
|
|
27469
|
+
abs: uint2566.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
27457
27470
|
is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
|
|
27458
27471
|
}
|
|
27459
27472
|
};
|
|
@@ -27462,7 +27475,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27462
27475
|
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
27463
27476
|
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
27464
27477
|
value: {
|
|
27465
|
-
abs:
|
|
27478
|
+
abs: uint2566.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
27466
27479
|
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
27467
27480
|
}
|
|
27468
27481
|
};
|
|
@@ -27548,15 +27561,15 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27548
27561
|
}
|
|
27549
27562
|
};
|
|
27550
27563
|
};
|
|
27551
|
-
this.getVesuModifyDelegationAdapter = (id) => {
|
|
27564
|
+
this.getVesuModifyDelegationAdapter = (id, delegatee) => {
|
|
27552
27565
|
return () => {
|
|
27553
27566
|
const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
27554
27567
|
const packedArguments = isV2 ? [
|
|
27555
|
-
toBigInt(
|
|
27568
|
+
toBigInt(delegatee.toString())
|
|
27556
27569
|
// v2
|
|
27557
27570
|
] : [
|
|
27558
27571
|
this.config.poolId.toBigInt(),
|
|
27559
|
-
toBigInt(
|
|
27572
|
+
toBigInt(delegatee.toString())
|
|
27560
27573
|
// v1
|
|
27561
27574
|
];
|
|
27562
27575
|
const output = this.constructSimpleLeafData({
|
|
@@ -27565,29 +27578,31 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27565
27578
|
method: "modify_delegation",
|
|
27566
27579
|
packedArguments
|
|
27567
27580
|
}, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
|
|
27568
|
-
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
27581
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall(delegatee).bind(this) };
|
|
27569
27582
|
};
|
|
27570
27583
|
};
|
|
27571
|
-
this.getVesuModifyDelegationCall = (
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27579
|
-
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
|
|
27583
|
-
|
|
27584
|
-
|
|
27585
|
-
|
|
27586
|
-
|
|
27587
|
-
|
|
27588
|
-
|
|
27589
|
-
|
|
27590
|
-
|
|
27584
|
+
this.getVesuModifyDelegationCall = (delegatee) => {
|
|
27585
|
+
return (params) => {
|
|
27586
|
+
const VESU_SINGLETON2 = getVesuSingletonAddress(this.config.poolId).addr;
|
|
27587
|
+
const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
|
|
27588
|
+
const call = contract.populate("modify_delegation", isV2 ? {
|
|
27589
|
+
delegatee: delegatee.toBigInt(),
|
|
27590
|
+
delegation: params.delegation
|
|
27591
|
+
} : {
|
|
27592
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
27593
|
+
delegatee: delegatee.toBigInt(),
|
|
27594
|
+
delegation: params.delegation
|
|
27595
|
+
});
|
|
27596
|
+
return {
|
|
27597
|
+
sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
|
|
27598
|
+
call: {
|
|
27599
|
+
contractAddress: VESU_SINGLETON2,
|
|
27600
|
+
selector: hash2.getSelectorFromName("modify_delegation"),
|
|
27601
|
+
calldata: [
|
|
27602
|
+
...call.calldata
|
|
27603
|
+
]
|
|
27604
|
+
}
|
|
27605
|
+
};
|
|
27591
27606
|
};
|
|
27592
27607
|
};
|
|
27593
27608
|
this.getDefispringRewardsAdapter = (id) => {
|
|
@@ -28096,7 +28111,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28096
28111
|
}
|
|
28097
28112
|
);
|
|
28098
28113
|
const amount = Web3Number.fromWei(
|
|
28099
|
-
|
|
28114
|
+
uint2567.uint256ToBN(result[1].estimated_size).toString(),
|
|
28100
28115
|
this.metadata.depositTokens[0].decimals
|
|
28101
28116
|
);
|
|
28102
28117
|
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
@@ -28146,10 +28161,10 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28146
28161
|
});
|
|
28147
28162
|
const call1 = mainTokenContract.populate("approve", [
|
|
28148
28163
|
this.address.address,
|
|
28149
|
-
|
|
28164
|
+
uint2567.bnToUint256(amountInfo.amount.toWei())
|
|
28150
28165
|
]);
|
|
28151
28166
|
const call2 = this.contract.populate("deposit", [
|
|
28152
|
-
|
|
28167
|
+
uint2567.bnToUint256(amountInfo.amount.toWei()),
|
|
28153
28168
|
receiver.address
|
|
28154
28169
|
]);
|
|
28155
28170
|
const calls = [call1, call2];
|
|
@@ -28157,7 +28172,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28157
28172
|
}
|
|
28158
28173
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
28159
28174
|
const call = this.contract.populate("withdraw", [
|
|
28160
|
-
|
|
28175
|
+
uint2567.bnToUint256(amountInfo.amount.toWei()),
|
|
28161
28176
|
receiver.address,
|
|
28162
28177
|
300
|
|
28163
28178
|
// 3% max slippage
|
|
@@ -28477,7 +28492,7 @@ var SenseiStrategies = [
|
|
|
28477
28492
|
];
|
|
28478
28493
|
|
|
28479
28494
|
// src/strategies/universal-adapters/common-adapter.ts
|
|
28480
|
-
import { hash as hash3, num as num9, uint256 as
|
|
28495
|
+
import { hash as hash3, num as num9, uint256 as uint2568 } from "starknet";
|
|
28481
28496
|
var CommonAdapter = class extends BaseAdapter {
|
|
28482
28497
|
constructor(config) {
|
|
28483
28498
|
super();
|
|
@@ -28502,7 +28517,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28502
28517
|
return { leaf, callConstructor: this.getFlashloanCall.bind(this) };
|
|
28503
28518
|
}
|
|
28504
28519
|
getFlashloanCall(params) {
|
|
28505
|
-
const uint256Amount =
|
|
28520
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28506
28521
|
return {
|
|
28507
28522
|
sanitizer: SIMPLE_SANITIZER,
|
|
28508
28523
|
call: {
|
|
@@ -28541,7 +28556,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28541
28556
|
}
|
|
28542
28557
|
getApproveCall(token, spender) {
|
|
28543
28558
|
return (params) => {
|
|
28544
|
-
const uint256Amount =
|
|
28559
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28545
28560
|
return {
|
|
28546
28561
|
sanitizer: SIMPLE_SANITIZER,
|
|
28547
28562
|
call: {
|
|
@@ -28572,7 +28587,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28572
28587
|
}
|
|
28573
28588
|
getBringLiquidityCall() {
|
|
28574
28589
|
return (params) => {
|
|
28575
|
-
const uint256Amount =
|
|
28590
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28576
28591
|
return {
|
|
28577
28592
|
sanitizer: SIMPLE_SANITIZER,
|
|
28578
28593
|
call: {
|
|
@@ -28651,7 +28666,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28651
28666
|
};
|
|
28652
28667
|
|
|
28653
28668
|
// src/strategies/universal-strategy.tsx
|
|
28654
|
-
import { CallData, Contract as Contract10, num as num10, uint256 as
|
|
28669
|
+
import { CallData, Contract as Contract10, num as num10, uint256 as uint2569 } from "starknet";
|
|
28655
28670
|
|
|
28656
28671
|
// src/data/universal-vault.abi.json
|
|
28657
28672
|
var universal_vault_abi_default = [
|
|
@@ -30939,10 +30954,10 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30939
30954
|
});
|
|
30940
30955
|
const call1 = assetContract.populate("approve", [
|
|
30941
30956
|
this.address.address,
|
|
30942
|
-
|
|
30957
|
+
uint2569.bnToUint256(amountInfo.amount.toWei())
|
|
30943
30958
|
]);
|
|
30944
30959
|
const call2 = this.contract.populate("deposit", [
|
|
30945
|
-
|
|
30960
|
+
uint2569.bnToUint256(amountInfo.amount.toWei()),
|
|
30946
30961
|
receiver.address
|
|
30947
30962
|
]);
|
|
30948
30963
|
return [call1, call2];
|
|
@@ -30952,9 +30967,9 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30952
30967
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
30953
30968
|
"Withdraw token mismatch"
|
|
30954
30969
|
);
|
|
30955
|
-
const shares = await this.contract.call("convert_to_shares", [
|
|
30970
|
+
const shares = await this.contract.call("convert_to_shares", [uint2569.bnToUint256(amountInfo.amount.toWei())]);
|
|
30956
30971
|
const call = this.contract.populate("request_redeem", [
|
|
30957
|
-
|
|
30972
|
+
uint2569.bnToUint256(shares.toString()),
|
|
30958
30973
|
receiver.address,
|
|
30959
30974
|
owner.address
|
|
30960
30975
|
]);
|
|
@@ -30964,7 +30979,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30964
30979
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
30965
30980
|
const assets = await this.contract.call(
|
|
30966
30981
|
"convert_to_assets",
|
|
30967
|
-
[
|
|
30982
|
+
[uint2569.bnToUint256(shares)],
|
|
30968
30983
|
{ blockIdentifier }
|
|
30969
30984
|
);
|
|
30970
30985
|
const amount = Web3Number.fromWei(
|
|
@@ -31965,7 +31980,7 @@ var UniversalStrategies = [
|
|
|
31965
31980
|
];
|
|
31966
31981
|
|
|
31967
31982
|
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
31968
|
-
import { Contract as Contract11, uint256 as
|
|
31983
|
+
import { Contract as Contract11, uint256 as uint25610 } from "starknet";
|
|
31969
31984
|
|
|
31970
31985
|
// src/utils/health-factor-math.ts
|
|
31971
31986
|
var HealthFactorMath = class {
|
|
@@ -32503,8 +32518,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32503
32518
|
address: lstTokenInfo.address.address,
|
|
32504
32519
|
providerOrAccount: this.config.provider
|
|
32505
32520
|
});
|
|
32506
|
-
const price = await lstABI.call("convert_to_assets", [
|
|
32507
|
-
const exchangeRate = Number(
|
|
32521
|
+
const price = await lstABI.call("convert_to_assets", [uint25610.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
32522
|
+
const exchangeRate = Number(uint25610.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
32508
32523
|
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
32509
32524
|
return exchangeRate;
|
|
32510
32525
|
}
|
|
@@ -32675,9 +32690,9 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
32675
32690
|
const leafIdApprove = getVesuGenericLegId(poolId.toString(), "multiple_approve" /* MULTIPLE_APPROVE */);
|
|
32676
32691
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
|
|
32677
32692
|
const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), "switch_delegation_on" /* SWITCH_DELEGATION_ON */);
|
|
32678
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
|
|
32693
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32679
32694
|
const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), "switch_delegation_off" /* SWITCH_DELEGATION_OFF */);
|
|
32680
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
|
|
32695
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32681
32696
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
32682
32697
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
32683
32698
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
@@ -32794,7 +32809,9 @@ var hyperxSTRK = {
|
|
|
32794
32809
|
minHealthFactor: 1.05,
|
|
32795
32810
|
borrowable_assets: [
|
|
32796
32811
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
32797
|
-
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime }))
|
|
32812
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
32813
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
32814
|
+
// v2, new alt for Re7xSTRK
|
|
32798
32815
|
],
|
|
32799
32816
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
32800
32817
|
defaultPoolId: VesuPools.Re7xSTRK
|
package/package.json
CHANGED