@glamsystems/glam-sdk 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.
Files changed (3) hide show
  1. package/index.cjs.js +25 -17
  2. package/index.esm.js +25 -17
  3. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -20711,7 +20711,6 @@ class KaminoLendingClient {
20711
20711
  const vault = this.base.vaultPda;
20712
20712
  const userMetadata = this.getUserMetadataPda(vault);
20713
20713
  const lookupTable = new web3_js.PublicKey(0); // FIXME: create lookup table
20714
- // @ts-ignore
20715
20714
  const tx = await this.base.program.methods.kaminoLendingInitUserMetadata(lookupTable).accounts({
20716
20715
  glamState: this.base.statePda,
20717
20716
  glamSigner,
@@ -20758,7 +20757,7 @@ class KaminoLendingClient {
20758
20757
  obligationFarm = this.getObligationFarmState(obligation, depositReserve.farmCollateral);
20759
20758
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20760
20759
  if (!obligationFarmAccount) {
20761
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20760
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20762
20761
  .accounts({
20763
20762
  glamState: this.base.statePda,
20764
20763
  glamSigner,
@@ -20796,7 +20795,8 @@ class KaminoLendingClient {
20796
20795
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20797
20796
  }
20798
20797
  // If deposit asset is WSOL, wrap SOL first in case vault doesn't have enough wSOL
20799
- const userSourceLiquidity = this.base.getVaultAta(asset);
20798
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20799
+ const userSourceLiquidity = this.base.getVaultAta(asset, tokenProgram);
20800
20800
  if (asset.equals(WSOL)) {
20801
20801
  const wrapSolIxs = await this.base.maybeWrapSol(amount);
20802
20802
  preInstructions.unshift(...wrapSolIxs);
@@ -20811,7 +20811,6 @@ class KaminoLendingClient {
20811
20811
  postInstructions.push(closeIx);
20812
20812
  }
20813
20813
  }
20814
- // @ts-ignore
20815
20814
  const tx = await this.base.program.methods.kaminoLendingDepositReserveLiquidityAndObligationCollateralV2(amount).accounts({
20816
20815
  glamState: this.base.statePda,
20817
20816
  glamSigner,
@@ -20826,7 +20825,7 @@ class KaminoLendingClient {
20826
20825
  userSourceLiquidity,
20827
20826
  placeholderUserDestinationCollateral: KAMINO_LENDING_PROGRAM,
20828
20827
  collateralTokenProgram: splToken.TOKEN_PROGRAM_ID,
20829
- liquidityTokenProgram: splToken.TOKEN_PROGRAM_ID,
20828
+ liquidityTokenProgram: tokenProgram,
20830
20829
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20831
20830
  obligationFarmUserState: obligationFarm,
20832
20831
  reserveFarmState: depositReserve.farmCollateral,
@@ -20848,7 +20847,7 @@ class KaminoLendingClient {
20848
20847
  obligationFarm = this.getObligationFarmState(obligation, withdrawReserve.farmCollateral);
20849
20848
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20850
20849
  if (!obligationFarmAccount) {
20851
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20850
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20852
20851
  .accounts({
20853
20852
  glamState: this.base.statePda,
20854
20853
  glamSigner,
@@ -20886,8 +20885,9 @@ class KaminoLendingClient {
20886
20885
  postInstructions.push(...ixs); // farms must be refreshed after withdraw
20887
20886
  }
20888
20887
  // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20889
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20890
- const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20888
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20889
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20890
+ const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20891
20891
  preInstructions.unshift(createAtaIx);
20892
20892
  const withdrawIx = await this.base.program.methods.kaminoLendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount).accounts({
20893
20893
  glamState: this.base.statePda,
@@ -20903,12 +20903,18 @@ class KaminoLendingClient {
20903
20903
  userDestinationLiquidity,
20904
20904
  placeholderUserDestinationCollateral: null,
20905
20905
  collateralTokenProgram: splToken.TOKEN_PROGRAM_ID,
20906
- liquidityTokenProgram: splToken.TOKEN_PROGRAM_ID,
20906
+ liquidityTokenProgram: tokenProgram,
20907
20907
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20908
20908
  obligationFarmUserState: obligationFarm,
20909
20909
  reserveFarmState: withdrawReserve.farmCollateral,
20910
20910
  farmsProgram: KAMINO_FARM_PROGRAM
20911
- }).instruction();
20911
+ }).remainingAccounts([
20912
+ {
20913
+ pubkey: web3_js.SystemProgram.programId,
20914
+ isSigner: false,
20915
+ isWritable: false
20916
+ }
20917
+ ]).instruction();
20912
20918
  // The final instructions in the tx:
20913
20919
  // - refreshReserve * N
20914
20920
  // - refreshObligation
@@ -20932,7 +20938,7 @@ class KaminoLendingClient {
20932
20938
  obligationFarm = this.getObligationFarmState(obligation, borrowReserve.farmDebt);
20933
20939
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20934
20940
  if (!obligationFarmAccount) {
20935
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20941
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20936
20942
  .accounts({
20937
20943
  glamState: this.base.statePda,
20938
20944
  glamSigner,
@@ -20972,8 +20978,9 @@ class KaminoLendingClient {
20972
20978
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20973
20979
  }
20974
20980
  */ // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20975
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20976
- const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20981
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20982
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20983
+ const createAtaIx = splToken.createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20977
20984
  preInstructions.unshift(createAtaIx);
20978
20985
  const borrowIx = await this.base.program.methods.kaminoLendingBorrowObligationLiquidityV2(amount).accounts({
20979
20986
  glamState: this.base.statePda,
@@ -20988,7 +20995,7 @@ class KaminoLendingClient {
20988
20995
  userDestinationLiquidity,
20989
20996
  referrerTokenState: null,
20990
20997
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
20991
- tokenProgram: splToken.TOKEN_PROGRAM_ID,
20998
+ tokenProgram,
20992
20999
  obligationFarmUserState: obligationFarm,
20993
21000
  reserveFarmState: borrowReserve.farmDebt,
20994
21001
  farmsProgram: KAMINO_FARM_PROGRAM
@@ -21014,7 +21021,7 @@ class KaminoLendingClient {
21014
21021
  obligationFarm = this.getObligationFarmState(obligation, repayReserve.farmDebt);
21015
21022
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
21016
21023
  if (!obligationFarmAccount) {
21017
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
21024
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
21018
21025
  .accounts({
21019
21026
  glamState: this.base.statePda,
21020
21027
  glamSigner,
@@ -21044,6 +21051,7 @@ class KaminoLendingClient {
21044
21051
  obligation,
21045
21052
  reserves: reservesInUse
21046
21053
  }));
21054
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
21047
21055
  const repayIx = await this.base.program.methods.kaminoLendingRepayObligationLiquidityV2(amount).accounts({
21048
21056
  glamState: this.base.statePda,
21049
21057
  glamSigner,
@@ -21053,9 +21061,9 @@ class KaminoLendingClient {
21053
21061
  repayReserve: repayReserve.address,
21054
21062
  reserveLiquidityMint: asset,
21055
21063
  reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
21056
- userSourceLiquidity: this.base.getVaultAta(asset),
21064
+ userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
21057
21065
  instructionSysvarAccount: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
21058
- tokenProgram: splToken.TOKEN_PROGRAM_ID,
21066
+ tokenProgram,
21059
21067
  obligationFarmUserState: obligationFarm,
21060
21068
  reserveFarmState: repayReserve.farmDebt,
21061
21069
  farmsProgram: KAMINO_FARM_PROGRAM
package/index.esm.js CHANGED
@@ -20691,7 +20691,6 @@ class KaminoLendingClient {
20691
20691
  const vault = this.base.vaultPda;
20692
20692
  const userMetadata = this.getUserMetadataPda(vault);
20693
20693
  const lookupTable = new PublicKey(0); // FIXME: create lookup table
20694
- // @ts-ignore
20695
20694
  const tx = await this.base.program.methods.kaminoLendingInitUserMetadata(lookupTable).accounts({
20696
20695
  glamState: this.base.statePda,
20697
20696
  glamSigner,
@@ -20738,7 +20737,7 @@ class KaminoLendingClient {
20738
20737
  obligationFarm = this.getObligationFarmState(obligation, depositReserve.farmCollateral);
20739
20738
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20740
20739
  if (!obligationFarmAccount) {
20741
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20740
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20742
20741
  .accounts({
20743
20742
  glamState: this.base.statePda,
20744
20743
  glamSigner,
@@ -20776,7 +20775,8 @@ class KaminoLendingClient {
20776
20775
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20777
20776
  }
20778
20777
  // If deposit asset is WSOL, wrap SOL first in case vault doesn't have enough wSOL
20779
- const userSourceLiquidity = this.base.getVaultAta(asset);
20778
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20779
+ const userSourceLiquidity = this.base.getVaultAta(asset, tokenProgram);
20780
20780
  if (asset.equals(WSOL)) {
20781
20781
  const wrapSolIxs = await this.base.maybeWrapSol(amount);
20782
20782
  preInstructions.unshift(...wrapSolIxs);
@@ -20791,7 +20791,6 @@ class KaminoLendingClient {
20791
20791
  postInstructions.push(closeIx);
20792
20792
  }
20793
20793
  }
20794
- // @ts-ignore
20795
20794
  const tx = await this.base.program.methods.kaminoLendingDepositReserveLiquidityAndObligationCollateralV2(amount).accounts({
20796
20795
  glamState: this.base.statePda,
20797
20796
  glamSigner,
@@ -20806,7 +20805,7 @@ class KaminoLendingClient {
20806
20805
  userSourceLiquidity,
20807
20806
  placeholderUserDestinationCollateral: KAMINO_LENDING_PROGRAM,
20808
20807
  collateralTokenProgram: TOKEN_PROGRAM_ID,
20809
- liquidityTokenProgram: TOKEN_PROGRAM_ID,
20808
+ liquidityTokenProgram: tokenProgram,
20810
20809
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20811
20810
  obligationFarmUserState: obligationFarm,
20812
20811
  reserveFarmState: depositReserve.farmCollateral,
@@ -20828,7 +20827,7 @@ class KaminoLendingClient {
20828
20827
  obligationFarm = this.getObligationFarmState(obligation, withdrawReserve.farmCollateral);
20829
20828
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20830
20829
  if (!obligationFarmAccount) {
20831
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20830
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // 0 - collateral farm
20832
20831
  .accounts({
20833
20832
  glamState: this.base.statePda,
20834
20833
  glamSigner,
@@ -20866,8 +20865,9 @@ class KaminoLendingClient {
20866
20865
  postInstructions.push(...ixs); // farms must be refreshed after withdraw
20867
20866
  }
20868
20867
  // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20869
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20870
- const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20868
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20869
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20870
+ const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20871
20871
  preInstructions.unshift(createAtaIx);
20872
20872
  const withdrawIx = await this.base.program.methods.kaminoLendingWithdrawObligationCollateralAndRedeemReserveCollateralV2(amount).accounts({
20873
20873
  glamState: this.base.statePda,
@@ -20883,12 +20883,18 @@ class KaminoLendingClient {
20883
20883
  userDestinationLiquidity,
20884
20884
  placeholderUserDestinationCollateral: null,
20885
20885
  collateralTokenProgram: TOKEN_PROGRAM_ID,
20886
- liquidityTokenProgram: TOKEN_PROGRAM_ID,
20886
+ liquidityTokenProgram: tokenProgram,
20887
20887
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20888
20888
  obligationFarmUserState: obligationFarm,
20889
20889
  reserveFarmState: withdrawReserve.farmCollateral,
20890
20890
  farmsProgram: KAMINO_FARM_PROGRAM
20891
- }).instruction();
20891
+ }).remainingAccounts([
20892
+ {
20893
+ pubkey: SystemProgram.programId,
20894
+ isSigner: false,
20895
+ isWritable: false
20896
+ }
20897
+ ]).instruction();
20892
20898
  // The final instructions in the tx:
20893
20899
  // - refreshReserve * N
20894
20900
  // - refreshObligation
@@ -20912,7 +20918,7 @@ class KaminoLendingClient {
20912
20918
  obligationFarm = this.getObligationFarmState(obligation, borrowReserve.farmDebt);
20913
20919
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20914
20920
  if (!obligationFarmAccount) {
20915
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
20921
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20916
20922
  .accounts({
20917
20923
  glamState: this.base.statePda,
20918
20924
  glamSigner,
@@ -20952,8 +20958,9 @@ class KaminoLendingClient {
20952
20958
  postInstructions.push(...ixs); // farms must be refreshed after deposit
20953
20959
  }
20954
20960
  */ // Create asset ATA in case it doesn't exist. Add it to the beginning of preInstructions
20955
- const userDestinationLiquidity = this.base.getVaultAta(asset);
20956
- const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset);
20961
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
20962
+ const userDestinationLiquidity = this.base.getVaultAta(asset, tokenProgram);
20963
+ const createAtaIx = createAssociatedTokenAccountIdempotentInstruction(glamSigner, userDestinationLiquidity, vault, asset, tokenProgram);
20957
20964
  preInstructions.unshift(createAtaIx);
20958
20965
  const borrowIx = await this.base.program.methods.kaminoLendingBorrowObligationLiquidityV2(amount).accounts({
20959
20966
  glamState: this.base.statePda,
@@ -20968,7 +20975,7 @@ class KaminoLendingClient {
20968
20975
  userDestinationLiquidity,
20969
20976
  referrerTokenState: null,
20970
20977
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
20971
- tokenProgram: TOKEN_PROGRAM_ID,
20978
+ tokenProgram,
20972
20979
  obligationFarmUserState: obligationFarm,
20973
20980
  reserveFarmState: borrowReserve.farmDebt,
20974
20981
  farmsProgram: KAMINO_FARM_PROGRAM
@@ -20994,7 +21001,7 @@ class KaminoLendingClient {
20994
21001
  obligationFarm = this.getObligationFarmState(obligation, repayReserve.farmDebt);
20995
21002
  const obligationFarmAccount = await this.base.provider.connection.getAccountInfo(obligationFarm);
20996
21003
  if (!obligationFarmAccount) {
20997
- preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(0) // TODO: What does mode do?
21004
+ preInstructions.push(await this.base.program.methods.kaminoLendingInitObligationFarmsForReserve(1) // 1 - debt farm
20998
21005
  .accounts({
20999
21006
  glamState: this.base.statePda,
21000
21007
  glamSigner,
@@ -21024,6 +21031,7 @@ class KaminoLendingClient {
21024
21031
  obligation,
21025
21032
  reserves: reservesInUse
21026
21033
  }));
21034
+ const { tokenProgram } = await this.base.fetchMintAndTokenProgram(asset);
21027
21035
  const repayIx = await this.base.program.methods.kaminoLendingRepayObligationLiquidityV2(amount).accounts({
21028
21036
  glamState: this.base.statePda,
21029
21037
  glamSigner,
@@ -21033,9 +21041,9 @@ class KaminoLendingClient {
21033
21041
  repayReserve: repayReserve.address,
21034
21042
  reserveLiquidityMint: asset,
21035
21043
  reserveDestinationLiquidity: repayReserve.liquiditySupplyVault,
21036
- userSourceLiquidity: this.base.getVaultAta(asset),
21044
+ userSourceLiquidity: this.base.getVaultAta(asset, tokenProgram),
21037
21045
  instructionSysvarAccount: SYSVAR_INSTRUCTIONS_PUBKEY,
21038
- tokenProgram: TOKEN_PROGRAM_ID,
21046
+ tokenProgram,
21039
21047
  obligationFarmUserState: obligationFarm,
21040
21048
  reserveFarmState: repayReserve.farmDebt,
21041
21049
  farmsProgram: KAMINO_FARM_PROGRAM
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glamsystems/glam-sdk",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "description": "TypeScript SDK for the GLAM Protocol",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",