@jpool/bond-sdk 0.11.0-next.7 → 0.11.0-next.9

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
@@ -1832,6 +1832,7 @@ type BondLockFunds = {
1832
1832
  bondType: BondType;
1833
1833
  name: string;
1834
1834
  amount: number;
1835
+ withdrawAuthority: PublicKey;
1835
1836
  voteAccount: PublicKey;
1836
1837
  collateralType?: CollateralType;
1837
1838
  };
@@ -1839,6 +1840,7 @@ type BondReleaseFunds = {
1839
1840
  bondType: BondType;
1840
1841
  name: string;
1841
1842
  amount: number;
1843
+ withdrawAuthority: PublicKey;
1842
1844
  voteAccount: PublicKey;
1843
1845
  };
1844
1846
  type ClaimAllProps = {
@@ -2091,6 +2093,8 @@ declare class JBondClient {
2091
2093
  * Build start crowdfunding session instruction
2092
2094
  */
2093
2095
  getBondSessionStartIx(props: BondStartProps): Promise<TransactionInstruction>;
2096
+ lockFunds(props: BondLockFunds): Promise<string | undefined>;
2097
+ releaseFunds(props: BondReleaseFunds): Promise<string | undefined>;
2094
2098
  /**
2095
2099
  * Build lock funds instruction
2096
2100
  */
@@ -2099,6 +2103,10 @@ declare class JBondClient {
2099
2103
  * Build release funds instruction
2100
2104
  */
2101
2105
  getReleaseFundsIx(props: BondReleaseFunds): Promise<TransactionInstruction>;
2106
+ /**
2107
+ * Get available collateral for withdrawal (taking into account locked funds)
2108
+ */
2109
+ getAvailableCollateral(bondType: BondType, bondName: string, voteAccount: PublicKeyInitData): Promise<number>;
2102
2110
  /**
2103
2111
  * Get all bond states with total collected collateral
2104
2112
  */
package/dist/index.d.ts CHANGED
@@ -1832,6 +1832,7 @@ type BondLockFunds = {
1832
1832
  bondType: BondType;
1833
1833
  name: string;
1834
1834
  amount: number;
1835
+ withdrawAuthority: PublicKey;
1835
1836
  voteAccount: PublicKey;
1836
1837
  collateralType?: CollateralType;
1837
1838
  };
@@ -1839,6 +1840,7 @@ type BondReleaseFunds = {
1839
1840
  bondType: BondType;
1840
1841
  name: string;
1841
1842
  amount: number;
1843
+ withdrawAuthority: PublicKey;
1842
1844
  voteAccount: PublicKey;
1843
1845
  };
1844
1846
  type ClaimAllProps = {
@@ -2091,6 +2093,8 @@ declare class JBondClient {
2091
2093
  * Build start crowdfunding session instruction
2092
2094
  */
2093
2095
  getBondSessionStartIx(props: BondStartProps): Promise<TransactionInstruction>;
2096
+ lockFunds(props: BondLockFunds): Promise<string | undefined>;
2097
+ releaseFunds(props: BondReleaseFunds): Promise<string | undefined>;
2094
2098
  /**
2095
2099
  * Build lock funds instruction
2096
2100
  */
@@ -2099,6 +2103,10 @@ declare class JBondClient {
2099
2103
  * Build release funds instruction
2100
2104
  */
2101
2105
  getReleaseFundsIx(props: BondReleaseFunds): Promise<TransactionInstruction>;
2106
+ /**
2107
+ * Get available collateral for withdrawal (taking into account locked funds)
2108
+ */
2109
+ getAvailableCollateral(bondType: BondType, bondName: string, voteAccount: PublicKeyInitData): Promise<number>;
2102
2110
  /**
2103
2111
  * Get all bond states with total collected collateral
2104
2112
  */
package/dist/index.js CHANGED
@@ -7079,11 +7079,19 @@ var JBondClient = class _JBondClient {
7079
7079
  const authority = this.provider.wallet?.publicKey;
7080
7080
  return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
7081
7081
  }
7082
+ async lockFunds(props) {
7083
+ const ix = await this.getLockFundsIx(props);
7084
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7085
+ }
7086
+ async releaseFunds(props) {
7087
+ const ix = await this.getReleaseFundsIx(props);
7088
+ return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7089
+ }
7082
7090
  /**
7083
7091
  * Build lock funds instruction
7084
7092
  */
7085
7093
  async getLockFundsIx(props) {
7086
- const { bondType, name, voteAccount, amount } = props;
7094
+ const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
7087
7095
  const [bondState] = this.pda.bondState(bondType, name);
7088
7096
  let collateralType = props.collateralType;
7089
7097
  if (!collateralType) {
@@ -7091,11 +7099,10 @@ var JBondClient = class _JBondClient {
7091
7099
  collateralType = bondState2.collateralType;
7092
7100
  }
7093
7101
  const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7094
- const authority = this.provider.wallet?.publicKey;
7095
7102
  const accounts = {
7096
7103
  bondState,
7097
7104
  validatorBond,
7098
- payer: authority,
7105
+ payer: withdrawAuthority,
7099
7106
  bondTokenAccount: null
7100
7107
  };
7101
7108
  matchVariant(collateralType, {
@@ -7112,15 +7119,21 @@ var JBondClient = class _JBondClient {
7112
7119
  * Build release funds instruction
7113
7120
  */
7114
7121
  async getReleaseFundsIx(props) {
7115
- const { bondType, name, voteAccount, amount } = props;
7122
+ const { bondType, name, voteAccount, amount, withdrawAuthority } = props;
7116
7123
  const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7117
- const authority = this.provider.wallet?.publicKey;
7118
7124
  const accounts = {
7119
7125
  validatorBond,
7120
- payer: authority
7126
+ payer: withdrawAuthority
7121
7127
  };
7122
7128
  return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7123
7129
  }
7130
+ /**
7131
+ * Get available collateral for withdrawal (taking into account locked funds)
7132
+ */
7133
+ async getAvailableCollateral(bondType, bondName, voteAccount) {
7134
+ const validatorBond = await this.getValidatorBond(bondType, bondName, voteAccount);
7135
+ return await this.getValidatorBondBalance(bondType, bondName, voteAccount) - validatorBond.currentEpochLocked.toNumber();
7136
+ }
7124
7137
  /**
7125
7138
  * Get all bond states with total collected collateral
7126
7139
  */