@jpool/bond-sdk 0.11.3 → 0.11.4

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.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as bn_js from 'bn.js';
2
2
  import * as _coral_xyz_anchor from '@coral-xyz/anchor';
3
- import { IdlTypes, IdlAccounts, Provider, Program } from '@coral-xyz/anchor';
3
+ import { IdlTypes, IdlAccounts, BN, Provider, Program } from '@coral-xyz/anchor';
4
4
  import * as _solana_web3_js from '@solana/web3.js';
5
- import { PublicKey, PublicKeyInitData, Cluster, Transaction, VersionedTransaction, Keypair, Connection, TransactionInstruction } from '@solana/web3.js';
5
+ import { PublicKey, PublicKeyInitData, Cluster, Transaction, VersionedTransaction, Keypair, Connection, TransactionInstruction, Signer } from '@solana/web3.js';
6
6
 
7
7
  /**
8
8
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -14,7 +14,7 @@ type Jbond = {
14
14
  "address": "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU";
15
15
  "metadata": {
16
16
  "name": "jbond";
17
- "version": "0.2.5";
17
+ "version": "0.2.6";
18
18
  "spec": "0.1.0";
19
19
  "description": "Jpool Bond Program";
20
20
  };
@@ -765,38 +765,6 @@ type Jbond = {
765
765
  }
766
766
  ];
767
767
  },
768
- {
769
- "name": "bondUpdate";
770
- "docs": [
771
- "Applies any pending unlocks from previous epochs.",
772
- "",
773
- "This instruction is optional - all other operations now automatically",
774
- "sync the epoch state. It is kept for backwards compatibility and can",
775
- "be used to explicitly trigger epoch synchronization without performing",
776
- "another operation."
777
- ];
778
- "discriminator": [
779
- 237,
780
- 102,
781
- 183,
782
- 192,
783
- 94,
784
- 83,
785
- 52,
786
- 82
787
- ];
788
- "accounts": [
789
- {
790
- "name": "validatorBond";
791
- "writable": true;
792
- },
793
- {
794
- "name": "payer";
795
- "signer": true;
796
- }
797
- ];
798
- "args": [];
799
- },
800
768
  {
801
769
  "name": "bondWithdraw";
802
770
  "docs": [
@@ -907,6 +875,103 @@ type Jbond = {
907
875
  }
908
876
  ];
909
877
  },
878
+ {
879
+ "name": "closeValidatorBond";
880
+ "docs": [
881
+ "Closes a validator bond account and transfers remaining balance to the rent receiver.",
882
+ "",
883
+ "# Security",
884
+ "- Only the validator identity or withdrawal authority can close the bond",
885
+ "- All funds must be unlocked (locked == 0 and pending_unlock == 0)",
886
+ "- For token collateral, closes the associated token account as well",
887
+ "- Decrements the bond state's total_members counter",
888
+ "",
889
+ "# Errors",
890
+ "Fails if the signer is not authorized, if funds are still locked,",
891
+ "or if the rent receiver is not the identity or withdrawal authority."
892
+ ];
893
+ "discriminator": [
894
+ 51,
895
+ 235,
896
+ 111,
897
+ 163,
898
+ 176,
899
+ 239,
900
+ 95,
901
+ 122
902
+ ];
903
+ "accounts": [
904
+ {
905
+ "name": "bondState";
906
+ "writable": true;
907
+ },
908
+ {
909
+ "name": "validatorBond";
910
+ "writable": true;
911
+ "pda": {
912
+ "seeds": [
913
+ {
914
+ "kind": "const";
915
+ "value": [
916
+ 118,
917
+ 97,
918
+ 108,
919
+ 105,
920
+ 100,
921
+ 97,
922
+ 116,
923
+ 111,
924
+ 114,
925
+ 95,
926
+ 98,
927
+ 111,
928
+ 110,
929
+ 100
930
+ ];
931
+ },
932
+ {
933
+ "kind": "account";
934
+ "path": "bondState";
935
+ },
936
+ {
937
+ "kind": "account";
938
+ "path": "validator_bond.vote_account";
939
+ "account": "validatorBond";
940
+ }
941
+ ];
942
+ };
943
+ },
944
+ {
945
+ "name": "authority";
946
+ "writable": true;
947
+ "signer": true;
948
+ },
949
+ {
950
+ "name": "rentReceiver";
951
+ "writable": true;
952
+ },
953
+ {
954
+ "name": "bondTokenAccount";
955
+ "writable": true;
956
+ "optional": true;
957
+ },
958
+ {
959
+ "name": "destinationTokenAccount";
960
+ "writable": true;
961
+ "optional": true;
962
+ },
963
+ {
964
+ "name": "systemProgram";
965
+ "address": "11111111111111111111111111111111";
966
+ },
967
+ {
968
+ "name": "tokenProgram";
969
+ "optional": true;
970
+ "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
971
+ }
972
+ ];
973
+ "args": [];
974
+ },
910
975
  {
911
976
  "name": "globalConfigure";
912
977
  "discriminator": [
@@ -1267,6 +1332,19 @@ type Jbond = {
1267
1332
  128
1268
1333
  ];
1269
1334
  },
1335
+ {
1336
+ "name": "validatorBondClosed";
1337
+ "discriminator": [
1338
+ 71,
1339
+ 54,
1340
+ 59,
1341
+ 241,
1342
+ 91,
1343
+ 35,
1344
+ 123,
1345
+ 123
1346
+ ];
1347
+ },
1270
1348
  {
1271
1349
  "name": "validatorRegistered";
1272
1350
  "discriminator": [
@@ -1966,6 +2044,34 @@ type Jbond = {
1966
2044
  ];
1967
2045
  };
1968
2046
  },
2047
+ {
2048
+ "name": "validatorBondClosed";
2049
+ "type": {
2050
+ "kind": "struct";
2051
+ "fields": [
2052
+ {
2053
+ "name": "validator";
2054
+ "type": "pubkey";
2055
+ },
2056
+ {
2057
+ "name": "voteAccount";
2058
+ "type": "pubkey";
2059
+ },
2060
+ {
2061
+ "name": "rentReceiver";
2062
+ "type": "pubkey";
2063
+ },
2064
+ {
2065
+ "name": "finalBalance";
2066
+ "type": "u64";
2067
+ },
2068
+ {
2069
+ "name": "timestamp";
2070
+ "type": "i64";
2071
+ }
2072
+ ];
2073
+ };
2074
+ },
1969
2075
  {
1970
2076
  "name": "validatorRegistered";
1971
2077
  "type": {
@@ -2045,6 +2151,7 @@ declare enum BondType {
2045
2151
  Crowdfunding = "crowdfunding"
2046
2152
  }
2047
2153
  declare enum BondTransactionType {
2154
+ Registered = "registered",
2048
2155
  Deposit = "deposit",
2049
2156
  Withdrawal = "withdrawal",
2050
2157
  Compensation = "compensation"
@@ -2077,6 +2184,7 @@ type TopUpCollateralProps = {
2077
2184
  identity: PublicKey;
2078
2185
  voteAccount: PublicKey;
2079
2186
  amount: number;
2187
+ solUsage?: boolean;
2080
2188
  collateralType?: CollateralType;
2081
2189
  payer?: PublicKey;
2082
2190
  };
@@ -2089,6 +2197,17 @@ type WithdrawCollateralProps = {
2089
2197
  destination?: PublicKey;
2090
2198
  withdrawalAuthority?: PublicKey;
2091
2199
  };
2200
+ type MigrateBondProps = {
2201
+ bondType: BondType;
2202
+ voteAccount: PublicKey;
2203
+ identity: PublicKey;
2204
+ withdrawName?: string;
2205
+ topUpName?: string;
2206
+ payer?: PublicKey;
2207
+ destination?: PublicKey;
2208
+ withdrawalAuthority?: PublicKey;
2209
+ stakePoolAddress?: PublicKey;
2210
+ };
2092
2211
  type ClaimProps = {
2093
2212
  bondType: BondType;
2094
2213
  name: string;
@@ -2179,6 +2298,14 @@ type BondRemoveProps = {
2179
2298
  name: string;
2180
2299
  authority?: PublicKey;
2181
2300
  };
2301
+ type CloseValidatorBondProps = {
2302
+ bondType: BondType;
2303
+ name: string;
2304
+ voteAccount: PublicKey;
2305
+ rentReceiver?: PublicKey;
2306
+ collateralType?: CollateralType;
2307
+ authority?: PublicKey;
2308
+ };
2182
2309
 
2183
2310
  type GetHistoryOpts = {
2184
2311
  cluster?: Cluster;
@@ -2215,12 +2342,17 @@ declare class NodeWallet implements Wallet {
2215
2342
  get publicKey(): PublicKey;
2216
2343
  }
2217
2344
 
2345
+ declare function lamportsToSol(lamports: number | BN): number;
2346
+
2218
2347
  /**
2219
2348
  * Options for configuring the JBondClient.
2220
2349
  */
