@glamsystems/glam-cli 0.1.33 → 0.1.34
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/main.js +26 -17
- package/package.json +2 -2
package/main.js
CHANGED
|
@@ -6496,7 +6496,6 @@ class KaminoLendingClient {
|
|
|
6496
6496
|
const vault = this.base.vaultPda;
|
|
6497
6497
|
const userMetadata = this.getUserMetadataPda(vault);
|
|
6498
6498
|
const lookupTable = new web3_js_1.PublicKey(0); // FIXME: create lookup table
|
|
6499
|
-
// @ts-ignore
|
|
6500
6499
|
const tx = await this.base.program.methods
|
|
6501
6500
|
.kaminoLendingInitUserMetadata(lookupTable)
|
|
6502
6501
|
.accounts({
|
|
@@ -6553,7 +6552,7 @@ class KaminoLendingClient {
|
|
|
6553
6552
|
const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
|
|
6554
6553
|
if (!obligationFarmAccount) {
|
|
6555
6554
|
preInstructions.push(await this.base.program.methods
|
|
6556
|
-
.kaminoLendingInitObligationFarmsForReserve(0) //
|
|
6555
|
+
.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
|
|
6557
6556
|
.accounts({
|
|
6558
6557
|
glamState: this.base.statePda,
|
|
6559
6558
|
glamSigner,
|
|
@@ -6591,7 +6590,8 @@ class KaminoLendingClient {
|
|
|
6591
6590
|
postInstructions.push(...ixs); // farms must be refreshed after deposit
|
|
6592
6591
|
}
|
|
6593
6592
|
// If deposit asset is WSOL, wrap SOL first in case vault doesn't have enough wSOL
|
|
6594
|
-
const
|
|
6593
|
+
const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
|
|
6594
|
+
const userSourceLiquidity = this.base.getVaultAta(asset, tokenProgram);
|
|
6595
6595
|
if (asset.equals(constants_1.WSOL)) {
|
|
6596
6596
|
const wrapSolIxs = await this.base.maybeWrapSol(amount);
|
|
6597
6597
|
preInstructions.unshift(...wrapSolIxs);
|
|
@@ -6609,7 +6609,6 @@ class KaminoLendingClient {
|
|
|
6609
6609
|
postInstructions.push(closeIx);
|
|
6610
6610
|
}
|
|
6611
6611
|
}
|
|
6612
|
-
// @ts-ignore
|
|
6613
6612
|
const tx = await this.base.program.methods
|
|
6614
6613
|
.kaminoLendingDepositReserveLiquidityAndObligationCollateralV2(amount)
|
|
6615
6614
|
.accounts({
|
|
@@ -6626,7 +6625,7 @@ class KaminoLendingClient {
|
|
|
6626
6625
|
userSourceLiquidity,
|
|
6627
6626
|
placeholderUserDestinationCollateral: constants_1.KAMINO_LENDING_PROGRAM,
|
|
6628
6627
|
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
6629
|
-
liquidityTokenProgram:
|
|
6628
|
+
liquidityTokenProgram: tokenProgram,
|
|
6630
6629
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6631
6630
|
obligationFarmUserState: obligationFarm,
|
|
6632
6631
|
reserveFarmState: depositReserve.farmCollateral,
|
|
@@ -6652,7 +6651,7 @@ class KaminoLendingClient {
|
|
|
6652
6651
|
const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
|
|
6653
6652
|
if (!obligationFarmAccount) {
|
|
6654
6653
|
preInstructions.push(await this.base.program.methods
|
|
6655
|
-
.kaminoLendingInitObligationFarmsForReserve(0) //
|
|
6654
|
+
.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
|
|
6656
6655
|
.accounts({
|
|
6657
6656
|
glamState: this.base.statePda,
|
|
6658
6657
|
glamSigner,
|
|
@@ -6690,8 +6689,9 @@ class KaminoLendingClient {
|
|
|
6690
6689
|
postInstructions.push(...ixs); // farms must be refreshed after withdraw
|
|
6691
6690
|
}
|
|
6692
6691
|
// Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
|
|
6693
|
-
const
|
|
6694
|
-
const
|
|
6692
|
+
const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
|
|
6693
|
+
const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
|
|
6694
|
+
const createAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
|
|
6695
6695
|
preInstructions.unshift(createAtaIx);
|
|
6696
6696
|
const withdrawIx = await this.base.program.methods
|
|
6697
6697
|
.kaminoLendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount)
|
|
@@ -6709,12 +6709,19 @@ class KaminoLendingClient {
|
|
|
6709
6709
|
userDestinationLiquidity,
|
|
6710
6710
|
placeholderUserDestinationCollateral: null,
|
|
6711
6711
|
collateralTokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
6712
|
-
liquidityTokenProgram:
|
|
6712
|
+
liquidityTokenProgram: tokenProgram,
|
|
6713
6713
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6714
6714
|
obligationFarmUserState: obligationFarm,
|
|
6715
6715
|
reserveFarmState: withdrawReserve.farmCollateral,
|
|
6716
6716
|
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
6717
6717
|
})
|
|
6718
|
+
.remainingAccounts([
|
|
6719
|
+
{
|
|
6720
|
+
pubkey: web3_js_1.SystemProgram.programId,
|
|
6721
|
+
isSigner: false,
|
|
6722
|
+
isWritable: false,
|
|
6723
|
+
},
|
|
6724
|
+
])
|
|
6718
6725
|
.instruction();
|
|
6719
6726
|
// The final instructions in the tx:
|
|
6720
6727
|
// - refreshReserve * N
|
|
@@ -6741,7 +6748,7 @@ class KaminoLendingClient {
|
|
|
6741
6748
|
const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
|
|
6742
6749
|
if (!obligationFarmAccount) {
|
|
6743
6750
|
preInstructions.push(await this.base.program.methods
|
|
6744
|
-
.kaminoLendingInitObligationFarmsForReserve(
|
|
6751
|
+
.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
|
|
6745
6752
|
.accounts({
|
|
6746
6753
|
glamState: this.base.statePda,
|
|
6747
6754
|
glamSigner,
|
|
@@ -6784,8 +6791,9 @@ class KaminoLendingClient {
|
|
|
6784
6791
|
}
|
|
6785
6792
|
*/
|
|
6786
6793
|
// Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
|
|
6787
|
-
const
|
|
6788
|
-
const
|
|
6794
|
+
const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
|
|
6795
|
+
const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
|
|
6796
|
+
const createAtaIx = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
|
|
6789
6797
|
preInstructions.unshift(createAtaIx);
|
|
6790
6798
|
const borrowIx = await this.base.program.methods
|
|
6791
6799
|
.kaminoLendingBorrowObligationLiquidityV2(amount)
|
|
@@ -6802,7 +6810,7 @@ class KaminoLendingClient {
|
|
|
6802
6810
|
userDestinationLiquidity,
|
|
6803
6811
|
referrerTokenState: null,
|
|
6804
6812
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6805
|
-
tokenProgram
|
|
6813
|
+
tokenProgram,
|
|
6806
6814
|
obligationFarmUserState: obligationFarm,
|
|
6807
6815
|
reserveFarmState: borrowReserve.farmDebt,
|
|
6808
6816
|
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
@@ -6830,7 +6838,7 @@ class KaminoLendingClient {
|
|
|
6830
6838
|
const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
|
|
6831
6839
|
if (!obligationFarmAccount) {
|
|
6832
6840
|
preInstructions.push(await this.base.program.methods
|
|
6833
|
-
.kaminoLendingInitObligationFarmsForReserve(
|
|
6841
|
+
.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
|
|
6834
6842
|
.accounts({
|
|
6835
6843
|
glamState: this.base.statePda,
|
|
6836
6844
|
glamSigner,
|
|
@@ -6862,6 +6870,7 @@ class KaminoLendingClient {
|
|
|
6862
6870
|
obligation,
|
|
6863
6871
|
reserves: reservesInUse,
|
|
6864
6872
|
}));
|
|
6873
|
+
const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
|
|
6865
6874
|
const repayIx = await this.base.program.methods
|
|
6866
6875
|
.kaminoLendingRepayObligationLiquidityV2(amount)
|
|
6867
6876
|
.accounts({
|
|
@@ -6873,9 +6882,9 @@ class KaminoLendingClient {
|
|
|
6873
6882
|
repayReserve: repayReserve.address,
|
|
6874
6883
|
reserveLiquidityMint: asset,
|
|
6875
6884
|
reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
|
|
6876
|
-
userSourceLiquidity: this.base.getVaultAta(asset),
|
|
6885
|
+
userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
|
|
6877
6886
|
instructionSysvarAccount: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
|
|
6878
|
-
tokenProgram
|
|
6887
|
+
tokenProgram,
|
|
6879
6888
|
obligationFarmUserState: obligationFarm,
|
|
6880
6889
|
reserveFarmState: repayReserve.farmDebt,
|
|
6881
6890
|
farmsProgram: constants_1.KAMINO_FARM_PROGRAM,
|
|
@@ -10633,7 +10642,7 @@ program
|
|
|
10633
10642
|
.hook("preSubcommand", async (thisCommand, actionCommand) => {
|
|
10634
10643
|
await (0, idl_1.idlCheck)(glamClient);
|
|
10635
10644
|
})
|
|
10636
|
-
.version("0.1.
|
|
10645
|
+
.version("0.1.34");
|
|
10637
10646
|
program
|
|
10638
10647
|
.command("env")
|
|
10639
10648
|
.description("Display current environment setup")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glamsystems/glam-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "CLI for interacting with the GLAM Protocol",
|
|
5
5
|
"main": "./main.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"node": ">=20.18.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@glamsystems/glam-sdk": "0.1.
|
|
24
|
+
"@glamsystems/glam-sdk": "0.1.34",
|
|
25
25
|
"commander": "^11.1.0",
|
|
26
26
|
"inquirer": "^8.2.6",
|
|
27
27
|
"@switchboard-xyz/common": "^3.0.0"
|