@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.browser.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import axios from "axios";
|
|
|
6
6
|
|
|
7
7
|
// src/dataTypes/_bignumber.ts
|
|
8
8
|
import BigNumber from "bignumber.js";
|
|
9
|
+
import { uint256 } from "starknet";
|
|
9
10
|
var _Web3Number = class extends BigNumber {
|
|
10
11
|
constructor(value, decimals) {
|
|
11
12
|
super(value);
|
|
@@ -80,6 +81,9 @@ var _Web3Number = class extends BigNumber {
|
|
|
80
81
|
sign
|
|
81
82
|
};
|
|
82
83
|
}
|
|
84
|
+
toUint256() {
|
|
85
|
+
return uint256.bnToUint256(this.toWei());
|
|
86
|
+
}
|
|
83
87
|
};
|
|
84
88
|
BigNumber.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
85
89
|
_Web3Number.config({ DECIMAL_PLACES: 18, ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
@@ -521,7 +525,7 @@ var PricerBase = class {
|
|
|
521
525
|
};
|
|
522
526
|
|
|
523
527
|
// src/modules/avnu.ts
|
|
524
|
-
import { uint256 } from "starknet";
|
|
528
|
+
import { uint256 as uint2562 } from "starknet";
|
|
525
529
|
import { fetchBuildExecuteTransaction, fetchQuotes } from "@avnu/avnu-sdk";
|
|
526
530
|
|
|
527
531
|
// src/utils/oz-merkle.ts
|
|
@@ -666,10 +670,10 @@ var AvnuWrapper = class {
|
|
|
666
670
|
const _minAmount = minAmount || (quote.buyAmount * 95n / 100n).toString();
|
|
667
671
|
const swapInfo = {
|
|
668
672
|
token_from_address: quote.sellTokenAddress,
|
|
669
|
-
token_from_amount:
|
|
673
|
+
token_from_amount: uint2562.bnToUint256(quote.sellAmount),
|
|
670
674
|
token_to_address: quote.buyTokenAddress,
|
|
671
|
-
token_to_amount:
|
|
672
|
-
token_to_min_amount:
|
|
675
|
+
token_to_amount: uint2562.bnToUint256(_minAmount),
|
|
676
|
+
token_to_min_amount: uint2562.bnToUint256(_minAmount),
|
|
673
677
|
beneficiary: taker,
|
|
674
678
|
integrator_fee_amount_bps: integratorFeeBps,
|
|
675
679
|
integrator_fee_recipient: integratorFeeRecipient,
|
|
@@ -680,10 +684,10 @@ var AvnuWrapper = class {
|
|
|
680
684
|
static buildZeroSwap(tokenToSell, beneficiary, tokenToBuy = tokenToSell) {
|
|
681
685
|
return {
|
|
682
686
|
token_from_address: tokenToSell.address,
|
|
683
|
-
token_from_amount:
|
|
687
|
+
token_from_amount: uint2562.bnToUint256(0),
|
|
684
688
|
token_to_address: tokenToBuy.address,
|
|
685
|
-
token_to_amount:
|
|
686
|
-
token_to_min_amount:
|
|
689
|
+
token_to_amount: uint2562.bnToUint256(0),
|
|
690
|
+
token_to_min_amount: uint2562.bnToUint256(0),
|
|
687
691
|
beneficiary,
|
|
688
692
|
integrator_fee_amount_bps: 0,
|
|
689
693
|
integrator_fee_recipient: beneficiary,
|
|
@@ -3250,7 +3254,7 @@ var Initializable = class {
|
|
|
3250
3254
|
};
|
|
3251
3255
|
|
|
3252
3256
|
// src/strategies/autoCompounderStrk.ts
|
|
3253
|
-
import { Contract as Contract4, uint256 as
|
|
3257
|
+
import { Contract as Contract4, uint256 as uint2563 } from "starknet";
|
|
3254
3258
|
var AutoCompounderSTRK = class {
|
|
3255
3259
|
constructor(config, pricer) {
|
|
3256
3260
|
this.addr = ContractAddr.from("0x541681b9ad63dff1b35f79c78d8477f64857de29a27902f7298f7b620838ea");
|
|
@@ -3294,7 +3298,7 @@ var AutoCompounderSTRK = class {
|
|
|
3294
3298
|
/** Returns underlying assets of user */
|
|
3295
3299
|
async balanceOfUnderlying(user) {
|
|
3296
3300
|
const balanceShares = await this.balanceOf(user);
|
|
3297
|
-
const assets = await this.contract.convert_to_assets(
|
|
3301
|
+
const assets = await this.contract.convert_to_assets(uint2563.bnToUint256(balanceShares.toWei()));
|
|
3298
3302
|
return Web3Number.fromWei(assets.toString(), this.metadata.decimals);
|
|
3299
3303
|
}
|
|
3300
3304
|
/** Returns usd value of assets */
|
|
@@ -3310,7 +3314,7 @@ var AutoCompounderSTRK = class {
|
|
|
3310
3314
|
};
|
|
3311
3315
|
|
|
3312
3316
|
// src/strategies/vesu-rebalance.tsx
|
|
3313
|
-
import { CairoCustomEnum, Contract as Contract6, num as num4, uint256 as
|
|
3317
|
+
import { CairoCustomEnum, Contract as Contract6, num as num4, uint256 as uint2564 } from "starknet";
|
|
3314
3318
|
|
|
3315
3319
|
// src/data/vesu-rebalance.abi.json
|
|
3316
3320
|
var vesu_rebalance_abi_default = [
|
|
@@ -10461,10 +10465,10 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10461
10465
|
});
|
|
10462
10466
|
const call1 = assetContract.populate("approve", [
|
|
10463
10467
|
this.address.address,
|
|
10464
|
-
|
|
10468
|
+
uint2564.bnToUint256(amountInfo.amount.toWei())
|
|
10465
10469
|
]);
|
|
10466
10470
|
const call2 = this.contract.populate("deposit", [
|
|
10467
|
-
|
|
10471
|
+
uint2564.bnToUint256(amountInfo.amount.toWei()),
|
|
10468
10472
|
receiver.address
|
|
10469
10473
|
]);
|
|
10470
10474
|
return [call1, call2];
|
|
@@ -10479,7 +10483,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10479
10483
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
10480
10484
|
return [
|
|
10481
10485
|
this.contract.populate("withdraw", [
|
|
10482
|
-
|
|
10486
|
+
uint2564.bnToUint256(amountInfo.amount.toWei()),
|
|
10483
10487
|
receiver.address,
|
|
10484
10488
|
owner.address
|
|
10485
10489
|
])
|
|
@@ -10503,7 +10507,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10503
10507
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
10504
10508
|
const assets = await this.contract.call(
|
|
10505
10509
|
"convert_to_assets",
|
|
10506
|
-
[
|
|
10510
|
+
[uint2564.bnToUint256(shares)],
|
|
10507
10511
|
{ blockIdentifier }
|
|
10508
10512
|
);
|
|
10509
10513
|
const amount = Web3Number.fromWei(
|
|
@@ -10661,7 +10665,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10661
10665
|
});
|
|
10662
10666
|
const bal = await vTokenContract.balanceOf(this.address.address);
|
|
10663
10667
|
const assets = await vTokenContract.convert_to_assets(
|
|
10664
|
-
|
|
10668
|
+
uint2564.bnToUint256(bal.toString())
|
|
10665
10669
|
);
|
|
10666
10670
|
logger.verbose(`Collateral: ${JSON.stringify(vesuPosition?.collateral)}`);
|
|
10667
10671
|
logger.verbose(`supplyApy: ${JSON.stringify(assetInfo?.stats.supplyApy)}`);
|
|
@@ -10967,7 +10971,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
10967
10971
|
p.isDeposit ? { DEPOSIT: {} } : { WITHDRAW: {} }
|
|
10968
10972
|
),
|
|
10969
10973
|
token: this.asset().address.address,
|
|
10970
|
-
amount:
|
|
10974
|
+
amount: uint2564.bnToUint256(
|
|
10971
10975
|
p.changeAmt.multipliedBy(p.isDeposit ? 1 : -1).toWei()
|
|
10972
10976
|
)
|
|
10973
10977
|
});
|
|
@@ -11026,10 +11030,10 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
11026
11030
|
const avnu = new AvnuWrapper();
|
|
11027
11031
|
let swapInfo = {
|
|
11028
11032
|
token_from_address: harvest.token.address,
|
|
11029
|
-
token_from_amount:
|
|
11033
|
+
token_from_amount: uint2564.bnToUint256(harvest.actualReward.toWei()),
|
|
11030
11034
|
token_to_address: this.asset().address.address,
|
|
11031
|
-
token_to_amount:
|
|
11032
|
-
token_to_min_amount:
|
|
11035
|
+
token_to_amount: uint2564.bnToUint256(0),
|
|
11036
|
+
token_to_min_amount: uint2564.bnToUint256(0),
|
|
11033
11037
|
beneficiary: this.address.address,
|
|
11034
11038
|
integrator_fee_amount_bps: 0,
|
|
11035
11039
|
integrator_fee_recipient: this.address.address,
|
|
@@ -11301,7 +11305,7 @@ VesuRebalanceStrategies.forEach((s) => {
|
|
|
11301
11305
|
import {
|
|
11302
11306
|
Contract as Contract7,
|
|
11303
11307
|
num as num5,
|
|
11304
|
-
uint256 as
|
|
11308
|
+
uint256 as uint2565
|
|
11305
11309
|
} from "starknet";
|
|
11306
11310
|
|
|
11307
11311
|
// src/data/cl-vault.abi.json
|
|
@@ -16371,7 +16375,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16371
16375
|
const shares = await this.tokensToShares(amountInfo);
|
|
16372
16376
|
const { amount0, amount1 } = await this.contract.call(
|
|
16373
16377
|
"convert_to_assets",
|
|
16374
|
-
[
|
|
16378
|
+
[uint2565.bnToUint256(shares.toWei())]
|
|
16375
16379
|
);
|
|
16376
16380
|
return {
|
|
16377
16381
|
token0: {
|
|
@@ -16404,15 +16408,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16404
16408
|
});
|
|
16405
16409
|
const call1 = token0Contract.populate("approve", [
|
|
16406
16410
|
this.address.address,
|
|
16407
|
-
|
|
16411
|
+
uint2565.bnToUint256(updateAmountInfo.token0.amount.toWei())
|
|
16408
16412
|
]);
|
|
16409
16413
|
const call2 = token1Contract.populate("approve", [
|
|
16410
16414
|
this.address.address,
|
|
16411
|
-
|
|
16415
|
+
uint2565.bnToUint256(updateAmountInfo.token1.amount.toWei())
|
|
16412
16416
|
]);
|
|
16413
16417
|
const call3 = this.contract.populate("deposit", [
|
|
16414
|
-
|
|
16415
|
-
|
|
16418
|
+
uint2565.bnToUint256(updateAmountInfo.token0.amount.toWei()),
|
|
16419
|
+
uint2565.bnToUint256(updateAmountInfo.token1.amount.toWei()),
|
|
16416
16420
|
receiver.address
|
|
16417
16421
|
]);
|
|
16418
16422
|
const calls = [];
|
|
@@ -16422,8 +16426,8 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16422
16426
|
}
|
|
16423
16427
|
async tokensToShares(amountInfo) {
|
|
16424
16428
|
const shares = await this.contract.call("convert_to_shares", [
|
|
16425
|
-
|
|
16426
|
-
|
|
16429
|
+
uint2565.bnToUint256(amountInfo.token0.amount.toWei()),
|
|
16430
|
+
uint2565.bnToUint256(amountInfo.token1.amount.toWei())
|
|
16427
16431
|
]);
|
|
16428
16432
|
return Web3Number.fromWei(shares.toString(), 18);
|
|
16429
16433
|
}
|
|
@@ -16434,7 +16438,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16434
16438
|
);
|
|
16435
16439
|
return [
|
|
16436
16440
|
this.contract.populate("withdraw", [
|
|
16437
|
-
|
|
16441
|
+
uint2565.bnToUint256(shares.toWei()),
|
|
16438
16442
|
receiver.address
|
|
16439
16443
|
])
|
|
16440
16444
|
];
|
|
@@ -16456,14 +16460,21 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16456
16460
|
handleFeesCall() {
|
|
16457
16461
|
return [this.contract.populate("handle_fees", [])];
|
|
16458
16462
|
}
|
|
16459
|
-
async getFeeHistory(timePeriod = "24h") {
|
|
16463
|
+
async getFeeHistory(timePeriod = "24h", range) {
|
|
16460
16464
|
const { data } = await apollo_client_default.query({
|
|
16461
16465
|
query: gql2`
|
|
16462
16466
|
query ContractFeeEarnings(
|
|
16463
16467
|
$timeframe: String!
|
|
16464
16468
|
$contract: String!
|
|
16469
|
+
$startTimestamp: Float
|
|
16470
|
+
$endTimestamp: Float
|
|
16465
16471
|
) {
|
|
16466
|
-
contractFeeEarnings(
|
|
16472
|
+
contractFeeEarnings(
|
|
16473
|
+
timeframe: $timeframe
|
|
16474
|
+
contract: $contract
|
|
16475
|
+
startTimestamp: $startTimestamp
|
|
16476
|
+
endTimestamp: $endTimestamp
|
|
16477
|
+
) {
|
|
16467
16478
|
contract
|
|
16468
16479
|
dailyEarnings {
|
|
16469
16480
|
date
|
|
@@ -16476,7 +16487,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16476
16487
|
`,
|
|
16477
16488
|
variables: {
|
|
16478
16489
|
timeframe: timePeriod,
|
|
16479
|
-
contract: this.address.address
|
|
16490
|
+
contract: this.address.address,
|
|
16491
|
+
startTimestamp: range?.startTimestamp,
|
|
16492
|
+
endTimestamp: range?.endTimestamp
|
|
16480
16493
|
},
|
|
16481
16494
|
fetchPolicy: "no-cache"
|
|
16482
16495
|
});
|
|
@@ -16648,7 +16661,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16648
16661
|
let bal = await this.balanceOf(user, blockIdentifier);
|
|
16649
16662
|
const assets = await this.contract.call(
|
|
16650
16663
|
"convert_to_assets",
|
|
16651
|
-
[
|
|
16664
|
+
[uint2565.bnToUint256(bal.toWei())],
|
|
16652
16665
|
{
|
|
16653
16666
|
blockIdentifier
|
|
16654
16667
|
}
|
|
@@ -16794,7 +16807,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16794
16807
|
return this.metadata.additionalInfo.truePrice;
|
|
16795
16808
|
} else if (this.lstContract) {
|
|
16796
16809
|
const result = await this.lstContract.call("convert_to_assets", [
|
|
16797
|
-
|
|
16810
|
+
uint2565.bnToUint256(BigInt(1e18).toString())
|
|
16798
16811
|
]);
|
|
16799
16812
|
const truePrice = Number(BigInt(result.toString()) * BigInt(1e9) / BigInt(1e18)) / 1e9;
|
|
16800
16813
|
return truePrice;
|
|
@@ -17295,7 +17308,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17295
17308
|
logger.error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17296
17309
|
throw new Error(`Rebalance failed after ${MAX_SAME_ERROR_COUNT} same errors`);
|
|
17297
17310
|
}
|
|
17298
|
-
const fromAmount =
|
|
17311
|
+
const fromAmount = uint2565.uint256ToBN(swapInfo.token_from_amount);
|
|
17299
17312
|
const fromTokenInfo = await Global.getTokenInfoFromAddr(ContractAddr.from(swapInfo.token_from_address));
|
|
17300
17313
|
logger.verbose(
|
|
17301
17314
|
`Selling ${fromAmount.toString()} of token ${swapInfo.token_from_address}`
|
|
@@ -17324,7 +17337,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17324
17337
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17325
17338
|
throw err;
|
|
17326
17339
|
}
|
|
17327
|
-
newSwapInfo.token_from_amount =
|
|
17340
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17328
17341
|
} else {
|
|
17329
17342
|
logger.verbose("Increasing swap amount - deficit token0");
|
|
17330
17343
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17336,7 +17349,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17336
17349
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17337
17350
|
throw err;
|
|
17338
17351
|
}
|
|
17339
|
-
newSwapInfo.token_from_amount =
|
|
17352
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17340
17353
|
}
|
|
17341
17354
|
} else if (err.message.includes("invalid token1 amount") || err.message.includes("invalid token1 balance")) {
|
|
17342
17355
|
if (isSellTokenToken0) {
|
|
@@ -17347,7 +17360,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17347
17360
|
logger.error("Convergence failed: nextAmount <= lowerLimit");
|
|
17348
17361
|
throw err;
|
|
17349
17362
|
}
|
|
17350
|
-
newSwapInfo.token_from_amount =
|
|
17363
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17351
17364
|
} else {
|
|
17352
17365
|
logger.verbose("Increasing swap amount - deficit token1");
|
|
17353
17366
|
let nextAmount = (fromAmount + upperLimit) / 2n;
|
|
@@ -17359,7 +17372,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17359
17372
|
logger.error("Convergence failed: nextAmount >= upperLimit");
|
|
17360
17373
|
throw err;
|
|
17361
17374
|
}
|
|
17362
|
-
newSwapInfo.token_from_amount =
|
|
17375
|
+
newSwapInfo.token_from_amount = uint2565.bnToUint256(nextAmount);
|
|
17363
17376
|
}
|
|
17364
17377
|
} else if (err.message.includes("Residual tokens")) {
|
|
17365
17378
|
logger.error("Residual tokens");
|
|
@@ -17389,7 +17402,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17389
17402
|
logger.error("Unexpected error:", err);
|
|
17390
17403
|
throw err;
|
|
17391
17404
|
}
|
|
17392
|
-
newSwapInfo.token_to_min_amount =
|
|
17405
|
+
newSwapInfo.token_to_min_amount = uint2565.bnToUint256("0");
|
|
17393
17406
|
return this.rebalanceIter(
|
|
17394
17407
|
newSwapInfo,
|
|
17395
17408
|
acc,
|
|
@@ -17440,15 +17453,15 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17440
17453
|
const result = await this.ekuboMathContract.call(
|
|
17441
17454
|
"liquidity_delta_to_amount_delta",
|
|
17442
17455
|
[
|
|
17443
|
-
|
|
17456
|
+
uint2565.bnToUint256(currentPrice.sqrtRatio),
|
|
17444
17457
|
{
|
|
17445
17458
|
mag: liquidity.toWei(),
|
|
17446
17459
|
sign: 0
|
|
17447
17460
|
},
|
|
17448
|
-
|
|
17461
|
+
uint2565.bnToUint256(
|
|
17449
17462
|
_EkuboCLVault.priceToSqrtRatio(lowerPrice).toString()
|
|
17450
17463
|
),
|
|
17451
|
-
|
|
17464
|
+
uint2565.bnToUint256(
|
|
17452
17465
|
_EkuboCLVault.priceToSqrtRatio(upperPrice).toString()
|
|
17453
17466
|
)
|
|
17454
17467
|
],
|
|
@@ -17551,7 +17564,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17551
17564
|
const claimTokenInfo = await Global.getTokenInfoFromAddr(claim.token);
|
|
17552
17565
|
const harvestEstimateCall = async (baseSwapInfo2) => {
|
|
17553
17566
|
let baseSwapAmount = Web3Number.fromWei(
|
|
17554
|
-
|
|
17567
|
+
uint2565.uint256ToBN(baseSwapInfo2.token_from_amount).toString(),
|
|
17555
17568
|
claimTokenInfo.decimals
|
|
17556
17569
|
).minimum(
|
|
17557
17570
|
postFeeAmount.toFixed(claimTokenInfo.decimals)
|
|
@@ -17559,7 +17572,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17559
17572
|
if (baseSwapAmount.lt(1e-4)) {
|
|
17560
17573
|
baseSwapAmount = new Web3Number(0, claimTokenInfo.decimals);
|
|
17561
17574
|
}
|
|
17562
|
-
baseSwapInfo2.token_from_amount =
|
|
17575
|
+
baseSwapInfo2.token_from_amount = uint2565.bnToUint256(baseSwapAmount.toWei());
|
|
17563
17576
|
const isToken0ClaimToken2 = claim.token.eq(poolKey.token0);
|
|
17564
17577
|
logger.verbose(
|
|
17565
17578
|
`${_EkuboCLVault.name}: harvest => isToken0ClaimToken: ${isToken0ClaimToken2}, baseSwapAmount: ${baseSwapAmount}`
|
|
@@ -17569,7 +17582,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17569
17582
|
`${_EkuboCLVault.name}: harvest => remainingAmount: ${remainingAmount}`
|
|
17570
17583
|
);
|
|
17571
17584
|
let dummySwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, claim.token);
|
|
17572
|
-
dummySwapInfo.token_from_amount =
|
|
17585
|
+
dummySwapInfo.token_from_amount = uint2565.bnToUint256(remainingAmount.toWei());
|
|
17573
17586
|
logger.verbose(
|
|
17574
17587
|
`${_EkuboCLVault.name}: harvest => dummySwapInfo: ${JSON.stringify(
|
|
17575
17588
|
dummySwapInfo
|
|
@@ -17596,7 +17609,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
17596
17609
|
};
|
|
17597
17610
|
const isToken0ClaimToken = claim.token.eq(poolKey.token0);
|
|
17598
17611
|
let baseSwapInfo = AvnuWrapper.buildZeroSwap(claim.token, this.address.address, isToken0ClaimToken ? token1Info.address : token0Info.address);
|
|
17599
|
-
baseSwapInfo.token_from_amount =
|
|
17612
|
+
baseSwapInfo.token_from_amount = uint2565.bnToUint256(postFeeAmount.toWei());
|
|
17600
17613
|
if (postFeeAmount.greaterThan(0) && !isToken0ClaimToken) {
|
|
17601
17614
|
const avnuWrapper = new AvnuWrapper();
|
|
17602
17615
|
const quote = await avnuWrapper.getQuotes(
|
|
@@ -18396,7 +18409,7 @@ EkuboCLVaultStrategies.forEach((s) => {
|
|
|
18396
18409
|
});
|
|
18397
18410
|
|
|
18398
18411
|
// src/strategies/sensei.ts
|
|
18399
|
-
import { Contract as Contract9, num as num8, uint256 as
|
|
18412
|
+
import { Contract as Contract9, num as num8, uint256 as uint2567 } from "starknet";
|
|
18400
18413
|
|
|
18401
18414
|
// src/data/sensei.abi.json
|
|
18402
18415
|
var sensei_abi_default = [
|
|
@@ -20160,7 +20173,7 @@ var sensei_abi_default = [
|
|
|
20160
20173
|
];
|
|
20161
20174
|
|
|
20162
20175
|
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
20163
|
-
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash2, num as num7, RpcProvider as RpcProvider5, shortString as shortString2, uint256 as
|
|
20176
|
+
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash2, num as num7, RpcProvider as RpcProvider5, shortString as shortString2, uint256 as uint2566 } from "starknet";
|
|
20164
20177
|
|
|
20165
20178
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
20166
20179
|
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
@@ -27400,7 +27413,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27400
27413
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27401
27414
|
extension: BigInt(num7.hexToDecimalString(route.pool_key.extension))
|
|
27402
27415
|
},
|
|
27403
|
-
sqrt_ratio_limit:
|
|
27416
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27404
27417
|
skip_ahead: BigInt(100)
|
|
27405
27418
|
})),
|
|
27406
27419
|
token_amount: {
|
|
@@ -27418,7 +27431,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27418
27431
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27419
27432
|
extension: BigInt(num7.hexToDecimalString(route.pool_key.extension))
|
|
27420
27433
|
},
|
|
27421
|
-
sqrt_ratio_limit:
|
|
27434
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27422
27435
|
skip_ahead: BigInt(100)
|
|
27423
27436
|
})),
|
|
27424
27437
|
token_amount: {
|
|
@@ -27448,7 +27461,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27448
27461
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27449
27462
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27450
27463
|
},
|
|
27451
|
-
sqrt_ratio_limit:
|
|
27464
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27452
27465
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27453
27466
|
})),
|
|
27454
27467
|
token_amount: {
|
|
@@ -27467,7 +27480,7 @@ function getVesuMultiplyParams(isIncrease, params) {
|
|
|
27467
27480
|
tick_spacing: route.pool_key.tick_spacing,
|
|
27468
27481
|
extension: ContractAddr.from(route.pool_key.extension).toBigInt()
|
|
27469
27482
|
},
|
|
27470
|
-
sqrt_ratio_limit:
|
|
27483
|
+
sqrt_ratio_limit: uint2566.bnToUint256(route.sqrt_ratio_limit.toWei()),
|
|
27471
27484
|
skip_ahead: BigInt(route.skip_ahead.toWei())
|
|
27472
27485
|
})),
|
|
27473
27486
|
token_amount: {
|
|
@@ -27551,7 +27564,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27551
27564
|
amount_type: this.formatAmountTypeEnum(params.collateralAmount.amount_type),
|
|
27552
27565
|
denomination: this.formatAmountDenominationEnum(params.collateralAmount.denomination),
|
|
27553
27566
|
value: {
|
|
27554
|
-
abs:
|
|
27567
|
+
abs: uint2566.bnToUint256(params.collateralAmount.value.abs.toWei()),
|
|
27555
27568
|
is_negative: params.collateralAmount.value.abs.isZero() ? false : params.collateralAmount.value.is_negative
|
|
27556
27569
|
}
|
|
27557
27570
|
};
|
|
@@ -27560,7 +27573,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27560
27573
|
amount_type: this.formatAmountTypeEnum(params.debtAmount.amount_type),
|
|
27561
27574
|
denomination: this.formatAmountDenominationEnum(params.debtAmount.denomination),
|
|
27562
27575
|
value: {
|
|
27563
|
-
abs:
|
|
27576
|
+
abs: uint2566.bnToUint256(params.debtAmount.value.abs.toWei()),
|
|
27564
27577
|
is_negative: params.debtAmount.value.abs.isZero() ? false : params.debtAmount.value.is_negative
|
|
27565
27578
|
}
|
|
27566
27579
|
};
|
|
@@ -27646,15 +27659,15 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27646
27659
|
}
|
|
27647
27660
|
};
|
|
27648
27661
|
};
|
|
27649
|
-
this.getVesuModifyDelegationAdapter = (id) => {
|
|
27662
|
+
this.getVesuModifyDelegationAdapter = (id, delegatee) => {
|
|
27650
27663
|
return () => {
|
|
27651
27664
|
const { addr: VESU_SINGLETON2, isV2 } = getVesuSingletonAddress(this.config.poolId);
|
|
27652
27665
|
const packedArguments = isV2 ? [
|
|
27653
|
-
toBigInt(
|
|
27666
|
+
toBigInt(delegatee.toString())
|
|
27654
27667
|
// v2
|
|
27655
27668
|
] : [
|
|
27656
27669
|
this.config.poolId.toBigInt(),
|
|
27657
|
-
toBigInt(
|
|
27670
|
+
toBigInt(delegatee.toString())
|
|
27658
27671
|
// v1
|
|
27659
27672
|
];
|
|
27660
27673
|
const output = this.constructSimpleLeafData({
|
|
@@ -27663,29 +27676,31 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
27663
27676
|
method: "modify_delegation",
|
|
27664
27677
|
packedArguments
|
|
27665
27678
|
}, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
|
|
27666
|
-
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
|
|
27679
|
+
return { leaf: output, callConstructor: this.getVesuModifyDelegationCall(delegatee).bind(this) };
|
|
27667
27680
|
};
|
|
27668
27681
|
};
|
|
27669
|
-
this.getVesuModifyDelegationCall = (
|
|
27670
|
-
|
|
27671
|
-
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
|
|
27675
|
-
|
|
27676
|
-
|
|
27677
|
-
|
|
27678
|
-
|
|
27679
|
-
|
|
27680
|
-
|
|
27681
|
-
|
|
27682
|
-
|
|
27683
|
-
|
|
27684
|
-
|
|
27685
|
-
|
|
27686
|
-
|
|
27687
|
-
|
|
27688
|
-
|
|
27682
|
+
this.getVesuModifyDelegationCall = (delegatee) => {
|
|
27683
|
+
return (params) => {
|
|
27684
|
+
const VESU_SINGLETON2 = getVesuSingletonAddress(this.config.poolId).addr;
|
|
27685
|
+
const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
|
|
27686
|
+
const call = contract.populate("modify_delegation", isV2 ? {
|
|
27687
|
+
delegatee: delegatee.toBigInt(),
|
|
27688
|
+
delegation: params.delegation
|
|
27689
|
+
} : {
|
|
27690
|
+
pool_id: this.config.poolId.toBigInt(),
|
|
27691
|
+
delegatee: delegatee.toBigInt(),
|
|
27692
|
+
delegation: params.delegation
|
|
27693
|
+
});
|
|
27694
|
+
return {
|
|
27695
|
+
sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
|
|
27696
|
+
call: {
|
|
27697
|
+
contractAddress: VESU_SINGLETON2,
|
|
27698
|
+
selector: hash2.getSelectorFromName("modify_delegation"),
|
|
27699
|
+
calldata: [
|
|
27700
|
+
...call.calldata
|
|
27701
|
+
]
|
|
27702
|
+
}
|
|
27703
|
+
};
|
|
27689
27704
|
};
|
|
27690
27705
|
};
|
|
27691
27706
|
this.getDefispringRewardsAdapter = (id) => {
|
|
@@ -28093,7 +28108,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28093
28108
|
}
|
|
28094
28109
|
);
|
|
28095
28110
|
const amount = Web3Number.fromWei(
|
|
28096
|
-
|
|
28111
|
+
uint2567.uint256ToBN(result[1].estimated_size).toString(),
|
|
28097
28112
|
this.metadata.depositTokens[0].decimals
|
|
28098
28113
|
);
|
|
28099
28114
|
const blockNumber = typeof blockIdentifier === "number" || typeof blockIdentifier === "bigint" ? Number(blockIdentifier) : void 0;
|
|
@@ -28143,10 +28158,10 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28143
28158
|
});
|
|
28144
28159
|
const call1 = mainTokenContract.populate("approve", [
|
|
28145
28160
|
this.address.address,
|
|
28146
|
-
|
|
28161
|
+
uint2567.bnToUint256(amountInfo.amount.toWei())
|
|
28147
28162
|
]);
|
|
28148
28163
|
const call2 = this.contract.populate("deposit", [
|
|
28149
|
-
|
|
28164
|
+
uint2567.bnToUint256(amountInfo.amount.toWei()),
|
|
28150
28165
|
receiver.address
|
|
28151
28166
|
]);
|
|
28152
28167
|
const calls = [call1, call2];
|
|
@@ -28154,7 +28169,7 @@ var SenseiVault = class _SenseiVault extends BaseStrategy {
|
|
|
28154
28169
|
}
|
|
28155
28170
|
async withdrawCall(amountInfo, receiver, owner) {
|
|
28156
28171
|
const call = this.contract.populate("withdraw", [
|
|
28157
|
-
|
|
28172
|
+
uint2567.bnToUint256(amountInfo.amount.toWei()),
|
|
28158
28173
|
receiver.address,
|
|
28159
28174
|
300
|
|
28160
28175
|
// 3% max slippage
|
|
@@ -28474,7 +28489,7 @@ var SenseiStrategies = [
|
|
|
28474
28489
|
];
|
|
28475
28490
|
|
|
28476
28491
|
// src/strategies/universal-adapters/common-adapter.ts
|
|
28477
|
-
import { hash as hash3, num as num9, uint256 as
|
|
28492
|
+
import { hash as hash3, num as num9, uint256 as uint2568 } from "starknet";
|
|
28478
28493
|
var CommonAdapter = class extends BaseAdapter {
|
|
28479
28494
|
constructor(config) {
|
|
28480
28495
|
super();
|
|
@@ -28499,7 +28514,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28499
28514
|
return { leaf, callConstructor: this.getFlashloanCall.bind(this) };
|
|
28500
28515
|
}
|
|
28501
28516
|
getFlashloanCall(params) {
|
|
28502
|
-
const uint256Amount =
|
|
28517
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28503
28518
|
return {
|
|
28504
28519
|
sanitizer: SIMPLE_SANITIZER,
|
|
28505
28520
|
call: {
|
|
@@ -28538,7 +28553,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28538
28553
|
}
|
|
28539
28554
|
getApproveCall(token, spender) {
|
|
28540
28555
|
return (params) => {
|
|
28541
|
-
const uint256Amount =
|
|
28556
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28542
28557
|
return {
|
|
28543
28558
|
sanitizer: SIMPLE_SANITIZER,
|
|
28544
28559
|
call: {
|
|
@@ -28569,7 +28584,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28569
28584
|
}
|
|
28570
28585
|
getBringLiquidityCall() {
|
|
28571
28586
|
return (params) => {
|
|
28572
|
-
const uint256Amount =
|
|
28587
|
+
const uint256Amount = uint2568.bnToUint256(params.amount.toWei());
|
|
28573
28588
|
return {
|
|
28574
28589
|
sanitizer: SIMPLE_SANITIZER,
|
|
28575
28590
|
call: {
|
|
@@ -28648,7 +28663,7 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
28648
28663
|
};
|
|
28649
28664
|
|
|
28650
28665
|
// src/strategies/universal-strategy.tsx
|
|
28651
|
-
import { CallData, Contract as Contract10, num as num10, uint256 as
|
|
28666
|
+
import { CallData, Contract as Contract10, num as num10, uint256 as uint2569 } from "starknet";
|
|
28652
28667
|
|
|
28653
28668
|
// src/data/universal-vault.abi.json
|
|
28654
28669
|
var universal_vault_abi_default = [
|
|
@@ -30936,10 +30951,10 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30936
30951
|
});
|
|
30937
30952
|
const call1 = assetContract.populate("approve", [
|
|
30938
30953
|
this.address.address,
|
|
30939
|
-
|
|
30954
|
+
uint2569.bnToUint256(amountInfo.amount.toWei())
|
|
30940
30955
|
]);
|
|
30941
30956
|
const call2 = this.contract.populate("deposit", [
|
|
30942
|
-
|
|
30957
|
+
uint2569.bnToUint256(amountInfo.amount.toWei()),
|
|
30943
30958
|
receiver.address
|
|
30944
30959
|
]);
|
|
30945
30960
|
return [call1, call2];
|
|
@@ -30949,9 +30964,9 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30949
30964
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
30950
30965
|
"Withdraw token mismatch"
|
|
30951
30966
|
);
|
|
30952
|
-
const shares = await this.contract.call("convert_to_shares", [
|
|
30967
|
+
const shares = await this.contract.call("convert_to_shares", [uint2569.bnToUint256(amountInfo.amount.toWei())]);
|
|
30953
30968
|
const call = this.contract.populate("request_redeem", [
|
|
30954
|
-
|
|
30969
|
+
uint2569.bnToUint256(shares.toString()),
|
|
30955
30970
|
receiver.address,
|
|
30956
30971
|
owner.address
|
|
30957
30972
|
]);
|
|
@@ -30961,7 +30976,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
30961
30976
|
const shares = await this.contract.call("balanceOf", [user.address], { blockIdentifier });
|
|
30962
30977
|
const assets = await this.contract.call(
|
|
30963
30978
|
"convert_to_assets",
|
|
30964
|
-
[
|
|
30979
|
+
[uint2569.bnToUint256(shares)],
|
|
30965
30980
|
{ blockIdentifier }
|
|
30966
30981
|
);
|
|
30967
30982
|
const amount = Web3Number.fromWei(
|
|
@@ -31962,7 +31977,7 @@ var UniversalStrategies = [
|
|
|
31962
31977
|
];
|
|
31963
31978
|
|
|
31964
31979
|
// src/strategies/universal-lst-muliplier-strategy.tsx
|
|
31965
|
-
import { Contract as Contract11, uint256 as
|
|
31980
|
+
import { Contract as Contract11, uint256 as uint25610 } from "starknet";
|
|
31966
31981
|
|
|
31967
31982
|
// src/utils/health-factor-math.ts
|
|
31968
31983
|
var HealthFactorMath = class {
|
|
@@ -32500,8 +32515,8 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
32500
32515
|
address: lstTokenInfo.address.address,
|
|
32501
32516
|
providerOrAccount: this.config.provider
|
|
32502
32517
|
});
|
|
32503
|
-
const price = await lstABI.call("convert_to_assets", [
|
|
32504
|
-
const exchangeRate = Number(
|
|
32518
|
+
const price = await lstABI.call("convert_to_assets", [uint25610.bnToUint256(new Web3Number(1, lstTokenInfo.decimals).toWei())]);
|
|
32519
|
+
const exchangeRate = Number(uint25610.uint256ToBN(price).toString()) / Math.pow(10, lstTokenInfo.decimals);
|
|
32505
32520
|
logger.verbose(`${this.getTag()}:: LST Exchange Rate: ${exchangeRate}`);
|
|
32506
32521
|
return exchangeRate;
|
|
32507
32522
|
}
|
|
@@ -32672,9 +32687,9 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
32672
32687
|
const leafIdApprove = getVesuGenericLegId(poolId.toString(), "multiple_approve" /* MULTIPLE_APPROVE */);
|
|
32673
32688
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, VESU_MULTIPLY, leafIdApprove).bind(commonAdapter));
|
|
32674
32689
|
const leafIdDelegationOn = getVesuGenericLegId(poolId.toString(), "switch_delegation_on" /* SWITCH_DELEGATION_ON */);
|
|
32675
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn).bind(vesuAdapterLST));
|
|
32690
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOn, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32676
32691
|
const leafIdDelegationOff = getVesuGenericLegId(poolId.toString(), "switch_delegation_off" /* SWITCH_DELEGATION_OFF */);
|
|
32677
|
-
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff).bind(vesuAdapterLST));
|
|
32692
|
+
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
32678
32693
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
32679
32694
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
32680
32695
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, "approve_token1" /* APPROVE_TOKEN1 */).bind(commonAdapter));
|
|
@@ -32791,7 +32806,9 @@ var hyperxSTRK = {
|
|
|
32791
32806
|
minHealthFactor: 1.05,
|
|
32792
32807
|
borrowable_assets: [
|
|
32793
32808
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
32794
|
-
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime }))
|
|
32809
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
32810
|
+
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
32811
|
+
// v2, new alt for Re7xSTRK
|
|
32795
32812
|
],
|
|
32796
32813
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
32797
32814
|
defaultPoolId: VesuPools.Re7xSTRK
|