@strkfarm/sdk 1.1.78 → 1.1.80
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 +15 -7
- package/dist/index.browser.mjs +15 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -7
- package/dist/index.mjs +15 -7
- package/package.json +1 -1
- package/src/strategies/universal-lst-muliplier-strategy.tsx +17 -8
|
@@ -95057,7 +95057,11 @@ spurious results.`);
|
|
|
95057
95057
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
95058
95058
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
95059
95059
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
95060
|
-
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
|
+
});
|
|
95061
95065
|
if (!vesuAdapter) {
|
|
95062
95066
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
95063
95067
|
}
|
|
@@ -95148,7 +95152,7 @@ spurious results.`);
|
|
|
95148
95152
|
return calls[0];
|
|
95149
95153
|
}
|
|
95150
95154
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
95151
|
-
const STEP0 =
|
|
95155
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
95152
95156
|
const manage0Info = this.getProofs(STEP0);
|
|
95153
95157
|
const manageCall0 = manage0Info.callConstructor({
|
|
95154
95158
|
amount: newDepositAmount
|
|
@@ -95203,7 +95207,7 @@ spurious results.`);
|
|
|
95203
95207
|
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
95204
95208
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
95205
95209
|
logger2.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
95206
|
-
const STEP4 =
|
|
95210
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
95207
95211
|
const manage4Info = this.getProofs(STEP4);
|
|
95208
95212
|
const manageCall4 = manage4Info.callConstructor({
|
|
95209
95213
|
amount: minAmount
|
|
@@ -95362,7 +95366,7 @@ spurious results.`);
|
|
|
95362
95366
|
for (const vesuAdapter of vesuAdapters) {
|
|
95363
95367
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
95364
95368
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
95365
|
-
maxBorrowables.push({ ...output, ltv });
|
|
95369
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
95366
95370
|
}
|
|
95367
95371
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
95368
95372
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -95632,6 +95636,9 @@ spurious results.`);
|
|
|
95632
95636
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
95633
95637
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
95634
95638
|
}
|
|
95639
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
95640
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
95641
|
+
}
|
|
95635
95642
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
95636
95643
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
95637
95644
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -95656,7 +95663,8 @@ spurious results.`);
|
|
|
95656
95663
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
95657
95664
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
95658
95665
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
95659
|
-
|
|
95666
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
95667
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
95660
95668
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
95661
95669
|
return vesuAdapterLST;
|
|
95662
95670
|
}
|
|
@@ -95769,13 +95777,13 @@ spurious results.`);
|
|
|
95769
95777
|
targetHealthFactor: 1.1,
|
|
95770
95778
|
minHealthFactor: 1.05,
|
|
95771
95779
|
borrowable_assets: [
|
|
95772
|
-
...Global.getDefaultTokens().filter(
|
|
95780
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
95773
95781
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
95774
95782
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
95775
95783
|
// v2, new alt for Re7xSTRK
|
|
95776
95784
|
],
|
|
95777
95785
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
95778
|
-
defaultPoolId: VesuPools.
|
|
95786
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
95779
95787
|
};
|
|
95780
95788
|
var hyperxWBTC = {
|
|
95781
95789
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/dist/index.browser.mjs
CHANGED
|
@@ -31035,7 +31035,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31035
31035
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
31036
31036
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
31037
31037
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
31038
|
-
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
|
+
});
|
|
31039
31043
|
if (!vesuAdapter) {
|
|
31040
31044
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
31041
31045
|
}
|
|
@@ -31126,7 +31130,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31126
31130
|
return calls[0];
|
|
31127
31131
|
}
|
|
31128
31132
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31129
|
-
const STEP0 =
|
|
31133
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31130
31134
|
const manage0Info = this.getProofs(STEP0);
|
|
31131
31135
|
const manageCall0 = manage0Info.callConstructor({
|
|
31132
31136
|
amount: newDepositAmount
|
|
@@ -31181,7 +31185,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31181
31185
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31182
31186
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31183
31187
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31184
|
-
const STEP4 =
|
|
31188
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31185
31189
|
const manage4Info = this.getProofs(STEP4);
|
|
31186
31190
|
const manageCall4 = manage4Info.callConstructor({
|
|
31187
31191
|
amount: minAmount
|
|
@@ -31340,7 +31344,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31340
31344
|
for (const vesuAdapter of vesuAdapters) {
|
|
31341
31345
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31342
31346
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31343
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31347
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31344
31348
|
}
|
|
31345
31349
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31346
31350
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31610,6 +31614,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31610
31614
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31611
31615
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31612
31616
|
}
|
|
31617
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31618
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31619
|
+
}
|
|
31613
31620
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31614
31621
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31615
31622
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31634,7 +31641,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31634
31641
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31635
31642
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31636
31643
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31637
|
-
|
|
31644
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31645
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31638
31646
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31639
31647
|
return vesuAdapterLST;
|
|
31640
31648
|
}
|
|
@@ -31747,13 +31755,13 @@ var hyperxSTRK = {
|
|
|
31747
31755
|
targetHealthFactor: 1.1,
|
|
31748
31756
|
minHealthFactor: 1.05,
|
|
31749
31757
|
borrowable_assets: [
|
|
31750
|
-
...Global.getDefaultTokens().filter(
|
|
31758
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31751
31759
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31752
31760
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31753
31761
|
// v2, new alt for Re7xSTRK
|
|
31754
31762
|
],
|
|
31755
31763
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31756
|
-
defaultPoolId: VesuPools.
|
|
31764
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31757
31765
|
};
|
|
31758
31766
|
var hyperxWBTC = {
|
|
31759
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
|
@@ -31036,7 +31036,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31036
31036
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
31037
31037
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
31038
31038
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
31039
|
-
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
|
+
});
|
|
31040
31044
|
if (!vesuAdapter) {
|
|
31041
31045
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
31042
31046
|
}
|
|
@@ -31127,7 +31131,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31127
31131
|
return calls[0];
|
|
31128
31132
|
}
|
|
31129
31133
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31130
|
-
const STEP0 =
|
|
31134
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31131
31135
|
const manage0Info = this.getProofs(STEP0);
|
|
31132
31136
|
const manageCall0 = manage0Info.callConstructor({
|
|
31133
31137
|
amount: newDepositAmount
|
|
@@ -31182,7 +31186,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31182
31186
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31183
31187
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31184
31188
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31185
|
-
const STEP4 =
|
|
31189
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31186
31190
|
const manage4Info = this.getProofs(STEP4);
|
|
31187
31191
|
const manageCall4 = manage4Info.callConstructor({
|
|
31188
31192
|
amount: minAmount
|
|
@@ -31341,7 +31345,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31341
31345
|
for (const vesuAdapter of vesuAdapters) {
|
|
31342
31346
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31343
31347
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31344
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31348
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31345
31349
|
}
|
|
31346
31350
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31347
31351
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31611,6 +31615,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31611
31615
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31612
31616
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31613
31617
|
}
|
|
31618
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31619
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31620
|
+
}
|
|
31614
31621
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31615
31622
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31616
31623
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31635,7 +31642,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31635
31642
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31636
31643
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31637
31644
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31638
|
-
|
|
31645
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31646
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31639
31647
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31640
31648
|
return vesuAdapterLST;
|
|
31641
31649
|
}
|
|
@@ -31748,13 +31756,13 @@ var hyperxSTRK = {
|
|
|
31748
31756
|
targetHealthFactor: 1.1,
|
|
31749
31757
|
minHealthFactor: 1.05,
|
|
31750
31758
|
borrowable_assets: [
|
|
31751
|
-
...Global.getDefaultTokens().filter(
|
|
31759
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31752
31760
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31753
31761
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31754
31762
|
// v2, new alt for Re7xSTRK
|
|
31755
31763
|
],
|
|
31756
31764
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31757
|
-
defaultPoolId: VesuPools.
|
|
31765
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31758
31766
|
};
|
|
31759
31767
|
var hyperxWBTC = {
|
|
31760
31768
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/dist/index.mjs
CHANGED
|
@@ -30933,7 +30933,11 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
30933
30933
|
const lstPrice = baseAssetPrice.price * lstExRate;
|
|
30934
30934
|
for (let i = 0; i < maxBorrowableAmounts.maxBorrowables.length; i++) {
|
|
30935
30935
|
const maxBorrowable = maxBorrowableAmounts.maxBorrowables[i];
|
|
30936
|
-
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
|
+
});
|
|
30937
30941
|
if (!vesuAdapter) {
|
|
30938
30942
|
throw new Error(`${this.getTag()}::getAvnuSwapMultiplyCall: vesuAdapter not found for borrowable asset: ${maxBorrowable.borrowableAsset.symbol}`);
|
|
30939
30943
|
}
|
|
@@ -31024,7 +31028,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31024
31028
|
return calls[0];
|
|
31025
31029
|
}
|
|
31026
31030
|
console.log(`debtAmount`, debtAmount.toWei(), params.leg1DepositAmount.toWei());
|
|
31027
|
-
const STEP0 =
|
|
31031
|
+
const STEP0 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31028
31032
|
const manage0Info = this.getProofs(STEP0);
|
|
31029
31033
|
const manageCall0 = manage0Info.callConstructor({
|
|
31030
31034
|
amount: newDepositAmount
|
|
@@ -31079,7 +31083,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31079
31083
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF: ${newHF}`);
|
|
31080
31084
|
if (newHF > this.metadata.additionalInfo.minHealthFactor && newHF < this.metadata.additionalInfo.targetHealthFactor + 0.05) {
|
|
31081
31085
|
logger.verbose(`${this.getTag()}::_getAvnuDepositSwapLegCall newHF is above min and below target + 0.05, adding collateral on vesu`);
|
|
31082
|
-
const STEP4 =
|
|
31086
|
+
const STEP4 = getApproveLegId(vesuAdapter.config.collateral.symbol, vesuAdapter.config.poolId);
|
|
31083
31087
|
const manage4Info = this.getProofs(STEP4);
|
|
31084
31088
|
const manageCall4 = manage4Info.callConstructor({
|
|
31085
31089
|
amount: minAmount
|
|
@@ -31238,7 +31242,7 @@ var UniversalLstMultiplierStrategy = class _UniversalLstMultiplierStrategy exten
|
|
|
31238
31242
|
for (const vesuAdapter of vesuAdapters) {
|
|
31239
31243
|
const output = await this.getMaxBorrowableAmountByVesuAdapter(vesuAdapter, params.isAPYComputation);
|
|
31240
31244
|
const ltv = await vesuAdapter.getLTVConfig(this.config);
|
|
31241
|
-
maxBorrowables.push({ ...output, ltv });
|
|
31245
|
+
maxBorrowables.push({ ...output, ltv, poolId: vesuAdapter.config.poolId });
|
|
31242
31246
|
}
|
|
31243
31247
|
maxBorrowables.sort((a, b) => b.amount.toNumber() - a.amount.toNumber());
|
|
31244
31248
|
netMaxBorrowableAmount = maxBorrowables.reduce((acc, curr) => acc.plus(curr.amount), Web3Number.fromWei("0", this.getLSTUnderlyingTokenInfo().decimals));
|
|
@@ -31508,6 +31512,9 @@ function getVesuGenericLegId(poolId, action) {
|
|
|
31508
31512
|
function getVesuLegId(baseID, debtTokenSymbol, poolId) {
|
|
31509
31513
|
return `${baseID}_${debtTokenSymbol.toLowerCase()}_${poolId.slice(-4).toLowerCase()}`;
|
|
31510
31514
|
}
|
|
31515
|
+
function getApproveLegId(tokenSymbol, spender) {
|
|
31516
|
+
return `appr_${tokenSymbol.toLowerCase()}_${spender.toString().slice(-4).toLowerCase()}`;
|
|
31517
|
+
}
|
|
31511
31518
|
function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commonAdapter) {
|
|
31512
31519
|
const lstToken = Global.getDefaultTokens().find((token) => token.symbol === lstSymbol);
|
|
31513
31520
|
const underlyingToken = Global.getDefaultTokens().find((token) => token.symbol === underlyingSymbol);
|
|
@@ -31532,7 +31539,8 @@ function addVesuLeaves(poolId, lstSymbol, underlyingSymbol, vaultSettings, commo
|
|
|
31532
31539
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getVesuModifyDelegationAdapter(leafIdDelegationOff, VESU_MULTIPLY).bind(vesuAdapterLST));
|
|
31533
31540
|
const multiplID = getVesuLegId("multiply_vesu" /* MULTIPLY_VESU */, underlyingToken.symbol, poolId.toString());
|
|
31534
31541
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getMultiplyAdapter(multiplID).bind(vesuAdapterLST));
|
|
31535
|
-
|
|
31542
|
+
const approveLegId = getApproveLegId(lstToken.symbol, poolAddr);
|
|
31543
|
+
vaultSettings.leafAdapters.push(commonAdapter.getApproveAdapter(lstToken.address, poolAddr, approveLegId).bind(commonAdapter));
|
|
31536
31544
|
vaultSettings.leafAdapters.push(vesuAdapterLST.getModifyPosition.bind(vesuAdapterLST));
|
|
31537
31545
|
return vesuAdapterLST;
|
|
31538
31546
|
}
|
|
@@ -31645,13 +31653,13 @@ var hyperxSTRK = {
|
|
|
31645
31653
|
targetHealthFactor: 1.1,
|
|
31646
31654
|
minHealthFactor: 1.05,
|
|
31647
31655
|
borrowable_assets: [
|
|
31648
|
-
...Global.getDefaultTokens().filter(
|
|
31656
|
+
// ...Global.getDefaultTokens().filter(token => token.symbol === 'STRK').map(token => ({ token, poolId: VesuPools.Re7xSTRK })),
|
|
31649
31657
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Prime })),
|
|
31650
31658
|
...Global.getDefaultTokens().filter((token) => token.symbol === "STRK").map((token) => ({ token, poolId: VesuPools.Re7STRK }))
|
|
31651
31659
|
// v2, new alt for Re7xSTRK
|
|
31652
31660
|
],
|
|
31653
31661
|
underlyingToken: Global.getDefaultTokens().find((token) => token.symbol === "STRK"),
|
|
31654
|
-
defaultPoolId: VesuPools.
|
|
31662
|
+
defaultPoolId: VesuPools.Re7STRK
|
|
31655
31663
|
};
|
|
31656
31664
|
var hyperxWBTC = {
|
|
31657
31665
|
vaultAddress: ContractAddr.from("0x2da9d0f96a46b453f55604313785dc866424240b1c6811d13bef594343db818"),
|
package/package.json
CHANGED
|
@@ -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 = {
|