@meteora-ag/cp-amm-sdk 1.0.11-rc.1 → 1.0.11-rc.2

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.d.mts CHANGED
@@ -6018,7 +6018,7 @@ type InitializeRewardParams = {
6018
6018
  funder: PublicKey;
6019
6019
  payer: PublicKey;
6020
6020
  creator: PublicKey;
6021
- rewardMintProgram?: PublicKey;
6021
+ rewardMintProgram: PublicKey;
6022
6022
  };
6023
6023
  type InitializeAndFundReward = {
6024
6024
  rewardIndex: number;
@@ -6049,6 +6049,9 @@ type FundRewardParams = {
6049
6049
  pool: PublicKey;
6050
6050
  carryForward: boolean;
6051
6051
  amount: BN;
6052
+ rewardMint: PublicKey;
6053
+ rewardVault: PublicKey;
6054
+ rewardMintProgram: PublicKey;
6052
6055
  };
6053
6056
  type WithdrawIneligibleRewardParams = {
6054
6057
  rewardIndex: number;
package/dist/index.d.ts CHANGED
@@ -6018,7 +6018,7 @@ type InitializeRewardParams = {
6018
6018
  funder: PublicKey;
6019
6019
  payer: PublicKey;
6020
6020
  creator: PublicKey;
6021
- rewardMintProgram?: PublicKey;
6021
+ rewardMintProgram: PublicKey;
6022
6022
  };
6023
6023
  type InitializeAndFundReward = {
6024
6024
  rewardIndex: number;
@@ -6049,6 +6049,9 @@ type FundRewardParams = {
6049
6049
  pool: PublicKey;
6050
6050
  carryForward: boolean;
6051
6051
  amount: BN;
6052
+ rewardMint: PublicKey;
6053
+ rewardVault: PublicKey;
6054
+ rewardMintProgram: PublicKey;
6052
6055
  };
6053
6056
  type WithdrawIneligibleRewardParams = {
6054
6057
  rewardIndex: number;
package/dist/index.js CHANGED
@@ -8532,7 +8532,6 @@ var CpAmm = class {
8532
8532
  rewardMintProgram
8533
8533
  } = params;
8534
8534
  const rewardVault = deriveRewardVaultAddress(pool, rewardIndex);
8535
- const tokenProgram = rewardMintProgram ? rewardMintProgram : (yield this._program.provider.connection.getAccountInfo(rewardMint)).owner;
8536
8535
  return yield this._program.methods.initializeReward(rewardIndex, rewardDuration, funder).accountsPartial({
8537
8536
  poolAuthority: this.poolAuthority,
8538
8537
  pool,
@@ -8540,7 +8539,7 @@ var CpAmm = class {
8540
8539
  rewardMint,
8541
8540
  signer: creator,
8542
8541
  payer,
8543
- tokenProgram
8542
+ tokenProgram: rewardMintProgram
8544
8543
  }).transaction();
8545
8544
  });
8546
8545
  }
@@ -8562,6 +8561,7 @@ var CpAmm = class {
8562
8561
  amount,
8563
8562
  rewardMintProgram
8564
8563
  } = params;
8564
+ const rewardVault = deriveRewardVaultAddress(pool, rewardIndex);
8565
8565
  const initializeRewardTx = yield this.initializeReward({
8566
8566
  rewardIndex,
8567
8567
  rewardDuration,
@@ -8577,7 +8577,10 @@ var CpAmm = class {
8577
8577
  carryForward,
8578
8578
  pool,
8579
8579
  funder: payer,
8580
- amount
8580
+ amount,
8581
+ rewardMint,
8582
+ rewardVault,
8583
+ rewardMintProgram
8581
8584
  });
8582
8585
  return new (0, _web3js.Transaction)().add(initializeRewardTx).add(fundRewardTx);
8583
8586
  });
@@ -8617,22 +8620,27 @@ var CpAmm = class {
8617
8620
  */
8618
8621
  fundReward(params) {
8619
8622
  return __async(this, null, function* () {
8620
- const { rewardIndex, carryForward, pool, funder, amount } = params;
8621
- const poolState = yield this.fetchPoolState(pool);
8622
- const rewardInfo = poolState.rewardInfos[rewardIndex];
8623
- const { vault, mint } = rewardInfo;
8624
- const tokenProgram = getTokenProgram(rewardIndex);
8623
+ const {
8624
+ rewardIndex,
8625
+ carryForward,
8626
+ pool,
8627
+ funder,
8628
+ amount,
8629
+ rewardMint,
8630
+ rewardVault,
8631
+ rewardMintProgram
8632
+ } = params;
8625
8633
  const preInstructions = [];
8626
8634
  const { ataPubkey: funderTokenAccount, ix: createFunderTokenAccountIx } = yield getOrCreateATAInstruction(
8627
8635
  this._program.provider.connection,
8628
- mint,
8636
+ rewardMint,
8629
8637
  funder,
8630
8638
  funder,
8631
8639
  true,
8632
- tokenProgram
8640
+ rewardMintProgram
8633
8641
  );
8634
8642
  createFunderTokenAccountIx && preInstructions.push(createFunderTokenAccountIx);
8635
- if (mint.equals(_spltoken.NATIVE_MINT) && !amount.isZero()) {
8643
+ if (rewardMint.equals(_spltoken.NATIVE_MINT) && !amount.isZero()) {
8636
8644
  const wrapSOLIx = wrapSOLInstruction(
8637
8645
  funder,
8638
8646
  funderTokenAccount,
@@ -8642,11 +8650,11 @@ var CpAmm = class {
8642
8650
  }
8643
8651
  return yield this._program.methods.fundReward(rewardIndex, amount, carryForward).accountsPartial({
8644
8652
  pool,
8645
- rewardVault: vault,
8646
- rewardMint: mint,
8653
+ rewardVault,
8654
+ rewardMint,
8647
8655
  funderTokenAccount,
8648
8656
  funder,
8649
- tokenProgram
8657
+ tokenProgram: rewardMintProgram
8650
8658
  }).transaction();
8651
8659
  });
8652
8660
  }