@jpool/bond-sdk 0.11.0-next.21 → 0.11.0-next.23

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
@@ -4578,8 +4578,9 @@ var VALIDATOR_BOND_SEED = "validator_bond";
4578
4578
  var STANDARD_BOND_SEED = "standard";
4579
4579
  var CROWDFUNDING_BOND_SEED = "crowdfunding";
4580
4580
  var ENV_PROGRAM_ID = {
4581
- ["dev" /* DEV */]: new PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4582
- ["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4581
+ ["dev" /* DEV */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4582
+ ["stage" /* STAGE */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4583
+ ["prod" /* PROD */]: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"
4583
4584
  };
4584
4585
  var { bs58 } = utils.bytes;
4585
4586
  var HistoryManager = class {
@@ -4743,7 +4744,7 @@ var jbond_default = {
4743
4744
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4744
4745
  metadata: {
4745
4746
  name: "jbond",
4746
- version: "0.2.1",
4747
+ version: "0.2.3",
4747
4748
  spec: "0.1.0",
4748
4749
  description: "Jpool Bond Program"
4749
4750
  },
@@ -4818,7 +4819,10 @@ var jbond_default = {
4818
4819
  },
4819
4820
  {
4820
4821
  name: "authority",
4821
- signer: true
4822
+ signer: true,
4823
+ relations: [
4824
+ "bond_state"
4825
+ ]
4822
4826
  },
4823
4827
  {
4824
4828
  name: "bond_token_account",
@@ -4992,10 +4996,12 @@ var jbond_default = {
4992
4996
  {
4993
4997
  name: "bond_lock_funds",
4994
4998
  docs: [
4995
- "Locks funds for both the current and upcoming epoch.",
4996
- "Moves collateral from available to locked state, making it unavailable for withdrawal for",
4997
- "the current and next epoch. # Errors",
4998
- "Fails if the validator is not active, or if there are insufficient available funds."
4999
+ "Locks funds immediately, making them unavailable for withdrawal.",
5000
+ "The locked amount takes effect immediately in the current epoch.",
5001
+ "",
5002
+ "# Errors",
5003
+ "Fails if the bond type is not lockable, if the amount is zero,",
5004
+ "or if there are insufficient available funds."
4999
5005
  ],
5000
5006
  discriminator: [
5001
5007
  117,
@@ -5092,7 +5098,34 @@ var jbond_default = {
5092
5098
  accounts: [
5093
5099
  {
5094
5100
  name: "bond_state",
5095
- writable: true
5101
+ writable: true,
5102
+ pda: {
5103
+ seeds: [
5104
+ {
5105
+ kind: "const",
5106
+ value: [
5107
+ 98,
5108
+ 111,
5109
+ 110,
5110
+ 100,
5111
+ 95,
5112
+ 115,
5113
+ 116,
5114
+ 97,
5115
+ 116,
5116
+ 101
5117
+ ]
5118
+ },
5119
+ {
5120
+ kind: "arg",
5121
+ path: "bond_type"
5122
+ },
5123
+ {
5124
+ kind: "arg",
5125
+ path: "bond_name"
5126
+ }
5127
+ ]
5128
+ }
5096
5129
  },
5097
5130
  {
5098
5131
  name: "validator_bond",
@@ -5180,10 +5213,13 @@ var jbond_default = {
5180
5213
  {
5181
5214
  name: "bond_release_funds",
5182
5215
  docs: [
5183
- "Releases locked funds after an epoch ends.",
5184
- "Moves collateral from locked back to available state, allowing withdrawals.",
5216
+ "Queues funds for unlock in the next epoch.",
5217
+ "The unlock is delayed by one epoch for security - funds remain locked",
5218
+ "in the current epoch but will be available after epoch transition.",
5219
+ "",
5185
5220
  "# Errors",
5186
- "Fails if the validator is not active, or if there are insufficient locked funds."
5221
+ "Fails if the bond type is not lockable, if the amount is zero,",
5222
+ "or if the amount exceeds currently locked funds."
5187
5223
  ],
5188
5224
  discriminator: [
5189
5225
  184,
@@ -5462,15 +5498,12 @@ var jbond_default = {
5462
5498
  {
5463
5499
  name: "bond_update",
5464
5500
  docs: [
5465
- "Transitions locked funds between epochs for a validator bond.",
5466
- "",
5467
- "This function should be called at epoch boundaries to update the bond's",
5468
- "`last_update_epoch` and move the `next_epoch_locked` amount into",
5469
- "`locked`. It ensures that the update only occurs once per epoch.",
5501
+ "Applies any pending unlocks from previous epochs.",
5470
5502
  "",
5471
- "# Errors",
5472
- "Returns [`BondError::InvalidEpoch`] if called more than once in the same epoch,",
5473
- "or if the system clock cannot be accessed."
5503
+ "This instruction is optional - all other operations now automatically",
5504
+ "sync the epoch state. It is kept for backwards compatibility and can",
5505
+ "be used to explicitly trigger epoch synchronization without performing",
5506
+ "another operation."
5474
5507
  ],
5475
5508
  discriminator: [
5476
5509
  237,
@@ -5489,7 +5522,6 @@ var jbond_default = {
5489
5522
  },
5490
5523
  {
5491
5524
  name: "payer",
5492
- writable: true,
5493
5525
  signer: true
5494
5526
  }
5495
5527
  ],
@@ -5857,6 +5889,19 @@ var jbond_default = {
5857
5889
  }
5858
5890
  ],
5859
5891
  events: [
5892
+ {
5893
+ name: "BondConfigured",
5894
+ discriminator: [
5895
+ 141,
5896
+ 252,
5897
+ 43,
5898
+ 54,
5899
+ 45,
5900
+ 157,
5901
+ 81,
5902
+ 14
5903
+ ]
5904
+ },
5860
5905
  {
5861
5906
  name: "BondFinished",
5862
5907
  discriminator: [
@@ -5870,6 +5915,32 @@ var jbond_default = {
5870
5915
  191
5871
5916
  ]
5872
5917
  },
5918
+ {
5919
+ name: "BondInitialized",
5920
+ discriminator: [
5921
+ 73,
5922
+ 68,
5923
+ 161,
5924
+ 2,
5925
+ 214,
5926
+ 12,
5927
+ 169,
5928
+ 53
5929
+ ]
5930
+ },
5931
+ {
5932
+ name: "BondRemoved",
5933
+ discriminator: [
5934
+ 177,
5935
+ 200,
5936
+ 116,
5937
+ 123,
5938
+ 1,
5939
+ 244,
5940
+ 161,
5941
+ 240
5942
+ ]
5943
+ },
5873
5944
  {
5874
5945
  name: "BondStarted",
5875
5946
  discriminator: [
@@ -5884,16 +5955,16 @@ var jbond_default = {
5884
5955
  ]
5885
5956
  },
5886
5957
  {
5887
- name: "CollateralToppedUp",
5958
+ name: "CollateralDeposited",
5888
5959
  discriminator: [
5889
- 189,
5890
- 137,
5891
- 204,
5892
- 58,
5960
+ 244,
5961
+ 62,
5962
+ 77,
5963
+ 11,
5893
5964
  135,
5894
- 182,
5895
- 19,
5896
- 176
5965
+ 112,
5966
+ 61,
5967
+ 96
5897
5968
  ]
5898
5969
  },
5899
5970
  {
@@ -5922,6 +5993,32 @@ var jbond_default = {
5922
5993
  32
5923
5994
  ]
5924
5995
  },
5996
+ {
5997
+ name: "FundsLocked",
5998
+ discriminator: [
5999
+ 227,
6000
+ 93,
6001
+ 162,
6002
+ 69,
6003
+ 181,
6004
+ 4,
6005
+ 71,
6006
+ 157
6007
+ ]
6008
+ },
6009
+ {
6010
+ name: "FundsUnlocked",
6011
+ discriminator: [
6012
+ 11,
6013
+ 240,
6014
+ 184,
6015
+ 107,
6016
+ 86,
6017
+ 187,
6018
+ 196,
6019
+ 128
6020
+ ]
6021
+ },
5925
6022
  {
5926
6023
  name: "ValidatorRegistered",
5927
6024
  discriminator: [
@@ -5934,33 +6031,46 @@ var jbond_default = {
5934
6031
  95,
5935
6032
  72
5936
6033
  ]
6034
+ },
6035
+ {
6036
+ name: "WithdrawAuthorityChanged",
6037
+ discriminator: [
6038
+ 91,
6039
+ 149,
6040
+ 224,
6041
+ 49,
6042
+ 187,
6043
+ 48,
6044
+ 190,
6045
+ 100
6046
+ ]
5937
6047
  }
5938
6048
  ],
5939
6049
  errors: [
5940
6050
  {
5941
6051
  code: 6e3,
5942
- name: "InvalidVoteAccount",
5943
- msg: "Invalid vote account"
6052
+ name: "Forbidden",
6053
+ msg: "Forbidden"
5944
6054
  },
5945
6055
  {
5946
6056
  code: 6001,
5947
- name: "IdentityMismatch",
5948
- msg: "Identity does not match vote account"
6057
+ name: "Unauthorized",
6058
+ msg: "Unauthorized"
5949
6059
  },
5950
6060
  {
5951
6061
  code: 6002,
5952
- name: "InsufficientCollateral",
5953
- msg: "Insufficient collateral amount"
6062
+ name: "InvalidVoteAccount",
6063
+ msg: "Invalid vote account"
5954
6064
  },
5955
6065
  {
5956
6066
  code: 6003,
5957
- name: "TargetAprTooLow",
5958
- msg: "Target APR is below minimum threshold"
6067
+ name: "IdentityMismatch",
6068
+ msg: "Vote account identity mismatch"
5959
6069
  },
5960
6070
  {
5961
6071
  code: 6004,
5962
- name: "MathOverflow",
5963
- msg: "Math overflow"
6072
+ name: "InvalidMint",
6073
+ msg: "Invalid mint address"
5964
6074
  },
5965
6075
  {
5966
6076
  code: 6005,
@@ -5969,103 +6079,53 @@ var jbond_default = {
5969
6079
  },
5970
6080
  {
5971
6081
  code: 6006,
5972
- name: "ValidatorNotActive",
5973
- msg: "Validator bond account is not active"
6082
+ name: "InvalidArgument",
6083
+ msg: "Invalid argument"
5974
6084
  },
5975
6085
  {
5976
6086
  code: 6007,
5977
- name: "ValidatorAlreadyRegistered",
5978
- msg: "Validator already registered"
6087
+ name: "InsufficientBalance",
6088
+ msg: "Insufficient balance"
5979
6089
  },
5980
6090
  {
5981
6091
  code: 6008,
5982
- name: "Unauthorized",
5983
- msg: "Unauthorized"
6092
+ name: "MathOverflow",
6093
+ msg: "Math overflow"
5984
6094
  },
5985
6095
  {
5986
6096
  code: 6009,
5987
- name: "WithdrawalLockedNearEpochEnd",
5988
- msg: "Withdrawals are locked near the end of the epoch."
6097
+ name: "Overflow",
6098
+ msg: "Arithmetic overflow"
5989
6099
  },
5990
6100
  {
5991
6101
  code: 6010,
5992
- name: "MissingTokenAccounts",
5993
- msg: "Missing token accounts for token collateral type"
6102
+ name: "BondNotRemovable",
6103
+ msg: "Bond cannot be removed"
5994
6104
  },
5995
6105
  {
5996
6106
  code: 6011,
5997
- name: "MissingTokenProgram",
5998
- msg: "Token program is required for token collateral type"
6107
+ name: "MissingTokenAccounts",
6108
+ msg: "Missing token accounts"
5999
6109
  },
6000
6110
  {
6001
6111
  code: 6012,
6002
- name: "InvalidMint",
6003
- msg: "Invalid mint for token collateral type"
6112
+ name: "MissingTokenProgram",
6113
+ msg: "Missing token program"
6004
6114
  },
6005
6115
  {
6006
6116
  code: 6013,
6007
6117
  name: "MissingStakeAccount",
6008
- msg: "Stake account is required for stake account collateral type"
6118
+ msg: "Missing stake account"
6009
6119
  },
6010
6120
  {
6011
6121
  code: 6014,
6012
6122
  name: "MissingStakeProgram",
6013
- msg: "Stake program is required for stake account collateral type"
6123
+ msg: "Missing stake program"
6014
6124
  },
6015
6125
  {
6016
6126
  code: 6015,
6017
- name: "BondFinished",
6018
- msg: "Bond is finished (deposits/withdrawals disabled)"
6019
- },
6020
- {
6021
- code: 6016,
6022
- name: "BondNotFinished",
6023
- msg: "Bond is not finished"
6024
- },
6025
- {
6026
- code: 6017,
6027
6127
  name: "UnsupportedCollateralType",
6028
6128
  msg: "Unsupported collateral type"
6029
- },
6030
- {
6031
- code: 6018,
6032
- name: "Overflow",
6033
- msg: "Math operation overflowed"
6034
- },
6035
- {
6036
- code: 6019,
6037
- name: "IncorrectBondType",
6038
- msg: "Incorrect bond type for this operation"
6039
- },
6040
- {
6041
- code: 6020,
6042
- name: "BondNotFinishable",
6043
- msg: "This bond type can't be finished"
6044
- },
6045
- {
6046
- code: 6021,
6047
- name: "InvalidArgument",
6048
- msg: "Invalid argument provided"
6049
- },
6050
- {
6051
- code: 6022,
6052
- name: "BondNotDisabled",
6053
- msg: "Bond is not disabled"
6054
- },
6055
- {
6056
- code: 6023,
6057
- name: "BondNotEnabled",
6058
- msg: "Bond is not enabled"
6059
- },
6060
- {
6061
- code: 6024,
6062
- name: "InvalidEpoch",
6063
- msg: "Invalid epoch for this operation"
6064
- },
6065
- {
6066
- code: 6025,
6067
- name: "BondNotRemovable",
6068
- msg: "Bond is not removable"
6069
6129
  }
6070
6130
  ],
6071
6131
  types: [
@@ -6099,6 +6159,26 @@ var jbond_default = {
6099
6159
  ]
6100
6160
  }
6101
6161
  },
6162
+ {
6163
+ name: "BondConfigured",
6164
+ type: {
6165
+ kind: "struct",
6166
+ fields: [
6167
+ {
6168
+ name: "bond",
6169
+ type: "pubkey"
6170
+ },
6171
+ {
6172
+ name: "authority",
6173
+ type: "pubkey"
6174
+ },
6175
+ {
6176
+ name: "timestamp",
6177
+ type: "i64"
6178
+ }
6179
+ ]
6180
+ }
6181
+ },
6102
6182
  {
6103
6183
  name: "BondFinished",
6104
6184
  type: {
@@ -6154,6 +6234,46 @@ var jbond_default = {
6154
6234
  ]
6155
6235
  }
6156
6236
  },
6237
+ {
6238
+ name: "BondInitialized",
6239
+ type: {
6240
+ kind: "struct",
6241
+ fields: [
6242
+ {
6243
+ name: "bond",
6244
+ type: "pubkey"
6245
+ },
6246
+ {
6247
+ name: "authority",
6248
+ type: "pubkey"
6249
+ },
6250
+ {
6251
+ name: "timestamp",
6252
+ type: "i64"
6253
+ }
6254
+ ]
6255
+ }
6256
+ },
6257
+ {
6258
+ name: "BondRemoved",
6259
+ type: {
6260
+ kind: "struct",
6261
+ fields: [
6262
+ {
6263
+ name: "bond",
6264
+ type: "pubkey"
6265
+ },
6266
+ {
6267
+ name: "authority",
6268
+ type: "pubkey"
6269
+ },
6270
+ {
6271
+ name: "timestamp",
6272
+ type: "i64"
6273
+ }
6274
+ ]
6275
+ }
6276
+ },
6157
6277
  {
6158
6278
  name: "BondStarted",
6159
6279
  type: {
@@ -6307,7 +6427,7 @@ var jbond_default = {
6307
6427
  }
6308
6428
  },
6309
6429
  {
6310
- name: "CollateralToppedUp",
6430
+ name: "CollateralDeposited",
6311
6431
  type: {
6312
6432
  kind: "struct",
6313
6433
  fields: [
@@ -6405,6 +6525,54 @@ var jbond_default = {
6405
6525
  ]
6406
6526
  }
6407
6527
  },
6528
+ {
6529
+ name: "FundsLocked",
6530
+ type: {
6531
+ kind: "struct",
6532
+ fields: [
6533
+ {
6534
+ name: "validator",
6535
+ type: "pubkey"
6536
+ },
6537
+ {
6538
+ name: "amount",
6539
+ type: "u64"
6540
+ },
6541
+ {
6542
+ name: "total_locked",
6543
+ type: "u64"
6544
+ },
6545
+ {
6546
+ name: "epoch",
6547
+ type: "u64"
6548
+ }
6549
+ ]
6550
+ }
6551
+ },
6552
+ {
6553
+ name: "FundsUnlocked",
6554
+ type: {
6555
+ kind: "struct",
6556
+ fields: [
6557
+ {
6558
+ name: "validator",
6559
+ type: "pubkey"
6560
+ },
6561
+ {
6562
+ name: "amount",
6563
+ type: "u64"
6564
+ },
6565
+ {
6566
+ name: "pending_unlock",
6567
+ type: "u64"
6568
+ },
6569
+ {
6570
+ name: "epoch",
6571
+ type: "u64"
6572
+ }
6573
+ ]
6574
+ }
6575
+ },
6408
6576
  {
6409
6577
  name: "GlobalConfigureData",
6410
6578
  type: {
@@ -6501,21 +6669,21 @@ var jbond_default = {
6501
6669
  {
6502
6670
  name: "locked",
6503
6671
  docs: [
6504
- "Amount of collateral currently locked"
6672
+ "Amount of collateral currently locked (unavailable for withdrawal)"
6505
6673
  ],
6506
6674
  type: "u64"
6507
6675
  },
6508
6676
  {
6509
- name: "next_epoch_locked",
6677
+ name: "pending_unlock",
6510
6678
  docs: [
6511
- "Amount of collateral locked for the next epoch"
6679
+ "Pending unlock amount (will reduce `locked` next epoch)"
6512
6680
  ],
6513
6681
  type: "u64"
6514
6682
  },
6515
6683
  {
6516
- name: "last_update_epoch",
6684
+ name: "pending_unlock_epoch",
6517
6685
  docs: [
6518
- "The last epoch when the bond was updated"
6686
+ "Epoch when pending_unlock was queued"
6519
6687
  ],
6520
6688
  type: "u64"
6521
6689
  }
@@ -6528,7 +6696,7 @@ var jbond_default = {
6528
6696
  kind: "struct",
6529
6697
  fields: [
6530
6698
  {
6531
- name: "identity",
6699
+ name: "validator",
6532
6700
  type: "pubkey"
6533
6701
  },
6534
6702
  {
@@ -6541,6 +6709,30 @@ var jbond_default = {
6541
6709
  }
6542
6710
  ]
6543
6711
  }
6712
+ },
6713
+ {
6714
+ name: "WithdrawAuthorityChanged",
6715
+ type: {
6716
+ kind: "struct",
6717
+ fields: [
6718
+ {
6719
+ name: "validator",
6720
+ type: "pubkey"
6721
+ },
6722
+ {
6723
+ name: "old_authority",
6724
+ type: {
6725
+ option: "pubkey"
6726
+ }
6727
+ },
6728
+ {
6729
+ name: "new_authority",
6730
+ type: {
6731
+ option: "pubkey"
6732
+ }
6733
+ }
6734
+ ]
6735
+ }
6544
6736
  }
6545
6737
  ],
6546
6738
  constants: [
@@ -6717,7 +6909,7 @@ var JBondClient = class _JBondClient {
6717
6909
  if (this.options.programId) {
6718
6910
  return this.options.programId;
6719
6911
  }
6720
- return ENV_PROGRAM_ID["prod" /* PROD */];
6912
+ return new PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
6721
6913
  }
6722
6914
  /**
6723
6915
  * Get the current connection.
@@ -6735,7 +6927,7 @@ var JBondClient = class _JBondClient {
6735
6927
  }
6736
6928
  this._program = null;
6737
6929
  this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6738
- return this.configure("programId", envProgramId);
6930
+ return this.configure("programId", new PublicKey(envProgramId));
6739
6931
  }
6740
6932
  /**
6741
6933
  * Configure a specific option.
@@ -7141,22 +7333,6 @@ var JBondClient = class _JBondClient {
7141
7333
  const ix = await this.getReleaseFundsIx(props);
7142
7334
  return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7143
7335
  }
7144
- /**
7145
- * Update epoch locks
7146
- */
7147
- async updateEpochLocks(props) {
7148
- const { bondType, bondName, voteAccount, payer } = props;
7149
- const ix = await this.getUpdateEpochLocksIx({ bondType, bondName, voteAccount, payer });
7150
- return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7151
- }
7152
- /**
7153
- * Build update epoch locks instruction
7154
- */
7155
- async getUpdateEpochLocksIx(props) {
7156
- const { bondType, bondName, voteAccount, payer } = props;
7157
- const [validatorBond, _] = this.pda.validatorBond(bondType, bondName, voteAccount);
7158
- return this.program.methods.bondUpdate().accountsPartial({ validatorBond, payer }).instruction();
7159
- }
7160
7336
  /**
7161
7337
  * Build bond remove instruction
7162
7338
  */
@@ -7291,7 +7467,7 @@ var JBondClient = class _JBondClient {
7291
7467
  const tokenAccount = getAssociatedTokenAddressSync(mint, address, true);
7292
7468
  try {
7293
7469
  const balance = await this.connection.getTokenAccountBalance(tokenAccount);
7294
- return solToLamports(balance.value.amount).toNumber();
7470
+ return Number(balance.value.amount);
7295
7471
  } catch {
7296
7472
  return 0;
7297
7473
  }