@jpool/bond-sdk 0.11.0-next.3 → 0.11.0-next.4

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.mjs CHANGED
@@ -6853,20 +6853,17 @@ var JBondClient = class _JBondClient {
6853
6853
  */
6854
6854
  async getClaimAllCompensationsIxs(props) {
6855
6855
  const ixs = [];
6856
- const validatorBonds = await this.getBondValidatorStates(props.bondType, props.name);
6857
6856
  const validatorBondBalances = await this.getBondStateValidatorBondBalances(
6858
6857
  props.bondType,
6859
6858
  props.name
6860
6859
  );
6861
- for (const vb of validatorBonds) {
6862
- console.log("Processing claim for validator:", vb.voteAccount.toBase58());
6863
- const validatorBondBalance = lamportsToSol(validatorBondBalances.find((vbb) => vbb.voteAccount.equals(vb.voteAccount))?.balance || 0);
6864
- const amountToClaim = validatorBondBalance - (props.collateralType ? 0 : lamportsToSol(await this.validatorBondRentExempt()));
6860
+ for (const bond_balance of validatorBondBalances) {
6861
+ const amountToClaim = lamportsToSol(bond_balance.balance);
6865
6862
  if (amountToClaim <= 0) {
6866
- console.log("No balance to claim for validator:", vb.voteAccount.toBase58());
6863
+ this.debug("No balance to claim for validator:", bond_balance.voteAccount.toBase58());
6867
6864
  continue;
6868
6865
  }
6869
- console.log("Amount to claim:", amountToClaim);
6866
+ this.debug("Amount to claim:", amountToClaim);
6870
6867
  const ix = await this.getClaimIx({
6871
6868
  bondType: props.bondType,
6872
6869
  name: props.name,
@@ -6874,7 +6871,7 @@ var JBondClient = class _JBondClient {
6874
6871
  collateralType: props.collateralType,
6875
6872
  reserve: props.reserve,
6876
6873
  authority: props.authority,
6877
- voteAccount: vb.voteAccount
6874
+ voteAccount: bond_balance.voteAccount
6878
6875
  });
6879
6876
  ixs.push(ix);
6880
6877
  }
@@ -6965,8 +6962,8 @@ var JBondClient = class _JBondClient {
6965
6962
  if (!accountInfo) {
6966
6963
  return 0;
6967
6964
  }
6968
- const { data, lamports } = accountInfo;
6969
- const rentExempt = await this.connection.getMinimumBalanceForRentExemption(data.length);
6965
+ const { lamports } = accountInfo;
6966
+ const rentExempt = await this.validatorBondRentExempt();
6970
6967
  return Math.max(0, lamports - rentExempt);
6971
6968
  },
6972
6969
  token: async (mint) => {
@@ -6983,7 +6980,7 @@ var JBondClient = class _JBondClient {
6983
6980
  async getBondStateValidatorBondBalances(bondType, bondName) {
6984
6981
  const bondState = await this.getBondState(bondType, bondName);
6985
6982
  const collateralType = bondState.collateralType;
6986
- const validatorBonds = await this.getBondValidatorStates(bondType, bondName);
6983
+ const validatorBonds = await this.getValidatorBondsForState(bondType, bondName);
6987
6984
  if (!validatorBonds.length) {
6988
6985
  return [];
6989
6986
  }
@@ -6998,9 +6995,10 @@ var JBondClient = class _JBondClient {
6998
6995
  native: async () => {
6999
6996
  const addresses = validatorBonds.map((vb) => vb.publicKey);
7000
6997
  const accountInfos = await this.connection.getMultipleAccountsInfo(addresses);
6998
+ const rentExempt = await this.validatorBondRentExempt();
7001
6999
  return validatorBonds.map((vb, idx) => ({
7002
7000
  voteAccount: vb.voteAccount,
7003
- balance: accountInfos[idx]?.lamports ?? 0
7001
+ balance: Math.max(0, (accountInfos[idx]?.lamports ?? 0) - rentExempt)
7004
7002
  }));
7005
7003
  },
7006
7004
  token: async (mint) => {
@@ -7067,7 +7065,7 @@ var JBondClient = class _JBondClient {
7067
7065
  /**
7068
7066
  * Get all validator bonds for a given bond state
7069
7067
  */
7070
- async getBondValidatorStates(bondType, bondName) {
7068
+ async getValidatorBondsForState(bondType, bondName) {
7071
7069
  const [bondState] = this.pda.bondState(bondType, bondName);
7072
7070
  const accounts = await this.program.account.validatorBond.all([
7073
7071
  {