@jpool/bond-sdk 0.11.0-next.22 → 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,9 +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
- ["stage" /* STAGE */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"),
4583
- ["prod" /* PROD */]: new PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4581
+ ["dev" /* DEV */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4582
+ ["stage" /* STAGE */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4583
+ ["prod" /* PROD */]: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"
4584
4584
  };
4585
4585
  var { bs58 } = utils.bytes;
4586
4586
  var HistoryManager = class {
@@ -4744,7 +4744,7 @@ var jbond_default = {
4744
4744
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4745
4745
  metadata: {
4746
4746
  name: "jbond",
4747
- version: "0.2.2",
4747
+ version: "0.2.3",
4748
4748
  spec: "0.1.0",
4749
4749
  description: "Jpool Bond Program"
4750
4750
  },
@@ -4819,7 +4819,10 @@ var jbond_default = {
4819
4819
  },
4820
4820
  {
4821
4821
  name: "authority",
4822
- signer: true
4822
+ signer: true,
4823
+ relations: [
4824
+ "bond_state"
4825
+ ]
4823
4826
  },
4824
4827
  {
4825
4828
  name: "bond_token_account",
@@ -4993,10 +4996,12 @@ var jbond_default = {
4993
4996
  {
4994
4997
  name: "bond_lock_funds",
4995
4998
  docs: [
4996
- "Locks funds for both the current and upcoming epoch.",
4997
- "Moves collateral from available to locked state, making it unavailable for withdrawal for",
4998
- "the current and next epoch. # Errors",
4999
- "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."
5000
5005
  ],
5001
5006
  discriminator: [
5002
5007
  117,
@@ -5093,7 +5098,34 @@ var jbond_default = {
5093
5098
  accounts: [
5094
5099
  {
5095
5100
  name: "bond_state",
5096
- 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
+ }
5097
5129
  },
5098
5130
  {
5099
5131
  name: "validator_bond",
@@ -5181,10 +5213,13 @@ var jbond_default = {
5181
5213
  {
5182
5214
  name: "bond_release_funds",
5183
5215
  docs: [
5184
- "Releases locked funds after an epoch ends.",
5185
- "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
+ "",
5186
5220
  "# Errors",
5187
- "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."
5188
5223
  ],
5189
5224
  discriminator: [
5190
5225
  184,
@@ -5463,15 +5498,12 @@ var jbond_default = {
5463
5498
  {
5464
5499
  name: "bond_update",
5465
5500
  docs: [
5466
- "Transitions locked funds between epochs for a validator bond.",
5467
- "",
5468
- "This function should be called at epoch boundaries to update the bond's",
5469
- "`last_update_epoch` and move the `next_epoch_locked` amount into",
5470
- "`locked`. It ensures that the update only occurs once per epoch.",
5501
+ "Applies any pending unlocks from previous epochs.",
5471
5502
  "",
5472
- "# Errors",
5473
- "Returns [`BondError::InvalidEpoch`] if called more than once in the same epoch,",
5474
- "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."
5475
5507
  ],
5476
5508
  discriminator: [
5477
5509
  237,
@@ -5490,7 +5522,6 @@ var jbond_default = {
5490
5522
  },
5491
5523
  {
5492
5524
  name: "payer",
5493
- writable: true,
5494
5525
  signer: true
5495
5526
  }
5496
5527
  ],
@@ -5713,38 +5744,6 @@ var jbond_default = {
5713
5744
  ],
5714
5745
  args: []
5715
5746
  },
5716
- {
5717
- name: "migrate_validator_bond",
5718
- docs: [
5719
- "migrate validator bond from legacy format to new format"
5720
- ],
5721
- discriminator: [
5722
- 214,
5723
- 114,
5724
- 65,
5725
- 138,
5726
- 248,
5727
- 45,
5728
- 186,
5729
- 229
5730
- ],
5731
- accounts: [
5732
- {
5733
- name: "validator_bond",
5734
- writable: true
5735
- },
5736
- {
5737
- name: "authority",
5738
- writable: true,
5739
- signer: true
5740
- },
5741
- {
5742
- name: "system_program",
5743
- address: "11111111111111111111111111111111"
5744
- }
5745
- ],
5746
- args: []
5747
- },
5748
5747
  {
5749
5748
  name: "session_finish",
5750
5749
  docs: [
@@ -5890,6 +5889,19 @@ var jbond_default = {
5890
5889
  }
5891
5890
  ],
5892
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
+ },
5893
5905
  {
5894
5906
  name: "BondFinished",
5895
5907
  discriminator: [
@@ -5903,6 +5915,32 @@ var jbond_default = {
5903
5915
  191
5904
5916
  ]
5905
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
+ },
5906
5944
  {
5907
5945
  name: "BondStarted",
5908
5946
  discriminator: [
@@ -5917,16 +5955,16 @@ var jbond_default = {
5917
5955
  ]
5918
5956
  },
5919
5957
  {
5920
- name: "CollateralToppedUp",
5958
+ name: "CollateralDeposited",
5921
5959
  discriminator: [
5922
- 189,
5923
- 137,
5924
- 204,
5925
- 58,
5960
+ 244,
5961
+ 62,
5962
+ 77,
5963
+ 11,
5926
5964
  135,
5927
- 182,
5928
- 19,
5929
- 176
5965
+ 112,
5966
+ 61,
5967
+ 96
5930
5968
  ]
5931
5969
  },
5932
5970
  {
@@ -5955,6 +5993,32 @@ var jbond_default = {
5955
5993
  32
5956
5994
  ]
5957
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
+ },
5958
6022
  {
5959
6023
  name: "ValidatorRegistered",
5960
6024
  discriminator: [
@@ -5967,33 +6031,46 @@ var jbond_default = {
5967
6031
  95,
5968
6032
  72
5969
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
+ ]
5970
6047
  }
5971
6048
  ],
5972
6049
  errors: [
5973
6050
  {
5974
6051
  code: 6e3,
5975
- name: "InvalidVoteAccount",
5976
- msg: "Invalid vote account"
6052
+ name: "Forbidden",
6053
+ msg: "Forbidden"
5977
6054
  },
5978
6055
  {
5979
6056
  code: 6001,
5980
- name: "IdentityMismatch",
5981
- msg: "Identity does not match vote account"
6057
+ name: "Unauthorized",
6058
+ msg: "Unauthorized"
5982
6059
  },
5983
6060
  {
5984
6061
  code: 6002,
5985
- name: "InsufficientCollateral",
5986
- msg: "Insufficient collateral amount"
6062
+ name: "InvalidVoteAccount",
6063
+ msg: "Invalid vote account"
5987
6064
  },
5988
6065
  {
5989
6066
  code: 6003,
5990
- name: "TargetAprTooLow",
5991
- msg: "Target APR is below minimum threshold"
6067
+ name: "IdentityMismatch",
6068
+ msg: "Vote account identity mismatch"
5992
6069
  },
5993
6070
  {
5994
6071
  code: 6004,
5995
- name: "MathOverflow",
5996
- msg: "Math overflow"
6072
+ name: "InvalidMint",
6073
+ msg: "Invalid mint address"
5997
6074
  },
5998
6075
  {
5999
6076
  code: 6005,
@@ -6002,103 +6079,53 @@ var jbond_default = {
6002
6079
  },
6003
6080
  {
6004
6081
  code: 6006,
6005
- name: "ValidatorNotActive",
6006
- msg: "Validator bond account is not active"
6082
+ name: "InvalidArgument",
6083
+ msg: "Invalid argument"
6007
6084
  },
6008
6085
  {
6009
6086
  code: 6007,
6010
- name: "ValidatorAlreadyRegistered",
6011
- msg: "Validator already registered"
6087
+ name: "InsufficientBalance",
6088
+ msg: "Insufficient balance"
6012
6089
  },
6013
6090
  {
6014
6091
  code: 6008,
6015
- name: "Unauthorized",
6016
- msg: "Unauthorized"
6092
+ name: "MathOverflow",
6093
+ msg: "Math overflow"
6017
6094
  },
6018
6095
  {
6019
6096
  code: 6009,
6020
- name: "WithdrawalLockedNearEpochEnd",
6021
- msg: "Withdrawals are locked near the end of the epoch."
6097
+ name: "Overflow",
6098
+ msg: "Arithmetic overflow"
6022
6099
  },
6023
6100
  {
6024
6101
  code: 6010,
6025
- name: "MissingTokenAccounts",
6026
- msg: "Missing token accounts for token collateral type"
6102
+ name: "BondNotRemovable",
6103
+ msg: "Bond cannot be removed"
6027
6104
  },
6028
6105
  {
6029
6106
  code: 6011,
6030
- name: "MissingTokenProgram",
6031
- msg: "Token program is required for token collateral type"
6107
+ name: "MissingTokenAccounts",
6108
+ msg: "Missing token accounts"
6032
6109
  },
6033
6110
  {
6034
6111
  code: 6012,
6035
- name: "InvalidMint",
6036
- msg: "Invalid mint for token collateral type"
6112
+ name: "MissingTokenProgram",
6113
+ msg: "Missing token program"
6037
6114
  },
6038
6115
  {
6039
6116
  code: 6013,
6040
6117
  name: "MissingStakeAccount",
6041
- msg: "Stake account is required for stake account collateral type"
6118
+ msg: "Missing stake account"
6042
6119
  },
6043
6120
  {
6044
6121
  code: 6014,
6045
6122
  name: "MissingStakeProgram",
6046
- msg: "Stake program is required for stake account collateral type"
6123
+ msg: "Missing stake program"
6047
6124
  },
6048
6125
  {
6049
6126
  code: 6015,
6050
- name: "BondFinished",
6051
- msg: "Bond is finished (deposits/withdrawals disabled)"
6052
- },
6053
- {
6054
- code: 6016,
6055
- name: "BondNotFinished",
6056
- msg: "Bond is not finished"
6057
- },
6058
- {
6059
- code: 6017,
6060
6127
  name: "UnsupportedCollateralType",
6061
6128
  msg: "Unsupported collateral type"
6062
- },
6063
- {
6064
- code: 6018,
6065
- name: "Overflow",
6066
- msg: "Math operation overflowed"
6067
- },
6068
- {
6069
- code: 6019,
6070
- name: "IncorrectBondType",
6071
- msg: "Incorrect bond type for this operation"
6072
- },
6073
- {
6074
- code: 6020,
6075
- name: "BondNotFinishable",
6076
- msg: "This bond type can't be finished"
6077
- },
6078
- {
6079
- code: 6021,
6080
- name: "InvalidArgument",
6081
- msg: "Invalid argument provided"
6082
- },
6083
- {
6084
- code: 6022,
6085
- name: "BondNotDisabled",
6086
- msg: "Bond is not disabled"
6087
- },
6088
- {
6089
- code: 6023,
6090
- name: "BondNotEnabled",
6091
- msg: "Bond is not enabled"
6092
- },
6093
- {
6094
- code: 6024,
6095
- name: "InvalidEpoch",
6096
- msg: "Invalid epoch for this operation"
6097
- },
6098
- {
6099
- code: 6025,
6100
- name: "BondNotRemovable",
6101
- msg: "Bond is not removable"
6102
6129
  }
6103
6130
  ],
6104
6131
  types: [
@@ -6132,6 +6159,26 @@ var jbond_default = {
6132
6159
  ]
6133
6160
  }
6134
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
+ },
6135
6182
  {
6136
6183
  name: "BondFinished",
6137
6184
  type: {
@@ -6187,6 +6234,46 @@ var jbond_default = {
6187
6234
  ]
6188
6235
  }
6189
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
+ },
6190
6277
  {
6191
6278
  name: "BondStarted",
6192
6279
  type: {
@@ -6340,7 +6427,7 @@ var jbond_default = {
6340
6427
  }
6341
6428
  },
6342
6429
  {
6343
- name: "CollateralToppedUp",
6430
+ name: "CollateralDeposited",
6344
6431
  type: {
6345
6432
  kind: "struct",
6346
6433
  fields: [
@@ -6438,6 +6525,54 @@ var jbond_default = {
6438
6525
  ]
6439
6526
  }
6440
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
+ },
6441
6576
  {
6442
6577
  name: "GlobalConfigureData",
6443
6578
  type: {
@@ -6534,21 +6669,21 @@ var jbond_default = {
6534
6669
  {
6535
6670
  name: "locked",
6536
6671
  docs: [
6537
- "Amount of collateral currently locked"
6672
+ "Amount of collateral currently locked (unavailable for withdrawal)"
6538
6673
  ],
6539
6674
  type: "u64"
6540
6675
  },
6541
6676
  {
6542
- name: "next_epoch_locked",
6677
+ name: "pending_unlock",
6543
6678
  docs: [
6544
- "Amount of collateral locked for the next epoch"
6679
+ "Pending unlock amount (will reduce `locked` next epoch)"
6545
6680
  ],
6546
6681
  type: "u64"
6547
6682
  },
6548
6683
  {
6549
- name: "last_update_epoch",
6684
+ name: "pending_unlock_epoch",
6550
6685
  docs: [
6551
- "The last epoch when the bond was updated"
6686
+ "Epoch when pending_unlock was queued"
6552
6687
  ],
6553
6688
  type: "u64"
6554
6689
  }
@@ -6561,7 +6696,7 @@ var jbond_default = {
6561
6696
  kind: "struct",
6562
6697
  fields: [
6563
6698
  {
6564
- name: "identity",
6699
+ name: "validator",
6565
6700
  type: "pubkey"
6566
6701
  },
6567
6702
  {
@@ -6574,6 +6709,30 @@ var jbond_default = {
6574
6709
  }
6575
6710
  ]
6576
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
+ }
6577
6736
  }
6578
6737
  ],
6579
6738
  constants: [
@@ -7174,22 +7333,6 @@ var JBondClient = class _JBondClient {
7174
7333
  const ix = await this.getReleaseFundsIx(props);
7175
7334
  return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7176
7335
  }
7177
- /**
7178
- * Update epoch locks
7179
- */
7180
- async updateEpochLocks(props) {
7181
- const { bondType, bondName, voteAccount, payer } = props;
7182
- const ix = await this.getUpdateEpochLocksIx({ bondType, bondName, voteAccount, payer });
7183
- return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7184
- }
7185
- /**
7186
- * Build update epoch locks instruction
7187
- */
7188
- async getUpdateEpochLocksIx(props) {
7189
- const { bondType, bondName, voteAccount, payer } = props;
7190
- const [validatorBond, _] = this.pda.validatorBond(bondType, bondName, voteAccount);
7191
- return this.program.methods.bondUpdate().accountsPartial({ validatorBond, payer }).instruction();
7192
- }
7193
7336
  /**
7194
7337
  * Build bond remove instruction
7195
7338
  */
@@ -7238,21 +7381,6 @@ var JBondClient = class _JBondClient {
7238
7381
  });
7239
7382
  return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7240
7383
  }
7241
- async migrateValidatorBond(props) {
7242
- const ix = await this.getMigrateValidatorBondIx(props);
7243
- return this.provider.sendAndConfirm?.(new Transaction().add(ix));
7244
- }
7245
- async getMigrateValidatorBondIx(props) {
7246
- const { bondType, name, voteAccount } = props;
7247
- const [bondState] = this.pda.bondState(bondType, name);
7248
- const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7249
- const accounts = {
7250
- bondState,
7251
- validatorBond,
7252
- systemProgram: PublicKey.default
7253
- };
7254
- return this.program.methods.migrateValidatorBond().accountsPartial(accounts).instruction();
7255
- }
7256
7384
  /**
7257
7385
  * Build release funds instruction
7258
7386
  */