@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.js CHANGED
@@ -4601,8 +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
- ["prod" /* PROD */]: new web3_js.PublicKey("BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU")
4604
+ ["dev" /* DEV */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4605
+ ["stage" /* STAGE */]: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4606
+ ["prod" /* PROD */]: "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU"
4606
4607
  };
4607
4608
 
4608
4609
  // src/history.ts
@@ -4769,7 +4770,7 @@ var jbond_default = {
4769
4770
  address: "Fo17edWRJewZNTRibgx9iTfjywCW6dzS81VwBLmPFVq1",
4770
4771
  metadata: {
4771
4772
  name: "jbond",
4772
- version: "0.2.1",
4773
+ version: "0.2.3",
4773
4774
  spec: "0.1.0",
4774
4775
  description: "Jpool Bond Program"
4775
4776
  },
@@ -4844,7 +4845,10 @@ var jbond_default = {
4844
4845
  },
4845
4846
  {
4846
4847
  name: "authority",
4847
- signer: true
4848
+ signer: true,
4849
+ relations: [
4850
+ "bond_state"
4851
+ ]
4848
4852
  },
4849
4853
  {
4850
4854
  name: "bond_token_account",
@@ -5018,10 +5022,12 @@ var jbond_default = {
5018
5022
  {
5019
5023
  name: "bond_lock_funds",
5020
5024
  docs: [
5021
- "Locks funds for both the current and upcoming epoch.",
5022
- "Moves collateral from available to locked state, making it unavailable for withdrawal for",
5023
- "the current and next epoch. # Errors",
5024
- "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."
5025
5031
  ],
5026
5032
  discriminator: [
5027
5033
  117,
@@ -5118,7 +5124,34 @@ var jbond_default = {
5118
5124
  accounts: [
5119
5125
  {
5120
5126
  name: "bond_state",
5121
- 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
+ }
5122
5155
  },
5123
5156
  {
5124
5157
  name: "validator_bond",
@@ -5206,10 +5239,13 @@ var jbond_default = {
5206
5239
  {
5207
5240
  name: "bond_release_funds",
5208
5241
  docs: [
5209
- "Releases locked funds after an epoch ends.",
5210
- "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
+ "",
5211
5246
  "# Errors",
5212
- "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."
5213
5249
  ],
5214
5250
  discriminator: [
5215
5251
  184,
@@ -5488,15 +5524,12 @@ var jbond_default = {
5488
5524
  {
5489
5525
  name: "bond_update",
5490
5526
  docs: [
5491
- "Transitions locked funds between epochs for a validator bond.",
5492
- "",
5493
- "This function should be called at epoch boundaries to update the bond's",
5494
- "`last_update_epoch` and move the `next_epoch_locked` amount into",
5495
- "`locked`. It ensures that the update only occurs once per epoch.",
5527
+ "Applies any pending unlocks from previous epochs.",
5496
5528
  "",
5497
- "# Errors",
5498
- "Returns [`BondError::InvalidEpoch`] if called more than once in the same epoch,",
5499
- "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."
5500
5533
  ],
5501
5534
  discriminator: [
5502
5535
  237,
@@ -5515,7 +5548,6 @@ var jbond_default = {
5515
5548
  },
5516
5549
  {
5517
5550
  name: "payer",
5518
- writable: true,
5519
5551
  signer: true
5520
5552
  }
5521
5553
  ],
@@ -5883,6 +5915,19 @@ var jbond_default = {
5883
5915
  }
5884
5916
  ],
5885
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
+ },
5886
5931
  {
5887
5932
  name: "BondFinished",
5888
5933
  discriminator: [
@@ -5896,6 +5941,32 @@ var jbond_default = {
5896
5941
  191
5897
5942
  ]
5898
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
+ },
5899
5970
  {
5900
5971
  name: "BondStarted",
5901
5972
  discriminator: [
@@ -5910,16 +5981,16 @@ var jbond_default = {
5910
5981
  ]
5911
5982
  },
5912
5983
  {
5913
- name: "CollateralToppedUp",
5984
+ name: "CollateralDeposited",
5914
5985
  discriminator: [
5915
- 189,
5916
- 137,
5917
- 204,
5918
- 58,
5986
+ 244,
5987
+ 62,
5988
+ 77,
5989
+ 11,
5919
5990
  135,
5920
- 182,
5921
- 19,
5922
- 176
5991
+ 112,
5992
+ 61,
5993
+ 96
5923
5994
  ]
5924
5995
  },
5925
5996
  {
@@ -5948,6 +6019,32 @@ var jbond_default = {
5948
6019
  32
5949
6020
  ]
5950
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
+ },
5951
6048
  {
5952
6049
  name: "ValidatorRegistered",
5953
6050
  discriminator: [
@@ -5960,33 +6057,46 @@ var jbond_default = {
5960
6057
  95,
5961
6058
  72
5962
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
+ ]
5963
6073
  }
5964
6074
  ],
5965
6075
  errors: [
5966
6076
  {
5967
6077
  code: 6e3,
5968
- name: "InvalidVoteAccount",
5969
- msg: "Invalid vote account"
6078
+ name: "Forbidden",
6079
+ msg: "Forbidden"
5970
6080
  },
5971
6081
  {
5972
6082
  code: 6001,
5973
- name: "IdentityMismatch",
5974
- msg: "Identity does not match vote account"
6083
+ name: "Unauthorized",
6084
+ msg: "Unauthorized"
5975
6085
  },
5976
6086
  {
5977
6087
  code: 6002,
5978
- name: "InsufficientCollateral",
5979
- msg: "Insufficient collateral amount"
6088
+ name: "InvalidVoteAccount",
6089
+ msg: "Invalid vote account"
5980
6090
  },
5981
6091
  {
5982
6092
  code: 6003,
5983
- name: "TargetAprTooLow",
5984
- msg: "Target APR is below minimum threshold"
6093
+ name: "IdentityMismatch",
6094
+ msg: "Vote account identity mismatch"
5985
6095
  },
5986
6096
  {
5987
6097
  code: 6004,
5988
- name: "MathOverflow",
5989
- msg: "Math overflow"
6098
+ name: "InvalidMint",
6099
+ msg: "Invalid mint address"
5990
6100
  },
5991
6101
  {
5992
6102
  code: 6005,
@@ -5995,103 +6105,53 @@ var jbond_default = {
5995
6105
  },
5996
6106
  {
5997
6107
  code: 6006,
5998
- name: "ValidatorNotActive",
5999
- msg: "Validator bond account is not active"
6108
+ name: "InvalidArgument",
6109
+ msg: "Invalid argument"
6000
6110
  },
6001
6111
  {
6002
6112
  code: 6007,
6003
- name: "ValidatorAlreadyRegistered",
6004
- msg: "Validator already registered"
6113
+ name: "InsufficientBalance",
6114
+ msg: "Insufficient balance"
6005
6115
  },
6006
6116
  {
6007
6117
  code: 6008,
6008
- name: "Unauthorized",
6009
- msg: "Unauthorized"
6118
+ name: "MathOverflow",
6119
+ msg: "Math overflow"
6010
6120
  },
6011
6121
  {
6012
6122
  code: 6009,
6013
- name: "WithdrawalLockedNearEpochEnd",
6014
- msg: "Withdrawals are locked near the end of the epoch."
6123
+ name: "Overflow",
6124
+ msg: "Arithmetic overflow"
6015
6125
  },
6016
6126
  {
6017
6127
  code: 6010,
6018
- name: "MissingTokenAccounts",
6019
- msg: "Missing token accounts for token collateral type"
6128
+ name: "BondNotRemovable",
6129
+ msg: "Bond cannot be removed"
6020
6130
  },
6021
6131
  {
6022
6132
  code: 6011,
6023
- name: "MissingTokenProgram",
6024
- msg: "Token program is required for token collateral type"
6133
+ name: "MissingTokenAccounts",
6134
+ msg: "Missing token accounts"
6025
6135
  },
6026
6136
  {
6027
6137
  code: 6012,
6028
- name: "InvalidMint",
6029
- msg: "Invalid mint for token collateral type"
6138
+ name: "MissingTokenProgram",
6139
+ msg: "Missing token program"
6030
6140
  },
6031
6141
  {
6032
6142
  code: 6013,
6033
6143
  name: "MissingStakeAccount",
6034
- msg: "Stake account is required for stake account collateral type"
6144
+ msg: "Missing stake account"
6035
6145
  },
6036
6146
  {
6037
6147
  code: 6014,
6038
6148
  name: "MissingStakeProgram",
6039
- msg: "Stake program is required for stake account collateral type"
6149
+ msg: "Missing stake program"
6040
6150
  },
6041
6151
  {
6042
6152
  code: 6015,
6043
- name: "BondFinished",
6044
- msg: "Bond is finished (deposits/withdrawals disabled)"
6045
- },
6046
- {
6047
- code: 6016,
6048
- name: "BondNotFinished",
6049
- msg: "Bond is not finished"
6050
- },
6051
- {
6052
- code: 6017,
6053
6153
  name: "UnsupportedCollateralType",
6054
6154
  msg: "Unsupported collateral type"
6055
- },
6056
- {
6057
- code: 6018,
6058
- name: "Overflow",
6059
- msg: "Math operation overflowed"
6060
- },
6061
- {
6062
- code: 6019,
6063
- name: "IncorrectBondType",
6064
- msg: "Incorrect bond type for this operation"
6065
- },
6066
- {
6067
- code: 6020,
6068
- name: "BondNotFinishable",
6069
- msg: "This bond type can't be finished"
6070
- },
6071
- {
6072
- code: 6021,
6073
- name: "InvalidArgument",
6074
- msg: "Invalid argument provided"
6075
- },
6076
- {
6077
- code: 6022,
6078
- name: "BondNotDisabled",
6079
- msg: "Bond is not disabled"
6080
- },
6081
- {
6082
- code: 6023,
6083
- name: "BondNotEnabled",
6084
- msg: "Bond is not enabled"
6085
- },
6086
- {
6087
- code: 6024,
6088
- name: "InvalidEpoch",
6089
- msg: "Invalid epoch for this operation"
6090
- },
6091
- {
6092
- code: 6025,
6093
- name: "BondNotRemovable",
6094
- msg: "Bond is not removable"
6095
6155
  }
6096
6156
  ],
6097
6157
  types: [
@@ -6125,6 +6185,26 @@ var jbond_default = {
6125
6185
  ]
6126
6186
  }
6127
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
+ },
6128
6208
  {
6129
6209
  name: "BondFinished",
6130
6210
  type: {
@@ -6180,6 +6260,46 @@ var jbond_default = {
6180
6260
  ]
6181
6261
  }
6182
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
+ },
6183
6303
  {
6184
6304
  name: "BondStarted",
6185
6305
  type: {
@@ -6333,7 +6453,7 @@ var jbond_default = {
6333
6453
  }
6334
6454
  },
6335
6455
  {
6336
- name: "CollateralToppedUp",
6456
+ name: "CollateralDeposited",
6337
6457
  type: {
6338
6458
  kind: "struct",
6339
6459
  fields: [
@@ -6431,6 +6551,54 @@ var jbond_default = {
6431
6551
  ]
6432
6552
  }
6433
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
+ },
6434
6602
  {
6435
6603
  name: "GlobalConfigureData",
6436
6604
  type: {
@@ -6527,21 +6695,21 @@ var jbond_default = {
6527
6695
  {
6528
6696
  name: "locked",
6529
6697
  docs: [
6530
- "Amount of collateral currently locked"
6698
+ "Amount of collateral currently locked (unavailable for withdrawal)"
6531
6699
  ],
6532
6700
  type: "u64"
6533
6701
  },
6534
6702
  {
6535
- name: "next_epoch_locked",
6703
+ name: "pending_unlock",
6536
6704
  docs: [
6537
- "Amount of collateral locked for the next epoch"
6705
+ "Pending unlock amount (will reduce `locked` next epoch)"
6538
6706
  ],
6539
6707
  type: "u64"
6540
6708
  },
6541
6709
  {
6542
- name: "last_update_epoch",
6710
+ name: "pending_unlock_epoch",
6543
6711
  docs: [
6544
- "The last epoch when the bond was updated"
6712
+ "Epoch when pending_unlock was queued"
6545
6713
  ],
6546
6714
  type: "u64"
6547
6715
  }
@@ -6554,7 +6722,7 @@ var jbond_default = {
6554
6722
  kind: "struct",
6555
6723
  fields: [
6556
6724
  {
6557
- name: "identity",
6725
+ name: "validator",
6558
6726
  type: "pubkey"
6559
6727
  },
6560
6728
  {
@@ -6567,6 +6735,30 @@ var jbond_default = {
6567
6735
  }
6568
6736
  ]
6569
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
+ }
6570
6762
  }
6571
6763
  ],
6572
6764
  constants: [
@@ -6751,7 +6943,7 @@ var JBondClient = class _JBondClient {
6751
6943
  if (this.options.programId) {
6752
6944
  return this.options.programId;
6753
6945
  }
6754
- return ENV_PROGRAM_ID["prod" /* PROD */];
6946
+ return new web3_js.PublicKey(ENV_PROGRAM_ID["prod" /* PROD */]);
6755
6947
  }
6756
6948
  /**
6757
6949
  * Get the current connection.
@@ -6769,7 +6961,7 @@ var JBondClient = class _JBondClient {
6769
6961
  }
6770
6962
  this._program = null;
6771
6963
  this.debug(`Set environment to ${env} with program ID: ${envProgramId.toString()}`);
6772
- return this.configure("programId", envProgramId);
6964
+ return this.configure("programId", new web3_js.PublicKey(envProgramId));
6773
6965
  }
6774
6966
  /**
6775
6967
  * Configure a specific option.
@@ -7175,22 +7367,6 @@ var JBondClient = class _JBondClient {
7175
7367
  const ix = await this.getReleaseFundsIx(props);
7176
7368
  return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7177
7369
  }
7178
- /**
7179
- * Update epoch locks
7180
- */
7181
- async updateEpochLocks(props) {
7182
- const { bondType, bondName, voteAccount, payer } = props;
7183
- const ix = await this.getUpdateEpochLocksIx({ bondType, bondName, voteAccount, payer });
7184
- return this.provider.sendAndConfirm?.(new web3_js.Transaction().add(ix));
7185
- }
7186
- /**
7187
- * Build update epoch locks instruction
7188
- */
7189
- async getUpdateEpochLocksIx(props) {
7190
- const { bondType, bondName, voteAccount, payer } = props;
7191
- const [validatorBond, _] = this.pda.validatorBond(bondType, bondName, voteAccount);
7192
- return this.program.methods.bondUpdate().accountsPartial({ validatorBond, payer }).instruction();
7193
- }
7194
7370
  /**
7195
7371
  * Build bond remove instruction
7196
7372
  */
@@ -7325,7 +7501,7 @@ var JBondClient = class _JBondClient {
7325
7501
  const tokenAccount = splToken.getAssociatedTokenAddressSync(mint, address, true);
7326
7502
  try {
7327
7503
  const balance = await this.connection.getTokenAccountBalance(tokenAccount);
7328
- return solToLamports(balance.value.amount).toNumber();
7504
+ return Number(balance.value.amount);
7329
7505
  } catch {
7330
7506
  return 0;
7331
7507
  }