2221
2350
  type JBondClientOptions = {
2222
2351
  debug?: boolean;
2223
2352
  } & Record<string, any>;
2353
+ type GetAllBondStatesOptions = {
2354
+ includeStats?: boolean;
2355
+ };
2224
2356
  declare class JBondClient {
2225
2357
  readonly provider: Provider;
2226
2358
  readonly options: JBondClientOptions;
@@ -2292,6 +2424,10 @@ declare class JBondClient {
2292
2424
  * Withdraw collateral
2293
2425
  */
2294
2426
  withdrawCollateral(props: WithdrawCollateralProps): Promise<string | undefined>;
2427
+ /**
2428
+ * Migrate SOL collateral from one bond account to JSOL collateral in another bond account
2429
+ */
2430
+ migrateBond(props: MigrateBondProps): Promise<string | undefined>;
2295
2431
  /**
2296
2432
  * Claim compensation for a validator
2297
2433
  */
@@ -2317,6 +2453,7 @@ declare class JBondClient {
2317
2453
  */
2318
2454
  bondFinish(props: BondFinishProps): Promise<string | undefined>;
2319
2455
  bondRemove(props: BondRemoveProps): Promise<string | undefined>;
2456
+ closeValidatorBond(props: CloseValidatorBondProps): Promise<string | undefined>;
2320
2457
  /**
2321
2458
  * Build global state initialize instruction
2322
2459
  */
@@ -2340,11 +2477,26 @@ declare class JBondClient {
2340
2477
  /**
2341
2478
  * Build top up collateral instructions
2342
2479
  */
2343
- getTopUpIxs(props: TopUpCollateralProps): Promise<TransactionInstruction[]>;
2480
+ getTopUpIxs(props: TopUpCollateralProps): Promise<{
2481
+ instructions: TransactionInstruction[];
2482
+ signers: Signer[];
2483
+ }>;
2344
2484
  /**
2345
2485
  * Build withdraw collateral instruction
2346
2486
  */
2347
2487
  getWithdrawIx(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
2488
+ /**
2489
+ * Build instructions for migrating SOL bond collateral into JSOL bond collateral in a single transaction
2490
+ */
2491
+ getMigrateBondIx(props: MigrateBondProps): Promise<{
2492
+ instructions: TransactionInstruction[];
2493
+ signers: Signer[];
2494
+ }>;
2495
+ /**
2496
+ * Build stake-pool SOL deposit instructions without pre-checking payer balance.
2497
+ * This allows composing withdraw->deposit in a single transaction where SOL is obtained by the prior instruction.
2498
+ */
2499
+ private getDepositSolIxsWithoutBalanceCheck;
2348
2500
  /**
2349
2501
  * Build claim instruction
2350
2502
  */
@@ -2367,41 +2519,20 @@ declare class JBondClient {
2367
2519
  getBondSessionStartIx(props: BondStartProps): Promise<TransactionInstruction>;
2368
2520
  lockFunds(props: BondLockFunds): Promise<string | undefined>;
2369
2521
  releaseFunds(props: BondReleaseFunds): Promise<string | undefined>;
2370
- /**
2371
- * Update epoch locks
2372
- */
2373
- updateEpochLocks(props: {
2374
- bondType: BondType;
2375
- bondName: string;
2376
- voteAccount: PublicKeyInitData;
2377
- payer: PublicKey;
2378
- }): Promise<string | undefined>;
2379
- /**
2380
- * Build update epoch locks instruction
2381
- */
2382
- getUpdateEpochLocksIx(props: {
2383
- bondType: BondType;
2384
- bondName: string;
2385
- voteAccount: PublicKeyInitData;
2386
- payer: PublicKey;
2387
- }): Promise<TransactionInstruction>;
2388
2522
  /**
2389
2523
  * Build bond remove instruction
2390
2524
  */
2391
2525
  getBondRemoveIx(props: BondRemoveProps): Promise<TransactionInstruction>;
2526
+ /**
2527
+ * Build close validator bond instruction
2528
+ */
2529
+ getCloseValidatorBondIx(props: CloseValidatorBondProps): Promise<TransactionInstruction>;
2392
2530
  /**
2393
2531
  * Build test set last update epoch instruction
2394
2532
  * NOTE!: This instruction is for testing purposes only.
2395
2533
  * It allows direct manipulation of the validator bond's last epoch update.
2396
2534
  * This should not be used in production environments.
2397
2535
  */
2398
- getTestSetLastUpdateEpochIx(props: {
2399
- bondType: BondType;
2400
- bondName: string;
2401
- voteAccount: PublicKeyInitData;
2402
- payer: PublicKey;
2403
- epoch: number;
2404
- }): Promise<any>;
2405
2536
  /**
2406
2537
  * Build lock funds instruction
2407
2538
  */
@@ -2417,7 +2548,57 @@ declare class JBondClient {
2417
2548
  /**
2418
2549
  * Get all bond states with total collected collateral
2419
2550
  */
2420
- getAllBondStates(bondType: BondType, sessionStatus?: SessionStatus): Promise<{
2551
+ getAllBondStates(bondType: BondType, sessionStatus?: SessionStatus, options?: GetAllBondStatesOptions): Promise<{
2552
+ publicKey: PublicKey;
2553
+ bondState: {
2554
+ name: string;
2555
+ bondType: ({
2556
+ crowdfunding?: undefined;
2557
+ } & {
2558
+ standard: Record<string, never>;
2559
+ }) | ({
2560
+ standard?: undefined;
2561
+ } & {
2562
+ crowdfunding: Record<string, never>;
2563
+ });
2564
+ collateralType: ({
2565
+ native?: undefined;
2566
+ token?: undefined;
2567
+ } & {
2568
+ stakeAccount: Record<string, never>;
2569
+ }) | ({
2570
+ stakeAccount?: undefined;
2571
+ token?: undefined;
2572
+ } & {
2573
+ native: Record<string, never>;
2574
+ }) | ({
2575
+ stakeAccount?: undefined;
2576
+ native?: undefined;
2577
+ } & {
2578
+ token: {
2579
+ 0: PublicKey;
2580
+ };
2581
+ });
2582
+ reserve: PublicKey;
2583
+ authority: PublicKey;
2584
+ sessionId: number;
2585
+ totalMembers: number;
2586
+ totalCompensationAmount: bn_js;
2587
+ sessionStartTs: bn_js;
2588
+ sessionFinishTs: bn_js;
2589
+ status: ({
2590
+ disabled?: undefined;
2591
+ } & {
2592
+ active: Record<string, never>;
2593
+ }) | ({
2594
+ active?: undefined;
2595
+ } & {
2596
+ disabled: Record<string, never>;
2597
+ });
2598
+ bump: number;
2599
+ };
2600
+ stateStats: null;
2601
+ }[] | {
2421
2602
  publicKey: PublicKey;
2422
2603
  bondState: {
2423
2604
  name: string;
@@ -2531,7 +2712,7 @@ declare class JBondClient {
2531
2712
  publicKey: PublicKey;
2532
2713
  }>;
2533
2714
  /**
2534
- * Fetch validator bond data or null if not found
2715
+ * Fetch validator bond data or error if not found
2535
2716
  */
2536
2717
  getValidatorBond(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<{
2537
2718
  state: PublicKey;
@@ -2546,18 +2727,34 @@ declare class JBondClient {
2546
2727
  pendingUnlockEpoch: bn_js;
2547
2728
  publicKey: PublicKey;
2548
2729
  }>;
2730
+ /**
2731
+ * Fetch validator bond data or null if not found
2732
+ */
2733
+ getValidatorBondNullable(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<{
2734
+ state: PublicKey;
2735
+ identity: PublicKey;
2736
+ voteAccount: PublicKey;
2737
+ creator: PublicKey;
2738
+ withdrawalAuthority: PublicKey | null;
2739
+ createdAt: bn_js;
2740
+ bump: number;
2741
+ locked: bn_js;
2742
+ pendingUnlock: bn_js;
2743
+ pendingUnlockEpoch: bn_js;
2744
+ publicKey: PublicKey;
2745
+ } | null>;
2549
2746
  /**
2550
2747
  * Get validator bond account balance (in SOL)
2551
2748
  */
2552
2749
  getValidatorBondBalance(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<number>;
2553
- getBondStateValidatorBondBalances(bondType: BondType, bondName: string): Promise<{
2750
+ getBondStateValidatorBondBalances(bondType: BondType, bondName: string, bondState?: BondState): Promise<{
2554
2751
  voteAccount: PublicKey;
2555
2752
  balance: number;
2556
2753
  }[]>;
2557
2754
  /**
2558
2755
  * Get total collected collateral for a bond state
2559
2756
  */
2560
- getBondStateTotalCollected(bondType: BondType, bondName: string): Promise<number>;
2757
+ getBondStateTotalCollected(bondType: BondType, bondName: string, bondState?: BondState): Promise<number>;
2561
2758
  /**
2562
2759
  * Get bond state stats
2563
2760
  * @param state
@@ -2587,5 +2784,7 @@ declare const CROWDFUNDING_BOND_SEED = "crowdfunding";
2587
2784
  * Program IDs for different environments
2588
2785
  */
2589
2786
  declare const ENV_PROGRAM_ID: Record<JBondClientEnv, string>;
2787
+ declare const JSOL_MINT: PublicKey;
2788
+ declare const JPOOL_POOL_ADDRESS: PublicKey;
2590
2789
 
2591
- export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondRemoveProps, 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 };
2790
+ export { BOND_STATE_SEED, type BondConfigureProps, type BondFinishProps, type BondInitializeProps, type BondLockFunds, type BondReleaseFunds, type BondRemoveProps, type BondStartProps, type BondState, type BondStateStats, type BondStateStatus, BondTransactionType, BondType, CROWDFUNDING_BOND_SEED, type ClaimAllProps, type ClaimProps, type CloseValidatorBondProps, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, GLOBAL_STATE_SEED, type GetAllBondStatesOptions, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JBondClientEnv, type JBondClientOptions, JPOOL_POOL_ADDRESS, JSOL_MINT, type Jbond, type MigrateBondProps, NodeWallet, type RegisterValidatorProps, STANDARD_BOND_SEED, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, VALIDATOR_BOND_SEED, type ValidatorBond, type WithdrawCollateralProps, lamportsToSol };