@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.js CHANGED
@@ -4601,9 +4601,9 @@ var VALIDATOR_BOND_SEED = "validator_bond";
4601
4601
  var STANDARD_BOND_SEED = "standard";
4602
4602
  var CROWDFUNDING_BOND_SEED = "crowdfunding";
4603
4603
  var ENV_PROGRAM_ID = {
4604
- ["dev" /* DEV */]: new web3_js.PublicKey("Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1"),
4605
- ["stage" /* STAGE */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"),
4606
- ["prod" /* PROD */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4604
+ ["dev" /* DEV */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4605
+ ["stage" /* STAGE */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4606
+ ["prod" /* PROD */]: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"
4607
4607
  };
4608
4608
 
4609
4609
  // src/history.ts
@@ -4770,7 +4770,7 @@ var jbond_default = {
4770
4770
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4771
4771
  metadata: {
4772
4772
  name: "jbond",
4773
- version: "0.2.2",
4773
+ version: "0.2.3",
4774
4774
  spec: "0.1.0",
4775
4775
  description: "Jpool Bond Program"
4776
4776
  },
@@ -4845,7 +4845,10 @@ var jbond_default = {
4845
4845
  },
4846
4846
  {
4847
4847
  name: "authority",
4848
- signer: true
4848
+ signer: true,
4849
+ relations: [
4850
+ "bond_state"
4851
+ ]
4849
4852
  },
4850
4853
  {
4851
4854
  name: "bond_token_account",
@@ -5019,10 +5022,12 @@ var jbond_default = {
5019
5022
  {
5020
5023
  name: "bond_lock_funds",
5021
5024
  docs: [
5022
- "Locks funds for both the current and upcoming epoch.",
5023
- "Moves collateral from available to locked state, making it unavailable for withdrawal for",
5024
- "the current and next epoch. # Errors",
5025
- "Fails if the validator is not active, or if there are insufficient available funds."
5025
+ "Locks funds immediately, making them unavailable for withdrawal.",
5026
+ "The locked amount takes effect immediately in the current epoch.",
5027
+ "",
5028
+ "# Errors",
5029
+ "Fails if the bond type is not lockable, if the amount is zero,",
5030
+ "or if there are insufficient available funds."
5026
5031
  ],
5027
5032
  discriminator: [
5028
5033
  117,
@@ -5119,7 +5124,34 @@ var jbond_default = {
5119
5124
  accounts: [
5120
5125
  {
5121
5126
  name: "bond_state",
5122
- writable: true
5127
+ writable: true,
5128
+ pda: {
5129
+ seeds: [
5130
+ {
5131
+ kind: "const",
5132
+ value: [
5133
+ 98,
5134
+ 111,
5135
+ 110,
5136
+ 100,
5137
+ 95,
5138
+ 115,
5139
+ 116,
5140
+ 97,
5141
+ 116,
5142
+ 101
5143
+ ]
5144
+ },
5145
+ {
5146
+ kind: "arg",
5147
+ path: "bond_type"
5148
+ },
5149
+ {
5150
+ kind: "arg",
5151
+ path: "bond_name"
5152
+ }
5153
+ ]
5154
+ }
5123
5155
  },
5124
5156
  {
5125
5157
  name: "validator_bond",
@@ -5207,10 +5239,13 @@ var jbond_default = {
5207
5239
  {
5208
5240
  name: "bond_release_funds",
5209
5241
  docs: [
5210
- "Releases locked funds after an epoch ends.",
5211
- "Moves collateral from locked back to available state, allowing withdrawals.",
5242
+ "Queues funds for unlock in the next epoch.",
5243
+ "The unlock is delayed by one epoch for security - funds remain locked",
5244
+ "in the current epoch but will be available after epoch transition.",
5245
+ "",
5212
5246
  "# Errors",
5213
- "Fails if the validator is not active, or if there are insufficient locked funds."
5247
+ "Fails if the bond type is not lockable, if the amount is zero,",
5248
+ "or if the amount exceeds currently locked funds."
5214
5249
  ],
5215
5250
  discriminator: [
5216
5251
  184,
@@ -5489,15 +5524,12 @@ var jbond_default = {
5489
5524
  {
5490
5525
  name: "bond_update",
5491
5526
  docs: [
5492
- "Transitions locked funds between epochs for a validator bond.",
5493
- "",
5494
- "This function should be called at epoch boundaries to update the bond's",
5495
- "`last_update_epoch` and move the `next_epoch_locked` amount into",
5496
- "`locked`. It ensures that the update only occurs once per epoch.",
5527
+ "Applies any pending unlocks from previous epochs.",
5497
5528
  "",
5498
- "# Errors",
5499
- "Returns [`BondError::InvalidEpoch`] if called more than once in the same epoch,",
5500
- "or if the system clock cannot be accessed."
5529
+ "This instruction is optional - all other operations now automatically",
5530
+ "sync the epoch state. It is kept for backwards compatibility and can",
5531
+ "be used to explicitly trigger epoch synchronization without performing",
5532
+ "another operation."
5501
5533
  ],
5502
5534
  discriminator: [
5503
5535
  237,
@@ -5516,7 +5548,6 @@ var jbond_default = {
5516
5548
  },
5517
5549
  {
5518
5550
  name: "payer",
5519
- writable: true,
5520
5551
  signer: true
5521
5552
  }
5522
5553
  ],
@@ -5739,38 +5770,6 @@ var jbond_default = {
5739
5770
  ],
5740
5771
  args: []
5741
5772
  },
5742
- {
5743
- name: "migrate_validator_bond",
5744
- docs: [
5745
- "migrate validator bond from legacy format to new format"
5746
- ],
5747
- discriminator: [
5748
- 214,
5749
- 114,
5750
- 65,
5751
- 138,
5752
- 248,
5753
- 45,
5754
- 186,
5755
- 229
5756
- ],
5757
- accounts: [
5758
- {
5759
- name: "validator_bond",
5760
- writable: true
5761
- },
5762
- {
5763
- name: "authority",
5764
- writable: true,
5765
- signer: true
5766
- },
5767
- {
5768
- name: "system_program",
5769
- address: "11111111111111111111111111111111"
5770
- }
5771
- ],
5772
- args: []
5773
- },
5774
5773
  {
5775
5774
  name: "session_finish",
5776
5775
  docs: [
@@ -5916,6 +5915,19 @@ var jbond_default = {
5916
5915
  }
5917
5916
  ],
5918
5917
  events: [
5918
+ {
5919
+ name: "BondConfigured",
5920
+ discriminator: [
5921
+ 141,
5922
+ 252,
5923
+ 43,
5924
+ 54,
5925
+ 45,
5926
+ 157,
5927
+ 81,
5928
+ 14
5929
+ ]
5930
+ },
5919
5931
  {
5920
5932
  name: "BondFinished",
5921
5933
  discriminator: [
@@ -5929,6 +5941,32 @@ var jbond_default = {
5929
5941
  191
5930
5942
  ]
5931
5943
  },
5944
+ {
5945
+ name: "BondInitialized",
5946
+ discriminator: [
5947
+ 73,
5948
+ 68,
5949
+ 161,
5950
+ 2,
5951
+ 214,
5952
+ 12,
5953
+ 169,
5954
+ 53
5955
+ ]
5956
+ },
5957
+ {
5958
+ name: "BondRemoved",
5959
+ discriminator: [
5960
+ 177,
5961
+ 200,
5962
+ 116,
5963
+ 123,
5964
+ 1,
5965
+ 244,
5966
+ 161,
5967
+ 240
5968
+ ]
5969
+ },
5932
5970
  {
5933
5971
  name: "BondStarted",
5934
5972
  discriminator: [
@@ -5943,16 +5981,16 @@ var jbond_default = {
5943
5981
  ]
5944
5982
  },
5945
5983
  {
5946
- name: "CollateralToppedUp",
5984
+ name: "CollateralDeposited",
5947
5985
  discriminator: [
5948
- 189,
5949
- 137,
5950
- 204,
5951
- 58,
5986
+ 244,
5987
+ 62,
5988
+ 77,
5989
+ 11,
5952
5990
  135,
5953
- 182,
5954
- 19,
5955
- 176
5991
+ 112,
5992
+ 61,
5993
+ 96
5956
5994
  ]
5957
5995
  },
5958
5996
  {
@@ -5981,6 +6019,32 @@ var jbond_default = {
5981
6019
  32
5982
6020
  ]
5983
6021
  },
6022
+ {
6023
+ name: "FundsLocked",
6024
+ discriminator: [
6025
+ 227,
6026
+ 93,
6027
+ 162,
6028
+ 69,
6029
+ 181,
6030
+ 4,
6031
+ 71,
6032
+ 157
6033
+ ]
6034
+ },
6035
+ {
6036
+ name: "FundsUnlocked",
6037
+ discriminator: [
6038
+ 11,
6039
+ 240,
6040
+ 184,
6041
+ 107,
6042
+ 86,
6043
+ 187,
6044
+ 196,
6045
+ 128
6046
+ ]
6047
+ },
5984
6048
  {
5985
6049
  name: "ValidatorRegistered",
5986
6050
  discriminator: [
@@ -5993,33 +6057,46 @@ var jbond_default = {
5993
6057
  95,
5994
6058
  72
5995
6059
  ]
6060
+ },
6061
+ {
6062
+ name: "WithdrawAuthorityChanged",
6063
+ discriminator: [
6064
+ 91,
6065
+ 149,
6066
+ 224,
6067
+ 49,
6068
+ 187,
6069
+ 48,
6070
+ 190,
6071
+ 100
6072
+ ]
5996
6073
  }
5997
6074
  ],
5998
6075
  errors: [
5999
6076
  {
6000
6077
  code: 6e3,
6001
- name: "InvalidVoteAccount",
6002
- msg: "Invalid vote account"
6078
+ name: "Forbidden",
6079
+ msg: "Forbidden"
6003
6080
  },
6004
6081
  {
6005
6082
  code: 6001,
6006
- name: "IdentityMismatch",
6007
- msg: "Identity does not match vote account"
6083
+ name: "Unauthorized",
6084
+ msg: "Unauthorized"
6008
6085
  },
6009
6086
  {
6010
6087
  code: 6002,
6011
- name: "InsufficientCollateral",
6012
- msg: "Insufficient collateral amount"
6088
+ name: "InvalidVoteAccount",
6089
+ msg: "Invalid vote account"
6013
6090
  },
6014
6091
  {
6015
6092
  code: 6003,
6016
- name: "TargetAprTooLow",
6017
- msg: "Target APR is below minimum threshold"
6093
+ name: "IdentityMismatch",
6094
+ msg: "Vote account identity mismatch"
6018
6095
  },
6019
6096
  {
6020
6097
  code: 6004,
6021
- name: "MathOverflow",
6022
- msg: "Math overflow"
6098
+ name: "InvalidMint",
6099
+ msg: "Invalid mint address"
6023
6100
  },
6024
6101
  {
6025
6102
  code: 6005,
@@ -6028,103 +6105,53 @@ var jbond_default = {
6028
6105
  },
6029
6106
  {
6030
6107
  code: 6006,
6031
- name: "ValidatorNotActive",
6032
- msg: "Validator bond account is not active"
6108
+ name: "InvalidArgument",
6109
+ msg: "Invalid argument"
6033
6110
  },
6034
6111
  {
6035
6112
  code: 6007,
6036
- name: "ValidatorAlreadyRegistered",
6037
- msg: "Validator already registered"
6113
+ name: "InsufficientBalance",
6114
+ msg: "Insufficient balance"
6038
6115
  },
6039
6116
  {
6040
6117
  code: 6008,
6041
- name: "Unauthorized",
6042
- msg: "Unauthorized"
6118
+ name: "MathOverflow",
6119
+ msg: "Math overflow"
6043
6120
  },
6044
6121
  {
6045
6122
  code: 6009,
6046
- name: "WithdrawalLockedNearEpochEnd",
6047
- msg: "Withdrawals are locked near the end of the epoch."
6123
+ name: "Overflow",
6124
+ msg: "Arithmetic overflow"
6048
6125
  },
6049
6126
  {
6050
6127
  code: 6010,
6051
- name: "MissingTokenAccounts",
6052
- msg: "Missing token accounts for token collateral type"
6128
+ name: "BondNotRemovable",
6129
+ msg: "Bond cannot be removed"
6053
6130
  },
6054
6131
  {
6055
6132
  code: 6011,
6056
- name: "MissingTokenProgram",
6057
- msg: "Token program is required for token collateral type"
6133
+ name: "MissingTokenAccounts",
6134
+ msg: "Missing token accounts"
6058
6135
  },
6059
6136
  {
6060
6137
  code: 6012,
6061
- name: "InvalidMint",
6062
- msg: "Invalid mint for token collateral type"
6138
+ name: "MissingTokenProgram",
6139
+ msg: "Missing token program"
6063
6140
  },
6064
6141
  {
6065
6142
  code: 6013,
6066
6143
  name: "MissingStakeAccount",
6067
- msg: "Stake account is required for stake account collateral type"
6144
+ msg: "Missing stake account"
6068
6145
  },
6069
6146
  {
6070
6147
  code: 6014,
6071
6148
  name: "MissingStakeProgram",
6072
- msg: "Stake program is required for stake account collateral type"
6149
+ msg: "Missing stake program"
6073
6150
  },
6074
6151
  {
6075
6152
  code: 6015,
6076
- name: "BondFinished",
6077
- msg: "Bond is finished (deposits/withdrawals disabled)"
6078
- },
6079
- {
6080
- code: 6016,
6081
- name: "BondNotFinished",
6082
- msg: "Bond is not finished"
6083
- },
6084
- {
6085
- code: 6017,
6086
6153
  name: "UnsupportedCollateralType",
6087
6154
  msg: "Unsupported collateral type"
6088
- },
6089
- {
6090
- code: 6018,
6091
- name: "Overflow",
6092
- msg: "Math operation overflowed"
6093
- },
6094
- {
6095
- code: 6019,
6096
- name: "IncorrectBondType",
6097
- msg: "Incorrect bond type for this operation"
6098
- },
6099
- {
6100
- code: 6020,
6101
- name: "BondNotFinishable",
6102
- msg: "This bond type can't be finished"
6103
- },
6104
- {
6105
- code: 6021,
6106
- name: "InvalidArgument",
6107
- msg: "Invalid argument provided"
6108
- },
6109
- {
6110
- code: 6022,
6111
- name: "BondNotDisabled",
6112
- msg: "Bond is not disabled"
6113
- },
6114
- {
6115
- code: 6023,
6116
- name: "BondNotEnabled",
6117
- msg: "Bond is not enabled"
6118
- },
6119
- {
6120
- code: 6024,
6121
- name: "InvalidEpoch",
6122
- msg: "Invalid epoch for this operation"
6123
- },
6124
- {
6125
- code: 6025,
6126
- name: "BondNotRemovable",
6127
- msg: "Bond is not removable"
6128
6155
  }
6129
6156
  ],
6130
6157
  types: [
@@ -6158,6 +6185,26 @@ var jbond_default = {
6158
6185
  ]
6159
6186
  }
6160
6187
  },
6188
+ {
6189
+ name: "BondConfigured",
6190
+ type: {
6191
+ kind: "struct",
6192
+ fields: [
6193
+ {
6194
+ name: "bond",
6195
+ type: "pubkey"
6196
+ },
6197
+ {
6198
+ name: "authority",
6199
+ type: "pubkey"
6200
+ },
6201
+ {
6202
+ name: "timestamp",
6203
+ type: "i64"
6204
+ }
6205
+ ]
6206
+ }
6207
+ },
6161
6208
  {
6162
6209
  name: "BondFinished",
6163
6210
  type: {
@@ -6213,6 +6260,46 @@ var jbond_default = {
6213
6260
  ]
6214
6261
  }
6215
6262
  },
6263
+ {
6264
+ name: "BondInitialized",
6265
+ type: {
6266
+ kind: "struct",
6267
+ fields: [
6268
+ {
6269
+ name: "bond",
6270
+ type: "pubkey"
6271
+ },
6272
+ {
6273
+ name: "authority",
6274
+ type: "pubkey"
6275
+ },
6276
+ {
6277
+ name: "timestamp",
6278
+ type: "i64"
6279
+ }
6280
+ ]
6281
+ }
6282
+ },
6283
+ {
6284
+ name: "BondRemoved",
6285
+ type: {
6286
+ kind: "struct",
6287
+ fields: [
6288
+ {
6289
+ name: "bond",
6290
+ type: "pubkey"
6291
+ },
6292
+ {
6293
+ name: "authority",
6294
+ type: "pubkey"
6295
+ },
6296
+ {
6297
+ name: "timestamp",
6298
+ type: "i64"
6299
+ }
6300
+ ]
6301
+ }
6302
+ },
6216
6303
  {
6217
6304
  name: "BondStarted",
6218
6305
  type: {
@@ -6366,7 +6453,7 @@ var jbond_default = {
6366
6453
  }
6367
6454
  },
6368
6455
  {
6369
- name: "CollateralToppedUp",
6456
+ name: "CollateralDeposited",
6370
6457
  type: {
6371
6458
  kind: "struct",
6372
6459
  fields: [
@@ -6464,6 +6551,54 @@ var jbond_default = {
6464
6551
  ]
6465
6552
  }
6466
6553
  },
6554
+ {
6555
+ name: "FundsLocked",
6556
+ type: {
6557
+ kind: "struct",
6558
+ fields: [
6559
+ {
6560
+ name: "validator",
6561
+ type: "pubkey"
6562
+ },
6563
+ {
6564
+ name: "amount",
6565
+ type: "u64"
6566
+ },
6567
+ {
6568
+ name: "total_locked",
6569
+ type: "u64"
6570
+ },
6571
+ {
6572
+ name: "epoch",
6573
+ type: "u64"
6574
+ }
6575
+ ]
6576
+ }
6577
+ },
6578
+ {
6579
+ name: "FundsUnlocked",
6580
+ type: {
6581
+ kind: "struct",
6582
+ fields: [
6583
+ {
6584
+ name: "validator",
6585
+ type: "pubkey"
6586
+ },
6587
+ {
6588
+ name: "amount",
6589
+ type: "u64"
6590
+ },
6591
+ {
6592
+ name: "pending_unlock",
6593
+ type: "u64"
6594
+ },
6595
+ {
6596
+ name: "epoch",
6597
+ type: "u64"
6598
+ }
6599
+ ]
6600
+ }
6601
+ },
6467
6602
  {
6468
6603
  name: "GlobalConfigureData",
6469
6604
  type: {
@@ -6560,21 +6695,21 @@ var jbond_default = {
6560
6695
  {
6561
6696
  name: "locked",
6562
6697
  docs: [
6563
- "Amount of collateral currently locked"
6698
+ "Amount of collateral currently locked (unavailable for withdrawal)"
6564
6699
  ],
6565
6700
  type: "u64"
6566
6701
  },
6567
6702
  {
6568
- name: "next_epoch_locked",
6703
+ name: "pending_unlock",
6569
6704
  docs: [
6570
- "Amount of collateral locked for the next epoch"
6705
+ "Pending unlock amount (will reduce `locked` next epoch)"
6571
6706
  ],
6572
6707
  type: "u64"
6573
6708
  },
6574
6709
  {
6575
- name: "last_update_epoch",
6710
+ name: "pending_unlock_epoch",
6576
6711
  docs: [
6577
- "The last epoch when the bond was updated"
6712
+ "Epoch when pending_unlock was queued"
6578
6713
  ],
6579
6714
  type: "u64"
6580
6715
  }
@@ -6587,7 +6722,7 @@ var jbond_default = {
6587
6722
  kind: "struct",
6588
6723
  fields: [
6589
6724
  {
6590
- name: "identity",
6725
+ name: "validator",
6591
6726
  type: "pubkey"
6592
6727
  },
6593
6728
  {
@@ -6600,6 +6735,30 @@ var jbond_default = {
6600
6735
  }
6601
6736
  ]
6602
6737
  }
6738
+ },
6739
+ {
6740
+ name: "WithdrawAuthorityChanged",
6741
+ type: {
6742
+ kind: "struct",
6743
+ fields: [
6744
+ {
6745
+ name: "validator",
6746
+ type: "pubkey"
6747
+ },
6748
+ {
6749
+ name: "old_authority",
6750
+ type: {
6751
+ option: "pubkey"
6752
+ }
6753
+ },
6754
+ {
6755
+ name: "new_authority",
6756
+ type: {
6757
+ option: "pubkey"
6758
+ }
6759
+ }
6760
+ ]
6761
+ }
6603
6762
  }
6604
6763
  ],
6605
6764
  constants: [
@@ -7208,22 +7367,6 @@ var JBondClient = class _JBondClient {
7208
7367
  const ix = await this.getReleaseFundsIx(props);
7209
7368
  return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7210
7369
  }
7211
- /**
7212
- * Update epoch locks
7213
- */
7214
- async updateEpochLocks(props) {
7215
- const { bondType, bondName, voteAccount, payer } = props;
7216
- const ix = await this.getUpdateEpochLocksIx({ bondType, bondName, voteAccount, payer });
7217
- return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7218
- }
7219
- /**
7220
- * Build update epoch locks instruction
7221
- */
7222
- async getUpdateEpochLocksIx(props) {
7223
- const { bondType, bondName, voteAccount, payer } = props;
7224
- const [validatorBond, _] = this.pda.validatorBond(bondType, bondName, voteAccount);
7225
- return this.program.methods.bondUpdate().accountsPartial({ validatorBond, payer }).instruction();
7226
- }
7227
7370
  /**
7228
7371
  * Build bond remove instruction
7229
7372
  */
@@ -7272,21 +7415,6 @@ var JBondClient = class _JBondClient {
7272
7415
  });
7273
7416
  return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7274
7417
  }
7275
- async migrateValidatorBond(props) {
7276
- const ix = await this.getMigrateValidatorBondIx(props);
7277
- return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7278
- }
7279
- async getMigrateValidatorBondIx(props) {
7280
- const { bondType, name, voteAccount } = props;
7281
- const [bondState] = this.pda.bondState(bondType, name);
7282
- const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7283
- const accounts = {
7284
- bondState,
7285
- validatorBond,
7286
- systemProgram: web3_js.PublicKey.default
7287
- };
7288
- return this.program.methods.migrateValidatorBond().accountsPartial(accounts).instruction();
7289
- }
7290
7418
  /**
7291
7419
  * Build release funds instruction
7292
7420
  */