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

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
@@ -4984,6 +4984,50 @@ var jbond_default = {
4984
4984
  }
4985
4985
  ]
4986
4986
  },
4987
+ {
4988
+ name: "bond_lock_funds",
4989
+ docs: [
4990
+ "Locks funds for both the current and upcoming epoch.",
4991
+ "Moves collateral from available to locked state, making it unavailable for withdrawal for the current and next epoch.",
4992
+ "# Errors",
4993
+ "Fails if the validator is not active, or if there are insufficient available funds."
4994
+ ],
4995
+ discriminator: [
4996
+ 117,
4997
+ 166,
4998
+ 195,
4999
+ 99,
5000
+ 103,
5001
+ 45,
5002
+ 195,
5003
+ 2
5004
+ ],
5005
+ accounts: [
5006
+ {
5007
+ name: "bond_state",
5008
+ writable: true
5009
+ },
5010
+ {
5011
+ name: "validator_bond",
5012
+ writable: true
5013
+ },
5014
+ {
5015
+ name: "bond_token_account",
5016
+ optional: true
5017
+ },
5018
+ {
5019
+ name: "payer",
5020
+ writable: true,
5021
+ signer: true
5022
+ }
5023
+ ],
5024
+ args: [
5025
+ {
5026
+ name: "amount",
5027
+ type: "u64"
5028
+ }
5029
+ ]
5030
+ },
4987
5031
  {
4988
5032
  name: "bond_register",
4989
5033
  docs: [
@@ -5096,6 +5140,42 @@ var jbond_default = {
5096
5140
  }
5097
5141
  ]
5098
5142
  },
5143
+ {
5144
+ name: "bond_release_funds",
5145
+ docs: [
5146
+ "Releases locked funds after an epoch ends.",
5147
+ "Moves collateral from locked back to available state, allowing withdrawals.",
5148
+ "# Errors",
5149
+ "Fails if the validator is not active, or if there are insufficient locked funds."
5150
+ ],
5151
+ discriminator: [
5152
+ 184,
5153
+ 224,
5154
+ 14,
5155
+ 24,
5156
+ 76,
5157
+ 14,
5158
+ 226,
5159
+ 190
5160
+ ],
5161
+ accounts: [
5162
+ {
5163
+ name: "validator_bond",
5164
+ writable: true
5165
+ },
5166
+ {
5167
+ name: "payer",
5168
+ writable: true,
5169
+ signer: true
5170
+ }
5171
+ ],
5172
+ args: [
5173
+ {
5174
+ name: "amount",
5175
+ type: "u64"
5176
+ }
5177
+ ]
5178
+ },
5099
5179
  {
5100
5180
  name: "bond_set_withdraw_authority",
5101
5181
  docs: [
@@ -5275,6 +5355,42 @@ var jbond_default = {
5275
5355
  }
5276
5356
  ]
5277
5357
  },
5358
+ {
5359
+ name: "bond_update",
5360
+ docs: [
5361
+ "Transitions locked funds between epochs for a validator bond.",
5362
+ "",
5363
+ "This function should be called at epoch boundaries to update the bond's",
5364
+ "`last_update_epoch` and move the `next_epoch_locked` amount into",
5365
+ "`current_epoch_locked`. It ensures that the update only occurs once per epoch.",
5366
+ "",
5367
+ "# Errors",
5368
+ "Returns [`BondError::InvalidEpoch`] if called more than once in the same epoch,",
5369
+ "or if the system clock cannot be accessed."
5370
+ ],
5371
+ discriminator: [
5372
+ 237,
5373
+ 102,
5374
+ 183,
5375
+ 192,
5376
+ 94,
5377
+ 83,
5378
+ 52,
5379
+ 82
5380
+ ],
5381
+ accounts: [
5382
+ {
5383
+ name: "validator_bond",
5384
+ writable: true
5385
+ },
5386
+ {
5387
+ name: "payer",
5388
+ writable: true,
5389
+ signer: true
5390
+ }
5391
+ ],
5392
+ args: []
5393
+ },
5278
5394
  {
5279
5395
  name: "bond_withdraw",
5280
5396
  docs: [
@@ -5875,6 +5991,11 @@ var jbond_default = {
5875
5991
  code: 6023,
5876
5992
  name: "BondNotEnabled",
5877
5993
  msg: "Bond is not enabled"
5994
+ },
5995
+ {
5996
+ code: 6024,
5997
+ name: "InvalidEpoch",
5998
+ msg: "Invalid epoch for this operation"
5878
5999
  }
5879
6000
  ],
5880
6001
  types: [
@@ -6306,6 +6427,27 @@ var jbond_default = {
6306
6427
  "Bump for the PDA"
6307
6428
  ],
6308
6429
  type: "u8"
6430
+ },
6431
+ {
6432
+ name: "next_epoch_locked",
6433
+ docs: [
6434
+ "Amount of collateral locked for the next epoch"
6435
+ ],
6436
+ type: "u64"
6437
+ },
6438
+ {
6439
+ name: "current_epoch_locked",
6440
+ docs: [
6441
+ "Amount of collateral locked for the current epoch"
6442
+ ],
6443
+ type: "u64"
6444
+ },
6445
+ {
6446
+ name: "last_update_epoch",
6447
+ docs: [
6448
+ "The last epoch when the bond was updated"
6449
+ ],
6450
+ type: "u64"
6309
6451
  }
6310
6452
  ]
6311
6453
  }
@@ -6905,6 +7047,48 @@ var JBondClient = class _JBondClient {
6905
7047
  const authority = this.provider.wallet?.publicKey;
6906
7048
  return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
6907
7049
  }
7050
+ /**
7051
+ * Build lock funds instruction
7052
+ */
7053
+ async getLockFundsIx(props) {
7054
+ const { bondType, name, voteAccount, amount } = props;
7055
+ const [bondState] = this.pda.bondState(bondType, name);
7056
+ let collateralType = props.collateralType;
7057
+ if (!collateralType) {
7058
+ const bondState2 = await this.getBondState(bondType, name);
7059
+ collateralType = bondState2.collateralType;
7060
+ }
7061
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7062
+ const authority = this.provider.wallet?.publicKey;
7063
+ const accounts = {
7064
+ bondState,
7065
+ validatorBond,
7066
+ payer: authority,
7067
+ bondTokenAccount: null
7068
+ };
7069
+ matchVariant(collateralType, {
7070
+ native: () => {
7071
+ },
7072
+ token: (mint) => {
7073
+ const bondTokenAccount = getAssociatedTokenAddressSync(mint, validatorBond, true);
7074
+ accounts.bondTokenAccount = bondTokenAccount;
7075
+ }
7076
+ });
7077
+ return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7078
+ }
7079
+ /**
7080
+ * Build release funds instruction
7081
+ */
7082
+ async getReleaseFundsIx(props) {
7083
+ const { bondType, name, voteAccount, amount } = props;
7084
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7085
+ const authority = this.provider.wallet?.publicKey;
7086
+ const accounts = {
7087
+ validatorBond,
7088
+ payer: authority
7089
+ };
7090
+ return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7091
+ }
6908
7092
  /**
6909
7093
  * Get all bond states with total collected collateral
6910
7094
  */