@strkfarm/sdk 1.1.77 → 1.1.79
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 +18 -9
- package/dist/index.browser.mjs +18 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -9
- package/dist/index.mjs +18 -9
- package/package.json +1 -1
- package/src/strategies/sensei.ts +3 -2
- package/src/strategies/universal-lst-muliplier-strategy.tsx +17 -8
|
@@ -83508,10 +83508,11 @@ spurious results.`);
|
|
|
83508
83508
|
const CACHE_KEY = "xSTRKPrice";
|
|
83509
83509
|
const existingCacheData = this.getCache(CACHE_KEY);
|
|
83510
83510
|
if (existingCacheData) return existingCacheData;
|
|
83511
|
+
let AMOUNT = 100;
|
|
83511
83512
|
const params = {
|
|
83512
83513
|
sellTokenAddress: this.metadata.additionalInfo.secondaryToken.address.address,
|
|
83513
83514
|
buyTokenAddress: this.metadata.additionalInfo.mainToken.address.address,
|
|
83514
|
-
sellAmount: BigInt(new Web3Number(
|
|
83515
|
+
sellAmount: BigInt(new Web3Number(AMOUNT.toString(), 18).toWei()),
|
|
83515
83516
|
takerAddress: this.address.address
|
|
83516
83517
|
};
|
|
83517
83518
|
logger2.verbose("getSecondaryTokenPriceRelativeToMain [1]", params);
|
|
@@ -83530,7 +83531,7 @@ spurious results.`);
|
|
|
83530
83531
|
Web3Number.fromWei(firstQuote.buyAmount.toString(), 18).toFixed(
|
|
83531
83532
|
6
|
|
83532
83533
|
)
|
|
83533
|
-
);
|
|
83534
|
+
) / AMOUNT;
|
|
83534
83535
|
logger2.verbose("getSecondaryTokenPriceRelativeToMain [2]", price);
|
|
83535
83536
|
this.setCache(CACHE_KEY, price);
|
|
83536
83537
|
return price;
|
|
@@ -95056,7 +95057,11 @@ spurious results.`);
|
|
|
95056
95057
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
95057
95058
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
95058
95059
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
95059
|
-
const vesuAdapter = allVesuAdapters.find((adapter2) =>
|
|
95060
|
+
const vesuAdapter = allVesuAdapters.find((adapter2) => {
|
|
95061
|
+
const isDebtTokenMatch = adapter2.config.debt.address.eq(maxBorrowable.borrowableAsset.address);
|
|
95062
|
+
const isPoolIdMatch = adapter2.config.poolId.eq(maxBorrowable.poolId);
|
|
95063
|
+
return isDebtTokenMatch && isPoolIdMatch;
|
|
95064
|
+
});
|
|
95060
95065
|
if (!vesuAdapter) {
|
|
95061
95066
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
95062
95067
|
}
|
|
@@ -95147,7 +95152,7 @@ spurious results.`);
|
|
|
95147
95152
|
return calls[0];
|
|
95148
95153
|
}
|
|
95149
95154
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
95150
|
-
const STEP0 =
|
|
95155
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
95151
95156
|
const manage0Info = this.getProofs(STEP0);
|
|
95152
95157
|
const manageCall0 = manage0Info.callConstructor({
|
|
95153
95158
|
amount: newDepositAmount
|
|
@@ -95202,7 +95207,7 @@ spurious results.`);
|
|
|
95202
95207
|
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
95203
95208
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
95204
95209
|
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
95205
|
-
const STEP4 =
|
|
95210
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
95206
95211
|
const manage4Info = this.getProofs(STEP4);
|
|
95207
95212
|
const manageCall4 = manage4Info.callConstructor({
|
|
95208
95213
|
amount: minAmount
|
|
@@ -95361,7 +95366,7 @@ spurious results.`);
|
|
|
95361
95366
|
for (const vesuAdapter of vesuAdapters) {
|
|
95362
95367
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
95363
95368
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
95364
|
-
maxBorrowables.push({ ...output, ltv });
|
|
95369
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
95365
95370
|
}
|
|
95366
95371
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
95367
95372
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -95631,6 +95636,9 @@ spurious results.`);
|
|
|
95631
95636
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
95632
95637
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
95633
95638
|
}
|
|
95639
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
95640
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
95641
|
+
}
|
|
95634
95642
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
95635
95643
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
95636
95644
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -95655,7 +95663,8 @@ spurious results.`);
|
|
|
95655
95663
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
95656
95664
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
95657
95665
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
95658
|
-
|
|
95666
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
95667
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
95659
95668
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
95660
95669
|
return vesuAdapterLST;
|
|
95661
95670
|
}
|
|
@@ -95768,13 +95777,13 @@ spurious results.`);
|
|
|
95768
95777
|
targetHealthFactor: 1.1,
|
|
95769
95778
|
minHealthFactor: 1.05,
|
|
95770
95779
|
borrowable_assets: [
|
|
95771
|
-
...Global.getDefaultTokens().filter(
|
|
95780
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
95772
95781
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
95773
95782
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
95774
95783
|
// v2, new alt for Re7xSTRK
|
|
95775
95784
|
],
|
|
95776
95785
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
95777
|
-
defaultPoolId: VesuPools.
|
|
95786
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
95778
95787
|
};
|
|
95779
95788
|
var hyperxWBTC = {
|
|
95780
95789
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/dist/index.browser.mjs
CHANGED
|
@@ -19473,10 +19473,11 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19473
19473
|
const CACHE_KEY = "xSTRKPrice";
|
|
19474
19474
|
const existingCacheData = this.getCache(CACHE_KEY);
|
|
19475
19475
|
if (existingCacheData) return existingCacheData;
|
|
19476
|
+
let AMOUNT = 100;
|
|
19476
19477
|
const params = {
|
|
19477
19478
|
sellTokenAddress: this.metadata.additionalInfo.secondaryToken.address.address,
|
|
19478
19479
|
buyTokenAddress: this.metadata.additionalInfo.mainToken.address.address,
|
|
19479
|
-
sellAmount: BigInt(new Web3Number(
|
|
19480
|
+
sellAmount: BigInt(new Web3Number(AMOUNT.toString(), 18).toWei()),
|
|
19480
19481
|
takerAddress: this.address.address
|
|
19481
19482
|
};
|
|
19482
19483
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [1]", params);
|
|
@@ -19495,7 +19496,7 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19495
19496
|
Web3Number.fromWei(firstQuote.buyAmount.toString(), 18).toFixed(
|
|
19496
19497
|
6
|
|
19497
19498
|
)
|
|
19498
|
-
);
|
|
19499
|
+
) / AMOUNT;
|
|
19499
19500
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [2]", price);
|
|
19500
19501
|
this.setCache(CACHE_KEY, price);
|
|
19501
19502
|
return price;
|
|
@@ -31034,7 +31035,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31034
31035
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
31035
31036
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
31036
31037
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
31037
|
-
const vesuAdapter = allVesuAdapters.find((adapter) =>
|
|
31038
|
+
const vesuAdapter = allVesuAdapters.find((adapter) => {
|
|
31039
|
+
const isDebtTokenMatch = adapter.config.debt.address.eq(maxBorrowable.borrowableAsset.address);
|
|
31040
|
+
const isPoolIdMatch = adapter.config.poolId.eq(maxBorrowable.poolId);
|
|
31041
|
+
return isDebtTokenMatch && isPoolIdMatch;
|
|
31042
|
+
});
|
|
31038
31043
|
if (!vesuAdapter) {
|
|
31039
31044
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
31040
31045
|
}
|
|
@@ -31125,7 +31130,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31125
31130
|
return calls[0];
|
|
31126
31131
|
}
|
|
31127
31132
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31128
|
-
const STEP0 =
|
|
31133
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31129
31134
|
const manage0Info = this.getProofs(STEP0);
|
|
31130
31135
|
const manageCall0 = manage0Info.callConstructor({
|
|
31131
31136
|
amount: newDepositAmount
|
|
@@ -31180,7 +31185,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31180
31185
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31181
31186
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31182
31187
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31183
|
-
const STEP4 =
|
|
31188
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31184
31189
|
const manage4Info = this.getProofs(STEP4);
|
|
31185
31190
|
const manageCall4 = manage4Info.callConstructor({
|
|
31186
31191
|
amount: minAmount
|
|
@@ -31339,7 +31344,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31339
31344
|
for (const vesuAdapter of vesuAdapters) {
|
|
31340
31345
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31341
31346
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31342
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31347
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31343
31348
|
}
|
|
31344
31349
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31345
31350
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31609,6 +31614,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31609
31614
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31610
31615
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31611
31616
|
}
|
|
31617
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31618
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31619
|
+
}
|
|
31612
31620
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31613
31621
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31614
31622
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31633,7 +31641,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31633
31641
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31634
31642
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31635
31643
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31636
|
-
|
|
31644
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31645
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31637
31646
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31638
31647
|
return vesuAdapterLST;
|
|
31639
31648
|
}
|
|
@@ -31746,13 +31755,13 @@ var hyperxSTRK = {
|
|
|
31746
31755
|
targetHealthFactor: 1.1,
|
|
31747
31756
|
minHealthFactor: 1.05,
|
|
31748
31757
|
borrowable_assets: [
|
|
31749
|
-
...Global.getDefaultTokens().filter(
|
|
31758
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31750
31759
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31751
31760
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31752
31761
|
// v2, new alt for Re7xSTRK
|
|
31753
31762
|
],
|
|
31754
31763
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31755
|
-
defaultPoolId: VesuPools.
|
|
31764
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31756
31765
|
};
|
|
31757
31766
|
var hyperxWBTC = {
|
|
31758
31767
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/dist/index.d.ts
CHANGED
|
@@ -1522,6 +1522,7 @@ declare class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTS
|
|
|
1522
1522
|
maxBorrowableAmount: Web3Number;
|
|
1523
1523
|
borrowableAsset: TokenInfo;
|
|
1524
1524
|
ltv: number;
|
|
1525
|
+
poolId: ContractAddr;
|
|
1525
1526
|
}[];
|
|
1526
1527
|
}>;
|
|
1527
1528
|
getMaxSwappableWithMaxSlippage(fromToken: TokenInfo, toToken: TokenInfo, maxSlippage: number, maxAmount: Web3Number): Promise<Web3Number>;
|
package/dist/index.js
CHANGED
|
@@ -19474,10 +19474,11 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19474
19474
|
const CACHE_KEY = "xSTRKPrice";
|
|
19475
19475
|
const existingCacheData = this.getCache(CACHE_KEY);
|
|
19476
19476
|
if (existingCacheData) return existingCacheData;
|
|
19477
|
+
let AMOUNT = 100;
|
|
19477
19478
|
const params = {
|
|
19478
19479
|
sellTokenAddress: this.metadata.additionalInfo.secondaryToken.address.address,
|
|
19479
19480
|
buyTokenAddress: this.metadata.additionalInfo.mainToken.address.address,
|
|
19480
|
-
sellAmount: BigInt(new Web3Number(
|
|
19481
|
+
sellAmount: BigInt(new Web3Number(AMOUNT.toString(), 18).toWei()),
|
|
19481
19482
|
takerAddress: this.address.address
|
|
19482
19483
|
};
|
|
19483
19484
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [1]", params);
|
|
@@ -19496,7 +19497,7 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19496
19497
|
Web3Number.fromWei(firstQuote.buyAmount.toString(), 18).toFixed(
|
|
19497
19498
|
6
|
|
19498
19499
|
)
|
|
19499
|
-
);
|
|
19500
|
+
) / AMOUNT;
|
|
19500
19501
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [2]", price);
|
|
19501
19502
|
this.setCache(CACHE_KEY, price);
|
|
19502
19503
|
return price;
|
|
@@ -31035,7 +31036,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31035
31036
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
31036
31037
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
31037
31038
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
31038
|
-
const vesuAdapter = allVesuAdapters.find((adapter) =>
|
|
31039
|
+
const vesuAdapter = allVesuAdapters.find((adapter) => {
|
|
31040
|
+
const isDebtTokenMatch = adapter.config.debt.address.eq(maxBorrowable.borrowableAsset.address);
|
|
31041
|
+
const isPoolIdMatch = adapter.config.poolId.eq(maxBorrowable.poolId);
|
|
31042
|
+
return isDebtTokenMatch && isPoolIdMatch;
|
|
31043
|
+
});
|
|
31039
31044
|
if (!vesuAdapter) {
|
|
31040
31045
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
31041
31046
|
}
|
|
@@ -31126,7 +31131,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31126
31131
|
return calls[0];
|
|
31127
31132
|
}
|
|
31128
31133
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31129
|
-
const STEP0 =
|
|
31134
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31130
31135
|
const manage0Info = this.getProofs(STEP0);
|
|
31131
31136
|
const manageCall0 = manage0Info.callConstructor({
|
|
31132
31137
|
amount: newDepositAmount
|
|
@@ -31181,7 +31186,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31181
31186
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31182
31187
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31183
31188
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31184
|
-
const STEP4 =
|
|
31189
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31185
31190
|
const manage4Info = this.getProofs(STEP4);
|
|
31186
31191
|
const manageCall4 = manage4Info.callConstructor({
|
|
31187
31192
|
amount: minAmount
|
|
@@ -31340,7 +31345,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31340
31345
|
for (const vesuAdapter of vesuAdapters) {
|
|
31341
31346
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31342
31347
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31343
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31348
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31344
31349
|
}
|
|
31345
31350
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31346
31351
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31610,6 +31615,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31610
31615
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31611
31616
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31612
31617
|
}
|
|
31618
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31619
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31620
|
+
}
|
|
31613
31621
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31614
31622
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31615
31623
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31634,7 +31642,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31634
31642
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31635
31643
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31636
31644
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31637
|
-
|
|
31645
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31646
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31638
31647
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31639
31648
|
return vesuAdapterLST;
|
|
31640
31649
|
}
|
|
@@ -31747,13 +31756,13 @@ var hyperxSTRK = {
|
|
|
31747
31756
|
targetHealthFactor: 1.1,
|
|
31748
31757
|
minHealthFactor: 1.05,
|
|
31749
31758
|
borrowable_assets: [
|
|
31750
|
-
...Global.getDefaultTokens().filter(
|
|
31759
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31751
31760
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31752
31761
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31753
31762
|
// v2, new alt for Re7xSTRK
|
|
31754
31763
|
],
|
|
31755
31764
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31756
|
-
defaultPoolId: VesuPools.
|
|
31765
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31757
31766
|
};
|
|
31758
31767
|
var hyperxWBTC = {
|
|
31759
31768
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/dist/index.mjs
CHANGED
|
@@ -19371,10 +19371,11 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19371
19371
|
const CACHE_KEY = "xSTRKPrice";
|
|
19372
19372
|
const existingCacheData = this.getCache(CACHE_KEY);
|
|
19373
19373
|
if (existingCacheData) return existingCacheData;
|
|
19374
|
+
let AMOUNT = 100;
|
|
19374
19375
|
const params = {
|
|
19375
19376
|
sellTokenAddress: this.metadata.additionalInfo.secondaryToken.address.address,
|
|
19376
19377
|
buyTokenAddress: this.metadata.additionalInfo.mainToken.address.address,
|
|
19377
|
-
sellAmount: BigInt(new Web3Number(
|
|
19378
|
+
sellAmount: BigInt(new Web3Number(AMOUNT.toString(), 18).toWei()),
|
|
19378
19379
|
takerAddress: this.address.address
|
|
19379
19380
|
};
|
|
19380
19381
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [1]", params);
|
|
@@ -19393,7 +19394,7 @@ var SenseiVault = class extends BaseStrategy {
|
|
|
19393
19394
|
Web3Number.fromWei(firstQuote.buyAmount.toString(), 18).toFixed(
|
|
19394
19395
|
6
|
|
19395
19396
|
)
|
|
19396
|
-
);
|
|
19397
|
+
) / AMOUNT;
|
|
19397
19398
|
logger.verbose("getSecondaryTokenPriceRelativeToMain [2]", price);
|
|
19398
19399
|
this.setCache(CACHE_KEY, price);
|
|
19399
19400
|
return price;
|
|
@@ -30932,7 +30933,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
30932
30933
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
30933
30934
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
30934
30935
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
30935
|
-
const vesuAdapter = allVesuAdapters.find((adapter) =>
|
|
30936
|
+
const vesuAdapter = allVesuAdapters.find((adapter) => {
|
|
30937
|
+
const isDebtTokenMatch = adapter.config.debt.address.eq(maxBorrowable.borrowableAsset.address);
|
|
30938
|
+
const isPoolIdMatch = adapter.config.poolId.eq(maxBorrowable.poolId);
|
|
30939
|
+
return isDebtTokenMatch && isPoolIdMatch;
|
|
30940
|
+
});
|
|
30936
30941
|
if (!vesuAdapter) {
|
|
30937
30942
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
30938
30943
|
}
|
|
@@ -31023,7 +31028,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31023
31028
|
return calls[0];
|
|
31024
31029
|
}
|
|
31025
31030
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31026
|
-
const STEP0 =
|
|
31031
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31027
31032
|
const manage0Info = this.getProofs(STEP0);
|
|
31028
31033
|
const manageCall0 = manage0Info.callConstructor({
|
|
31029
31034
|
amount: newDepositAmount
|
|
@@ -31078,7 +31083,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31078
31083
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31079
31084
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31080
31085
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31081
|
-
const STEP4 =
|
|
31086
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31082
31087
|
const manage4Info = this.getProofs(STEP4);
|
|
31083
31088
|
const manageCall4 = manage4Info.callConstructor({
|
|
31084
31089
|
amount: minAmount
|
|
@@ -31237,7 +31242,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31237
31242
|
for (const vesuAdapter of vesuAdapters) {
|
|
31238
31243
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31239
31244
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31240
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31245
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31241
31246
|
}
|
|
31242
31247
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31243
31248
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31507,6 +31512,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31507
31512
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31508
31513
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31509
31514
|
}
|
|
31515
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31516
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31517
|
+
}
|
|
31510
31518
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31511
31519
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31512
31520
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31531,7 +31539,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31531
31539
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31532
31540
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31533
31541
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31534
|
-
|
|
31542
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31543
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31535
31544
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31536
31545
|
return vesuAdapterLST;
|
|
31537
31546
|
}
|
|
@@ -31644,13 +31653,13 @@ var hyperxSTRK = {
|
|
|
31644
31653
|
targetHealthFactor: 1.1,
|
|
31645
31654
|
minHealthFactor: 1.05,
|
|
31646
31655
|
borrowable_assets: [
|
|
31647
|
-
...Global.getDefaultTokens().filter(
|
|
31656
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31648
31657
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31649
31658
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31650
31659
|
// v2, new alt for Re7xSTRK
|
|
31651
31660
|
],
|
|
31652
31661
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31653
|
-
defaultPoolId: VesuPools.
|
|
31662
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31654
31663
|
};
|
|
31655
31664
|
var hyperxWBTC = {
|
|
31656
31665
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/package.json
CHANGED
package/src/strategies/sensei.ts
CHANGED
|
@@ -208,10 +208,11 @@ export class SenseiVault extends BaseStrategy<
|
|
|
208
208
|
const existingCacheData = this.getCache<number>(CACHE_KEY);
|
|
209
209
|
if (existingCacheData) return existingCacheData;
|
|
210
210
|
|
|
211
|
+
let AMOUNT = 100;
|
|
211
212
|
const params: QuoteRequest = {
|
|
212
213
|
sellTokenAddress: this.metadata.additionalInfo.secondaryToken.address.address,
|
|
213
214
|
buyTokenAddress: this.metadata.additionalInfo.mainToken.address.address,
|
|
214
|
-
sellAmount: BigInt(new Web3Number(
|
|
215
|
+
sellAmount: BigInt(new Web3Number(AMOUNT.toString(), 18).toWei()),
|
|
215
216
|
takerAddress: this.address.address,
|
|
216
217
|
};
|
|
217
218
|
logger.verbose('getSecondaryTokenPriceRelativeToMain [1]', params);
|
|
@@ -231,7 +232,7 @@ export class SenseiVault extends BaseStrategy<
|
|
|
231
232
|
Web3Number.fromWei(firstQuote.buyAmount.toString(), 18).toFixed(
|
|
232
233
|
6,
|
|
233
234
|
),
|
|
234
|
-
);
|
|
235
|
+
) / AMOUNT;
|
|
235
236
|
logger.verbose('getSecondaryTokenPriceRelativeToMain [2]', price);
|
|
236
237
|
this.setCache(CACHE_KEY, price); // cache for 1 min
|
|
237
238
|
return price;
|
|
@@ -117,7 +117,11 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
117
117
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
118
118
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
119
119
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
120
|
-
const vesuAdapter = allVesuAdapters.find(adapter =>
|
|
120
|
+
const vesuAdapter = allVesuAdapters.find(adapter => {
|
|
121
|
+
const isDebtTokenMatch = adapter.config.debt.address.eq(maxBorrowable.borrowableAsset.address);
|
|
122
|
+
const isPoolIdMatch = adapter.config.poolId.eq(maxBorrowable.poolId);
|
|
123
|
+
return isDebtTokenMatch && isPoolIdMatch;
|
|
124
|
+
});
|
|
121
125
|
if (!vesuAdapter) {
|
|
122
126
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
123
127
|
}
|
|
@@ -233,7 +237,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
233
237
|
return calls[0];
|
|
234
238
|
}
|
|
235
239
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
236
|
-
const STEP0 =
|
|
240
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
237
241
|
const manage0Info = this.getProofs<ApproveCallParams>(STEP0);
|
|
238
242
|
const manageCall0 = manage0Info.callConstructor({
|
|
239
243
|
amount: newDepositAmount
|
|
@@ -298,7 +302,7 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
298
302
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
299
303
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
300
304
|
// approve and add collateral on vesu (modify position)
|
|
301
|
-
const STEP4 =
|
|
305
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
302
306
|
const manage4Info = this.getProofs<ApproveCallParams>(STEP4);
|
|
303
307
|
const manageCall4 = manage4Info.callConstructor({
|
|
304
308
|
amount: minAmount
|
|
@@ -526,11 +530,11 @@ export class UniversalLstMultiplierStrategy extends UniversalStrategy<HyperLSTSt
|
|
|
526
530
|
async getMaxBorrowableAmount(params: { isAPYComputation: boolean } = { isAPYComputation: false }) {
|
|
527
531
|
const vesuAdapters = this.getVesuAdapters();
|
|
528
532
|
let netMaxBorrowableAmount = Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals);
|
|
529
|
-
const maxBorrowables: {amount: Web3Number, dexSwappableAmount: Web3Number, maxBorrowableAmount: Web3Number, borrowableAsset: TokenInfo, ltv: number}[] = [];
|
|
533
|
+
const maxBorrowables: {amount: Web3Number, dexSwappableAmount: Web3Number, maxBorrowableAmount: Web3Number, borrowableAsset: TokenInfo, ltv: number, poolId: ContractAddr}[] = [];
|
|
530
534
|
for (const vesuAdapter of vesuAdapters) {
|
|
531
535
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
532
536
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
533
|
-
maxBorrowables.push({...output, ltv});
|
|
537
|
+
maxBorrowables.push({...output, ltv, poolId: vesuAdapter.config.poolId});
|
|
534
538
|
}
|
|
535
539
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
536
540
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -880,6 +884,10 @@ function getVesuLegId(baseID: string, debtTokenSymbol: string, poolId: string) {
|
|
|
880
884
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
881
885
|
}
|
|
882
886
|
|
|
887
|
+
function getApproveLegId(tokenSymbol: string, spender: ContractAddr) {
|
|
888
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
889
|
+
}
|
|
890
|
+
|
|
883
891
|
function addVesuLeaves(
|
|
884
892
|
poolId: ContractAddr,
|
|
885
893
|
lstSymbol: string,
|
|
@@ -924,7 +932,8 @@ function addVesuLeaves(
|
|
|
924
932
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
925
933
|
|
|
926
934
|
// direct modify position stuff
|
|
927
|
-
|
|
935
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
936
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
928
937
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
929
938
|
|
|
930
939
|
return vesuAdapterLST;
|
|
@@ -1069,12 +1078,12 @@ const hyperxSTRK: HyperLSTStrategySettings = {
|
|
|
1069
1078
|
targetHealthFactor: 1.1,
|
|
1070
1079
|
minHealthFactor: 1.05,
|
|
1071
1080
|
borrowable_assets: [
|
|
1072
|
-
...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
1081
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
1073
1082
|
...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Prime })),
|
|
1074
1083
|
...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7STRK })), // v2, new alt for Re7xSTRK
|
|
1075
1084
|
],
|
|
1076
1085
|
underlyingToken: Global.getDefaultTokens().find(token => token.symbol === 'STRK')!,
|
|
1077
|
-
defaultPoolId: VesuPools.
|
|
1086
|
+
defaultPoolId: VesuPools.Re7STRK,
|
|
1078
1087
|
}
|
|
1079
1088
|
|
|
1080
1089
|
const hyperxWBTC: HyperLSTStrategySettings = {
|