@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.d.mts CHANGED
@@ -260,6 +260,50 @@ type Jbond = {
260
260
  }
261
261
  ];
262
262
  },
263
+ {
264
+ "name": "bondLockFunds";
265
+ "docs": [
266
+ "Locks funds for the upcoming epoch.",
267
+ "Moves collateral from available to locked state which cannot be withdrawn.",
268
+ "# Errors",
269
+ "Fails if the validator is not active, or if there are insufficient available funds."
270
+ ];
271
+ "discriminator": [
272
+ 117,
273
+ 166,
274
+ 195,
275
+ 99,
276
+ 103,
277
+ 45,
278
+ 195,
279
+ 2
280
+ ];
281
+ "accounts": [
282
+ {
283
+ "name": "bondState";
284
+ "writable": true;
285
+ },
286
+ {
287
+ "name": "validatorBond";
288
+ "writable": true;
289
+ },
290
+ {
291
+ "name": "bondTokenAccount";
292
+ "optional": true;
293
+ },
294
+ {
295
+ "name": "payer";
296
+ "writable": true;
297
+ "signer": true;
298
+ }
299
+ ];
300
+ "args": [
301
+ {
302
+ "name": "amount";
303
+ "type": "u64";
304
+ }
305
+ ];
306
+ },
263
307
  {
264
308
  "name": "bondRegister";
265
309
  "docs": [
@@ -372,6 +416,42 @@ type Jbond = {
372
416
  }
373
417
  ];
374
418
  },
419
+ {
420
+ "name": "bondReleaseFunds";
421
+ "docs": [
422
+ "Releases locked funds after an epoch ends.",
423
+ "Moves collateral from locked back to available state, allowing withdrawals.",
424
+ "# Errors",
425
+ "Fails if the validator is not active, or if there are insufficient locked funds."
426
+ ];
427
+ "discriminator": [
428
+ 184,
429
+ 224,
430
+ 14,
431
+ 24,
432
+ 76,
433
+ 14,
434
+ 226,
435
+ 190
436
+ ];
437
+ "accounts": [
438
+ {
439
+ "name": "validatorBond";
440
+ "writable": true;
441
+ },
442
+ {
443
+ "name": "payer";
444
+ "writable": true;
445
+ "signer": true;
446
+ }
447
+ ];
448
+ "args": [
449
+ {
450
+ "name": "amount";
451
+ "type": "u64";
452
+ }
453
+ ];
454
+ },
375
455
  {
376
456
  "name": "bondSetWithdrawAuthority";
377
457
  "docs": [
@@ -551,6 +631,31 @@ type Jbond = {
551
631
  }
552
632
  ];
553
633
  },
634
+ {
635
+ "name": "bondUpdate";
636
+ "discriminator": [
637
+ 237,
638
+ 102,
639
+ 183,
640
+ 192,
641
+ 94,
642
+ 83,
643
+ 52,
644
+ 82
645
+ ];
646
+ "accounts": [
647
+ {
648
+ "name": "validatorBond";
649
+ "writable": true;
650
+ },
651
+ {
652
+ "name": "payer";
653
+ "writable": true;
654
+ "signer": true;
655
+ }
656
+ ];
657
+ "args": [];
658
+ },
554
659
  {
555
660
  "name": "bondWithdraw";
556
661
  "docs": [
@@ -1151,6 +1256,11 @@ type Jbond = {
1151
1256
  "code": 6023;
1152
1257
  "name": "bondNotEnabled";
1153
1258
  "msg": "Bond is not enabled";
1259
+ },
1260
+ {
1261
+ "code": 6024;
1262
+ "name": "invalidEpoch";
1263
+ "msg": "Invalid epoch for this operation";
1154
1264
  }
1155
1265
  ];
1156
1266
  "types": [
@@ -1582,6 +1692,27 @@ type Jbond = {
1582
1692
  "Bump for the PDA"
1583
1693
  ];
1584
1694
  "type": "u8";
1695
+ },
1696
+ {
1697
+ "name": "nextEpochLocked";
1698
+ "docs": [
1699
+ "Amount of collateral locked for the next epoch"
1700
+ ];
1701
+ "type": "u64";
1702
+ },
1703
+ {
1704
+ "name": "currentEpochLocked";
1705
+ "docs": [
1706
+ "Amount of collateral locked for the current epoch"
1707
+ ];
1708
+ "type": "u64";
1709
+ },
1710
+ {
1711
+ "name": "lastUpdateEpoch";
1712
+ "docs": [
1713
+ "The last epoch when the bond was updated"
1714
+ ];
1715
+ "type": "u64";
1585
1716
  }
1586
1717
  ];
