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

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 the upcoming epoch.",
4991
+ "Moves collateral from available to locked state which cannot be withdrawn.",
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,31 @@ var jbond_default = {
5275
5355
  }
5276
5356
  ]
5277
5357
  },
5358
+ {
5359
+ name: "bond_update",
5360
+ discriminator: [
5361
+ 237,
5362
+ 102,
5363
+ 183,
5364
+ 192,
5365
+ 94,
5366
+ 83,
5367
+ 52,
5368
+ 82
5369
+ ],
5370
+ accounts: [
5371
+ {
5372
+ name: "validator_bond",
5373
+ writable: true
5374
+ },
5375
+ {
5376
+ name: "payer",
5377
+ writable: true,
5378
+ signer: true
5379
+ }
5380
+ ],
5381
+ args: []
5382
+ },
5278
5383
  {
5279
5384
  name: "bond_withdraw",
5280
5385
  docs: [
@@ -5875,6 +5980,11 @@ var jbond_default = {
5875
5980
  code: 6023,
5876
5981
  name: "BondNotEnabled",
5877
5982
  msg: "Bond is not enabled"
5983
+ },
5984
+ {
5985
+ code: 6024,
5986
+ name: "InvalidEpoch",
5987
+ msg: "Invalid epoch for this operation"
5878
5988
  }
5879
5989
  ],
5880
5990
  types: [
@@ -6306,6 +6416,27 @@ var jbond_default = {
6306
6416
  "Bump for the PDA"
6307
6417
  ],
6308
6418
  type: "u8"
6419
+ },
6420
+ {
6421
+ name: "next_epoch_locked",
6422
+ docs: [
6423
+ "Amount of collateral locked for the next epoch"
6424
+ ],
6425
+ type: "u64"
6426
+ },
6427
+ {
6428
+ name: "current_epoch_locked",
6429
+ docs: [
6430
+ "Amount of collateral locked for the current epoch"
6431
+ ],
6432
+ type: "u64"
6433
+ },
6434
+ {
6435
+ name: "last_update_epoch",
6436
+ docs: [
6437
+ "The last epoch when the bond was updated"
6438
+ ],
6439
+ type: "u64"
6309
6440
  }
6310
6441
  ]
6311
6442
  }
@@ -6905,6 +7036,48 @@ var JBondClient = class _JBondClient {
6905
7036
  const authority = this.provider.wallet?.publicKey;
6906
7037
  return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
6907
7038
  }
7039
+ /**
7040
+ * Build lock funds instruction
7041
+ */
7042
+ async getLockFundsIx(props) {
7043
+ const { bondType, name, voteAccount, amount } = props;
7044
+ const [bondState] = this.pda.bondState(bondType, name);
7045
+ let collateralType = props.collateralType;
7046
+ if (!collateralType) {
7047
+ const bondState2 = await this.getBondState(bondType, name);
7048
+ collateralType = bondState2.collateralType;
7049
+ }
7050
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7051
+ const authority = this.provider.wallet?.publicKey;
7052
+ const accounts = {
7053
+ bondState,
7054
+ validatorBond,
7055
+ payer: authority,
7056
+ bondTokenAccount: null
7057
+ };
7058
+ matchVariant(collateralType, {
7059
+ native: () => {
7060
+ },
7061
+ token: (mint) => {
7062
+ const bondTokenAccount = getAssociatedTokenAddressSync(mint, validatorBond, true);
7063
+ accounts.bondTokenAccount = bondTokenAccount;
7064
+ }
7065
+ });
7066
+ return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7067
+ }
7068
+ /**
7069
+ * Build release funds instruction
7070
+ */
7071
+ async getReleaseFundsIx(props) {
7072
+ const { bondType, name, voteAccount, amount } = props;
7073
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7074
+ const authority = this.provider.wallet?.publicKey;
7075
+ const accounts = {
7076
+ validatorBond,
7077
+ payer: authority
7078
+ };
7079
+ return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7080
+ }
6908
7081
  /**
6909
7082
  * Get all bond states with total collected collateral
6910
7083
  */