@strkfarm/sdk 1.0.62 → 1.1.0
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/cli.js +8 -2
- package/dist/cli.mjs +9 -3
- package/dist/index.browser.global.js +37782 -36017
- package/dist/index.browser.mjs +241 -92
- package/dist/index.d.ts +23 -4
- package/dist/index.js +247 -92
- package/dist/index.mjs +252 -97
- package/package.json +2 -2
- package/src/interfaces/common.tsx +2 -2
- package/src/modules/erc20.ts +1 -1
- package/src/modules/harvests.ts +6 -4
- package/src/modules/pragma.ts +1 -1
- package/src/modules/pricer.ts +1 -1
- package/src/node/deployer.ts +2 -2
- package/src/strategies/autoCompounderStrk.ts +1 -1
- package/src/strategies/ekubo-cl-vault.tsx +41 -41
- package/src/strategies/sensei.ts +6 -6
- package/src/strategies/universal-adapters/adapter-utils.ts +3 -1
- package/src/strategies/universal-adapters/common-adapter.ts +57 -1
- package/src/strategies/universal-adapters/vesu-adapter.ts +41 -2
- package/src/strategies/universal-strategy.tsx +93 -20
- package/src/strategies/vesu-rebalance.tsx +15 -15
- package/src/utils/store.ts +9 -2
package/dist/index.browser.mjs
CHANGED
|
@@ -376,7 +376,7 @@ var Pricer = class extends PricerBase {
|
|
|
376
376
|
}
|
|
377
377
|
async _getPrice(token, defaultMethod = "all") {
|
|
378
378
|
const methodToUse = this.methodToUse[token.symbol] || defaultMethod;
|
|
379
|
-
logger.
|
|
379
|
+
logger.verbose(`Fetching price of ${token.symbol} using ${methodToUse}`);
|
|
380
380
|
switch (methodToUse) {
|
|
381
381
|
case "Coinbase":
|
|
382
382
|
try {
|
|
@@ -541,7 +541,7 @@ var pragma_abi_default = [
|
|
|
541
541
|
var Pragma = class {
|
|
542
542
|
constructor(provider) {
|
|
543
543
|
this.contractAddr = "0x023fb3afbff2c0e3399f896dcf7400acf1a161941cfb386e34a123f228c62832";
|
|
544
|
-
this.contract = new Contract(pragma_abi_default, this.contractAddr, provider);
|
|
544
|
+
this.contract = new Contract({ abi: pragma_abi_default, address: this.contractAddr, providerOrAccount: provider });
|
|
545
545
|
}
|
|
546
546
|
async getPrice(tokenAddr) {
|
|
547
547
|
if (!tokenAddr) {
|
|
@@ -1909,7 +1909,7 @@ var ERC20 = class {
|
|
|
1909
1909
|
}
|
|
1910
1910
|
contract(addr) {
|
|
1911
1911
|
const _addr = typeof addr === "string" ? addr : addr.address;
|
|
1912
|
-
return new Contract2(erc20_abi_default, _addr, this.config.provider);
|
|
1912
|
+
return new Contract2({ abi: erc20_abi_default, address: _addr, providerOrAccount: this.config.provider });
|
|
1913
1913
|
}
|
|
1914
1914
|
async balanceOf(token, address, tokenDecimals) {
|
|
1915
1915
|
const contract = this.contract(token);
|
|
@@ -2072,7 +2072,7 @@ var AvnuWrapper = class _AvnuWrapper {
|
|
|
2072
2072
|
};
|
|
2073
2073
|
|
|
2074
2074
|
// src/interfaces/common.tsx
|
|
2075
|
-
import { RpcProvider as RpcProvider2 } from "starknet";
|
|
2075
|
+
import { BlockTag, RpcProvider as RpcProvider2 } from "starknet";
|
|
2076
2076
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2077
2077
|
var RiskType = /* @__PURE__ */ ((RiskType2) => {
|
|
2078
2078
|
RiskType2["MARKET_RISK"] = "Market Risk";
|
|
@@ -2098,7 +2098,7 @@ var FlowChartColors = /* @__PURE__ */ ((FlowChartColors2) => {
|
|
|
2098
2098
|
FlowChartColors2["Purple"] = "#6e53dc";
|
|
2099
2099
|
return FlowChartColors2;
|
|
2100
2100
|
})(FlowChartColors || {});
|
|
2101
|
-
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier =
|
|
2101
|
+
function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io", blockIdentifier = BlockTag.LATEST) {
|
|
2102
2102
|
return {
|
|
2103
2103
|
provider: new RpcProvider2({
|
|
2104
2104
|
nodeUrl: rpcUrl,
|
|
@@ -2217,7 +2217,7 @@ var AutoCompounderSTRK = class {
|
|
|
2217
2217
|
async init() {
|
|
2218
2218
|
const provider = this.config.provider;
|
|
2219
2219
|
const cls = await provider.getClassAt(this.addr.address);
|
|
2220
|
-
this.contract = new Contract3(cls.abi, this.addr.address, provider);
|
|
2220
|
+
this.contract = new Contract3({ abi: cls.abi, address: this.addr.address, providerOrAccount: provider });
|
|
2221
2221
|
this.initialized = true;
|
|
2222
2222
|
}
|
|
2223
2223
|
async waitForInitilisation() {
|
|
@@ -3798,7 +3798,7 @@ var Harvests = class _Harvests {
|
|
|
3798
3798
|
const unClaimed = [];
|
|
3799
3799
|
const cls = await this.config.provider.getClassAt(rewards[0].rewardsContract.address);
|
|
3800
3800
|
for (let reward of rewards) {
|
|
3801
|
-
const contract = new Contract4(cls.abi, reward.rewardsContract.address, this.config.provider);
|
|
3801
|
+
const contract = new Contract4({ abi: cls.abi, address: reward.rewardsContract.address, providerOrAccount: this.config.provider });
|
|
3802
3802
|
const isClaimed = await contract.call("is_claimed", [reward.claim.id]);
|
|
3803
3803
|
logger.verbose(`${_Harvests.name}: isClaimed: ${isClaimed}`);
|
|
3804
3804
|
if (isClaimed) {
|
|
@@ -3841,13 +3841,14 @@ var EkuboHarvests = class extends Harvests {
|
|
|
3841
3841
|
return rewards.sort((a, b) => b.endDate.getTime() - a.endDate.getTime());
|
|
3842
3842
|
}
|
|
3843
3843
|
};
|
|
3844
|
+
var VESU_REWARDS_CONTRACT = ContractAddr.from("0x0387f3eb1d98632fbe3440a9f1385Aec9d87b6172491d3Dd81f1c35A7c61048F");
|
|
3844
3845
|
var VesuHarvests = class _VesuHarvests extends Harvests {
|
|
3845
3846
|
async getHarvests(addr) {
|
|
3846
3847
|
const result = await fetch(`https://api.vesu.xyz/users/${addr.address}/strk-rewards/calldata`);
|
|
3847
3848
|
const data = await result.json();
|
|
3848
|
-
const rewardsContract =
|
|
3849
|
+
const rewardsContract = VESU_REWARDS_CONTRACT;
|
|
3849
3850
|
const cls = await this.config.provider.getClassAt(rewardsContract.address);
|
|
3850
|
-
const contract = new Contract4(cls.abi, rewardsContract.address, this.config.provider);
|
|
3851
|
+
const contract = new Contract4({ abi: cls.abi, address: rewardsContract.address, providerOrAccount: this.config.provider });
|
|
3851
3852
|
const _claimed_amount = await contract.call("amount_already_claimed", [addr.address]);
|
|
3852
3853
|
const claimed_amount = Web3Number.fromWei(_claimed_amount.toString(), 18);
|
|
3853
3854
|
logger.verbose(`${_VesuHarvests.name}: claimed_amount: ${claimed_amount.toString()}`);
|
|
@@ -9349,11 +9350,11 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9349
9350
|
);
|
|
9350
9351
|
this.metadata = metadata;
|
|
9351
9352
|
this.address = metadata.address;
|
|
9352
|
-
this.contract = new Contract5(
|
|
9353
|
-
vesu_rebalance_abi_default,
|
|
9354
|
-
this.address.address,
|
|
9355
|
-
this.config.provider
|
|
9356
|
-
);
|
|
9353
|
+
this.contract = new Contract5({
|
|
9354
|
+
abi: vesu_rebalance_abi_default,
|
|
9355
|
+
address: this.address.address,
|
|
9356
|
+
providerOrAccount: this.config.provider
|
|
9357
|
+
});
|
|
9357
9358
|
}
|
|
9358
9359
|
/**
|
|
9359
9360
|
* Creates a deposit call to the strategy contract.
|
|
@@ -9366,11 +9367,11 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9366
9367
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
9367
9368
|
"Deposit token mismatch"
|
|
9368
9369
|
);
|
|
9369
|
-
const assetContract = new Contract5(
|
|
9370
|
-
vesu_rebalance_abi_default,
|
|
9371
|
-
this.asset().address.address,
|
|
9372
|
-
this.config.provider
|
|
9373
|
-
);
|
|
9370
|
+
const assetContract = new Contract5({
|
|
9371
|
+
abi: vesu_rebalance_abi_default,
|
|
9372
|
+
address: this.asset().address.address,
|
|
9373
|
+
providerOrAccount: this.config.provider
|
|
9374
|
+
});
|
|
9374
9375
|
const call1 = assetContract.populate("approve", [
|
|
9375
9376
|
this.address.address,
|
|
9376
9377
|
uint2563.bnToUint256(amountInfo.amount.toWei())
|
|
@@ -9503,11 +9504,11 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
|
|
|
9503
9504
|
`Asset ${this.asset().address.toString()} not found in pool ${p.pool_id.address.toString()}`
|
|
9504
9505
|
);
|
|
9505
9506
|
}
|
|
9506
|
-
let vTokenContract = new Contract5(
|
|
9507
|
-
vesu_rebalance_abi_default,
|
|
9508
|
-
p.v_token.address,
|
|
9509
|
-
this.config.provider
|
|
9510
|
-
);
|
|
9507
|
+
let vTokenContract = new Contract5({
|
|
9508
|
+
abi: vesu_rebalance_abi_default,
|
|
9509
|
+
address: p.v_token.address,
|
|
9510
|
+
providerOrAccount: this.config.provider
|
|
9511
|
+
});
|
|
9511
9512
|
const bal = await vTokenContract.balanceOf(this.address.address);
|
|
9512
9513
|
const assets = await vTokenContract.convert_to_assets(
|
|
9513
9514
|
uint2563.bnToUint256(bal.toString())
|
|
@@ -15092,32 +15093,32 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15092
15093
|
);
|
|
15093
15094
|
this.metadata = metadata;
|
|
15094
15095
|
this.address = metadata.address;
|
|
15095
|
-
this.contract = new Contract6(
|
|
15096
|
-
cl_vault_abi_default,
|
|
15097
|
-
this.address.address,
|
|
15098
|
-
this.config.provider
|
|
15099
|
-
);
|
|
15096
|
+
this.contract = new Contract6({
|
|
15097
|
+
abi: cl_vault_abi_default,
|
|
15098
|
+
address: this.address.address,
|
|
15099
|
+
providerOrAccount: this.config.provider
|
|
15100
|
+
});
|
|
15100
15101
|
if (this.metadata.additionalInfo.lstContract) {
|
|
15101
|
-
this.lstContract = new Contract6(
|
|
15102
|
-
erc4626_abi_default,
|
|
15103
|
-
this.metadata.additionalInfo.lstContract.address,
|
|
15104
|
-
this.config.provider
|
|
15105
|
-
);
|
|
15102
|
+
this.lstContract = new Contract6({
|
|
15103
|
+
abi: erc4626_abi_default,
|
|
15104
|
+
address: this.metadata.additionalInfo.lstContract.address,
|
|
15105
|
+
providerOrAccount: this.config.provider
|
|
15106
|
+
});
|
|
15106
15107
|
} else {
|
|
15107
15108
|
this.lstContract = null;
|
|
15108
15109
|
}
|
|
15109
15110
|
const EKUBO_POSITION = "0x02e0af29598b407c8716b17f6d2795eca1b471413fa03fb145a5e33722184067";
|
|
15110
|
-
this.ekuboPositionsContract = new Contract6(
|
|
15111
|
-
ekubo_positions_abi_default,
|
|
15112
|
-
EKUBO_POSITION,
|
|
15113
|
-
this.config.provider
|
|
15114
|
-
);
|
|
15111
|
+
this.ekuboPositionsContract = new Contract6({
|
|
15112
|
+
abi: ekubo_positions_abi_default,
|
|
15113
|
+
address: EKUBO_POSITION,
|
|
15114
|
+
providerOrAccount: this.config.provider
|
|
15115
|
+
});
|
|
15115
15116
|
const EKUBO_MATH = "0x04a72e9e166f6c0e9d800af4dc40f6b6fb4404b735d3f528d9250808b2481995";
|
|
15116
|
-
this.ekuboMathContract = new Contract6(
|
|
15117
|
-
ekubo_math_abi_default,
|
|
15118
|
-
EKUBO_MATH,
|
|
15119
|
-
this.config.provider
|
|
15120
|
-
);
|
|
15117
|
+
this.ekuboMathContract = new Contract6({
|
|
15118
|
+
abi: ekubo_math_abi_default,
|
|
15119
|
+
address: EKUBO_MATH,
|
|
15120
|
+
providerOrAccount: this.config.provider
|
|
15121
|
+
});
|
|
15121
15122
|
this.avnu = new AvnuWrapper();
|
|
15122
15123
|
}
|
|
15123
15124
|
async matchInputAmounts(amountInfo) {
|
|
@@ -15165,16 +15166,16 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15165
15166
|
}
|
|
15166
15167
|
async depositCall(amountInfo, receiver) {
|
|
15167
15168
|
const updateAmountInfo = await this.getMinDepositAmounts(amountInfo);
|
|
15168
|
-
const token0Contract = new Contract6(
|
|
15169
|
-
erc4626_abi_default,
|
|
15170
|
-
amountInfo.token0.tokenInfo.address.address,
|
|
15171
|
-
this.config.provider
|
|
15172
|
-
);
|
|
15173
|
-
const token1Contract = new Contract6(
|
|
15174
|
-
erc4626_abi_default,
|
|
15175
|
-
amountInfo.token1.tokenInfo.address.address,
|
|
15176
|
-
this.config.provider
|
|
15177
|
-
);
|
|
15169
|
+
const token0Contract = new Contract6({
|
|
15170
|
+
abi: erc4626_abi_default,
|
|
15171
|
+
address: amountInfo.token0.tokenInfo.address.address,
|
|
15172
|
+
providerOrAccount: this.config.provider
|
|
15173
|
+
});
|
|
15174
|
+
const token1Contract = new Contract6({
|
|
15175
|
+
abi: erc4626_abi_default,
|
|
15176
|
+
address: amountInfo.token1.tokenInfo.address.address,
|
|
15177
|
+
providerOrAccount: this.config.provider
|
|
15178
|
+
});
|
|
15178
15179
|
const call1 = token0Contract.populate("approve", [
|
|
15179
15180
|
this.address.address,
|
|
15180
15181
|
uint2564.bnToUint256(updateAmountInfo.token0.amount.toWei())
|
|
@@ -15233,7 +15234,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15233
15234
|
* Calculates assets before and now in a given token of TVL per share to observe growth
|
|
15234
15235
|
* @returns {Promise<number>} The weighted average APY across all pools
|
|
15235
15236
|
*/
|
|
15236
|
-
async netAPY(blockIdentifier = "
|
|
15237
|
+
async netAPY(blockIdentifier = "pre_confirmed", sinceBlocks = 2e4) {
|
|
15237
15238
|
const tvlNow = await this._getTVL(blockIdentifier);
|
|
15238
15239
|
const supplyNow = await this.totalSupply(blockIdentifier);
|
|
15239
15240
|
const priceNow = await this.getCurrentPrice(blockIdentifier);
|
|
@@ -15292,13 +15293,13 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15292
15293
|
}
|
|
15293
15294
|
return shares;
|
|
15294
15295
|
}
|
|
15295
|
-
async balanceOf(user, blockIdentifier = "
|
|
15296
|
+
async balanceOf(user, blockIdentifier = "pre_confirmed") {
|
|
15296
15297
|
let bal = await this.contract.call("balance_of", [user.address], {
|
|
15297
15298
|
blockIdentifier
|
|
15298
15299
|
});
|
|
15299
15300
|
return Web3Number.fromWei(bal.toString(), 18);
|
|
15300
15301
|
}
|
|
15301
|
-
async getUserTVL(user, blockIdentifier = "
|
|
15302
|
+
async getUserTVL(user, blockIdentifier = "pre_confirmed") {
|
|
15302
15303
|
let bal = await this.balanceOf(user, blockIdentifier);
|
|
15303
15304
|
const assets = await this.contract.call(
|
|
15304
15305
|
"convert_to_assets",
|
|
@@ -15337,7 +15338,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15337
15338
|
}
|
|
15338
15339
|
};
|
|
15339
15340
|
}
|
|
15340
|
-
async _getTVL(blockIdentifier = "
|
|
15341
|
+
async _getTVL(blockIdentifier = "pre_confirmed") {
|
|
15341
15342
|
const result = await this.contract.call("total_liquidity", [], {
|
|
15342
15343
|
blockIdentifier
|
|
15343
15344
|
});
|
|
@@ -15349,7 +15350,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15349
15350
|
);
|
|
15350
15351
|
return { amount0, amount1 };
|
|
15351
15352
|
}
|
|
15352
|
-
async totalSupply(blockIdentifier = "
|
|
15353
|
+
async totalSupply(blockIdentifier = "pre_confirmed") {
|
|
15353
15354
|
const res = await this.contract.call("total_supply", [], {
|
|
15354
15355
|
blockIdentifier
|
|
15355
15356
|
});
|
|
@@ -15365,7 +15366,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15365
15366
|
"Expected token1 in depositTokens[1]"
|
|
15366
15367
|
);
|
|
15367
15368
|
}
|
|
15368
|
-
async getTVL(blockIdentifier = "
|
|
15369
|
+
async getTVL(blockIdentifier = "pre_confirmed") {
|
|
15369
15370
|
const { amount0, amount1 } = await this._getTVL(blockIdentifier);
|
|
15370
15371
|
const poolKey = await this.getPoolKey(blockIdentifier);
|
|
15371
15372
|
this.assertValidDepositTokens(poolKey);
|
|
@@ -15454,11 +15455,11 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15454
15455
|
}
|
|
15455
15456
|
throw new Error("No true price available");
|
|
15456
15457
|
}
|
|
15457
|
-
async getCurrentPrice(blockIdentifier = "
|
|
15458
|
+
async getCurrentPrice(blockIdentifier = "pre_confirmed") {
|
|
15458
15459
|
const poolKey = await this.getPoolKey(blockIdentifier);
|
|
15459
15460
|
return this._getCurrentPrice(poolKey, blockIdentifier);
|
|
15460
15461
|
}
|
|
15461
|
-
async _getCurrentPrice(poolKey, blockIdentifier = "
|
|
15462
|
+
async _getCurrentPrice(poolKey, blockIdentifier = "pre_confirmed") {
|
|
15462
15463
|
const priceInfo = await this.ekuboPositionsContract.call(
|
|
15463
15464
|
"get_pool_price",
|
|
15464
15465
|
[
|
|
@@ -15493,7 +15494,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15493
15494
|
sqrtRatio: priceInfo.sqrt_ratio.toString()
|
|
15494
15495
|
};
|
|
15495
15496
|
}
|
|
15496
|
-
async getCurrentBounds(blockIdentifier = "
|
|
15497
|
+
async getCurrentBounds(blockIdentifier = "pre_confirmed") {
|
|
15497
15498
|
const result = await this.contract.call("get_position_key", [], {
|
|
15498
15499
|
blockIdentifier
|
|
15499
15500
|
});
|
|
@@ -15510,7 +15511,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
15510
15511
|
const tick = Math.floor(value / tickSpacing) * tickSpacing;
|
|
15511
15512
|
return this.tickToi129(tick);
|
|
15512
15513
|
}
|
|
15513
|
-
async getPoolKey(blockIdentifier = "
|
|
15514
|
+
async getPoolKey(blockIdentifier = "pre_confirmed") {
|
|
15514
15515
|
if (this.poolKey) {
|
|
15515
15516
|
return this.poolKey;
|
|
15516
15517
|
}
|
|
@@ -16008,7 +16009,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
|
|
|
16008
16009
|
static tickToPrice(tick) {
|
|
16009
16010
|
return Math.pow(1.000001, Number(tick));
|
|
16010
16011
|
}
|
|
16011
|
-
async getLiquidityToAmounts(liquidity, bounds, blockIdentifier = "
|
|
16012
|
+
async getLiquidityToAmounts(liquidity, bounds, blockIdentifier = "pre_confirmed", _poolKey = null, _currentPrice = null) {
|
|
16012
16013
|
const currentPrice = _currentPrice || await this.getCurrentPrice(blockIdentifier);
|
|
16013
16014
|
const lowerPrice = _EkuboCLVault.tickToPrice(bounds.lowerTick);
|
|
16014
16015
|
const upperPrice = _EkuboCLVault.tickToPrice(bounds.upperTick);
|
|
@@ -18170,7 +18171,7 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
18170
18171
|
this.address = metadata.address;
|
|
18171
18172
|
this.pricer = pricer;
|
|
18172
18173
|
this.metadata = metadata;
|
|
18173
|
-
this.contract = new Contract7(sensei_abi_default, this.address.address, this.config.provider);
|
|
18174
|
+
this.contract = new Contract7({ abi: sensei_abi_default, address: this.address.address, providerOrAccount: this.config.provider });
|
|
18174
18175
|
if (metadata.depositTokens.length === 0) {
|
|
18175
18176
|
throw new Error("Deposit tokens are not defined in metadata");
|
|
18176
18177
|
}
|
|
@@ -18222,11 +18223,11 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
18222
18223
|
}
|
|
18223
18224
|
}
|
|
18224
18225
|
async depositCall(amountInfo, receiver) {
|
|
18225
|
-
const mainTokenContract = new Contract7(
|
|
18226
|
-
erc20_abi_default,
|
|
18227
|
-
this.metadata.depositTokens[0].address.address,
|
|
18228
|
-
this.config.provider
|
|
18229
|
-
);
|
|
18226
|
+
const mainTokenContract = new Contract7({
|
|
18227
|
+
abi: erc20_abi_default,
|
|
18228
|
+
address: this.metadata.depositTokens[0].address.address,
|
|
18229
|
+
providerOrAccount: this.config.provider
|
|
18230
|
+
});
|
|
18230
18231
|
const call1 = mainTokenContract.populate("approve", [
|
|
18231
18232
|
this.address.address,
|
|
18232
18233
|
uint2565.bnToUint256(amountInfo.amount.toWei())
|
|
@@ -18437,7 +18438,9 @@ var SenseiStrategies = [
|
|
|
18437
18438
|
import { hash, num as num6, shortString } from "starknet";
|
|
18438
18439
|
|
|
18439
18440
|
// src/strategies/universal-adapters/adapter-utils.ts
|
|
18440
|
-
var SIMPLE_SANITIZER = ContractAddr.from("
|
|
18441
|
+
var SIMPLE_SANITIZER = ContractAddr.from("0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4");
|
|
18442
|
+
var PRICE_ROUTER = ContractAddr.from("0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837");
|
|
18443
|
+
var AVNU_MIDDLEWARE = ContractAddr.from("0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d");
|
|
18441
18444
|
function toBigInt(value) {
|
|
18442
18445
|
if (typeof value === "string") {
|
|
18443
18446
|
return BigInt(value);
|
|
@@ -18470,7 +18473,7 @@ var BaseAdapter = class extends CacheClass {
|
|
|
18470
18473
|
};
|
|
18471
18474
|
|
|
18472
18475
|
// src/strategies/universal-adapters/common-adapter.ts
|
|
18473
|
-
import { hash as hash2, uint256 as uint2566 } from "starknet";
|
|
18476
|
+
import { hash as hash2, num as num7, uint256 as uint2566 } from "starknet";
|
|
18474
18477
|
var CommonAdapter = class extends BaseAdapter {
|
|
18475
18478
|
constructor(config) {
|
|
18476
18479
|
super();
|
|
@@ -18581,10 +18584,70 @@ var CommonAdapter = class extends BaseAdapter {
|
|
|
18581
18584
|
};
|
|
18582
18585
|
};
|
|
18583
18586
|
}
|
|
18587
|
+
getAvnuAdapter(fromToken, toToken, id) {
|
|
18588
|
+
return () => ({
|
|
18589
|
+
leaf: this.constructSimpleLeafData({
|
|
18590
|
+
id,
|
|
18591
|
+
target: AVNU_MIDDLEWARE,
|
|
18592
|
+
method: "multi_route_swap",
|
|
18593
|
+
packedArguments: [
|
|
18594
|
+
fromToken.toBigInt(),
|
|
18595
|
+
toToken.toBigInt(),
|
|
18596
|
+
this.config.vaultAllocator.toBigInt()
|
|
18597
|
+
]
|
|
18598
|
+
}),
|
|
18599
|
+
callConstructor: this.getAvnuCall(fromToken, toToken).bind(this)
|
|
18600
|
+
});
|
|
18601
|
+
}
|
|
18602
|
+
getAvnuCall(fromToken, toToken) {
|
|
18603
|
+
return (params) => {
|
|
18604
|
+
return {
|
|
18605
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
18606
|
+
call: {
|
|
18607
|
+
contractAddress: AVNU_MIDDLEWARE,
|
|
18608
|
+
selector: hash2.getSelectorFromName("multi_route_swap"),
|
|
18609
|
+
calldata: [
|
|
18610
|
+
fromToken.toBigInt(),
|
|
18611
|
+
// sell_token_address
|
|
18612
|
+
toBigInt(params.props.token_from_amount.low.toString()),
|
|
18613
|
+
// sell_token_amount low
|
|
18614
|
+
toBigInt(params.props.token_from_amount.high.toString()),
|
|
18615
|
+
// sell_token_amount high
|
|
18616
|
+
toToken.toBigInt(),
|
|
18617
|
+
// buy_token_address
|
|
18618
|
+
toBigInt(params.props.token_to_amount.low.toString()),
|
|
18619
|
+
// buy_token_amount low
|
|
18620
|
+
toBigInt(params.props.token_to_amount.high.toString()),
|
|
18621
|
+
// buy_token_amount high
|
|
18622
|
+
toBigInt(params.props.token_to_min_amount.low.toString()),
|
|
18623
|
+
// buy_token_min_amount low
|
|
18624
|
+
toBigInt(params.props.token_to_min_amount.high.toString()),
|
|
18625
|
+
// buy_token_min_amount high
|
|
18626
|
+
this.config.vaultAllocator.toBigInt(),
|
|
18627
|
+
// beneficiary
|
|
18628
|
+
toBigInt(0),
|
|
18629
|
+
// integrator_fee_amount_bps
|
|
18630
|
+
this.config.vaultAllocator.toBigInt(),
|
|
18631
|
+
// integrator_fee_recipient
|
|
18632
|
+
// unpack routes
|
|
18633
|
+
BigInt(params.props.routes.length),
|
|
18634
|
+
...params.props.routes.map((r) => [
|
|
18635
|
+
BigInt(num7.hexToDecimalString(r.token_from)),
|
|
18636
|
+
BigInt(num7.hexToDecimalString(r.token_to)),
|
|
18637
|
+
BigInt(num7.hexToDecimalString(r.exchange_address)),
|
|
18638
|
+
BigInt(r.percent),
|
|
18639
|
+
BigInt(r.additional_swap_params.length),
|
|
18640
|
+
...r.additional_swap_params.map((p) => BigInt(num7.hexToDecimalString(p)))
|
|
18641
|
+
]).flat()
|
|
18642
|
+
]
|
|
18643
|
+
}
|
|
18644
|
+
};
|
|
18645
|
+
};
|
|
18646
|
+
}
|
|
18584
18647
|
};
|
|
18585
18648
|
|
|
18586
18649
|
// src/strategies/universal-adapters/vesu-adapter.ts
|
|
18587
|
-
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash3, RpcProvider as RpcProvider4, uint256 as uint2567 } from "starknet";
|
|
18650
|
+
import { CairoCustomEnum as CairoCustomEnum2, Contract as Contract8, hash as hash3, num as num8, RpcProvider as RpcProvider4, shortString as shortString3, uint256 as uint2567 } from "starknet";
|
|
18588
18651
|
|
|
18589
18652
|
// src/data/vesu-singleton.abi.json
|
|
18590
18653
|
var vesu_singleton_abi_default = [
|
|
@@ -20894,7 +20957,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
20894
20957
|
}
|
|
20895
20958
|
};
|
|
20896
20959
|
logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`);
|
|
20897
|
-
const singletonContract = new Contract8(vesu_singleton_abi_default, this.VESU_SINGLETON.toString(), new RpcProvider4({ nodeUrl: "" }));
|
|
20960
|
+
const singletonContract = new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider4({ nodeUrl: "" }) });
|
|
20898
20961
|
const call = singletonContract.populate("modify_position", {
|
|
20899
20962
|
params: {
|
|
20900
20963
|
pool_id: this.config.poolId.toBigInt(),
|
|
@@ -20917,6 +20980,40 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
20917
20980
|
}
|
|
20918
20981
|
};
|
|
20919
20982
|
};
|
|
20983
|
+
this.getDefispringRewardsAdapter = (id) => {
|
|
20984
|
+
return () => {
|
|
20985
|
+
const packedArguments = [];
|
|
20986
|
+
const output = {
|
|
20987
|
+
id: BigInt(num8.getDecimalString(shortString3.encodeShortString(id))),
|
|
20988
|
+
readableId: id,
|
|
20989
|
+
data: [
|
|
20990
|
+
SIMPLE_SANITIZER.toBigInt(),
|
|
20991
|
+
// sanitizer address
|
|
20992
|
+
VESU_REWARDS_CONTRACT.toBigInt(),
|
|
20993
|
+
// contract
|
|
20994
|
+
toBigInt(hash3.getSelectorFromName("claim")),
|
|
20995
|
+
// method name
|
|
20996
|
+
BigInt(packedArguments.length),
|
|
20997
|
+
...packedArguments
|
|
20998
|
+
]
|
|
20999
|
+
};
|
|
21000
|
+
return { leaf: output, callConstructor: this.getDefiSpringClaimCall().bind(this) };
|
|
21001
|
+
};
|
|
21002
|
+
};
|
|
21003
|
+
this.getDefiSpringClaimCall = () => {
|
|
21004
|
+
return (params) => ({
|
|
21005
|
+
sanitizer: SIMPLE_SANITIZER,
|
|
21006
|
+
call: {
|
|
21007
|
+
contractAddress: VESU_REWARDS_CONTRACT,
|
|
21008
|
+
selector: hash3.getSelectorFromName("claim"),
|
|
21009
|
+
calldata: [
|
|
21010
|
+
BigInt(params.amount.toWei()),
|
|
21011
|
+
BigInt(params.proofs.length),
|
|
21012
|
+
...params.proofs.map((proof) => BigInt(num8.hexToDecimalString(proof)))
|
|
21013
|
+
]
|
|
21014
|
+
}
|
|
21015
|
+
});
|
|
21016
|
+
};
|
|
20920
21017
|
this.config = config;
|
|
20921
21018
|
}
|
|
20922
21019
|
static getDefaultModifyPositionCallParams(params) {
|
|
@@ -20958,7 +21055,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
|
|
|
20958
21055
|
throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
|
|
20959
21056
|
}
|
|
20960
21057
|
getVesuSingletonContract(config) {
|
|
20961
|
-
return new Contract8(vesu_singleton_abi_default, this.VESU_SINGLETON.address, config.provider);
|
|
21058
|
+
return new Contract8({ abi: vesu_singleton_abi_default, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider });
|
|
20962
21059
|
}
|
|
20963
21060
|
async getLTVConfig(config) {
|
|
20964
21061
|
const CACHE_KEY = "ltv_config";
|
|
@@ -23321,16 +23418,16 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23321
23418
|
);
|
|
23322
23419
|
this.metadata = metadata;
|
|
23323
23420
|
this.address = metadata.address;
|
|
23324
|
-
this.contract = new Contract9(
|
|
23325
|
-
universal_vault_abi_default,
|
|
23326
|
-
this.address.address,
|
|
23327
|
-
this.config.provider
|
|
23328
|
-
);
|
|
23329
|
-
this.managerContract = new Contract9(
|
|
23330
|
-
vault_manager_abi_default,
|
|
23331
|
-
this.metadata.additionalInfo.manager.address,
|
|
23332
|
-
this.config.provider
|
|
23333
|
-
);
|
|
23421
|
+
this.contract = new Contract9({
|
|
23422
|
+
abi: universal_vault_abi_default,
|
|
23423
|
+
address: this.address.address,
|
|
23424
|
+
providerOrAccount: this.config.provider
|
|
23425
|
+
});
|
|
23426
|
+
this.managerContract = new Contract9({
|
|
23427
|
+
abi: vault_manager_abi_default,
|
|
23428
|
+
address: this.metadata.additionalInfo.manager.address,
|
|
23429
|
+
providerOrAccount: this.config.provider
|
|
23430
|
+
});
|
|
23334
23431
|
}
|
|
23335
23432
|
getMerkleTree() {
|
|
23336
23433
|
if (this.merkleTree) return this.merkleTree;
|
|
@@ -23380,11 +23477,11 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23380
23477
|
amountInfo.tokenInfo.address.eq(this.asset().address),
|
|
23381
23478
|
"Deposit token mismatch"
|
|
23382
23479
|
);
|
|
23383
|
-
const assetContract = new Contract9(
|
|
23384
|
-
universal_vault_abi_default,
|
|
23385
|
-
this.asset().address.address,
|
|
23386
|
-
this.config.provider
|
|
23387
|
-
);
|
|
23480
|
+
const assetContract = new Contract9({
|
|
23481
|
+
abi: universal_vault_abi_default,
|
|
23482
|
+
address: this.asset().address.address,
|
|
23483
|
+
providerOrAccount: this.config.provider
|
|
23484
|
+
});
|
|
23388
23485
|
const call1 = assetContract.populate("approve", [
|
|
23389
23486
|
this.address.address,
|
|
23390
23487
|
uint2568.bnToUint256(amountInfo.amount.toWei())
|
|
@@ -23546,7 +23643,7 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23546
23643
|
const aumToken = vesuAum.plus(balance.amount);
|
|
23547
23644
|
logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
|
|
23548
23645
|
const netAPY = await this.netAPY();
|
|
23549
|
-
const defispringAPY = netAPY.splits.find((s) => s.id === "defispring")?.apy || 0;
|
|
23646
|
+
const defispringAPY = (netAPY.splits.find((s) => s.id === "defispring")?.apy || 0) * 0.8;
|
|
23550
23647
|
if (!defispringAPY) throw new Error("DefiSpring APY not found");
|
|
23551
23648
|
const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
|
|
23552
23649
|
const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
|
|
@@ -23789,6 +23886,51 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
|
|
|
23789
23886
|
const manageCall = this.getManageCall(["approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */, "bring_liquidity" /* BRING_LIQUIDITY */], [manageCall1, manageCall2]);
|
|
23790
23887
|
return manageCall;
|
|
23791
23888
|
}
|
|
23889
|
+
async getHarvestCall() {
|
|
23890
|
+
const vesuHarvest = new VesuHarvests(this.config);
|
|
23891
|
+
const harvestInfo = await vesuHarvest.getUnHarvestedRewards(this.metadata.additionalInfo.vaultAllocator);
|
|
23892
|
+
if (harvestInfo.length != 1) {
|
|
23893
|
+
throw new Error(`Expected 1 harvest info, got ${harvestInfo.length}`);
|
|
23894
|
+
}
|
|
23895
|
+
const amount = harvestInfo[0].claim.amount;
|
|
23896
|
+
const actualReward = harvestInfo[0].actualReward;
|
|
23897
|
+
const proofs = harvestInfo[0].proof;
|
|
23898
|
+
if (actualReward.isZero()) {
|
|
23899
|
+
throw new Error(`Expected non-zero actual reward, got ${harvestInfo[0].actualReward}`);
|
|
23900
|
+
}
|
|
23901
|
+
const manage1Info = this.getProofs("defispring_rewards" /* DEFISPRING_REWARDS */);
|
|
23902
|
+
const manageCall1 = manage1Info.callConstructor({
|
|
23903
|
+
amount,
|
|
23904
|
+
proofs
|
|
23905
|
+
});
|
|
23906
|
+
const proofIds = ["defispring_rewards" /* DEFISPRING_REWARDS */];
|
|
23907
|
+
const manageCalls = [manageCall1];
|
|
23908
|
+
const STRK2 = Global.getDefaultTokens().find((t) => t.symbol === "STRK");
|
|
23909
|
+
if (this.asset().symbol != "STRK") {
|
|
23910
|
+
const manage2Info = this.getProofs("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
|
|
23911
|
+
const manageCall2 = manage2Info.callConstructor({
|
|
23912
|
+
amount: actualReward
|
|
23913
|
+
});
|
|
23914
|
+
const avnuModule = new AvnuWrapper();
|
|
23915
|
+
const quote = await avnuModule.getQuotes(
|
|
23916
|
+
STRK2.address.address,
|
|
23917
|
+
this.asset().address.address,
|
|
23918
|
+
actualReward.toWei(),
|
|
23919
|
+
this.address.address
|
|
23920
|
+
);
|
|
23921
|
+
const swapInfo = await avnuModule.getSwapInfo(quote, this.address.address, 0, this.address.address);
|
|
23922
|
+
const manage3Info = this.getProofs("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
|
|
23923
|
+
const manageCall3 = manage3Info.callConstructor({
|
|
23924
|
+
props: swapInfo
|
|
23925
|
+
});
|
|
23926
|
+
proofIds.push("approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */);
|
|
23927
|
+
proofIds.push("avnu_swap_rewards" /* AVNU_SWAP_REWARDS */);
|
|
23928
|
+
manageCalls.push(manageCall2);
|
|
23929
|
+
manageCalls.push(manageCall3);
|
|
23930
|
+
}
|
|
23931
|
+
const manageCall = this.getManageCall(proofIds, manageCalls);
|
|
23932
|
+
return { call: manageCall, reward: actualReward, tokenInfo: STRK2 };
|
|
23933
|
+
}
|
|
23792
23934
|
async getRebalanceCall(params) {
|
|
23793
23935
|
let callSet1 = this.getVesuModifyPositionCalls({
|
|
23794
23936
|
isLeg1: true,
|
|
@@ -23825,6 +23967,9 @@ var UNIVERSAL_MANAGE_IDS = /* @__PURE__ */ ((UNIVERSAL_MANAGE_IDS2) => {
|
|
|
23825
23967
|
UNIVERSAL_MANAGE_IDS2["APPROVE_TOKEN2"] = "approve_token2";
|
|
23826
23968
|
UNIVERSAL_MANAGE_IDS2["APPROVE_BRING_LIQUIDITY"] = "approve_bring_liquidity";
|
|
23827
23969
|
UNIVERSAL_MANAGE_IDS2["BRING_LIQUIDITY"] = "bring_liquidity";
|
|
23970
|
+
UNIVERSAL_MANAGE_IDS2["DEFISPRING_REWARDS"] = "defispring_rewards";
|
|
23971
|
+
UNIVERSAL_MANAGE_IDS2["APPROVE_SWAP_TOKEN1"] = "approve_swap_token1";
|
|
23972
|
+
UNIVERSAL_MANAGE_IDS2["AVNU_SWAP_REWARDS"] = "avnu_swap_rewards";
|
|
23828
23973
|
return UNIVERSAL_MANAGE_IDS2;
|
|
23829
23974
|
})(UNIVERSAL_MANAGE_IDS || {});
|
|
23830
23975
|
var UNIVERSAL_ADAPTERS = /* @__PURE__ */ ((UNIVERSAL_ADAPTERS2) => {
|
|
@@ -23874,6 +24019,10 @@ function getLooperSettings(token1Symbol, token2Symbol, vaultSettings, pool1, poo
|
|
|
23874
24019
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(ETHToken.address, vesuAdapterETHUSDC.VESU_SINGLETON, "approve_token2" /* APPROVE_TOKEN2 */).bind(commonAdapter));
|
|
23875
24020
|
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(USDCToken.address, vaultSettings.vaultAddress, "approve_bring_liquidity" /* APPROVE_BRING_LIQUIDITY */).bind(commonAdapter));
|
|
23876
24021
|
vaultSettings.leafAdapters.push(commonAdapter.getBringLiquidityAdapter("bring_liquidity" /* BRING_LIQUIDITY */).bind(commonAdapter));
|
|
24022
|
+
vaultSettings.leafAdapters.push(vesuAdapterUSDCETH.getDefispringRewardsAdapter("defispring_rewards" /* DEFISPRING_REWARDS */).bind(vesuAdapterUSDCETH));
|
|
24023
|
+
const STRKToken = Global.getDefaultTokens().find((token) => token.symbol === "STRK");
|
|
24024
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(STRKToken.address, AVNU_MIDDLEWARE, "approve_swap_token1" /* APPROVE_SWAP_TOKEN1 */).bind(commonAdapter));
|
|
24025
|
+
vaultSettings.leafAdapters.push(commonAdapter.getAvnuAdapter(STRKToken.address, USDCToken.address, "avnu_swap_rewards" /* AVNU_SWAP_REWARDS */).bind(commonAdapter));
|
|
23877
24026
|
return vaultSettings;
|
|
23878
24027
|
}
|
|
23879
24028
|
var _riskFactor4 = [
|