1587
1718
  };
@@ -1686,6 +1817,19 @@ type ClaimProps = {
1686
1817
  reserve?: PublicKey;
1687
1818
  authority?: PublicKey;
1688
1819
  };
1820
+ type BondLockFunds = {
1821
+ bondType: BondType;
1822
+ name: string;
1823
+ amount: number;
1824
+ voteAccount: PublicKey;
1825
+ collateralType?: CollateralType;
1826
+ };
1827
+ type BondReleaseFunds = {
1828
+ bondType: BondType;
1829
+ name: string;
1830
+ amount: number;
1831
+ voteAccount: PublicKey;
1832
+ };
1689
1833
  type ClaimAllProps = {
1690
1834
  bondType: BondType;
1691
1835
  name: string;
@@ -1936,6 +2080,14 @@ declare class JBondClient {
1936
2080
  * Build start crowdfunding session instruction
1937
2081
  */
1938
2082
  getBondSessionStartIx(props: BondStartProps): Promise<TransactionInstruction>;
2083
+ /**
2084
+ * Build lock funds instruction
2085
+ */
2086
+ getLockFundsIx(props: BondLockFunds): Promise<TransactionInstruction>;
2087
+ /**
2088
+ * Build release funds instruction
2089
+ */
2090
+ getReleaseFundsIx(props: BondReleaseFunds): Promise<TransactionInstruction>;
1939
2091
  /**
1940
2092
  * Get all bond states with total collected collateral
1941
2093
  */
@@ -2063,6 +2215,9 @@ declare class JBondClient {
2063
2215
  withdrawalAuthority: PublicKey | null;
2064
2216
  createdAt: bn_js;
2065
2217
  bump: number;
2218
+ nextEpochLocked: bn_js;
2219
+ currentEpochLocked: bn_js;
2220
+ lastUpdateEpoch: bn_js;
2066
2221
  publicKey: PublicKey;
2067
2222
  }>;
2068
2223
  /**
@@ -2107,4 +2262,4 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2107
2262
  */
2108
2263
  declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2109
2264
 
2110
- export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
2265
+ export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.d.ts CHANGED
@@ -260,6 +260,50 @@ type Jbond = {
260
260
  }
261
261
  ];
262
262
  },
263
+ {
264
+ "name": "bondLockFunds";
265
+ "docs": [
266
+ "Locks funds for the upcoming epoch.",
267
+ "Moves collateral from available to locked state which cannot be withdrawn.",
268
+ "# Errors",
269
+ "Fails if the validator is not active, or if there are insufficient available funds."
270
+ ];
271
+ "discriminator": [
272
+ 117,
273
+ 166,
274
+ 195,
275
+ 99,
276
+ 103,
277
+ 45,
278
+ 195,
279
+ 2
280
+ ];
281
+ "accounts": [
282
+ {
283
+ "name": "bondState";
284
+ "writable": true;
285
+ },
286
+ {
287
+ "name": "validatorBond";
288
+ "writable": true;
289
+ },
290
+ {
291
+ "name": "bondTokenAccount";
292
+ "optional": true;
293
+ },
294
+ {
295
+ "name": "payer";
296
+ "writable": true;
297
+ "signer": true;
298
+ }
299
+ ];
300
+ "args": [
301
+ {
302
+ "name": "amount";
303
+ "type": "u64";
304
+ }
305
+ ];
306
+ },
263
307
  {
264
308
  "name": "bondRegister";
265
309
  "docs": [
@@ -372,6 +416,42 @@ type Jbond = {
372
416
  }
373
417
  ];
374
418
  },
