@kamino-finance/klend-sdk 5.11.0-beta.0 → 5.11.1
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/classes/action.d.ts +16 -17
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +61 -102
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/manager.d.ts +16 -4
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +28 -3
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts +6 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +4 -2
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +2 -2
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +15 -11
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/types.d.ts +4 -0
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +1 -2
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +18 -4
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +87 -30
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +8 -3
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +199 -152
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +15 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +11 -1
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +18 -2
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +31 -3
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/borrowObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts +52 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js +219 -0
- package/dist/idl_codegen/instructions/depositAndWithdraw.js.map +1 -0
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +2 -2
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +3 -3
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/initObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.d.ts +1 -0
- package/dist/idl_codegen/instructions/initReserve.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/initReserve.js +5 -0
- package/dist/idl_codegen/instructions/initReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js +2 -2
- package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js +1 -1
- package/dist/idl_codegen/instructions/redeemFees.js.map +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/redeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js +1 -1
- package/dist/idl_codegen/instructions/refreshObligationFarmsForReserve.js.map +1 -1
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js +2 -2
- package/dist/idl_codegen/instructions/repayAndWithdrawAndRedeem.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidity.js.map +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js +1 -1
- package/dist/idl_codegen/instructions/repayObligationLiquidityV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js +1 -1
- package/dist/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js +1 -1
- package/dist/idl_codegen/instructions/withdrawReferrerFees.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +25 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +2 -2
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +10 -4
- package/dist/idl_codegen/zero_padding/ObligationZP.d.ts.map +1 -1
- package/dist/idl_codegen/zero_padding/ObligationZP.js +9 -7
- package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +3 -0
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +7 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +25 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +43 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +13 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +25 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +5 -3
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +1 -1
- package/dist/leverage/calcs.d.ts.map +1 -1
- package/dist/leverage/calcs.js +12 -10
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/instructions.d.ts +1 -2
- package/dist/leverage/instructions.d.ts.map +1 -1
- package/dist/leverage/instructions.js +2 -6
- package/dist/leverage/instructions.js.map +1 -1
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +19 -13
- package/dist/leverage/operations.js.map +1 -1
- package/dist/utils/ata.d.ts +1 -1
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +2 -2
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/constants.d.ts +5 -9
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +6 -10
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +1 -3
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/managerTypes.d.ts +1 -0
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +2 -1
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +7 -7
- package/src/classes/action.ts +77 -105
- package/src/classes/manager.ts +35 -3
- package/src/classes/obligation.ts +8 -4
- package/src/classes/reserve.ts +16 -13
- package/src/classes/types.ts +5 -0
- package/src/classes/utils.ts +3 -3
- package/src/classes/vault.ts +103 -45
- package/src/client_kamino_manager.ts +10 -3
- package/src/idl.json +199 -152
- package/src/idl_codegen/accounts/LendingMarket.ts +21 -1
- package/src/idl_codegen/errors/custom.ts +39 -2
- package/src/idl_codegen/instructions/borrowObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/borrowObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/depositAndWithdraw.ts +241 -0
- package/src/idl_codegen/instructions/depositReserveLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateral.ts +1 -1
- package/src/idl_codegen/instructions/depositReserveLiquidityAndObligationCollateralV2.ts +1 -1
- package/src/idl_codegen/instructions/index.ts +4 -4
- package/src/idl_codegen/instructions/initFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/initReserve.ts +6 -0
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.ts +2 -2
- package/src/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateralV2.ts +2 -2
- package/src/idl_codegen/instructions/redeemFees.ts +1 -1
- package/src/idl_codegen/instructions/redeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/refreshObligationFarmsForReserve.ts +1 -1
- package/src/idl_codegen/instructions/repayAndWithdrawAndRedeem.ts +2 -2
- package/src/idl_codegen/instructions/repayObligationLiquidity.ts +1 -1
- package/src/idl_codegen/instructions/repayObligationLiquidityV2.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateral.ts +1 -1
- package/src/idl_codegen/instructions/withdrawObligationCollateralAndRedeemReserveCollateralV2.ts +1 -1
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +1 -1
- package/src/idl_codegen/instructions/withdrawReferrerFees.ts +1 -1
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +30 -0
- package/src/idl_codegen/types/index.ts +2 -0
- package/src/idl_codegen/zero_padding/ObligationZP.ts +12 -6
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +9 -1
- package/src/idl_codegen_kamino_vault/errors/custom.ts +42 -0
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +2 -0
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +30 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +2 -0
- package/src/idl_kamino_vault.json +30 -3
- package/src/lending_operations/repay_with_collateral_operations.ts +1 -0
- package/src/lending_operations/swap_collateral_operations.ts +6 -5
- package/src/leverage/calcs.ts +16 -13
- package/src/leverage/instructions.ts +1 -6
- package/src/leverage/operations.ts +28 -18
- package/src/utils/ata.ts +1 -1
- package/src/utils/constants.ts +6 -11
- package/src/utils/instruction.ts +1 -3
- package/src/utils/managerTypes.ts +1 -0
- package/src/utils/userMetadata.ts +2 -2
package/src/classes/reserve.ts
CHANGED
|
@@ -1134,6 +1134,7 @@ const truncateBorrowCurve = (points: CurvePointFields[]): [number, number][] =>
|
|
|
1134
1134
|
export async function createReserveIxs(
|
|
1135
1135
|
connection: Connection,
|
|
1136
1136
|
owner: PublicKey,
|
|
1137
|
+
ownerLiquiditySource: PublicKey,
|
|
1137
1138
|
lendingMarket: PublicKey,
|
|
1138
1139
|
liquidityMint: PublicKey,
|
|
1139
1140
|
reserveAddress: PublicKey,
|
|
@@ -1166,6 +1167,7 @@ export async function createReserveIxs(
|
|
|
1166
1167
|
feeReceiver: feeVault,
|
|
1167
1168
|
reserveCollateralMint: collateralMint,
|
|
1168
1169
|
reserveCollateralSupply: collateralSupplyVault,
|
|
1170
|
+
initialLiquiditySource: ownerLiquiditySource,
|
|
1169
1171
|
liquidityTokenProgram: TOKEN_PROGRAM_ID,
|
|
1170
1172
|
collateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
1171
1173
|
systemProgram: SystemProgram.programId,
|
|
@@ -1537,7 +1539,7 @@ function handleConfigUpdate(
|
|
|
1537
1539
|
mode: UpdateConfigMode.UpdateDepositLimit.discriminator,
|
|
1538
1540
|
value: updateReserveConfigEncodedValue(
|
|
1539
1541
|
UpdateConfigMode.UpdateDepositLimit.discriminator,
|
|
1540
|
-
reserveConfig.depositLimit.
|
|
1542
|
+
BigInt(reserveConfig.depositLimit.toString())
|
|
1541
1543
|
),
|
|
1542
1544
|
});
|
|
1543
1545
|
} else if (!reserve.config.depositLimit.eq(reserveConfig.depositLimit)) {
|
|
@@ -1545,7 +1547,7 @@ function handleConfigUpdate(
|
|
|
1545
1547
|
mode: UpdateConfigMode.UpdateDepositLimit.discriminator,
|
|
1546
1548
|
value: updateReserveConfigEncodedValue(
|
|
1547
1549
|
UpdateConfigMode.UpdateDepositLimit.discriminator,
|
|
1548
|
-
reserveConfig.depositLimit.
|
|
1550
|
+
BigInt(reserveConfig.depositLimit.toString())
|
|
1549
1551
|
),
|
|
1550
1552
|
});
|
|
1551
1553
|
}
|
|
@@ -1556,7 +1558,7 @@ function handleConfigUpdate(
|
|
|
1556
1558
|
mode: UpdateConfigMode.UpdateBorrowLimit.discriminator,
|
|
1557
1559
|
value: updateReserveConfigEncodedValue(
|
|
1558
1560
|
UpdateConfigMode.UpdateBorrowLimit.discriminator,
|
|
1559
|
-
reserveConfig.borrowLimit.
|
|
1561
|
+
BigInt(reserveConfig.borrowLimit.toString())
|
|
1560
1562
|
),
|
|
1561
1563
|
});
|
|
1562
1564
|
} else if (!reserve.config.borrowLimit.eq(reserveConfig.borrowLimit)) {
|
|
@@ -1564,7 +1566,7 @@ function handleConfigUpdate(
|
|
|
1564
1566
|
mode: UpdateConfigMode.UpdateBorrowLimit.discriminator,
|
|
1565
1567
|
value: updateReserveConfigEncodedValue(
|
|
1566
1568
|
UpdateConfigMode.UpdateBorrowLimit.discriminator,
|
|
1567
|
-
reserveConfig.borrowLimit.
|
|
1569
|
+
BigInt(reserveConfig.borrowLimit.toString())
|
|
1568
1570
|
),
|
|
1569
1571
|
});
|
|
1570
1572
|
}
|
|
@@ -1976,15 +1978,12 @@ function handleConfigUpdate(
|
|
|
1976
1978
|
reserveConfig.borrowLimitOutsideElevationGroup.toNumber()
|
|
1977
1979
|
),
|
|
1978
1980
|
});
|
|
1979
|
-
} else if (
|
|
1980
|
-
reserve.config.borrowLimitOutsideElevationGroup.toNumber() !==
|
|
1981
|
-
reserveConfig.borrowLimitOutsideElevationGroup.toNumber()
|
|
1982
|
-
) {
|
|
1981
|
+
} else if (!reserve.config.borrowLimitOutsideElevationGroup.eq(reserveConfig.borrowLimitOutsideElevationGroup)) {
|
|
1983
1982
|
updateReserveIxnsArgs.push({
|
|
1984
1983
|
mode: UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup.discriminator,
|
|
1985
1984
|
value: updateReserveConfigEncodedValue(
|
|
1986
1985
|
UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup.discriminator,
|
|
1987
|
-
reserveConfig.borrowLimitOutsideElevationGroup.
|
|
1986
|
+
BigInt(reserveConfig.borrowLimitOutsideElevationGroup.toString())
|
|
1988
1987
|
),
|
|
1989
1988
|
});
|
|
1990
1989
|
}
|
|
@@ -2106,7 +2105,7 @@ export function parseForChangesReserveConfigAndGetIxs(
|
|
|
2106
2105
|
|
|
2107
2106
|
export function updateReserveConfigEncodedValue(
|
|
2108
2107
|
discriminator: number,
|
|
2109
|
-
value: number | number[] | BorrowRateCurve | PublicKey
|
|
2108
|
+
value: number | number[] | bigint | BorrowRateCurve | PublicKey
|
|
2110
2109
|
): Uint8Array {
|
|
2111
2110
|
let buffer: Buffer;
|
|
2112
2111
|
let valueArray: number[] = [];
|
|
@@ -2133,8 +2132,6 @@ export function updateReserveConfigEncodedValue(
|
|
|
2133
2132
|
break;
|
|
2134
2133
|
case UpdateConfigMode.UpdateFeesBorrowFee.discriminator:
|
|
2135
2134
|
case UpdateConfigMode.UpdateFeesFlashLoanFee.discriminator:
|
|
2136
|
-
case UpdateConfigMode.UpdateDepositLimit.discriminator:
|
|
2137
|
-
case UpdateConfigMode.UpdateBorrowLimit.discriminator:
|
|
2138
2135
|
case UpdateConfigMode.UpdateTokenInfoLowerHeuristic.discriminator:
|
|
2139
2136
|
case UpdateConfigMode.UpdateTokenInfoUpperHeuristic.discriminator:
|
|
2140
2137
|
case UpdateConfigMode.UpdateTokenInfoExpHeuristic.discriminator:
|
|
@@ -2147,11 +2144,17 @@ export function updateReserveConfigEncodedValue(
|
|
|
2147
2144
|
case UpdateConfigMode.UpdateBorrowFactor.discriminator:
|
|
2148
2145
|
case UpdateConfigMode.UpdateDeleveragingThresholdDecreaseBpsPerDay.discriminator:
|
|
2149
2146
|
case UpdateConfigMode.UpdateDeleveragingBonusIncreaseBpsPerDay.discriminator:
|
|
2150
|
-
case UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup.discriminator:
|
|
2151
2147
|
value = value as number;
|
|
2152
2148
|
buffer = Buffer.alloc(8);
|
|
2153
2149
|
buffer.writeBigUint64LE(BigInt(value), 0);
|
|
2154
2150
|
break;
|
|
2151
|
+
case UpdateConfigMode.UpdateDepositLimit.discriminator:
|
|
2152
|
+
case UpdateConfigMode.UpdateBorrowLimit.discriminator:
|
|
2153
|
+
case UpdateConfigMode.UpdateBorrowLimitOutsideElevationGroup.discriminator:
|
|
2154
|
+
value = value as bigint;
|
|
2155
|
+
buffer = Buffer.alloc(8);
|
|
2156
|
+
buffer.writeBigUint64LE(value, 0);
|
|
2157
|
+
break;
|
|
2155
2158
|
case UpdateConfigMode.UpdateTokenInfoScopeChain.discriminator:
|
|
2156
2159
|
case UpdateConfigMode.UpdateTokenInfoScopeTwap.discriminator:
|
|
2157
2160
|
valueArray = value as number[];
|
package/src/classes/types.ts
CHANGED
package/src/classes/utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PubkeyHashMap, SLOTS_PER_SECOND, SLOTS_PER_YEAR } from '../utils';
|
|
2
2
|
import Decimal from 'decimal.js';
|
|
3
3
|
import { AccountInfo, PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { MarketOverview, ReserveOverview
|
|
5
|
-
import { AccountLayout } from '@solana/spl-token';
|
|
4
|
+
import { MarketOverview, ReserveOverview } from '../lib';
|
|
5
|
+
import { AccountLayout, NATIVE_MINT } from '@solana/spl-token';
|
|
6
6
|
import { ReserveAllocationOverview } from './types';
|
|
7
7
|
import axios from 'axios';
|
|
8
8
|
|
|
@@ -188,7 +188,7 @@ export function lamportsToDecimal(amount: Decimal.Value, decimals: Decimal.Value
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
export const isSolMint = (mint: PublicKey): boolean => {
|
|
191
|
-
return
|
|
191
|
+
return NATIVE_MINT.equals(mint);
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
export const valueOrZero = (value: Decimal): Decimal => {
|
package/src/classes/vault.ts
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
SYSVAR_RENT_PUBKEY,
|
|
12
12
|
TransactionInstruction,
|
|
13
13
|
} from '@solana/web3.js';
|
|
14
|
-
import { TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
|
|
14
|
+
import { getAssociatedTokenAddressSync, NATIVE_MINT, TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
|
|
15
15
|
import {
|
|
16
16
|
getAssociatedTokenAddress,
|
|
17
|
-
|
|
17
|
+
getTransferWsolIxns,
|
|
18
18
|
getTokenOracleData,
|
|
19
19
|
KaminoMarket,
|
|
20
20
|
KaminoReserve,
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
PubkeyHashMap,
|
|
23
23
|
Reserve,
|
|
24
24
|
UserState,
|
|
25
|
-
WRAPPED_SOL_MINT,
|
|
26
25
|
} from '../lib';
|
|
27
26
|
import {
|
|
28
27
|
DepositAccounts,
|
|
@@ -70,6 +69,7 @@ import bs58 from 'bs58';
|
|
|
70
69
|
import { getAccountOwner, getProgramAccounts } from '../utils/rpc';
|
|
71
70
|
import {
|
|
72
71
|
AcceptVaultOwnershipIxs,
|
|
72
|
+
APYs,
|
|
73
73
|
DepositIxs,
|
|
74
74
|
InitVaultIxs,
|
|
75
75
|
ReserveAllocationOverview,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
UserSharesForVault,
|
|
80
80
|
WithdrawIxs,
|
|
81
81
|
} from './types';
|
|
82
|
-
import { collToLamportsDecimal, ZERO } from '@kamino-finance/kliquidity-sdk';
|
|
82
|
+
import { batchFetch, collToLamportsDecimal, ZERO } from '@kamino-finance/kliquidity-sdk';
|
|
83
83
|
import { FullBPSDecimal } from '@kamino-finance/kliquidity-sdk/dist/utils/CreationParameters';
|
|
84
84
|
import { FarmState } from '@kamino-finance/farms-sdk/dist';
|
|
85
85
|
import { getAccountsInLUT, initLookupTableIx } from './lut_utils';
|
|
@@ -98,7 +98,9 @@ export const kaminoVaultStagingId = new PublicKey('STkvh7ostar39Fwr4uZKASs1RNNuY
|
|
|
98
98
|
const TOKEN_VAULT_SEED = 'token_vault';
|
|
99
99
|
const CTOKEN_VAULT_SEED = 'ctoken_vault';
|
|
100
100
|
const BASE_VAULT_AUTHORITY_SEED = 'authority';
|
|
101
|
-
const
|
|
101
|
+
const SHARES_SEED = 'shares';
|
|
102
|
+
|
|
103
|
+
export const INITIAL_DEPOSIT_LAMPORTS = 1000;
|
|
102
104
|
|
|
103
105
|
/**
|
|
104
106
|
* KaminoVaultClient is a class that provides a high-level interface to interact with the Kamino Vault program.
|
|
@@ -191,10 +193,12 @@ export class KaminoVaultClient {
|
|
|
191
193
|
)[0];
|
|
192
194
|
|
|
193
195
|
const sharesMint = PublicKey.findProgramAddressSync(
|
|
194
|
-
[Buffer.from(
|
|
196
|
+
[Buffer.from(SHARES_SEED), vaultState.publicKey.toBytes()],
|
|
195
197
|
this._kaminoVaultProgramId
|
|
196
198
|
)[0];
|
|
197
199
|
|
|
200
|
+
const adminTokenAccount = getAssociatedTokenAddressSync(vaultConfig.tokenMint, vaultConfig.admin, false);
|
|
201
|
+
|
|
198
202
|
const initVaultAccounts: InitVaultAccounts = {
|
|
199
203
|
adminAuthority: vaultConfig.admin,
|
|
200
204
|
vaultState: vaultState.publicKey,
|
|
@@ -206,6 +210,7 @@ export class KaminoVaultClient {
|
|
|
206
210
|
rent: SYSVAR_RENT_PUBKEY,
|
|
207
211
|
tokenProgram: vaultConfig.tokenMintProgramId,
|
|
208
212
|
sharesTokenProgram: TOKEN_PROGRAM_ID,
|
|
213
|
+
adminTokenAccount,
|
|
209
214
|
};
|
|
210
215
|
const initVaultIx = initVault(initVaultAccounts, this._kaminoVaultProgramId);
|
|
211
216
|
|
|
@@ -288,7 +293,7 @@ export class KaminoVaultClient {
|
|
|
288
293
|
);
|
|
289
294
|
|
|
290
295
|
const updateReserveAllocationAccounts: UpdateReserveAllocationAccounts = {
|
|
291
|
-
|
|
296
|
+
signer: vaultState.adminAuthority,
|
|
292
297
|
vaultState: vault.address,
|
|
293
298
|
baseVaultAuthority: vaultState.baseVaultAuthority,
|
|
294
299
|
reserveCollateralMint: reserveState.collateral.mintPubkey,
|
|
@@ -694,20 +699,20 @@ export class KaminoVaultClient {
|
|
|
694
699
|
const userTokenAta = getAssociatedTokenAddress(vaultState.tokenMint, user, true, tokenProgramID);
|
|
695
700
|
const createAtasIxns: TransactionInstruction[] = [];
|
|
696
701
|
const closeAtasIxns: TransactionInstruction[] = [];
|
|
697
|
-
if (vaultState.tokenMint.equals(
|
|
702
|
+
if (vaultState.tokenMint.equals(NATIVE_MINT)) {
|
|
698
703
|
const [{ ata: wsolAta, createAtaIx: createWsolAtaIxn }] = createAtasIdempotent(user, [
|
|
699
704
|
{
|
|
700
|
-
mint:
|
|
705
|
+
mint: NATIVE_MINT,
|
|
701
706
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
702
707
|
},
|
|
703
708
|
]);
|
|
704
709
|
createAtasIxns.push(createWsolAtaIxn);
|
|
705
|
-
const
|
|
710
|
+
const transferWsolIxns = getTransferWsolIxns(
|
|
706
711
|
user,
|
|
707
712
|
wsolAta,
|
|
708
713
|
numberToLamportsDecimal(tokenAmount, vaultState.tokenMintDecimals.toNumber()).ceil()
|
|
709
714
|
);
|
|
710
|
-
createAtasIxns.push(...
|
|
715
|
+
createAtasIxns.push(...transferWsolIxns);
|
|
711
716
|
}
|
|
712
717
|
|
|
713
718
|
const [{ ata: userSharesAta, createAtaIx: createSharesAtaIxns }] = createAtasIdempotent(user, [
|
|
@@ -1005,25 +1010,23 @@ export class KaminoVaultClient {
|
|
|
1005
1010
|
*/
|
|
1006
1011
|
async investAllReservesIxs(payer: PublicKey, vault: KaminoVault): Promise<TransactionInstruction[]> {
|
|
1007
1012
|
const vaultState = await vault.getState(this.getConnection());
|
|
1013
|
+
const minInvestAmount = vaultState.minInvestAmount;
|
|
1008
1014
|
const allReserves = this.getVaultReserves(vaultState);
|
|
1009
1015
|
if (allReserves.length === 0) {
|
|
1010
1016
|
throw new Error('No reserves found for the vault, please select at least one reserve for the vault');
|
|
1011
1017
|
}
|
|
1012
|
-
|
|
1013
1018
|
const [allReservesStateMap, computedReservesAllocation] = await Promise.all([
|
|
1014
1019
|
this.loadVaultReserves(vaultState),
|
|
1015
1020
|
this.getVaultComputedReservesAllocation(vaultState),
|
|
1016
1021
|
]);
|
|
1017
|
-
|
|
1018
1022
|
const tokenProgram = await getAccountOwner(this.getConnection(), vaultState.tokenMint);
|
|
1019
1023
|
const [{ ata: _payerTokenAta, createAtaIx }] = createAtasIdempotent(payer, [
|
|
1020
1024
|
{ mint: vaultState.tokenMint, tokenProgram },
|
|
1021
1025
|
]);
|
|
1022
|
-
|
|
1023
1026
|
// compute total vault holdings and expected distribution based on weights
|
|
1024
1027
|
const curentVaultAllocations = this.getVaultAllocations(vaultState);
|
|
1025
|
-
|
|
1026
1028
|
const reservesToDisinvestFrom: PublicKey[] = [];
|
|
1029
|
+
const reservesToInvestInto: PublicKey[] = [];
|
|
1027
1030
|
|
|
1028
1031
|
for (let index = 0; index < allReserves.length; index++) {
|
|
1029
1032
|
const reservePubkey = allReserves[index];
|
|
@@ -1037,8 +1040,15 @@ export class KaminoVaultClient {
|
|
|
1037
1040
|
vaultState.tokenMintDecimals.toNumber()
|
|
1038
1041
|
);
|
|
1039
1042
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1043
|
+
const diffInReserveTokens = computedAllocation.sub(reserveAllocationLiquidityAmount);
|
|
1044
|
+
const diffInReserveLamports = collToLamportsDecimal(diffInReserveTokens, vaultState.tokenMintDecimals.toNumber());
|
|
1045
|
+
// if the diff for the reserve is smaller than the min invest amount, we do not need to invest or disinvest
|
|
1046
|
+
if (diffInReserveLamports.abs().gte(new Decimal(minInvestAmount.toString()))) {
|
|
1047
|
+
if (computedAllocation.lt(reserveAllocationLiquidityAmount)) {
|
|
1048
|
+
reservesToDisinvestFrom.push(reservePubkey);
|
|
1049
|
+
} else {
|
|
1050
|
+
reservesToInvestInto.push(reservePubkey);
|
|
1051
|
+
}
|
|
1042
1052
|
}
|
|
1043
1053
|
}
|
|
1044
1054
|
|
|
@@ -1062,24 +1072,22 @@ export class KaminoVaultClient {
|
|
|
1062
1072
|
investIxnsPromises.push(investIxsPromise);
|
|
1063
1073
|
}
|
|
1064
1074
|
|
|
1065
|
-
for (const reserve of
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
throw new Error(`Reserve ${reserve.toBase58()} not found`);
|
|
1070
|
-
}
|
|
1071
|
-
const investIxsPromise = this.investSingleReserveIxs(
|
|
1072
|
-
payer,
|
|
1073
|
-
vault,
|
|
1074
|
-
{
|
|
1075
|
-
address: reserve,
|
|
1076
|
-
state: reserveState!.state,
|
|
1077
|
-
},
|
|
1078
|
-
allReservesStateMap,
|
|
1079
|
-
false
|
|
1080
|
-
);
|
|
1081
|
-
investIxnsPromises.push(investIxsPromise);
|
|
1075
|
+
for (const reserve of reservesToInvestInto) {
|
|
1076
|
+
const reserveState = allReservesStateMap.get(reserve);
|
|
1077
|
+
if (reserveState === null) {
|
|
1078
|
+
throw new Error(`Reserve ${reserve.toBase58()} not found`);
|
|
1082
1079
|
}
|
|
1080
|
+
const investIxsPromise = this.investSingleReserveIxs(
|
|
1081
|
+
payer,
|
|
1082
|
+
vault,
|
|
1083
|
+
{
|
|
1084
|
+
address: reserve,
|
|
1085
|
+
state: reserveState!.state,
|
|
1086
|
+
},
|
|
1087
|
+
allReservesStateMap,
|
|
1088
|
+
false
|
|
1089
|
+
);
|
|
1090
|
+
investIxnsPromises.push(investIxsPromise);
|
|
1083
1091
|
}
|
|
1084
1092
|
|
|
1085
1093
|
let investIxns: TransactionInstruction[] = [];
|
|
@@ -1493,6 +1501,21 @@ export class KaminoVaultClient {
|
|
|
1493
1501
|
vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>,
|
|
1494
1502
|
currentSlot?: number
|
|
1495
1503
|
): Promise<PubkeyHashMap<PublicKey, Decimal>> {
|
|
1504
|
+
// if there are no vault reserves or all have weight 0 everything has to be in Available
|
|
1505
|
+
const allReservesPubkeys = this.getVaultReserves(vaultState);
|
|
1506
|
+
const reservesAllocations = this.getVaultAllocations(vaultState);
|
|
1507
|
+
const allReservesHaveWeight0 = allReservesPubkeys.every((reserve) => {
|
|
1508
|
+
const allocation = reservesAllocations.get(reserve);
|
|
1509
|
+
return allocation?.targetWeight.isZero();
|
|
1510
|
+
});
|
|
1511
|
+
if (allReservesPubkeys.length === 0 || allReservesHaveWeight0) {
|
|
1512
|
+
const computedHoldings = new PubkeyHashMap<PublicKey, Decimal>();
|
|
1513
|
+
allReservesPubkeys.forEach((reserve) => {
|
|
1514
|
+
computedHoldings.set(reserve, new Decimal(0));
|
|
1515
|
+
});
|
|
1516
|
+
return computedHoldings;
|
|
1517
|
+
}
|
|
1518
|
+
|
|
1496
1519
|
const holdings = await this.getVaultHoldings(vaultState, slot, vaultReserves, currentSlot);
|
|
1497
1520
|
const initialVaultAllocations = this.getVaultAllocations(vaultState);
|
|
1498
1521
|
|
|
@@ -1506,14 +1529,13 @@ export class KaminoVaultClient {
|
|
|
1506
1529
|
|
|
1507
1530
|
let totalLeftToInvest = holdings.totalAUMIncludingFees.sub(holdings.pendingFees);
|
|
1508
1531
|
let currentAllocationSum = totalAllocation;
|
|
1509
|
-
const
|
|
1510
|
-
while (totalLeftToInvest.gt(
|
|
1532
|
+
const ONE = new Decimal(1);
|
|
1533
|
+
while (totalLeftToInvest.gt(ONE)) {
|
|
1511
1534
|
const totalLeftover = totalLeftToInvest;
|
|
1512
1535
|
for (const reserve of allReserves) {
|
|
1513
1536
|
const reserveWithWeight = initialVaultAllocations.get(reserve);
|
|
1514
1537
|
const targetAllocation = reserveWithWeight!.targetWeight.mul(totalLeftover).div(currentAllocationSum);
|
|
1515
1538
|
const reserveCap = reserveWithWeight!.tokenAllocationCap;
|
|
1516
|
-
// todo: check if both target and reserveCap
|
|
1517
1539
|
const amountToInvest = Decimal.min(targetAllocation, reserveCap, totalLeftToInvest);
|
|
1518
1540
|
totalLeftToInvest = totalLeftToInvest.sub(amountToInvest);
|
|
1519
1541
|
if (amountToInvest.eq(reserveCap)) {
|
|
@@ -1749,6 +1771,26 @@ export class KaminoVaultClient {
|
|
|
1749
1771
|
});
|
|
1750
1772
|
}
|
|
1751
1773
|
|
|
1774
|
+
/**
|
|
1775
|
+
* Get a list of kaminoVaults
|
|
1776
|
+
* @param vaults - a list of vaults to get the states for; if not provided, all vaults will be fetched
|
|
1777
|
+
* @returns a list of vaults
|
|
1778
|
+
*/
|
|
1779
|
+
async getVaults(vaults?: Array<PublicKey>): Promise<Array<KaminoVault | null>> {
|
|
1780
|
+
if (!vaults) {
|
|
1781
|
+
vaults = (await this.getAllVaults()).map((x) => x.address);
|
|
1782
|
+
}
|
|
1783
|
+
const vaultStates = await batchFetch(vaults, (chunk) => this.getVaultsStates(chunk));
|
|
1784
|
+
return vaults.map((vault, index) => {
|
|
1785
|
+
const state = vaultStates[index];
|
|
1786
|
+
return state ? new KaminoVault(vault, state, this._kaminoVaultProgramId) : null;
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
|
|
1790
|
+
private async getVaultsStates(vaults: PublicKey[]): Promise<Array<VaultState | null>> {
|
|
1791
|
+
return await VaultState.fetchMultiple(this.getConnection(), vaults, this._kaminoVaultProgramId);
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1752
1794
|
/**
|
|
1753
1795
|
* This will return the amount of token invested from the vault into the given reserve
|
|
1754
1796
|
* @param vault - the kamino vault to get invested amount in reserve for
|
|
@@ -1898,7 +1940,17 @@ export class KaminoVaultClient {
|
|
|
1898
1940
|
* @returns a hashmap from each reserve pubkey to the reserve state
|
|
1899
1941
|
*/
|
|
1900
1942
|
async loadVaultReserves(vaultState: VaultState): Promise<PubkeyHashMap<PublicKey, KaminoReserve>> {
|
|
1901
|
-
|
|
1943
|
+
return this.loadVaultsReserves([vaultState]);
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
/**
|
|
1947
|
+
* This will load the onchain state for all the reserves that the vaults have allocations for, deduplicating the reserves
|
|
1948
|
+
* @param vaults - the vault states to load reserves for
|
|
1949
|
+
* @returns a hashmap from each reserve pubkey to the reserve state
|
|
1950
|
+
*/
|
|
1951
|
+
async loadVaultsReserves(vaults: VaultState[]): Promise<PubkeyHashMap<PublicKey, KaminoReserve>> {
|
|
1952
|
+
const vaultReservesAddressesSet = new PublicKeySet(vaults.flatMap((vault) => this.getVaultReserves(vault)));
|
|
1953
|
+
const vaultReservesAddresses = vaultReservesAddressesSet.toArray();
|
|
1902
1954
|
const reserveAccounts = await this.getConnection().getMultipleAccountsInfo(vaultReservesAddresses, 'processed');
|
|
1903
1955
|
|
|
1904
1956
|
const deserializedReserves = reserveAccounts.map((reserve, i) => {
|
|
@@ -2179,7 +2231,7 @@ export class KaminoVaultClient {
|
|
|
2179
2231
|
// all the async part of the functions above just read the vaultReservesState which is read beforehand, so excepting vaultCollateralsPromise they should do no additional network calls
|
|
2180
2232
|
const [
|
|
2181
2233
|
vaultHoldingsWithUSDValue,
|
|
2182
|
-
|
|
2234
|
+
vaultTheoreticalAPYs,
|
|
2183
2235
|
totalInvestedAndBorrowed,
|
|
2184
2236
|
vaultCollaterals,
|
|
2185
2237
|
reservesOverview,
|
|
@@ -2195,7 +2247,7 @@ export class KaminoVaultClient {
|
|
|
2195
2247
|
holdingsUSD: vaultHoldingsWithUSDValue,
|
|
2196
2248
|
reservesOverview: reservesOverview,
|
|
2197
2249
|
vaultCollaterals: vaultCollaterals,
|
|
2198
|
-
theoreticalSupplyAPY:
|
|
2250
|
+
theoreticalSupplyAPY: vaultTheoreticalAPYs,
|
|
2199
2251
|
totalBorrowed: totalInvestedAndBorrowed.totalBorrowed,
|
|
2200
2252
|
utilizationRatio: totalInvestedAndBorrowed.utilizationRatio,
|
|
2201
2253
|
totalSupplied: totalInvestedAndBorrowed.totalInvested,
|
|
@@ -2306,13 +2358,13 @@ export class KaminoVaultClient {
|
|
|
2306
2358
|
* @param vault - the kamino vault to get APY for
|
|
2307
2359
|
* @param slot - current slot
|
|
2308
2360
|
* @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
2309
|
-
* @returns APY for the vault
|
|
2361
|
+
* @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
|
|
2310
2362
|
*/
|
|
2311
2363
|
async getVaultTheoreticalAPY(
|
|
2312
2364
|
vault: VaultState,
|
|
2313
2365
|
slot: number,
|
|
2314
2366
|
vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>
|
|
2315
|
-
): Promise<
|
|
2367
|
+
): Promise<APYs> {
|
|
2316
2368
|
const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vault);
|
|
2317
2369
|
|
|
2318
2370
|
let totalWeights = new Decimal(0);
|
|
@@ -2334,14 +2386,20 @@ export class KaminoVaultClient {
|
|
|
2334
2386
|
totalWeights = totalWeights.add(weight);
|
|
2335
2387
|
});
|
|
2336
2388
|
if (totalWeights.isZero()) {
|
|
2337
|
-
return
|
|
2389
|
+
return {
|
|
2390
|
+
grossAPY: new Decimal(0),
|
|
2391
|
+
netAPY: new Decimal(0),
|
|
2392
|
+
};
|
|
2338
2393
|
}
|
|
2339
2394
|
|
|
2340
2395
|
const grossAPY = totalAPY.div(totalWeights);
|
|
2341
2396
|
const netAPY = grossAPY
|
|
2342
2397
|
.mul(new Decimal(1).sub(new Decimal(vault.performanceFeeBps.toString()).div(FullBPSDecimal)))
|
|
2343
2398
|
.mul(new Decimal(1).sub(new Decimal(vault.managementFeeBps.toString()).div(FullBPSDecimal)));
|
|
2344
|
-
return
|
|
2399
|
+
return {
|
|
2400
|
+
grossAPY,
|
|
2401
|
+
netAPY,
|
|
2402
|
+
};
|
|
2345
2403
|
}
|
|
2346
2404
|
|
|
2347
2405
|
/**
|
|
@@ -2610,7 +2668,7 @@ export type VaultOverview = {
|
|
|
2610
2668
|
holdingsUSD: VaultHoldingsWithUSDValue;
|
|
2611
2669
|
reservesOverview: PubkeyHashMap<PublicKey, ReserveOverview>;
|
|
2612
2670
|
vaultCollaterals: PubkeyHashMap<PublicKey, MarketOverview>;
|
|
2613
|
-
theoreticalSupplyAPY:
|
|
2671
|
+
theoreticalSupplyAPY: APYs;
|
|
2614
2672
|
totalBorrowed: Decimal;
|
|
2615
2673
|
totalSupplied: Decimal;
|
|
2616
2674
|
utilizationRatio: Decimal;
|
|
@@ -54,6 +54,7 @@ import {
|
|
|
54
54
|
} from './idl_codegen_kamino_vault/types/VaultConfigField';
|
|
55
55
|
import { getAccountOwner } from './utils/rpc';
|
|
56
56
|
import { printHoldings } from './classes/types_utils';
|
|
57
|
+
import { getAssociatedTokenAddressSync } from '@solana/spl-token';
|
|
57
58
|
|
|
58
59
|
dotenv.config({
|
|
59
60
|
path: `.env${process.env.ENV ? '.' + process.env.ENV : ''}`,
|
|
@@ -87,7 +88,7 @@ async function main() {
|
|
|
87
88
|
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
88
89
|
});
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
await processTxn(env.client, env.payer, createMarketIxns, mode, 2500, [marketKp]);
|
|
91
92
|
|
|
92
93
|
mode === 'execute' && console.log('Market created:', marketKp.publicKey.toBase58());
|
|
93
94
|
});
|
|
@@ -122,8 +123,14 @@ async function main() {
|
|
|
122
123
|
const reserveConfig = parseReserveConfigFromFile(reserveConfigFromFile);
|
|
123
124
|
const assetConfig = new AssetReserveConfigCli(tokenMint, tokenMintProgramId, reserveConfig);
|
|
124
125
|
|
|
126
|
+
const adminAta =
|
|
127
|
+
mode === 'multisig'
|
|
128
|
+
? getAssociatedTokenAddressSync(tokenMint, multisigPk)
|
|
129
|
+
: getAssociatedTokenAddressSync(tokenMint, env.payer.publicKey);
|
|
130
|
+
|
|
125
131
|
const { reserve, txnIxns } = await kaminoManager.addAssetToMarketIxs({
|
|
126
132
|
admin: mode === 'multisig' ? multisigPk : env.payer.publicKey,
|
|
133
|
+
adminLiquiditySource: adminAta,
|
|
127
134
|
marketAddress: marketAddress,
|
|
128
135
|
assetConfig: assetConfig,
|
|
129
136
|
});
|
|
@@ -260,7 +267,7 @@ async function main() {
|
|
|
260
267
|
2500,
|
|
261
268
|
[vaultKp]
|
|
262
269
|
);
|
|
263
|
-
await sleep(
|
|
270
|
+
await sleep(2000);
|
|
264
271
|
const _populateLUTSig = await processTxn(env.client, env.payer, instructions.populateLUTIxs, mode, 2500, []);
|
|
265
272
|
|
|
266
273
|
mode === 'execute' && console.log('Vault created:', vaultKp.publicKey.toBase58());
|
|
@@ -426,7 +433,7 @@ async function main() {
|
|
|
426
433
|
// if we need to create the LUT we have to do that in a separate tx and wait a little bit after
|
|
427
434
|
if (syncLUTIxs.setupLUTIfNeededIxs.length > 0) {
|
|
428
435
|
const setupLUTSig = await processTxn(env.client, env.payer, syncLUTIxs.setupLUTIfNeededIxs, mode, 2500, []);
|
|
429
|
-
await sleep(
|
|
436
|
+
await sleep(2000);
|
|
430
437
|
mode === 'execute' && console.log('LUT created and set to the vault:', setupLUTSig);
|
|
431
438
|
}
|
|
432
439
|
// if there are accounts to be added to the LUT we have to do that in a separate tx
|