@strkfarm/sdk 2.0.0-dev.13 → 2.0.0-dev.14
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 +345 -328
- package/dist/index.browser.mjs +807 -790
- package/dist/index.d.ts +19 -1
- package/dist/index.js +353 -334
- package/dist/index.mjs +807 -790
- package/package.json +1 -1
- package/src/strategies/universal-adapters/index.ts +2 -1
- package/src/strategies/vesu-extended-strategy/utils/helper.ts +40 -0
package/dist/index.mjs
CHANGED
|
@@ -28208,6 +28208,21 @@ var calculateAmountDepositOnExtendedWhenIncurringLosses = async (client) => {
|
|
|
28208
28208
|
return null;
|
|
28209
28209
|
}
|
|
28210
28210
|
};
|
|
28211
|
+
var calculateWBTCAmountToMaintainLTV = (collateralAmount, debtAmount, debtPrice, maxLtv = MAX_LIQUIDATION_RATIO, collateralPrice, targetHF = TARGET_HF) => {
|
|
28212
|
+
try {
|
|
28213
|
+
const numerator1 = collateralAmount.multipliedBy(collateralPrice).multipliedBy(maxLtv);
|
|
28214
|
+
const numerator2 = debtAmount.multipliedBy(debtPrice).multipliedBy(targetHF);
|
|
28215
|
+
const denominator = maxLtv;
|
|
28216
|
+
const collateralAmountToMaintainLTV = numerator2.minus(numerator1).dividedBy(denominator);
|
|
28217
|
+
let deltaCollateralAmountUnits = new Web3Number(
|
|
28218
|
+
collateralAmountToMaintainLTV.dividedBy(collateralPrice).toFixed(WBTC_TOKEN_DECIMALS),
|
|
28219
|
+
WBTC_TOKEN_DECIMALS
|
|
28220
|
+
);
|
|
28221
|
+
return { deltaCollateralAmountUnits };
|
|
28222
|
+
} catch (err) {
|
|
28223
|
+
return { deltaCollateralAmountUnits: null };
|
|
28224
|
+
}
|
|
28225
|
+
};
|
|
28211
28226
|
var calculateExposureDelta = (exposure_extended, exposure_vesu) => {
|
|
28212
28227
|
const exposure_delta = new Web3Number(exposure_extended - exposure_vesu, 2);
|
|
28213
28228
|
return exposure_delta.absoluteValue().toNumber();
|
|
@@ -30489,519 +30504,604 @@ var UnusedBalanceAdapter = class _UnusedBalanceAdapter extends BaseAdapter {
|
|
|
30489
30504
|
}
|
|
30490
30505
|
};
|
|
30491
30506
|
|
|
30492
|
-
// src/strategies/universal-
|
|
30493
|
-
|
|
30494
|
-
|
|
30495
|
-
|
|
30496
|
-
|
|
30497
|
-
|
|
30498
|
-
|
|
30499
|
-
|
|
30500
|
-
PositionTypeAvnuExtended2["CLOSE"] = "close";
|
|
30501
|
-
return PositionTypeAvnuExtended2;
|
|
30502
|
-
})(PositionTypeAvnuExtended || {});
|
|
30503
|
-
var UNIVERSAL_MANAGE_IDS = /* @__PURE__ */ ((UNIVERSAL_MANAGE_IDS2) => {
|
|
30504
|
-
UNIVERSAL_MANAGE_IDS2["FLASH_LOAN"] = "flash_loan_init";
|
|
30505
|
-
UNIVERSAL_MANAGE_IDS2["VESU_LEG1"] = "vesu_leg1";
|
|
30506
|
-
UNIVERSAL_MANAGE_IDS2["VESU_LEG2"] = "vesu_leg2";
|
|
30507
|
-
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN1"] = "approve_token1";
|
|
30508
|
-
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
|
|
30509
|
-
UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
|
|
30510
|
-
UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
|
|
30511
|
-
UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
|
|
30512
|
-
UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
|
|
30513
|
-
UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
|
|
30514
|
-
return UNIVERSAL_MANAGE_IDS2;
|
|
30515
|
-
})(UNIVERSAL_MANAGE_IDS || {});
|
|
30516
|
-
function getContractDetails(settings) {
|
|
30517
|
-
const contracts = [
|
|
30518
|
-
{ address: settings.vaultAddress, name: "Vault" },
|
|
30519
|
-
{ address: settings.manager, name: "Vault Manager" },
|
|
30520
|
-
{ address: settings.vaultAllocator, name: "Vault Allocator" },
|
|
30521
|
-
{ address: settings.redeemRequestNFT, name: "Redeem Request NFT" }
|
|
30522
|
-
];
|
|
30523
|
-
if (settings.aumOracle) {
|
|
30524
|
-
contracts.push({ address: settings.aumOracle, name: "AUM Oracle" });
|
|
30507
|
+
// src/strategies/universal-adapters/avnu-adapter.ts
|
|
30508
|
+
import { hash as hash7, uint256 as uint25614 } from "starknet";
|
|
30509
|
+
import axios9 from "axios";
|
|
30510
|
+
var AvnuAdapter = class _AvnuAdapter extends BaseAdapter {
|
|
30511
|
+
constructor(config) {
|
|
30512
|
+
super(config, _AvnuAdapter.name, Protocols.AVNU);
|
|
30513
|
+
this.config = config;
|
|
30514
|
+
this.avnuWrapper = new AvnuWrapper();
|
|
30525
30515
|
}
|
|
30526
|
-
|
|
30527
|
-
|
|
30528
|
-
|
|
30529
|
-
|
|
30530
|
-
|
|
30531
|
-
|
|
30532
|
-
|
|
30533
|
-
|
|
30534
|
-
|
|
30535
|
-
|
|
30536
|
-
|
|
30537
|
-
|
|
30538
|
-
|
|
30539
|
-
|
|
30540
|
-
|
|
30541
|
-
|
|
30542
|
-
|
|
30516
|
+
//abstract means the method has no implementation in this class; instead, child classes must implement it.
|
|
30517
|
+
async getAPY(supportedPosition) {
|
|
30518
|
+
return Promise.resolve({ apy: 0, type: "base" /* BASE */ });
|
|
30519
|
+
}
|
|
30520
|
+
async getPosition(supportedPosition) {
|
|
30521
|
+
return Promise.resolve({ amount: new Web3Number(0, 0), remarks: "" });
|
|
30522
|
+
}
|
|
30523
|
+
async maxDeposit(amount) {
|
|
30524
|
+
return Promise.resolve({
|
|
30525
|
+
tokenInfo: this.config.baseToken,
|
|
30526
|
+
amount: new Web3Number(0, 0),
|
|
30527
|
+
usdValue: 0,
|
|
30528
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
30529
|
+
protocol: Protocols.AVNU,
|
|
30530
|
+
remarks: ""
|
|
30531
|
+
});
|
|
30532
|
+
}
|
|
30533
|
+
async maxWithdraw() {
|
|
30534
|
+
return Promise.resolve({
|
|
30535
|
+
tokenInfo: this.config.baseToken,
|
|
30536
|
+
amount: new Web3Number(0, 0),
|
|
30537
|
+
usdValue: 0,
|
|
30538
|
+
apy: { apy: 0, type: "base" /* BASE */ },
|
|
30539
|
+
protocol: Protocols.AVNU,
|
|
30540
|
+
remarks: ""
|
|
30541
|
+
});
|
|
30542
|
+
}
|
|
30543
|
+
_getDepositLeaf() {
|
|
30544
|
+
const vaultAllocator = ContractAddr.from(
|
|
30545
|
+
this.config.vaultAllocator.address
|
|
30546
|
+
);
|
|
30547
|
+
return [
|
|
30543
30548
|
{
|
|
30544
|
-
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
name: "new_class_hash",
|
|
30549
|
-
type: "core::starknet::class_hash::ClassHash"
|
|
30550
|
-
}
|
|
30549
|
+
target: this.config.supportedPositions[0].asset.address,
|
|
30550
|
+
method: "approve",
|
|
30551
|
+
packedArguments: [
|
|
30552
|
+
AVNU_EXCHANGE.toBigInt()
|
|
30551
30553
|
],
|
|
30552
|
-
|
|
30553
|
-
|
|
30554
|
-
}
|
|
30555
|
-
]
|
|
30556
|
-
},
|
|
30557
|
-
{
|
|
30558
|
-
type: "impl",
|
|
30559
|
-
name: "VaultMetadataImpl",
|
|
30560
|
-
interface_name: "openzeppelin_interfaces::token::erc20::IERC20Metadata"
|
|
30561
|
-
},
|
|
30562
|
-
{
|
|
30563
|
-
type: "struct",
|
|
30564
|
-
name: "core::byte_array::ByteArray",
|
|
30565
|
-
members: [
|
|
30566
|
-
{
|
|
30567
|
-
name: "data",
|
|
30568
|
-
type: "core::array::Array::<core::bytes_31::bytes31>"
|
|
30569
|
-
},
|
|
30570
|
-
{
|
|
30571
|
-
name: "pending_word",
|
|
30572
|
-
type: "core::felt252"
|
|
30554
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30555
|
+
id: `approve_${this.config.supportedPositions[0].asset.symbol}`
|
|
30573
30556
|
},
|
|
30574
30557
|
{
|
|
30575
|
-
|
|
30576
|
-
|
|
30577
|
-
|
|
30578
|
-
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30583
|
-
items: [
|
|
30584
|
-
{
|
|
30585
|
-
type: "function",
|
|
30586
|
-
name: "name",
|
|
30587
|
-
inputs: [],
|
|
30588
|
-
outputs: [
|
|
30589
|
-
{
|
|
30590
|
-
type: "core::byte_array::ByteArray"
|
|
30591
|
-
}
|
|
30558
|
+
target: AVNU_EXCHANGE,
|
|
30559
|
+
method: "multi_route_swap",
|
|
30560
|
+
packedArguments: [
|
|
30561
|
+
this.config.supportedPositions[0].asset.address.toBigInt(),
|
|
30562
|
+
//usdc
|
|
30563
|
+
this.config.supportedPositions[1].asset.address.toBigInt(),
|
|
30564
|
+
//wbtc
|
|
30565
|
+
vaultAllocator.toBigInt()
|
|
30592
30566
|
],
|
|
30593
|
-
|
|
30594
|
-
|
|
30567
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30568
|
+
id: `asutb_${this.config.supportedPositions[0].asset.symbol}_${this.config.supportedPositions[1].asset.symbol}`
|
|
30569
|
+
}
|
|
30570
|
+
];
|
|
30571
|
+
}
|
|
30572
|
+
_getWithdrawLeaf() {
|
|
30573
|
+
const vaultAllocator = ContractAddr.from(
|
|
30574
|
+
this.config.vaultAllocator.address
|
|
30575
|
+
);
|
|
30576
|
+
const toToken = this.config.supportedPositions[0].asset;
|
|
30577
|
+
const fromToken = this.config.supportedPositions[1].asset;
|
|
30578
|
+
return [
|
|
30595
30579
|
{
|
|
30596
|
-
|
|
30597
|
-
|
|
30598
|
-
|
|
30599
|
-
|
|
30600
|
-
{
|
|
30601
|
-
type: "core::byte_array::ByteArray"
|
|
30602
|
-
}
|
|
30580
|
+
target: fromToken.address,
|
|
30581
|
+
method: "approve",
|
|
30582
|
+
packedArguments: [
|
|
30583
|
+
AVNU_EXCHANGE.toBigInt()
|
|
30603
30584
|
],
|
|
30604
|
-
|
|
30585
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30586
|
+
id: `approve_${fromToken.symbol}`
|
|
30605
30587
|
},
|
|
30606
30588
|
{
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
|
|
30610
|
-
|
|
30611
|
-
|
|
30612
|
-
|
|
30613
|
-
|
|
30589
|
+
target: AVNU_EXCHANGE,
|
|
30590
|
+
method: "multi_route_swap",
|
|
30591
|
+
packedArguments: [
|
|
30592
|
+
fromToken.address.toBigInt(),
|
|
30593
|
+
//wbtc
|
|
30594
|
+
toToken.address.toBigInt(),
|
|
30595
|
+
//usdc
|
|
30596
|
+
vaultAllocator.toBigInt()
|
|
30614
30597
|
],
|
|
30615
|
-
|
|
30598
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30599
|
+
id: `asbtu_${fromToken.symbol}_${fromToken.symbol}`
|
|
30616
30600
|
}
|
|
30617
|
-
]
|
|
30618
|
-
}
|
|
30619
|
-
{
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30628
|
-
|
|
30629
|
-
|
|
30630
|
-
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
|
|
30601
|
+
];
|
|
30602
|
+
}
|
|
30603
|
+
_getLegacySwapLeaf() {
|
|
30604
|
+
return [];
|
|
30605
|
+
}
|
|
30606
|
+
async getDepositCall(params) {
|
|
30607
|
+
try {
|
|
30608
|
+
const fromToken = this.config.supportedPositions[0].asset;
|
|
30609
|
+
const toToken = this.config.supportedPositions[1].asset;
|
|
30610
|
+
const vaultAllocator = ContractAddr.from(
|
|
30611
|
+
this.config.vaultAllocator.address
|
|
30612
|
+
);
|
|
30613
|
+
const quote = await this.getQuotesAvnu(
|
|
30614
|
+
fromToken.address.toString(),
|
|
30615
|
+
toToken.address.toString(),
|
|
30616
|
+
params.amount.toNumber(),
|
|
30617
|
+
vaultAllocator.address.toString(),
|
|
30618
|
+
toToken.decimals,
|
|
30619
|
+
true
|
|
30620
|
+
);
|
|
30621
|
+
if (!quote) {
|
|
30622
|
+
logger.error("error getting quote from avnu");
|
|
30623
|
+
return [];
|
|
30635
30624
|
}
|
|
30636
|
-
|
|
30637
|
-
|
|
30638
|
-
|
|
30639
|
-
|
|
30640
|
-
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30646
|
-
|
|
30647
|
-
|
|
30648
|
-
|
|
30649
|
-
|
|
30650
|
-
|
|
30651
|
-
|
|
30652
|
-
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
type: "function",
|
|
30656
|
-
name: "register_vault_allocator",
|
|
30657
|
-
inputs: [
|
|
30658
|
-
{
|
|
30659
|
-
name: "vault_allocator",
|
|
30660
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
30661
|
-
}
|
|
30662
|
-
],
|
|
30663
|
-
outputs: [],
|
|
30664
|
-
state_mutability: "external"
|
|
30665
|
-
},
|
|
30666
|
-
{
|
|
30667
|
-
type: "function",
|
|
30668
|
-
name: "request_redeem",
|
|
30669
|
-
inputs: [
|
|
30670
|
-
{
|
|
30671
|
-
name: "shares",
|
|
30672
|
-
type: "core::integer::u256"
|
|
30673
|
-
},
|
|
30674
|
-
{
|
|
30675
|
-
name: "receiver",
|
|
30676
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
30677
|
-
},
|
|
30678
|
-
{
|
|
30679
|
-
name: "owner",
|
|
30680
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
30681
|
-
}
|
|
30682
|
-
],
|
|
30683
|
-
outputs: [
|
|
30684
|
-
{
|
|
30685
|
-
type: "core::integer::u256"
|
|
30686
|
-
}
|
|
30687
|
-
],
|
|
30688
|
-
state_mutability: "external"
|
|
30689
|
-
},
|
|
30690
|
-
{
|
|
30691
|
-
type: "function",
|
|
30692
|
-
name: "claim_redeem",
|
|
30693
|
-
inputs: [
|
|
30694
|
-
{
|
|
30695
|
-
name: "id",
|
|
30696
|
-
type: "core::integer::u256"
|
|
30697
|
-
}
|
|
30698
|
-
],
|
|
30699
|
-
outputs: [
|
|
30700
|
-
{
|
|
30701
|
-
type: "core::integer::u256"
|
|
30702
|
-
}
|
|
30703
|
-
],
|
|
30704
|
-
state_mutability: "external"
|
|
30705
|
-
},
|
|
30706
|
-
{
|
|
30707
|
-
type: "function",
|
|
30708
|
-
name: "set_fees_config",
|
|
30709
|
-
inputs: [
|
|
30710
|
-
{
|
|
30711
|
-
name: "fees_recipient",
|
|
30712
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
30713
|
-
},
|
|
30714
|
-
{
|
|
30715
|
-
name: "redeem_fees",
|
|
30716
|
-
type: "core::integer::u256"
|
|
30717
|
-
},
|
|
30718
|
-
{
|
|
30719
|
-
name: "management_fees",
|
|
30720
|
-
type: "core::integer::u256"
|
|
30721
|
-
},
|
|
30722
|
-
{
|
|
30723
|
-
name: "performance_fees",
|
|
30724
|
-
type: "core::integer::u256"
|
|
30725
|
-
}
|
|
30726
|
-
],
|
|
30727
|
-
outputs: [],
|
|
30728
|
-
state_mutability: "external"
|
|
30729
|
-
},
|
|
30730
|
-
{
|
|
30731
|
-
type: "function",
|
|
30732
|
-
name: "set_report_delay",
|
|
30733
|
-
inputs: [
|
|
30734
|
-
{
|
|
30735
|
-
name: "report_delay",
|
|
30736
|
-
type: "core::integer::u64"
|
|
30737
|
-
}
|
|
30738
|
-
],
|
|
30739
|
-
outputs: [],
|
|
30740
|
-
state_mutability: "external"
|
|
30741
|
-
},
|
|
30742
|
-
{
|
|
30743
|
-
type: "function",
|
|
30744
|
-
name: "set_max_delta",
|
|
30745
|
-
inputs: [
|
|
30746
|
-
{
|
|
30747
|
-
name: "max_delta",
|
|
30748
|
-
type: "core::integer::u256"
|
|
30749
|
-
}
|
|
30750
|
-
],
|
|
30751
|
-
outputs: [],
|
|
30752
|
-
state_mutability: "external"
|
|
30753
|
-
},
|
|
30754
|
-
{
|
|
30755
|
-
type: "function",
|
|
30756
|
-
name: "report",
|
|
30757
|
-
inputs: [
|
|
30758
|
-
{
|
|
30759
|
-
name: "new_aum",
|
|
30760
|
-
type: "core::integer::u256"
|
|
30761
|
-
}
|
|
30762
|
-
],
|
|
30763
|
-
outputs: [],
|
|
30764
|
-
state_mutability: "external"
|
|
30765
|
-
},
|
|
30766
|
-
{
|
|
30767
|
-
type: "function",
|
|
30768
|
-
name: "bring_liquidity",
|
|
30769
|
-
inputs: [
|
|
30770
|
-
{
|
|
30771
|
-
name: "amount",
|
|
30772
|
-
type: "core::integer::u256"
|
|
30625
|
+
const getCalldata = await this.avnuWrapper.getSwapCallData(
|
|
30626
|
+
quote,
|
|
30627
|
+
vaultAllocator.address
|
|
30628
|
+
);
|
|
30629
|
+
const swapCallData = getCalldata[0];
|
|
30630
|
+
const amount = uint25614.bnToUint256(quote.sellAmountInUsd * 10 ** 7);
|
|
30631
|
+
return [
|
|
30632
|
+
{
|
|
30633
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30634
|
+
call: {
|
|
30635
|
+
contractAddress: fromToken.address,
|
|
30636
|
+
selector: hash7.getSelectorFromName("approve"),
|
|
30637
|
+
calldata: [
|
|
30638
|
+
AVNU_EXCHANGE.toBigInt(),
|
|
30639
|
+
toBigInt(amount.low.toString()),
|
|
30640
|
+
// amount low
|
|
30641
|
+
toBigInt(amount.high.toString())
|
|
30642
|
+
// amount high
|
|
30643
|
+
]
|
|
30773
30644
|
}
|
|
30774
|
-
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30778
|
-
|
|
30779
|
-
|
|
30780
|
-
|
|
30781
|
-
inputs: [],
|
|
30782
|
-
outputs: [],
|
|
30783
|
-
state_mutability: "external"
|
|
30784
|
-
},
|
|
30785
|
-
{
|
|
30786
|
-
type: "function",
|
|
30787
|
-
name: "unpause",
|
|
30788
|
-
inputs: [],
|
|
30789
|
-
outputs: [],
|
|
30790
|
-
state_mutability: "external"
|
|
30791
|
-
},
|
|
30792
|
-
{
|
|
30793
|
-
type: "function",
|
|
30794
|
-
name: "epoch",
|
|
30795
|
-
inputs: [],
|
|
30796
|
-
outputs: [
|
|
30797
|
-
{
|
|
30798
|
-
type: "core::integer::u256"
|
|
30645
|
+
},
|
|
30646
|
+
{
|
|
30647
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30648
|
+
call: {
|
|
30649
|
+
contractAddress: AVNU_EXCHANGE,
|
|
30650
|
+
selector: hash7.getSelectorFromName("multi_route_swap"),
|
|
30651
|
+
calldata: swapCallData
|
|
30799
30652
|
}
|
|
30800
|
-
|
|
30801
|
-
|
|
30802
|
-
|
|
30803
|
-
{
|
|
30804
|
-
|
|
30805
|
-
|
|
30806
|
-
|
|
30807
|
-
|
|
30808
|
-
|
|
30809
|
-
|
|
30653
|
+
}
|
|
30654
|
+
];
|
|
30655
|
+
} catch (error) {
|
|
30656
|
+
logger.error(`Error getting Avnu quote: ${error}`);
|
|
30657
|
+
return [];
|
|
30658
|
+
}
|
|
30659
|
+
}
|
|
30660
|
+
//Swap wbtc to usdc
|
|
30661
|
+
async getWithdrawCall(params) {
|
|
30662
|
+
try {
|
|
30663
|
+
const toToken = this.config.supportedPositions[0].asset;
|
|
30664
|
+
const fromToken = this.config.supportedPositions[1].asset;
|
|
30665
|
+
const vaultAllocator = ContractAddr.from(
|
|
30666
|
+
this.config.vaultAllocator.address
|
|
30667
|
+
);
|
|
30668
|
+
const quote = await this.getQuotesAvnu(
|
|
30669
|
+
fromToken.address.toString(),
|
|
30670
|
+
toToken.address.toString(),
|
|
30671
|
+
params.amount.toNumber(),
|
|
30672
|
+
vaultAllocator.address.toString(),
|
|
30673
|
+
fromToken.decimals,
|
|
30674
|
+
false
|
|
30675
|
+
);
|
|
30676
|
+
if (!quote) {
|
|
30677
|
+
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
30678
|
+
return [];
|
|
30679
|
+
}
|
|
30680
|
+
const getCalldata = await this.avnuWrapper.getSwapCallData(
|
|
30681
|
+
quote,
|
|
30682
|
+
vaultAllocator.address
|
|
30683
|
+
);
|
|
30684
|
+
const swapCallData = getCalldata[0];
|
|
30685
|
+
const amount = uint25614.bnToUint256(params.amount.toWei());
|
|
30686
|
+
return [
|
|
30687
|
+
{
|
|
30688
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30689
|
+
call: {
|
|
30690
|
+
contractAddress: fromToken.address,
|
|
30691
|
+
selector: hash7.getSelectorFromName("approve"),
|
|
30692
|
+
calldata: [
|
|
30693
|
+
AVNU_EXCHANGE.toBigInt(),
|
|
30694
|
+
toBigInt(amount.low.toString()),
|
|
30695
|
+
// amount low
|
|
30696
|
+
toBigInt(amount.high.toString())
|
|
30697
|
+
// amount high
|
|
30698
|
+
]
|
|
30810
30699
|
}
|
|
30811
|
-
|
|
30812
|
-
|
|
30813
|
-
|
|
30814
|
-
|
|
30815
|
-
|
|
30816
|
-
|
|
30817
|
-
|
|
30818
|
-
outputs: [
|
|
30819
|
-
{
|
|
30820
|
-
type: "core::integer::u256"
|
|
30700
|
+
},
|
|
30701
|
+
{
|
|
30702
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
30703
|
+
call: {
|
|
30704
|
+
contractAddress: AVNU_EXCHANGE,
|
|
30705
|
+
selector: hash7.getSelectorFromName("multi_route_swap"),
|
|
30706
|
+
calldata: swapCallData
|
|
30821
30707
|
}
|
|
30822
|
-
|
|
30823
|
-
|
|
30824
|
-
|
|
30825
|
-
{
|
|
30826
|
-
|
|
30827
|
-
|
|
30828
|
-
|
|
30829
|
-
|
|
30830
|
-
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30708
|
+
}
|
|
30709
|
+
];
|
|
30710
|
+
} catch (error) {
|
|
30711
|
+
logger.error(`Error getting Avnu quote: ${error}`);
|
|
30712
|
+
return [];
|
|
30713
|
+
}
|
|
30714
|
+
}
|
|
30715
|
+
async getSwapCallData(quote) {
|
|
30716
|
+
return await this.avnuWrapper.getSwapCallData(quote, this.config.vaultAllocator.address);
|
|
30717
|
+
}
|
|
30718
|
+
async getHealthFactor() {
|
|
30719
|
+
return Promise.resolve(1);
|
|
30720
|
+
}
|
|
30721
|
+
async fetchQuoteWithRetry(params, retries = 5) {
|
|
30722
|
+
for (let attempt = 0; attempt < retries; attempt++) {
|
|
30723
|
+
try {
|
|
30724
|
+
const response = await axios9.get(this.config.baseUrl, { params });
|
|
30725
|
+
if (response.data && response.data.length > 0) {
|
|
30726
|
+
return response;
|
|
30727
|
+
}
|
|
30728
|
+
throw new Error("Empty response data");
|
|
30729
|
+
} catch (err) {
|
|
30730
|
+
logger.error(`Error fetching quote with retry: ${err}`);
|
|
30731
|
+
if (attempt === retries - 1) {
|
|
30732
|
+
throw err;
|
|
30733
|
+
}
|
|
30734
|
+
await new Promise((resolve) => setTimeout(resolve, MAX_DELAY));
|
|
30735
|
+
}
|
|
30736
|
+
}
|
|
30737
|
+
throw new Error("Failed to fetch quote after retries");
|
|
30738
|
+
}
|
|
30739
|
+
async getQuotesAvnu(from_token_address, to_token_address, amount, takerAddress, toTokenDecimals, usdcToBtc, maxIterations = 5, tolerance = 5e3) {
|
|
30740
|
+
try {
|
|
30741
|
+
const fromToken = this.config.supportedPositions[0].asset;
|
|
30742
|
+
const toToken = this.config.supportedPositions[1].asset;
|
|
30743
|
+
if (!usdcToBtc) {
|
|
30744
|
+
const sellAmount2 = returnFormattedAmount(amount, toTokenDecimals);
|
|
30745
|
+
const params2 = {
|
|
30746
|
+
sellTokenAddress: from_token_address,
|
|
30747
|
+
buyTokenAddress: to_token_address,
|
|
30748
|
+
takerAddress,
|
|
30749
|
+
sellAmount: sellAmount2
|
|
30750
|
+
};
|
|
30751
|
+
const finalQuote2 = await this.fetchQuoteWithRetry(params2);
|
|
30752
|
+
if (!finalQuote2.data.length) {
|
|
30753
|
+
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
30754
|
+
return null;
|
|
30755
|
+
}
|
|
30756
|
+
const dataObject2 = finalQuote2.data[0];
|
|
30757
|
+
return dataObject2;
|
|
30758
|
+
}
|
|
30759
|
+
const btcPrice = await this.getPriceOfToken(toToken.address.toString());
|
|
30760
|
+
if (!btcPrice) {
|
|
30761
|
+
logger.error(`error getting btc price: ${btcPrice}`);
|
|
30762
|
+
return null;
|
|
30763
|
+
}
|
|
30764
|
+
const estimatedUsdcAmount = Math.floor(amount * btcPrice);
|
|
30765
|
+
const targetBtcBig = BigInt(returnFormattedAmount(amount, toTokenDecimals));
|
|
30766
|
+
let low = BigInt(
|
|
30767
|
+
Math.floor(
|
|
30768
|
+
estimatedUsdcAmount * 10 ** fromToken.decimals * 0.9
|
|
30769
|
+
)
|
|
30770
|
+
);
|
|
30771
|
+
let high = BigInt(
|
|
30772
|
+
Math.floor(
|
|
30773
|
+
estimatedUsdcAmount * 10 ** fromToken.decimals * 1.1
|
|
30774
|
+
)
|
|
30775
|
+
);
|
|
30776
|
+
let mid = 0n;
|
|
30777
|
+
for (let i = 0; i < maxIterations; i++) {
|
|
30778
|
+
mid = (low + high) / 2n;
|
|
30779
|
+
const sellAmount2 = returnFormattedAmount(Number(mid), 0);
|
|
30780
|
+
const quote = await this.fetchQuoteWithRetry({
|
|
30781
|
+
sellTokenAddress: from_token_address,
|
|
30782
|
+
buyTokenAddress: to_token_address,
|
|
30783
|
+
takerAddress,
|
|
30784
|
+
sellAmount: sellAmount2
|
|
30785
|
+
});
|
|
30786
|
+
const gotBtc = BigInt(quote.data[0].buyAmount);
|
|
30787
|
+
if (gotBtc === targetBtcBig) return quote.data[0];
|
|
30788
|
+
if (gotBtc > targetBtcBig) {
|
|
30789
|
+
high = mid;
|
|
30790
|
+
} else {
|
|
30791
|
+
low = mid;
|
|
30792
|
+
}
|
|
30793
|
+
if (gotBtc >= targetBtcBig && gotBtc <= targetBtcBig + BigInt(tolerance)) {
|
|
30794
|
+
return quote.data[0];
|
|
30795
|
+
}
|
|
30796
|
+
}
|
|
30797
|
+
let sellAmount = returnFormattedAmount(
|
|
30798
|
+
Number(mid),
|
|
30799
|
+
0
|
|
30800
|
+
);
|
|
30801
|
+
const params = {
|
|
30802
|
+
sellTokenAddress: from_token_address,
|
|
30803
|
+
buyTokenAddress: to_token_address,
|
|
30804
|
+
takerAddress,
|
|
30805
|
+
sellAmount
|
|
30806
|
+
};
|
|
30807
|
+
const finalQuote = await this.fetchQuoteWithRetry(params);
|
|
30808
|
+
if (!finalQuote.data.length) {
|
|
30809
|
+
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
30810
|
+
return null;
|
|
30811
|
+
}
|
|
30812
|
+
const dataObject = finalQuote.data[0];
|
|
30813
|
+
return dataObject;
|
|
30814
|
+
} catch (err) {
|
|
30815
|
+
logger.error(`No quotes available for this swap: ${err}`);
|
|
30816
|
+
return null;
|
|
30817
|
+
}
|
|
30818
|
+
}
|
|
30819
|
+
async getPriceOfToken(tokenAddress, retries = MAX_RETRIES) {
|
|
30820
|
+
try {
|
|
30821
|
+
const url = `https://starknet.impulse.avnu.fi/v1/tokens/${tokenAddress}/prices/line`;
|
|
30822
|
+
const response = await axios9.get(url);
|
|
30823
|
+
const length = response.data.length;
|
|
30824
|
+
return response.data[length - 1].value;
|
|
30825
|
+
} catch (err) {
|
|
30826
|
+
if (retries > 0) {
|
|
30827
|
+
await new Promise((resolve) => setTimeout(resolve, MAX_DELAY));
|
|
30828
|
+
return this.getPriceOfToken(tokenAddress, retries - 1);
|
|
30829
|
+
} else {
|
|
30830
|
+
logger.error(`Failed to fetch price for ${tokenAddress} after ${MAX_RETRIES} attempts`);
|
|
30831
|
+
return null;
|
|
30832
|
+
}
|
|
30833
|
+
}
|
|
30834
|
+
}
|
|
30835
|
+
};
|
|
30836
|
+
|
|
30837
|
+
// src/strategies/universal-strategy.tsx
|
|
30838
|
+
var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
|
|
30839
|
+
AUMTypes2["FINALISED"] = "finalised";
|
|
30840
|
+
AUMTypes2["DEFISPRING"] = "defispring";
|
|
30841
|
+
return AUMTypes2;
|
|
30842
|
+
})(AUMTypes || {});
|
|
30843
|
+
var PositionTypeAvnuExtended = /* @__PURE__ */ ((PositionTypeAvnuExtended2) => {
|
|
30844
|
+
PositionTypeAvnuExtended2["OPEN"] = "open";
|
|
30845
|
+
PositionTypeAvnuExtended2["CLOSE"] = "close";
|
|
30846
|
+
return PositionTypeAvnuExtended2;
|
|
30847
|
+
})(PositionTypeAvnuExtended || {});
|
|
30848
|
+
var UNIVERSAL_MANAGE_IDS = /* @__PURE__ */ ((UNIVERSAL_MANAGE_IDS2) => {
|
|
30849
|
+
UNIVERSAL_MANAGE_IDS2["FLASH_LOAN"] = "flash_loan_init";
|
|
30850
|
+
UNIVERSAL_MANAGE_IDS2["VESU_LEG1"] = "vesu_leg1";
|
|
30851
|
+
UNIVERSAL_MANAGE_IDS2["VESU_LEG2"] = "vesu_leg2";
|
|
30852
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN1"] = "approve_token1";
|
|
30853
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
|
|
30854
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
|
|
30855
|
+
UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
|
|
30856
|
+
UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
|
|
30857
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
|
|
30858
|
+
UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
|
|
30859
|
+
return UNIVERSAL_MANAGE_IDS2;
|
|
30860
|
+
})(UNIVERSAL_MANAGE_IDS || {});
|
|
30861
|
+
function getContractDetails(settings) {
|
|
30862
|
+
const contracts = [
|
|
30863
|
+
{ address: settings.vaultAddress, name: "Vault" },
|
|
30864
|
+
{ address: settings.manager, name: "Vault Manager" },
|
|
30865
|
+
{ address: settings.vaultAllocator, name: "Vault Allocator" },
|
|
30866
|
+
{ address: settings.redeemRequestNFT, name: "Redeem Request NFT" }
|
|
30867
|
+
];
|
|
30868
|
+
if (settings.aumOracle) {
|
|
30869
|
+
contracts.push({ address: settings.aumOracle, name: "AUM Oracle" });
|
|
30870
|
+
}
|
|
30871
|
+
return contracts;
|
|
30872
|
+
}
|
|
30873
|
+
|
|
30874
|
+
// src/strategies/svk-strategy.ts
|
|
30875
|
+
import { Contract as Contract13, num as num10 } from "starknet";
|
|
30876
|
+
|
|
30877
|
+
// src/data/universal-vault.abi.json
|
|
30878
|
+
var universal_vault_abi_default = [
|
|
30879
|
+
{
|
|
30880
|
+
type: "impl",
|
|
30881
|
+
name: "UpgradeableImpl",
|
|
30882
|
+
interface_name: "openzeppelin_interfaces::upgrades::IUpgradeable"
|
|
30883
|
+
},
|
|
30884
|
+
{
|
|
30885
|
+
type: "interface",
|
|
30886
|
+
name: "openzeppelin_interfaces::upgrades::IUpgradeable",
|
|
30887
|
+
items: [
|
|
30836
30888
|
{
|
|
30837
30889
|
type: "function",
|
|
30838
|
-
name: "
|
|
30890
|
+
name: "upgrade",
|
|
30839
30891
|
inputs: [
|
|
30840
30892
|
{
|
|
30841
|
-
name: "
|
|
30842
|
-
type: "core::
|
|
30843
|
-
}
|
|
30844
|
-
],
|
|
30845
|
-
outputs: [
|
|
30846
|
-
{
|
|
30847
|
-
type: "core::integer::u256"
|
|
30893
|
+
name: "new_class_hash",
|
|
30894
|
+
type: "core::starknet::class_hash::ClassHash"
|
|
30848
30895
|
}
|
|
30849
30896
|
],
|
|
30850
|
-
|
|
30897
|
+
outputs: [],
|
|
30898
|
+
state_mutability: "external"
|
|
30899
|
+
}
|
|
30900
|
+
]
|
|
30901
|
+
},
|
|
30902
|
+
{
|
|
30903
|
+
type: "impl",
|
|
30904
|
+
name: "VaultMetadataImpl",
|
|
30905
|
+
interface_name: "openzeppelin_interfaces::token::erc20::IERC20Metadata"
|
|
30906
|
+
},
|
|
30907
|
+
{
|
|
30908
|
+
type: "struct",
|
|
30909
|
+
name: "core::byte_array::ByteArray",
|
|
30910
|
+
members: [
|
|
30911
|
+
{
|
|
30912
|
+
name: "data",
|
|
30913
|
+
type: "core::array::Array::<core::bytes_31::bytes31>"
|
|
30851
30914
|
},
|
|
30852
30915
|
{
|
|
30853
|
-
|
|
30854
|
-
|
|
30855
|
-
inputs: [
|
|
30856
|
-
{
|
|
30857
|
-
name: "epoch",
|
|
30858
|
-
type: "core::integer::u256"
|
|
30859
|
-
}
|
|
30860
|
-
],
|
|
30861
|
-
outputs: [
|
|
30862
|
-
{
|
|
30863
|
-
type: "core::integer::u256"
|
|
30864
|
-
}
|
|
30865
|
-
],
|
|
30866
|
-
state_mutability: "view"
|
|
30916
|
+
name: "pending_word",
|
|
30917
|
+
type: "core::felt252"
|
|
30867
30918
|
},
|
|
30919
|
+
{
|
|
30920
|
+
name: "pending_word_len",
|
|
30921
|
+
type: "core::integer::u32"
|
|
30922
|
+
}
|
|
30923
|
+
]
|
|
30924
|
+
},
|
|
30925
|
+
{
|
|
30926
|
+
type: "interface",
|
|
30927
|
+
name: "openzeppelin_interfaces::token::erc20::IERC20Metadata",
|
|
30928
|
+
items: [
|
|
30868
30929
|
{
|
|
30869
30930
|
type: "function",
|
|
30870
|
-
name: "
|
|
30931
|
+
name: "name",
|
|
30871
30932
|
inputs: [],
|
|
30872
30933
|
outputs: [
|
|
30873
30934
|
{
|
|
30874
|
-
type: "core::
|
|
30935
|
+
type: "core::byte_array::ByteArray"
|
|
30875
30936
|
}
|
|
30876
30937
|
],
|
|
30877
30938
|
state_mutability: "view"
|
|
30878
30939
|
},
|
|
30879
30940
|
{
|
|
30880
30941
|
type: "function",
|
|
30881
|
-
name: "
|
|
30942
|
+
name: "symbol",
|
|
30882
30943
|
inputs: [],
|
|
30883
30944
|
outputs: [
|
|
30884
30945
|
{
|
|
30885
|
-
type: "core::
|
|
30946
|
+
type: "core::byte_array::ByteArray"
|
|
30886
30947
|
}
|
|
30887
30948
|
],
|
|
30888
30949
|
state_mutability: "view"
|
|
30889
30950
|
},
|
|
30890
30951
|
{
|
|
30891
30952
|
type: "function",
|
|
30892
|
-
name: "
|
|
30953
|
+
name: "decimals",
|
|
30893
30954
|
inputs: [],
|
|
30894
30955
|
outputs: [
|
|
30895
30956
|
{
|
|
30896
|
-
type: "core::integer::
|
|
30897
|
-
}
|
|
30898
|
-
],
|
|
30899
|
-
state_mutability: "view"
|
|
30900
|
-
},
|
|
30901
|
-
{
|
|
30902
|
-
type: "function",
|
|
30903
|
-
name: "performance_fees",
|
|
30904
|
-
inputs: [],
|
|
30905
|
-
outputs: [
|
|
30906
|
-
{
|
|
30907
|
-
type: "core::integer::u256"
|
|
30957
|
+
type: "core::integer::u8"
|
|
30908
30958
|
}
|
|
30909
30959
|
],
|
|
30910
30960
|
state_mutability: "view"
|
|
30961
|
+
}
|
|
30962
|
+
]
|
|
30963
|
+
},
|
|
30964
|
+
{
|
|
30965
|
+
type: "impl",
|
|
30966
|
+
name: "VaultImpl",
|
|
30967
|
+
interface_name: "vault::vault::interface::IVault"
|
|
30968
|
+
},
|
|
30969
|
+
{
|
|
30970
|
+
type: "struct",
|
|
30971
|
+
name: "core::integer::u256",
|
|
30972
|
+
members: [
|
|
30973
|
+
{
|
|
30974
|
+
name: "low",
|
|
30975
|
+
type: "core::integer::u128"
|
|
30911
30976
|
},
|
|
30977
|
+
{
|
|
30978
|
+
name: "high",
|
|
30979
|
+
type: "core::integer::u128"
|
|
30980
|
+
}
|
|
30981
|
+
]
|
|
30982
|
+
},
|
|
30983
|
+
{
|
|
30984
|
+
type: "interface",
|
|
30985
|
+
name: "vault::vault::interface::IVault",
|
|
30986
|
+
items: [
|
|
30912
30987
|
{
|
|
30913
30988
|
type: "function",
|
|
30914
|
-
name: "
|
|
30915
|
-
inputs: [
|
|
30916
|
-
outputs: [
|
|
30989
|
+
name: "register_redeem_request",
|
|
30990
|
+
inputs: [
|
|
30917
30991
|
{
|
|
30992
|
+
name: "redeem_request",
|
|
30918
30993
|
type: "core::starknet::contract_address::ContractAddress"
|
|
30919
30994
|
}
|
|
30920
30995
|
],
|
|
30921
|
-
|
|
30996
|
+
outputs: [],
|
|
30997
|
+
state_mutability: "external"
|
|
30922
30998
|
},
|
|
30923
30999
|
{
|
|
30924
31000
|
type: "function",
|
|
30925
|
-
name: "
|
|
30926
|
-
inputs: [
|
|
30927
|
-
outputs: [
|
|
31001
|
+
name: "register_vault_allocator",
|
|
31002
|
+
inputs: [
|
|
30928
31003
|
{
|
|
30929
|
-
|
|
31004
|
+
name: "vault_allocator",
|
|
31005
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
30930
31006
|
}
|
|
30931
31007
|
],
|
|
30932
|
-
|
|
31008
|
+
outputs: [],
|
|
31009
|
+
state_mutability: "external"
|
|
30933
31010
|
},
|
|
30934
31011
|
{
|
|
30935
31012
|
type: "function",
|
|
30936
|
-
name: "
|
|
30937
|
-
inputs: [
|
|
30938
|
-
|
|
31013
|
+
name: "request_redeem",
|
|
31014
|
+
inputs: [
|
|
31015
|
+
{
|
|
31016
|
+
name: "shares",
|
|
31017
|
+
type: "core::integer::u256"
|
|
31018
|
+
},
|
|
31019
|
+
{
|
|
31020
|
+
name: "receiver",
|
|
31021
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31022
|
+
},
|
|
30939
31023
|
{
|
|
31024
|
+
name: "owner",
|
|
30940
31025
|
type: "core::starknet::contract_address::ContractAddress"
|
|
30941
31026
|
}
|
|
30942
31027
|
],
|
|
30943
|
-
state_mutability: "view"
|
|
30944
|
-
},
|
|
30945
|
-
{
|
|
30946
|
-
type: "function",
|
|
30947
|
-
name: "last_report_timestamp",
|
|
30948
|
-
inputs: [],
|
|
30949
31028
|
outputs: [
|
|
30950
31029
|
{
|
|
30951
|
-
type: "core::integer::
|
|
31030
|
+
type: "core::integer::u256"
|
|
30952
31031
|
}
|
|
30953
31032
|
],
|
|
30954
|
-
state_mutability: "
|
|
31033
|
+
state_mutability: "external"
|
|
30955
31034
|
},
|
|
30956
31035
|
{
|
|
30957
31036
|
type: "function",
|
|
30958
|
-
name: "
|
|
30959
|
-
inputs: [
|
|
31037
|
+
name: "claim_redeem",
|
|
31038
|
+
inputs: [
|
|
31039
|
+
{
|
|
31040
|
+
name: "id",
|
|
31041
|
+
type: "core::integer::u256"
|
|
31042
|
+
}
|
|
31043
|
+
],
|
|
30960
31044
|
outputs: [
|
|
30961
31045
|
{
|
|
30962
31046
|
type: "core::integer::u256"
|
|
30963
31047
|
}
|
|
30964
31048
|
],
|
|
30965
|
-
state_mutability: "
|
|
31049
|
+
state_mutability: "external"
|
|
30966
31050
|
},
|
|
30967
31051
|
{
|
|
30968
31052
|
type: "function",
|
|
30969
|
-
name: "
|
|
31053
|
+
name: "set_fees_config",
|
|
30970
31054
|
inputs: [
|
|
30971
31055
|
{
|
|
30972
|
-
name: "
|
|
31056
|
+
name: "fees_recipient",
|
|
31057
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31058
|
+
},
|
|
31059
|
+
{
|
|
31060
|
+
name: "redeem_fees",
|
|
30973
31061
|
type: "core::integer::u256"
|
|
30974
|
-
}
|
|
30975
|
-
|
|
30976
|
-
|
|
31062
|
+
},
|
|
31063
|
+
{
|
|
31064
|
+
name: "management_fees",
|
|
31065
|
+
type: "core::integer::u256"
|
|
31066
|
+
},
|
|
30977
31067
|
{
|
|
31068
|
+
name: "performance_fees",
|
|
30978
31069
|
type: "core::integer::u256"
|
|
30979
31070
|
}
|
|
30980
31071
|
],
|
|
30981
|
-
|
|
31072
|
+
outputs: [],
|
|
31073
|
+
state_mutability: "external"
|
|
30982
31074
|
},
|
|
30983
31075
|
{
|
|
30984
31076
|
type: "function",
|
|
30985
|
-
name: "
|
|
31077
|
+
name: "set_report_delay",
|
|
30986
31078
|
inputs: [
|
|
30987
31079
|
{
|
|
30988
|
-
name: "
|
|
30989
|
-
type: "core::
|
|
31080
|
+
name: "report_delay",
|
|
31081
|
+
type: "core::integer::u64"
|
|
30990
31082
|
}
|
|
30991
31083
|
],
|
|
30992
|
-
outputs: [
|
|
31084
|
+
outputs: [],
|
|
31085
|
+
state_mutability: "external"
|
|
31086
|
+
},
|
|
31087
|
+
{
|
|
31088
|
+
type: "function",
|
|
31089
|
+
name: "set_max_delta",
|
|
31090
|
+
inputs: [
|
|
30993
31091
|
{
|
|
31092
|
+
name: "max_delta",
|
|
30994
31093
|
type: "core::integer::u256"
|
|
30995
31094
|
}
|
|
30996
31095
|
],
|
|
30997
|
-
|
|
31096
|
+
outputs: [],
|
|
31097
|
+
state_mutability: "external"
|
|
30998
31098
|
},
|
|
30999
31099
|
{
|
|
31000
31100
|
type: "function",
|
|
31001
|
-
name: "
|
|
31101
|
+
name: "report",
|
|
31002
31102
|
inputs: [
|
|
31003
31103
|
{
|
|
31004
|
-
name: "
|
|
31104
|
+
name: "new_aum",
|
|
31005
31105
|
type: "core::integer::u256"
|
|
31006
31106
|
}
|
|
31007
31107
|
],
|
|
@@ -31010,10 +31110,10 @@ var universal_vault_abi_default = [
|
|
|
31010
31110
|
},
|
|
31011
31111
|
{
|
|
31012
31112
|
type: "function",
|
|
31013
|
-
name: "
|
|
31113
|
+
name: "bring_liquidity",
|
|
31014
31114
|
inputs: [
|
|
31015
31115
|
{
|
|
31016
|
-
name: "
|
|
31116
|
+
name: "amount",
|
|
31017
31117
|
type: "core::integer::u256"
|
|
31018
31118
|
}
|
|
31019
31119
|
],
|
|
@@ -31022,7 +31122,21 @@ var universal_vault_abi_default = [
|
|
|
31022
31122
|
},
|
|
31023
31123
|
{
|
|
31024
31124
|
type: "function",
|
|
31025
|
-
name: "
|
|
31125
|
+
name: "pause",
|
|
31126
|
+
inputs: [],
|
|
31127
|
+
outputs: [],
|
|
31128
|
+
state_mutability: "external"
|
|
31129
|
+
},
|
|
31130
|
+
{
|
|
31131
|
+
type: "function",
|
|
31132
|
+
name: "unpause",
|
|
31133
|
+
inputs: [],
|
|
31134
|
+
outputs: [],
|
|
31135
|
+
state_mutability: "external"
|
|
31136
|
+
},
|
|
31137
|
+
{
|
|
31138
|
+
type: "function",
|
|
31139
|
+
name: "epoch",
|
|
31026
31140
|
inputs: [],
|
|
31027
31141
|
outputs: [
|
|
31028
31142
|
{
|
|
@@ -31033,7 +31147,7 @@ var universal_vault_abi_default = [
|
|
|
31033
31147
|
},
|
|
31034
31148
|
{
|
|
31035
31149
|
type: "function",
|
|
31036
|
-
name: "
|
|
31150
|
+
name: "handled_epoch_len",
|
|
31037
31151
|
inputs: [],
|
|
31038
31152
|
outputs: [
|
|
31039
31153
|
{
|
|
@@ -31041,32 +31155,21 @@ var universal_vault_abi_default = [
|
|
|
31041
31155
|
}
|
|
31042
31156
|
],
|
|
31043
31157
|
state_mutability: "view"
|
|
31044
|
-
}
|
|
31045
|
-
]
|
|
31046
|
-
},
|
|
31047
|
-
{
|
|
31048
|
-
type: "impl",
|
|
31049
|
-
name: "ERC4626Impl",
|
|
31050
|
-
interface_name: "openzeppelin_interfaces::token::erc4626::IERC4626"
|
|
31051
|
-
},
|
|
31052
|
-
{
|
|
31053
|
-
type: "interface",
|
|
31054
|
-
name: "openzeppelin_interfaces::token::erc4626::IERC4626",
|
|
31055
|
-
items: [
|
|
31158
|
+
},
|
|
31056
31159
|
{
|
|
31057
31160
|
type: "function",
|
|
31058
|
-
name: "
|
|
31161
|
+
name: "buffer",
|
|
31059
31162
|
inputs: [],
|
|
31060
31163
|
outputs: [
|
|
31061
31164
|
{
|
|
31062
|
-
type: "core::
|
|
31165
|
+
type: "core::integer::u256"
|
|
31063
31166
|
}
|
|
31064
31167
|
],
|
|
31065
31168
|
state_mutability: "view"
|
|
31066
31169
|
},
|
|
31067
31170
|
{
|
|
31068
31171
|
type: "function",
|
|
31069
|
-
name: "
|
|
31172
|
+
name: "aum",
|
|
31070
31173
|
inputs: [],
|
|
31071
31174
|
outputs: [
|
|
31072
31175
|
{
|
|
@@ -31077,10 +31180,10 @@ var universal_vault_abi_default = [
|
|
|
31077
31180
|
},
|
|
31078
31181
|
{
|
|
31079
31182
|
type: "function",
|
|
31080
|
-
name: "
|
|
31183
|
+
name: "redeem_assets",
|
|
31081
31184
|
inputs: [
|
|
31082
31185
|
{
|
|
31083
|
-
name: "
|
|
31186
|
+
name: "epoch",
|
|
31084
31187
|
type: "core::integer::u256"
|
|
31085
31188
|
}
|
|
31086
31189
|
],
|
|
@@ -31093,10 +31196,10 @@ var universal_vault_abi_default = [
|
|
|
31093
31196
|
},
|
|
31094
31197
|
{
|
|
31095
31198
|
type: "function",
|
|
31096
|
-
name: "
|
|
31199
|
+
name: "redeem_nominal",
|
|
31097
31200
|
inputs: [
|
|
31098
31201
|
{
|
|
31099
|
-
name: "
|
|
31202
|
+
name: "epoch",
|
|
31100
31203
|
type: "core::integer::u256"
|
|
31101
31204
|
}
|
|
31102
31205
|
],
|
|
@@ -31109,13 +31212,19 @@ var universal_vault_abi_default = [
|
|
|
31109
31212
|
},
|
|
31110
31213
|
{
|
|
31111
31214
|
type: "function",
|
|
31112
|
-
name: "
|
|
31113
|
-
inputs: [
|
|
31215
|
+
name: "fees_recipient",
|
|
31216
|
+
inputs: [],
|
|
31217
|
+
outputs: [
|
|
31114
31218
|
{
|
|
31115
|
-
name: "receiver",
|
|
31116
31219
|
type: "core::starknet::contract_address::ContractAddress"
|
|
31117
31220
|
}
|
|
31118
31221
|
],
|
|
31222
|
+
state_mutability: "view"
|
|
31223
|
+
},
|
|
31224
|
+
{
|
|
31225
|
+
type: "function",
|
|
31226
|
+
name: "redeem_fees",
|
|
31227
|
+
inputs: [],
|
|
31119
31228
|
outputs: [
|
|
31120
31229
|
{
|
|
31121
31230
|
type: "core::integer::u256"
|
|
@@ -31125,13 +31234,19 @@ var universal_vault_abi_default = [
|
|
|
31125
31234
|
},
|
|
31126
31235
|
{
|
|
31127
31236
|
type: "function",
|
|
31128
|
-
name: "
|
|
31129
|
-
inputs: [
|
|
31237
|
+
name: "management_fees",
|
|
31238
|
+
inputs: [],
|
|
31239
|
+
outputs: [
|
|
31130
31240
|
{
|
|
31131
|
-
name: "assets",
|
|
31132
31241
|
type: "core::integer::u256"
|
|
31133
31242
|
}
|
|
31134
31243
|
],
|
|
31244
|
+
state_mutability: "view"
|
|
31245
|
+
},
|
|
31246
|
+
{
|
|
31247
|
+
type: "function",
|
|
31248
|
+
name: "performance_fees",
|
|
31249
|
+
inputs: [],
|
|
31135
31250
|
outputs: [
|
|
31136
31251
|
{
|
|
31137
31252
|
type: "core::integer::u256"
|
|
@@ -31141,49 +31256,52 @@ var universal_vault_abi_default = [
|
|
|
31141
31256
|
},
|
|
31142
31257
|
{
|
|
31143
31258
|
type: "function",
|
|
31144
|
-
name: "
|
|
31145
|
-
inputs: [
|
|
31146
|
-
|
|
31147
|
-
name: "assets",
|
|
31148
|
-
type: "core::integer::u256"
|
|
31149
|
-
},
|
|
31259
|
+
name: "redeem_request",
|
|
31260
|
+
inputs: [],
|
|
31261
|
+
outputs: [
|
|
31150
31262
|
{
|
|
31151
|
-
name: "receiver",
|
|
31152
31263
|
type: "core::starknet::contract_address::ContractAddress"
|
|
31153
31264
|
}
|
|
31154
31265
|
],
|
|
31266
|
+
state_mutability: "view"
|
|
31267
|
+
},
|
|
31268
|
+
{
|
|
31269
|
+
type: "function",
|
|
31270
|
+
name: "report_delay",
|
|
31271
|
+
inputs: [],
|
|
31155
31272
|
outputs: [
|
|
31156
31273
|
{
|
|
31157
|
-
type: "core::integer::
|
|
31274
|
+
type: "core::integer::u64"
|
|
31158
31275
|
}
|
|
31159
31276
|
],
|
|
31160
|
-
state_mutability: "
|
|
31277
|
+
state_mutability: "view"
|
|
31161
31278
|
},
|
|
31162
31279
|
{
|
|
31163
31280
|
type: "function",
|
|
31164
|
-
name: "
|
|
31165
|
-
inputs: [
|
|
31281
|
+
name: "vault_allocator",
|
|
31282
|
+
inputs: [],
|
|
31283
|
+
outputs: [
|
|
31166
31284
|
{
|
|
31167
|
-
name: "receiver",
|
|
31168
31285
|
type: "core::starknet::contract_address::ContractAddress"
|
|
31169
31286
|
}
|
|
31170
31287
|
],
|
|
31288
|
+
state_mutability: "view"
|
|
31289
|
+
},
|
|
31290
|
+
{
|
|
31291
|
+
type: "function",
|
|
31292
|
+
name: "last_report_timestamp",
|
|
31293
|
+
inputs: [],
|
|
31171
31294
|
outputs: [
|
|
31172
31295
|
{
|
|
31173
|
-
type: "core::integer::
|
|
31296
|
+
type: "core::integer::u64"
|
|
31174
31297
|
}
|
|
31175
31298
|
],
|
|
31176
31299
|
state_mutability: "view"
|
|
31177
31300
|
},
|
|
31178
31301
|
{
|
|
31179
31302
|
type: "function",
|
|
31180
|
-
name: "
|
|
31181
|
-
inputs: [
|
|
31182
|
-
{
|
|
31183
|
-
name: "shares",
|
|
31184
|
-
type: "core::integer::u256"
|
|
31185
|
-
}
|
|
31186
|
-
],
|
|
31303
|
+
name: "max_delta",
|
|
31304
|
+
inputs: [],
|
|
31187
31305
|
outputs: [
|
|
31188
31306
|
{
|
|
31189
31307
|
type: "core::integer::u256"
|
|
@@ -31193,15 +31311,11 @@ var universal_vault_abi_default = [
|
|
|
31193
31311
|
},
|
|
31194
31312
|
{
|
|
31195
31313
|
type: "function",
|
|
31196
|
-
name: "
|
|
31314
|
+
name: "due_assets_from_id",
|
|
31197
31315
|
inputs: [
|
|
31198
31316
|
{
|
|
31199
|
-
name: "
|
|
31317
|
+
name: "id",
|
|
31200
31318
|
type: "core::integer::u256"
|
|
31201
|
-
},
|
|
31202
|
-
{
|
|
31203
|
-
name: "receiver",
|
|
31204
|
-
type: "core::starknet::contract_address::ContractAddress"
|
|
31205
31319
|
}
|
|
31206
31320
|
],
|
|
31207
31321
|
outputs: [
|
|
@@ -31209,11 +31323,242 @@ var universal_vault_abi_default = [
|
|
|
31209
31323
|
type: "core::integer::u256"
|
|
31210
31324
|
}
|
|
31211
31325
|
],
|
|
31212
|
-
state_mutability: "
|
|
31326
|
+
state_mutability: "view"
|
|
31213
31327
|
},
|
|
31214
31328
|
{
|
|
31215
31329
|
type: "function",
|
|
31216
|
-
name: "
|
|
31330
|
+
name: "due_assets_from_owner",
|
|
31331
|
+
inputs: [
|
|
31332
|
+
{
|
|
31333
|
+
name: "owner",
|
|
31334
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31335
|
+
}
|
|
31336
|
+
],
|
|
31337
|
+
outputs: [
|
|
31338
|
+
{
|
|
31339
|
+
type: "core::integer::u256"
|
|
31340
|
+
}
|
|
31341
|
+
],
|
|
31342
|
+
state_mutability: "view"
|
|
31343
|
+
},
|
|
31344
|
+
{
|
|
31345
|
+
type: "function",
|
|
31346
|
+
name: "set_deposit_limit",
|
|
31347
|
+
inputs: [
|
|
31348
|
+
{
|
|
31349
|
+
name: "limit",
|
|
31350
|
+
type: "core::integer::u256"
|
|
31351
|
+
}
|
|
31352
|
+
],
|
|
31353
|
+
outputs: [],
|
|
31354
|
+
state_mutability: "external"
|
|
31355
|
+
},
|
|
31356
|
+
{
|
|
31357
|
+
type: "function",
|
|
31358
|
+
name: "set_mint_limit",
|
|
31359
|
+
inputs: [
|
|
31360
|
+
{
|
|
31361
|
+
name: "limit",
|
|
31362
|
+
type: "core::integer::u256"
|
|
31363
|
+
}
|
|
31364
|
+
],
|
|
31365
|
+
outputs: [],
|
|
31366
|
+
state_mutability: "external"
|
|
31367
|
+
},
|
|
31368
|
+
{
|
|
31369
|
+
type: "function",
|
|
31370
|
+
name: "get_deposit_limit",
|
|
31371
|
+
inputs: [],
|
|
31372
|
+
outputs: [
|
|
31373
|
+
{
|
|
31374
|
+
type: "core::integer::u256"
|
|
31375
|
+
}
|
|
31376
|
+
],
|
|
31377
|
+
state_mutability: "view"
|
|
31378
|
+
},
|
|
31379
|
+
{
|
|
31380
|
+
type: "function",
|
|
31381
|
+
name: "get_mint_limit",
|
|
31382
|
+
inputs: [],
|
|
31383
|
+
outputs: [
|
|
31384
|
+
{
|
|
31385
|
+
type: "core::integer::u256"
|
|
31386
|
+
}
|
|
31387
|
+
],
|
|
31388
|
+
state_mutability: "view"
|
|
31389
|
+
}
|
|
31390
|
+
]
|
|
31391
|
+
},
|
|
31392
|
+
{
|
|
31393
|
+
type: "impl",
|
|
31394
|
+
name: "ERC4626Impl",
|
|
31395
|
+
interface_name: "openzeppelin_interfaces::token::erc4626::IERC4626"
|
|
31396
|
+
},
|
|
31397
|
+
{
|
|
31398
|
+
type: "interface",
|
|
31399
|
+
name: "openzeppelin_interfaces::token::erc4626::IERC4626",
|
|
31400
|
+
items: [
|
|
31401
|
+
{
|
|
31402
|
+
type: "function",
|
|
31403
|
+
name: "asset",
|
|
31404
|
+
inputs: [],
|
|
31405
|
+
outputs: [
|
|
31406
|
+
{
|
|
31407
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31408
|
+
}
|
|
31409
|
+
],
|
|
31410
|
+
state_mutability: "view"
|
|
31411
|
+
},
|
|
31412
|
+
{
|
|
31413
|
+
type: "function",
|
|
31414
|
+
name: "total_assets",
|
|
31415
|
+
inputs: [],
|
|
31416
|
+
outputs: [
|
|
31417
|
+
{
|
|
31418
|
+
type: "core::integer::u256"
|
|
31419
|
+
}
|
|
31420
|
+
],
|
|
31421
|
+
state_mutability: "view"
|
|
31422
|
+
},
|
|
31423
|
+
{
|
|
31424
|
+
type: "function",
|
|
31425
|
+
name: "convert_to_shares",
|
|
31426
|
+
inputs: [
|
|
31427
|
+
{
|
|
31428
|
+
name: "assets",
|
|
31429
|
+
type: "core::integer::u256"
|
|
31430
|
+
}
|
|
31431
|
+
],
|
|
31432
|
+
outputs: [
|
|
31433
|
+
{
|
|
31434
|
+
type: "core::integer::u256"
|
|
31435
|
+
}
|
|
31436
|
+
],
|
|
31437
|
+
state_mutability: "view"
|
|
31438
|
+
},
|
|
31439
|
+
{
|
|
31440
|
+
type: "function",
|
|
31441
|
+
name: "convert_to_assets",
|
|
31442
|
+
inputs: [
|
|
31443
|
+
{
|
|
31444
|
+
name: "shares",
|
|
31445
|
+
type: "core::integer::u256"
|
|
31446
|
+
}
|
|
31447
|
+
],
|
|
31448
|
+
outputs: [
|
|
31449
|
+
{
|
|
31450
|
+
type: "core::integer::u256"
|
|
31451
|
+
}
|
|
31452
|
+
],
|
|
31453
|
+
state_mutability: "view"
|
|
31454
|
+
},
|
|
31455
|
+
{
|
|
31456
|
+
type: "function",
|
|
31457
|
+
name: "max_deposit",
|
|
31458
|
+
inputs: [
|
|
31459
|
+
{
|
|
31460
|
+
name: "receiver",
|
|
31461
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31462
|
+
}
|
|
31463
|
+
],
|
|
31464
|
+
outputs: [
|
|
31465
|
+
{
|
|
31466
|
+
type: "core::integer::u256"
|
|
31467
|
+
}
|
|
31468
|
+
],
|
|
31469
|
+
state_mutability: "view"
|
|
31470
|
+
},
|
|
31471
|
+
{
|
|
31472
|
+
type: "function",
|
|
31473
|
+
name: "preview_deposit",
|
|
31474
|
+
inputs: [
|
|
31475
|
+
{
|
|
31476
|
+
name: "assets",
|
|
31477
|
+
type: "core::integer::u256"
|
|
31478
|
+
}
|
|
31479
|
+
],
|
|
31480
|
+
outputs: [
|
|
31481
|
+
{
|
|
31482
|
+
type: "core::integer::u256"
|
|
31483
|
+
}
|
|
31484
|
+
],
|
|
31485
|
+
state_mutability: "view"
|
|
31486
|
+
},
|
|
31487
|
+
{
|
|
31488
|
+
type: "function",
|
|
31489
|
+
name: "deposit",
|
|
31490
|
+
inputs: [
|
|
31491
|
+
{
|
|
31492
|
+
name: "assets",
|
|
31493
|
+
type: "core::integer::u256"
|
|
31494
|
+
},
|
|
31495
|
+
{
|
|
31496
|
+
name: "receiver",
|
|
31497
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31498
|
+
}
|
|
31499
|
+
],
|
|
31500
|
+
outputs: [
|
|
31501
|
+
{
|
|
31502
|
+
type: "core::integer::u256"
|
|
31503
|
+
}
|
|
31504
|
+
],
|
|
31505
|
+
state_mutability: "external"
|
|
31506
|
+
},
|
|
31507
|
+
{
|
|
31508
|
+
type: "function",
|
|
31509
|
+
name: "max_mint",
|
|
31510
|
+
inputs: [
|
|
31511
|
+
{
|
|
31512
|
+
name: "receiver",
|
|
31513
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31514
|
+
}
|
|
31515
|
+
],
|
|
31516
|
+
outputs: [
|
|
31517
|
+
{
|
|
31518
|
+
type: "core::integer::u256"
|
|
31519
|
+
}
|
|
31520
|
+
],
|
|
31521
|
+
state_mutability: "view"
|
|
31522
|
+
},
|
|
31523
|
+
{
|
|
31524
|
+
type: "function",
|
|
31525
|
+
name: "preview_mint",
|
|
31526
|
+
inputs: [
|
|
31527
|
+
{
|
|
31528
|
+
name: "shares",
|
|
31529
|
+
type: "core::integer::u256"
|
|
31530
|
+
}
|
|
31531
|
+
],
|
|
31532
|
+
outputs: [
|
|
31533
|
+
{
|
|
31534
|
+
type: "core::integer::u256"
|
|
31535
|
+
}
|
|
31536
|
+
],
|
|
31537
|
+
state_mutability: "view"
|
|
31538
|
+
},
|
|
31539
|
+
{
|
|
31540
|
+
type: "function",
|
|
31541
|
+
name: "mint",
|
|
31542
|
+
inputs: [
|
|
31543
|
+
{
|
|
31544
|
+
name: "shares",
|
|
31545
|
+
type: "core::integer::u256"
|
|
31546
|
+
},
|
|
31547
|
+
{
|
|
31548
|
+
name: "receiver",
|
|
31549
|
+
type: "core::starknet::contract_address::ContractAddress"
|
|
31550
|
+
}
|
|
31551
|
+
],
|
|
31552
|
+
outputs: [
|
|
31553
|
+
{
|
|
31554
|
+
type: "core::integer::u256"
|
|
31555
|
+
}
|
|
31556
|
+
],
|
|
31557
|
+
state_mutability: "external"
|
|
31558
|
+
},
|
|
31559
|
+
{
|
|
31560
|
+
type: "function",
|
|
31561
|
+
name: "max_withdraw",
|
|
31217
31562
|
inputs: [
|
|
31218
31563
|
{
|
|
31219
31564
|
name: "owner",
|
|
@@ -33910,336 +34255,6 @@ var HyperLSTStrategies = [
|
|
|
33910
34255
|
getStrategySettings("mRe7YIELD", "mRe7YIELD", hypermRe7YIELD, false, false)
|
|
33911
34256
|
];
|
|
33912
34257
|
|
|
33913
|
-
// src/strategies/universal-adapters/avnu-adapter.ts
|
|
33914
|
-
import { hash as hash7, uint256 as uint25614 } from "starknet";
|
|
33915
|
-
import axios9 from "axios";
|
|
33916
|
-
var AvnuAdapter = class _AvnuAdapter extends BaseAdapter {
|
|
33917
|
-
constructor(config) {
|
|
33918
|
-
super(config, _AvnuAdapter.name, Protocols.AVNU);
|
|
33919
|
-
this.config = config;
|
|
33920
|
-
this.avnuWrapper = new AvnuWrapper();
|
|
33921
|
-
}
|
|
33922
|
-
//abstract means the method has no implementation in this class; instead, child classes must implement it.
|
|
33923
|
-
async getAPY(supportedPosition) {
|
|
33924
|
-
return Promise.resolve({ apy: 0, type: "base" /* BASE */ });
|
|
33925
|
-
}
|
|
33926
|
-
async getPosition(supportedPosition) {
|
|
33927
|
-
return Promise.resolve({ amount: new Web3Number(0, 0), remarks: "" });
|
|
33928
|
-
}
|
|
33929
|
-
async maxDeposit(amount) {
|
|
33930
|
-
return Promise.resolve({
|
|
33931
|
-
tokenInfo: this.config.baseToken,
|
|
33932
|
-
amount: new Web3Number(0, 0),
|
|
33933
|
-
usdValue: 0,
|
|
33934
|
-
apy: { apy: 0, type: "base" /* BASE */ },
|
|
33935
|
-
protocol: Protocols.AVNU,
|
|
33936
|
-
remarks: ""
|
|
33937
|
-
});
|
|
33938
|
-
}
|
|
33939
|
-
async maxWithdraw() {
|
|
33940
|
-
return Promise.resolve({
|
|
33941
|
-
tokenInfo: this.config.baseToken,
|
|
33942
|
-
amount: new Web3Number(0, 0),
|
|
33943
|
-
usdValue: 0,
|
|
33944
|
-
apy: { apy: 0, type: "base" /* BASE */ },
|
|
33945
|
-
protocol: Protocols.AVNU,
|
|
33946
|
-
remarks: ""
|
|
33947
|
-
});
|
|
33948
|
-
}
|
|
33949
|
-
_getDepositLeaf() {
|
|
33950
|
-
const vaultAllocator = ContractAddr.from(
|
|
33951
|
-
this.config.vaultAllocator.address
|
|
33952
|
-
);
|
|
33953
|
-
return [
|
|
33954
|
-
{
|
|
33955
|
-
target: this.config.supportedPositions[0].asset.address,
|
|
33956
|
-
method: "approve",
|
|
33957
|
-
packedArguments: [
|
|
33958
|
-
AVNU_EXCHANGE.toBigInt()
|
|
33959
|
-
],
|
|
33960
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
33961
|
-
id: `approve_${this.config.supportedPositions[0].asset.symbol}`
|
|
33962
|
-
},
|
|
33963
|
-
{
|
|
33964
|
-
target: AVNU_EXCHANGE,
|
|
33965
|
-
method: "multi_route_swap",
|
|
33966
|
-
packedArguments: [
|
|
33967
|
-
this.config.supportedPositions[0].asset.address.toBigInt(),
|
|
33968
|
-
//usdc
|
|
33969
|
-
this.config.supportedPositions[1].asset.address.toBigInt(),
|
|
33970
|
-
//wbtc
|
|
33971
|
-
vaultAllocator.toBigInt()
|
|
33972
|
-
],
|
|
33973
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
33974
|
-
id: `asutb_${this.config.supportedPositions[0].asset.symbol}_${this.config.supportedPositions[1].asset.symbol}`
|
|
33975
|
-
}
|
|
33976
|
-
];
|
|
33977
|
-
}
|
|
33978
|
-
_getWithdrawLeaf() {
|
|
33979
|
-
const vaultAllocator = ContractAddr.from(
|
|
33980
|
-
this.config.vaultAllocator.address
|
|
33981
|
-
);
|
|
33982
|
-
const toToken = this.config.supportedPositions[0].asset;
|
|
33983
|
-
const fromToken = this.config.supportedPositions[1].asset;
|
|
33984
|
-
return [
|
|
33985
|
-
{
|
|
33986
|
-
target: fromToken.address,
|
|
33987
|
-
method: "approve",
|
|
33988
|
-
packedArguments: [
|
|
33989
|
-
AVNU_EXCHANGE.toBigInt()
|
|
33990
|
-
],
|
|
33991
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
33992
|
-
id: `approve_${fromToken.symbol}`
|
|
33993
|
-
},
|
|
33994
|
-
{
|
|
33995
|
-
target: AVNU_EXCHANGE,
|
|
33996
|
-
method: "multi_route_swap",
|
|
33997
|
-
packedArguments: [
|
|
33998
|
-
fromToken.address.toBigInt(),
|
|
33999
|
-
//wbtc
|
|
34000
|
-
toToken.address.toBigInt(),
|
|
34001
|
-
//usdc
|
|
34002
|
-
vaultAllocator.toBigInt()
|
|
34003
|
-
],
|
|
34004
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
34005
|
-
id: `asbtu_${fromToken.symbol}_${fromToken.symbol}`
|
|
34006
|
-
}
|
|
34007
|
-
];
|
|
34008
|
-
}
|
|
34009
|
-
_getLegacySwapLeaf() {
|
|
34010
|
-
return [];
|
|
34011
|
-
}
|
|
34012
|
-
async getDepositCall(params) {
|
|
34013
|
-
try {
|
|
34014
|
-
const fromToken = this.config.supportedPositions[0].asset;
|
|
34015
|
-
const toToken = this.config.supportedPositions[1].asset;
|
|
34016
|
-
const vaultAllocator = ContractAddr.from(
|
|
34017
|
-
this.config.vaultAllocator.address
|
|
34018
|
-
);
|
|
34019
|
-
const quote = await this.getQuotesAvnu(
|
|
34020
|
-
fromToken.address.toString(),
|
|
34021
|
-
toToken.address.toString(),
|
|
34022
|
-
params.amount.toNumber(),
|
|
34023
|
-
vaultAllocator.address.toString(),
|
|
34024
|
-
toToken.decimals,
|
|
34025
|
-
true
|
|
34026
|
-
);
|
|
34027
|
-
if (!quote) {
|
|
34028
|
-
logger.error("error getting quote from avnu");
|
|
34029
|
-
return [];
|
|
34030
|
-
}
|
|
34031
|
-
const getCalldata = await this.avnuWrapper.getSwapCallData(
|
|
34032
|
-
quote,
|
|
34033
|
-
vaultAllocator.address
|
|
34034
|
-
);
|
|
34035
|
-
const swapCallData = getCalldata[0];
|
|
34036
|
-
const amount = uint25614.bnToUint256(quote.sellAmountInUsd * 10 ** 7);
|
|
34037
|
-
return [
|
|
34038
|
-
{
|
|
34039
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
34040
|
-
call: {
|
|
34041
|
-
contractAddress: fromToken.address,
|
|
34042
|
-
selector: hash7.getSelectorFromName("approve"),
|
|
34043
|
-
calldata: [
|
|
34044
|
-
AVNU_EXCHANGE.toBigInt(),
|
|
34045
|
-
toBigInt(amount.low.toString()),
|
|
34046
|
-
// amount low
|
|
34047
|
-
toBigInt(amount.high.toString())
|
|
34048
|
-
// amount high
|
|
34049
|
-
]
|
|
34050
|
-
}
|
|
34051
|
-
},
|
|
34052
|
-
{
|
|
34053
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
34054
|
-
call: {
|
|
34055
|
-
contractAddress: AVNU_EXCHANGE,
|
|
34056
|
-
selector: hash7.getSelectorFromName("multi_route_swap"),
|
|
34057
|
-
calldata: swapCallData
|
|
34058
|
-
}
|
|
34059
|
-
}
|
|
34060
|
-
];
|
|
34061
|
-
} catch (error) {
|
|
34062
|
-
logger.error(`Error getting Avnu quote: ${error}`);
|
|
34063
|
-
return [];
|
|
34064
|
-
}
|
|
34065
|
-
}
|
|
34066
|
-
//Swap wbtc to usdc
|
|
34067
|
-
async getWithdrawCall(params) {
|
|
34068
|
-
try {
|
|
34069
|
-
const toToken = this.config.supportedPositions[0].asset;
|
|
34070
|
-
const fromToken = this.config.supportedPositions[1].asset;
|
|
34071
|
-
const vaultAllocator = ContractAddr.from(
|
|
34072
|
-
this.config.vaultAllocator.address
|
|
34073
|
-
);
|
|
34074
|
-
const quote = await this.getQuotesAvnu(
|
|
34075
|
-
fromToken.address.toString(),
|
|
34076
|
-
toToken.address.toString(),
|
|
34077
|
-
params.amount.toNumber(),
|
|
34078
|
-
vaultAllocator.address.toString(),
|
|
34079
|
-
fromToken.decimals,
|
|
34080
|
-
false
|
|
34081
|
-
);
|
|
34082
|
-
if (!quote) {
|
|
34083
|
-
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
34084
|
-
return [];
|
|
34085
|
-
}
|
|
34086
|
-
const getCalldata = await this.avnuWrapper.getSwapCallData(
|
|
34087
|
-
quote,
|
|
34088
|
-
vaultAllocator.address
|
|
34089
|
-
);
|
|
34090
|
-
const swapCallData = getCalldata[0];
|
|
34091
|
-
const amount = uint25614.bnToUint256(params.amount.toWei());
|
|
34092
|
-
return [
|
|
34093
|
-
{
|
|
34094
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
34095
|
-
call: {
|
|
34096
|
-
contractAddress: fromToken.address,
|
|
34097
|
-
selector: hash7.getSelectorFromName("approve"),
|
|
34098
|
-
calldata: [
|
|
34099
|
-
AVNU_EXCHANGE.toBigInt(),
|
|
34100
|
-
toBigInt(amount.low.toString()),
|
|
34101
|
-
// amount low
|
|
34102
|
-
toBigInt(amount.high.toString())
|
|
34103
|
-
// amount high
|
|
34104
|
-
]
|
|
34105
|
-
}
|
|
34106
|
-
},
|
|
34107
|
-
{
|
|
34108
|
-
sanitizer: SIMPLE_SANITIZER,
|
|
34109
|
-
call: {
|
|
34110
|
-
contractAddress: AVNU_EXCHANGE,
|
|
34111
|
-
selector: hash7.getSelectorFromName("multi_route_swap"),
|
|
34112
|
-
calldata: swapCallData
|
|
34113
|
-
}
|
|
34114
|
-
}
|
|
34115
|
-
];
|
|
34116
|
-
} catch (error) {
|
|
34117
|
-
logger.error(`Error getting Avnu quote: ${error}`);
|
|
34118
|
-
return [];
|
|
34119
|
-
}
|
|
34120
|
-
}
|
|
34121
|
-
async getSwapCallData(quote) {
|
|
34122
|
-
return await this.avnuWrapper.getSwapCallData(quote, this.config.vaultAllocator.address);
|
|
34123
|
-
}
|
|
34124
|
-
async getHealthFactor() {
|
|
34125
|
-
return Promise.resolve(1);
|
|
34126
|
-
}
|
|
34127
|
-
async fetchQuoteWithRetry(params, retries = 5) {
|
|
34128
|
-
for (let attempt = 0; attempt < retries; attempt++) {
|
|
34129
|
-
try {
|
|
34130
|
-
const response = await axios9.get(this.config.baseUrl, { params });
|
|
34131
|
-
if (response.data && response.data.length > 0) {
|
|
34132
|
-
return response;
|
|
34133
|
-
}
|
|
34134
|
-
throw new Error("Empty response data");
|
|
34135
|
-
} catch (err) {
|
|
34136
|
-
logger.error(`Error fetching quote with retry: ${err}`);
|
|
34137
|
-
if (attempt === retries - 1) {
|
|
34138
|
-
throw err;
|
|
34139
|
-
}
|
|
34140
|
-
await new Promise((resolve) => setTimeout(resolve, MAX_DELAY));
|
|
34141
|
-
}
|
|
34142
|
-
}
|
|
34143
|
-
throw new Error("Failed to fetch quote after retries");
|
|
34144
|
-
}
|
|
34145
|
-
async getQuotesAvnu(from_token_address, to_token_address, amount, takerAddress, toTokenDecimals, usdcToBtc, maxIterations = 5, tolerance = 5e3) {
|
|
34146
|
-
try {
|
|
34147
|
-
const fromToken = this.config.supportedPositions[0].asset;
|
|
34148
|
-
const toToken = this.config.supportedPositions[1].asset;
|
|
34149
|
-
if (!usdcToBtc) {
|
|
34150
|
-
const sellAmount2 = returnFormattedAmount(amount, toTokenDecimals);
|
|
34151
|
-
const params2 = {
|
|
34152
|
-
sellTokenAddress: from_token_address,
|
|
34153
|
-
buyTokenAddress: to_token_address,
|
|
34154
|
-
takerAddress,
|
|
34155
|
-
sellAmount: sellAmount2
|
|
34156
|
-
};
|
|
34157
|
-
const finalQuote2 = await this.fetchQuoteWithRetry(params2);
|
|
34158
|
-
if (!finalQuote2.data.length) {
|
|
34159
|
-
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
34160
|
-
return null;
|
|
34161
|
-
}
|
|
34162
|
-
const dataObject2 = finalQuote2.data[0];
|
|
34163
|
-
return dataObject2;
|
|
34164
|
-
}
|
|
34165
|
-
const btcPrice = await this.getPriceOfToken(toToken.address.toString());
|
|
34166
|
-
if (!btcPrice) {
|
|
34167
|
-
logger.error(`error getting btc price: ${btcPrice}`);
|
|
34168
|
-
return null;
|
|
34169
|
-
}
|
|
34170
|
-
const estimatedUsdcAmount = Math.floor(amount * btcPrice);
|
|
34171
|
-
const targetBtcBig = BigInt(returnFormattedAmount(amount, toTokenDecimals));
|
|
34172
|
-
let low = BigInt(
|
|
34173
|
-
Math.floor(
|
|
34174
|
-
estimatedUsdcAmount * 10 ** fromToken.decimals * 0.9
|
|
34175
|
-
)
|
|
34176
|
-
);
|
|
34177
|
-
let high = BigInt(
|
|
34178
|
-
Math.floor(
|
|
34179
|
-
estimatedUsdcAmount * 10 ** fromToken.decimals * 1.1
|
|
34180
|
-
)
|
|
34181
|
-
);
|
|
34182
|
-
let mid = 0n;
|
|
34183
|
-
for (let i = 0; i < maxIterations; i++) {
|
|
34184
|
-
mid = (low + high) / 2n;
|
|
34185
|
-
const sellAmount2 = returnFormattedAmount(Number(mid), 0);
|
|
34186
|
-
const quote = await this.fetchQuoteWithRetry({
|
|
34187
|
-
sellTokenAddress: from_token_address,
|
|
34188
|
-
buyTokenAddress: to_token_address,
|
|
34189
|
-
takerAddress,
|
|
34190
|
-
sellAmount: sellAmount2
|
|
34191
|
-
});
|
|
34192
|
-
const gotBtc = BigInt(quote.data[0].buyAmount);
|
|
34193
|
-
if (gotBtc === targetBtcBig) return quote.data[0];
|
|
34194
|
-
if (gotBtc > targetBtcBig) {
|
|
34195
|
-
high = mid;
|
|
34196
|
-
} else {
|
|
34197
|
-
low = mid;
|
|
34198
|
-
}
|
|
34199
|
-
if (gotBtc >= targetBtcBig && gotBtc <= targetBtcBig + BigInt(tolerance)) {
|
|
34200
|
-
return quote.data[0];
|
|
34201
|
-
}
|
|
34202
|
-
}
|
|
34203
|
-
let sellAmount = returnFormattedAmount(
|
|
34204
|
-
Number(mid),
|
|
34205
|
-
0
|
|
34206
|
-
);
|
|
34207
|
-
const params = {
|
|
34208
|
-
sellTokenAddress: from_token_address,
|
|
34209
|
-
buyTokenAddress: to_token_address,
|
|
34210
|
-
takerAddress,
|
|
34211
|
-
sellAmount
|
|
34212
|
-
};
|
|
34213
|
-
const finalQuote = await this.fetchQuoteWithRetry(params);
|
|
34214
|
-
if (!finalQuote.data.length) {
|
|
34215
|
-
logger.error("No quotes available for this swap, error in quotes avnu");
|
|
34216
|
-
return null;
|
|
34217
|
-
}
|
|
34218
|
-
const dataObject = finalQuote.data[0];
|
|
34219
|
-
return dataObject;
|
|
34220
|
-
} catch (err) {
|
|
34221
|
-
logger.error(`No quotes available for this swap: ${err}`);
|
|
34222
|
-
return null;
|
|
34223
|
-
}
|
|
34224
|
-
}
|
|
34225
|
-
async getPriceOfToken(tokenAddress, retries = MAX_RETRIES) {
|
|
34226
|
-
try {
|
|
34227
|
-
const url = `https://starknet.impulse.avnu.fi/v1/tokens/${tokenAddress}/prices/line`;
|
|
34228
|
-
const response = await axios9.get(url);
|
|
34229
|
-
const length = response.data.length;
|
|
34230
|
-
return response.data[length - 1].value;
|
|
34231
|
-
} catch (err) {
|
|
34232
|
-
if (retries > 0) {
|
|
34233
|
-
await new Promise((resolve) => setTimeout(resolve, MAX_DELAY));
|
|
34234
|
-
return this.getPriceOfToken(tokenAddress, retries - 1);
|
|
34235
|
-
} else {
|
|
34236
|
-
logger.error(`Failed to fetch price for ${tokenAddress} after ${MAX_RETRIES} attempts`);
|
|
34237
|
-
return null;
|
|
34238
|
-
}
|
|
34239
|
-
}
|
|
34240
|
-
}
|
|
34241
|
-
};
|
|
34242
|
-
|
|
34243
34258
|
// src/strategies/vesu-extended-strategy/vesu-extended-strategy.tsx
|
|
34244
34259
|
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
34245
34260
|
var VesuExtendedMultiplierStrategy = class _VesuExtendedMultiplierStrategy extends SVKStrategy {
|
|
@@ -39656,6 +39671,7 @@ export {
|
|
|
39656
39671
|
AssetOperationStatus,
|
|
39657
39672
|
AssetOperationType,
|
|
39658
39673
|
AutoCompounderSTRK,
|
|
39674
|
+
AvnuAdapter,
|
|
39659
39675
|
AvnuWrapper,
|
|
39660
39676
|
BaseAdapter,
|
|
39661
39677
|
BaseStrategy,
|
|
@@ -39739,6 +39755,7 @@ export {
|
|
|
39739
39755
|
calculateExtendedLevergae,
|
|
39740
39756
|
calculateVesUPositionSizeGivenExtended,
|
|
39741
39757
|
calculateVesuLeverage,
|
|
39758
|
+
calculateWBTCAmountToMaintainLTV,
|
|
39742
39759
|
extensionMap,
|
|
39743
39760
|
getAPIUsingHeadlessBrowser,
|
|
39744
39761
|
getContractDetails,
|