419
+ {
420
+ "name": "bondReleaseFunds";
421
+ "docs": [
422
+ "Releases locked funds after an epoch ends.",
423
+ "Moves collateral from locked back to available state, allowing withdrawals.",
424
+ "# Errors",
425
+ "Fails if the validator is not active, or if there are insufficient locked funds."
426
+ ];
427
+ "discriminator": [
428
+ 184,
429
+ 224,
430
+ 14,
431
+ 24,
432
+ 76,
433
+ 14,
434
+ 226,
435
+ 190
436
+ ];
437
+ "accounts": [
438
+ {
439
+ "name": "validatorBond";
440
+ "writable": true;
441
+ },
442
+ {
443
+ "name": "payer";
444
+ "writable": true;
445
+ "signer": true;
446
+ }
447
+ ];
448
+ "args": [
449
+ {
450
+ "name": "amount";
451
+ "type": "u64";
452
+ }
453
+ ];
454
+ },
375
455
  {
376
456
  "name": "bondSetWithdrawAuthority";
377
457
  "docs": [
@@ -551,6 +631,31 @@ type Jbond = {
551
631
  }
552
632
  ];
553
633
  },
634
+ {
635
+ "name": "bondUpdate";
636
+ "discriminator": [
637
+ 237,
638
+ 102,
639
+ 183,
640
+ 192,
641
+ 94,
642
+ 83,
643
+ 52,
644
+ 82
645
+ ];
646
+ "accounts": [
647
+ {
648
+ "name": "validatorBond";
649
+ "writable": true;
650
+ },
651
+ {
652
+ "name": "payer";
653
+ "writable": true;
654
+ "signer": true;
655
+ }
656
+ ];
657
+ "args": [];
658
+ },
554
659
  {
555
660
  "name": "bondWithdraw";
556
661
  "docs": [
@@ -1151,6 +1256,11 @@ type Jbond = {
1151
1256
  "code": 6023;
1152
1257
  "name": "bondNotEnabled";
1153
1258
  "msg": "Bond is not enabled";
1259
+ },
1260
+ {
1261
+ "code": 6024;
1262
+ "name": "invalidEpoch";
1263
+ "msg": "Invalid epoch for this operation";
1154
1264
  }
1155
1265
  ];
1156
1266
  "types": [
@@ -1582,6 +1692,27 @@ type Jbond = {
1582
1692
  "Bump for the PDA"
1583
1693
  ];
1584
1694
  "type": "u8";
1695
+ },
1696
+ {
1697
+ "name": "nextEpochLocked";
1698
+ "docs": [
1699
+ "Amount of collateral locked for the next epoch"
1700
+ ];
1701
+ "type": "u64";
1702
+ },
1703
+ {
1704
+ "name": "currentEpochLocked";
1705
+ "docs": [
1706
+ "Amount of collateral locked for the current epoch"
1707
+ ];
1708
+ "type": "u64";
1709
+ },
1710
+ {
1711
+ "name": "lastUpdateEpoch";
1712
+ "docs": [
1713
+ "The last epoch when the bond was updated"
1714
+ ];
1715
+ "type": "u64";
1585
1716
  }
1586
1717
  ];
1587
1718
  };
@@ -1686,6 +1817,19 @@ type ClaimProps = {
1686
1817
  reserve?: PublicKey;
1687
1818
  authority?: PublicKey;
1688
1819
  };
1820
+ type BondLockFunds = {
1821
+ bondType: BondType;
1822
+ name: string;
1823
+ amount: number;
1824
+ voteAccount: PublicKey;
1825
+ collateralType?: CollateralType;
1826
+ };
1827
+ type BondReleaseFunds = {
1828
+ bondType: BondType;
1829
+ name: string;
1830
+ amount: number;
1831
+ voteAccount: PublicKey;
1832
+ };
1689
1833
  type ClaimAllProps = {
1690
1834
  bondType: BondType;
1691
1835
  name: string;
@@ -1936,6 +2080,14 @@ declare class JBondClient {
1936
2080
  * Build start crowdfunding session instruction
1937
2081
  */
1938
2082
  getBondSessionStartIx(props: BondStartProps): Promise<TransactionInstruction>;
2083
+ /**
2084
+ * Build lock funds instruction
2085
+ */
2086
+ getLockFundsIx(props: BondLockFunds): Promise<TransactionInstruction>;
2087
+ /**
2088
+ * Build release funds instruction
2089
+ */
2090
+ getReleaseFundsIx(props: BondReleaseFunds): Promise<TransactionInstruction>;
1939
2091
  /**
1940
2092
  * Get all bond states with total collected collateral
1941
2093
  */
@@ -2063,6 +2215,9 @@ declare class JBondClient {
2063
2215
  withdrawalAuthority: PublicKey | null;
2064
2216
  createdAt: bn_js;
2065
2217
  bump: number;
2218
+ nextEpochLocked: bn_js;
2219
+ currentEpochLocked: bn_js;
2220
+ lastUpdateEpoch: bn_js;
2066
2221
  publicKey: PublicKey;
2067
2222
  }>;
2068
2223
  /**
@@ -2107,4 +2262,4 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2107
2262
  */
2108
2263
  declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
2109
2264
 
2110
- export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
2265
+ export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, type Jbond, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps };
package/dist/index.js CHANGED
@@ -5008,6 +5008,50 @@ var jbond_default = {
5008
5008
  }
5009
5009
  ]
5010
5010
  },
5011
+ {
5012
+ name: "bond_lock_funds",
5013
+ docs: [
5014
+ "Locks funds for the upcoming epoch.",
5015
+ "Moves collateral from available to locked state which cannot be withdrawn.",
5016
+ "# Errors",
5017
+ "Fails if the validator is not active, or if there are insufficient available funds."
5018
+ ],
5019
+ discriminator: [
5020
+ 117,
5021
+ 166,
5022
+ 195,
5023
+ 99,
5024
+ 103,
5025
+ 45,
5026
+ 195,
5027
+ 2
5028
+ ],
5029
+ accounts: [
5030
+ {
5031
+ name: "bond_state",
5032
+ writable: true
5033
+ },
5034
+ {
5035
+ name: "validator_bond",
5036
+ writable: true
5037
+ },
5038
+ {
5039
+ name: "bond_token_account",
5040
+ optional: true
5041
+ },
5042
+ {
5043
+ name: "payer",
5044
+ writable: true,
5045
+ signer: true
5046
+ }
5047
+ ],
5048
+ args: [
5049
+ {
5050
+ name: "amount",
5051
+ type: "u64"
5052
+ }
5053
+ ]
5054
+ },
5011
5055
  {
5012
5056
  name: "bond_register",
5013
5057
  docs: [
@@ -5120,6 +5164,42 @@ var jbond_default = {
5120
5164
  }
5121
5165
  ]
5122
5166
  },
5167
+ {
5168
+ name: "bond_release_funds",
5169
+ docs: [
5170
+ "Releases locked funds after an epoch ends.",
5171
+ "Moves collateral from locked back to available state, allowing withdrawals.",
5172
+ "# Errors",
5173
+ "Fails if the validator is not active, or if there are insufficient locked funds."
5174
+ ],
5175
+ discriminator: [
5176
+ 184,
5177
+ 224,
5178
+ 14,
5179
+ 24,
5180
+ 76,
5181
+ 14,
5182
+ 226,
5183
+ 190
5184
+ ],
5185
+ accounts: [
5186
+ {
5187
+ name: "validator_bond",
5188
+ writable: true
5189
+ },
5190
+ {
5191
+ name: "payer",
5192
+ writable: true,
5193
+ signer: true
5194
+ }
5195
+ ],
5196
+ args: [
5197
+ {
5198
+ name: "amount",
5199
+ type: "u64"
5200
+ }
5201
+ ]
5202
+ },
5123
5203
  {
5124
5204
  name: "bond_set_withdraw_authority",
5125
5205
  docs: [
@@ -5299,6 +5379,31 @@ var jbond_default = {
5299
5379
  }
5300
5380
  ]
5301
5381
  },
5382
+ {
5383
+ name: "bond_update",
5384
+ discriminator: [
5385
+ 237,
5386
+ 102,
5387
+ 183,
5388
+ 192,
5389
+ 94,
5390
+ 83,
5391
+ 52,
5392
+ 82
5393
+ ],
5394
+ accounts: [
5395
+ {
5396
+ name: "validator_bond",
5397
+ writable: true
5398
+ },
5399
+ {
5400
+ name: "payer",
5401
+ writable: true,
5402
+ signer: true
5403
+ }
5404
+ ],
5405
+ args: []
5406
+ },
5302
5407
  {
5303
5408
  name: "bond_withdraw",
5304
5409
  docs: [
@@ -5899,6 +6004,11 @@ var jbond_default = {
5899
6004
  code: 6023,
5900
6005
  name: "BondNotEnabled",
5901
6006
  msg: "Bond is not enabled"
6007
+ },
6008
+ {
6009
+ code: 6024,
6010
+ name: "InvalidEpoch",
6011
+ msg: "Invalid epoch for this operation"
5902
6012
  }
5903
6013
  ],
5904
6014
  types: [
@@ -6330,6 +6440,27 @@ var jbond_default = {
6330
6440
  "Bump for the PDA"
6331
6441
  ],
6332
6442
  type: "u8"
6443
+ },
6444
+ {
6445
+ name: "next_epoch_locked",
6446
+ docs: [
6447
+ "Amount of collateral locked for the next epoch"
6448
+ ],
6449
+ type: "u64"
6450
+ },
6451
+ {
6452
+ name: "current_epoch_locked",
6453
+ docs: [
6454
+ "Amount of collateral locked for the current epoch"
6455
+ ],
6456
+ type: "u64"
6457
+ },
6458
+ {
6459
+ name: "last_update_epoch",
6460
+ docs: [
6461
+ "The last epoch when the bond was updated"
6462
+ ],
6463
+ type: "u64"
6333
6464
  }
6334
6465
  ]
6335
6466
  }
@@ -6937,6 +7068,48 @@ var JBondClient = class _JBondClient {
6937
7068
  const authority = this.provider.wallet?.publicKey;
6938
7069
  return this.program.methods.sessionStart(new import_bn.BN(props.duration)).accountsPartial({ bondState, authority }).instruction();
6939
7070
  }
7071
+ /**
7072
+ * Build lock funds instruction
7073
+ */
7074
+ async getLockFundsIx(props) {
7075
+ const { bondType, name, voteAccount, amount } = props;
7076
+ const [bondState] = this.pda.bondState(bondType, name);
7077
+ let collateralType = props.collateralType;
7078
+ if (!collateralType) {
7079
+ const bondState2 = await this.getBondState(bondType, name);
7080
+ collateralType = bondState2.collateralType;
7081
+ }
7082
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7083
+ const authority = this.provider.wallet?.publicKey;
7084
+ const accounts = {
7085
+ bondState,
7086
+ validatorBond,
7087
+ payer: authority,
7088
+ bondTokenAccount: null
7089
+ };
7090
+ matchVariant(collateralType, {
7091
+ native: () => {
7092
+ },
7093
+ token: (mint) => {
7094
+ const bondTokenAccount = splToken.getAssociatedTokenAddressSync(mint, validatorBond, true);
7095
+ accounts.bondTokenAccount = bondTokenAccount;
7096
+ }
7097
+ });
7098
+ return this.program.methods.bondLockFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7099
+ }
7100
+ /**
7101
+ * Build release funds instruction
7102
+ */
7103
+ async getReleaseFundsIx(props) {
7104
+ const { bondType, name, voteAccount, amount } = props;
7105
+ const [validatorBond] = this.pda.validatorBond(bondType, name, voteAccount);
7106
+ const authority = this.provider.wallet?.publicKey;
7107
+ const accounts = {
7108
+ validatorBond,
7109
+ payer: authority
7110
+ };
7111
+ return this.program.methods.bondReleaseFunds(solToLamports(amount)).accountsPartial(accounts).instruction();
7112
+ }
6940
7113
  /**
6941
7114
  * Get all bond states with total collected collateral
6942
7115
  */