@jpool/bond-sdk 0.9.0-next.9 → 0.10.0

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
@@ -1,12 +1,13 @@
1
1
  import { Fee } from '@solana/spl-stake-pool/src/layouts';
2
2
  import { PublicKey, TransactionInstruction, Connection, PublicKeyInitData, Transaction, VersionedTransaction, Keypair } from '@solana/web3.js';
3
- import BN from 'bn.js';
3
+ import * as bn_js from 'bn.js';
4
+ import bn_js__default from 'bn.js';
4
5
  import { IdlTypes, IdlAccounts, Program, Provider } from '@coral-xyz/anchor';
5
6
 
6
7
  type StakePoolManager = {
7
8
  stakePoolAddress: PublicKey;
8
- depositSol: (lamports: BN) => TransactionInstruction;
9
- withdrawSol: (poolTokens: BN) => TransactionInstruction;
9
+ depositSol: (lamports: bn_js__default) => TransactionInstruction;
10
+ withdrawSol: (poolTokens: bn_js__default) => TransactionInstruction;
10
11
  readonly exchangeRate: number;
11
12
  readonly withdrawSolFee: Fee;
12
13
  };
@@ -16,7 +17,7 @@ declare enum Seeds {
16
17
  GlobalState = "global_state",
17
18
  BondState = "bond_state",
18
19
  ValidatorBond = "validator_bond",
19
- PerformanceBond = "performance",
20
+ StandardBond = "standard",
20
21
  CrowdFundingBond = "crowdfunding"
21
22
  }
22
23
  /**
@@ -31,7 +32,7 @@ declare const ENV_PROGRAM_ID: Record<string, PublicKey>;
31
32
  * IDL can be found at `target/idl/jbond.json`.
32
33
  */
33
34
  type Jbond = {
34
- "address": "DBuUGWbLz8CkAMQiagMfrQzj8SSg1rHQJWrTSc97HWfR";
35
+ "address": "BondQ7KqZreTcW2UbeTNDcLCJQ3aXAtLn2Fm6ftaJDU";
35
36
  "metadata": {
36
37
  "name": "jbond";
37
38
  "version": "0.2.1";
@@ -208,10 +209,6 @@ type Jbond = {
208
209
  210
209
210
  ];
210
211
  "accounts": [
211
- {
212
- "name": "globalState";
213
- "writable": true;
214
- },
215
212
  {
216
213
  "name": "bondState";
217
214
  "writable": true;
@@ -744,9 +741,6 @@ type Jbond = {
744
741
  },
745
742
  {
746
743
  "name": "globalInitialize";
747
- "docs": [
748
- "----------------------------- Global Instructions ----------------------------"
749
- ];
750
744
  "discriminator": [
751
745
  30,
752
746
  79,
@@ -795,6 +789,111 @@ type Jbond = {
795
789
  ];
796
790
  "args": [];
797
791
  },
792
+ {
793
+ "name": "migrateBond";
794
+ "docs": [
795
+ "Migrates validator bond data from legacy structure to new structure."
796
+ ];
797
+ "discriminator": [
798
+ 107,
799
+ 119,
800
+ 59,
801
+ 110,
802
+ 76,
803
+ 18,
804
+ 37,
805
+ 163
806
+ ];
807
+ "accounts": [
808
+ {
809
+ "name": "bondState";
810
+ "writable": true;
811
+ },
812
+ {
813
+ "name": "legacyValidatorBond";
814
+ "writable": true;
815
+ },
816
+ {
817
+ "name": "legacyVoteAccount";
818
+ },
819
+ {
820
+ "name": "validatorBond";
821
+ "writable": true;
822
+ "pda": {
823
+ "seeds": [
824
+ {
825
+ "kind": "const";
826
+ "value": [
827
+ 118,
828
+ 97,
829
+ 108,
830
+ 105,
831
+ 100,
832
+ 97,
833
+ 116,
834
+ 111,
835
+ 114,
836
+ 95,
837
+ 98,
838
+ 111,
839
+ 110,
840
+ 100
841
+ ];
842
+ },
843
+ {
844
+ "kind": "account";
845
+ "path": "bondState";
846
+ },
847
+ {
848
+ "kind": "account";
849
+ "path": "legacyVoteAccount";
850
+ }
851
+ ];
852
+ };
853
+ },
854
+ {
855
+ "name": "creator";
856
+ "writable": true;
857
+ "signer": true;
858
+ },
859
+ {
860
+ "name": "systemProgram";
861
+ "address": "11111111111111111111111111111111";
862
+ }
863
+ ];
864
+ "args": [];
865
+ },
866
+ {
867
+ "name": "sessionFinish";
868
+ "docs": [
869
+ "Finishes a bond, preventing further deposits and withdrawals."
870
+ ];
871
+ "discriminator": [
872
+ 230,
873
+ 209,
874
+ 54,
875
+ 205,
876
+ 127,
877
+ 141,
878
+ 137,
879
+ 113
880
+ ];
881
+ "accounts": [
882
+ {
883
+ "name": "bondState";
884
+ "writable": true;
885
+ },
886
+ {
887
+ "name": "authority";
888
+ "writable": true;
889
+ "signer": true;
890
+ "relations": [
891
+ "bondState"
892
+ ];
893
+ }
894
+ ];
895
+ "args": [];
896
+ },
798
897
  {
799
898
  "name": "sessionStart";
800
899
  "docs": [
@@ -1063,6 +1162,16 @@ type Jbond = {
1063
1162
  "code": 6021;
1064
1163
  "name": "invalidArgument";
1065
1164
  "msg": "Invalid argument provided";
1165
+ },
1166
+ {
1167
+ "code": 6022;
1168
+ "name": "bondNotDisabled";
1169
+ "msg": "Bond is not disabled";
1170
+ },
1171
+ {
1172
+ "code": 6023;
1173
+ "name": "bondNotEnabled";
1174
+ "msg": "Bond is not enabled";
1066
1175
  }
1067
1176
  ];
1068
1177
  "types": [
@@ -1071,6 +1180,16 @@ type Jbond = {
1071
1180
  "type": {
1072
1181
  "kind": "struct";
1073
1182
  "fields": [
1183
+ {
1184
+ "name": "status";
1185
+ "type": {
1186
+ "option": {
1187
+ "defined": {
1188
+ "name": "bondStatus";
1189
+ };
1190
+ };
1191
+ };
1192
+ },
1074
1193
  {
1075
1194
  "name": "newReserve";
1076
1195
  "type": {
@@ -1173,7 +1292,7 @@ type Jbond = {
1173
1292
  {
1174
1293
  "name": "bondType";
1175
1294
  "docs": [
1176
- "The type of bond (e.g., Performance, Crowdfunding)"
1295
+ "The type of bond (e.g., Standard, Crowdfunding)"
1177
1296
  ];
1178
1297
  "type": {
1179
1298
  "defined": {
@@ -1241,6 +1360,17 @@ type Jbond = {
1241
1360
  ];
1242
1361
  "type": "i64";
1243
1362
  },
1363
+ {
1364
+ "name": "status";
1365
+ "docs": [
1366
+ "Current status of the bond"
1367
+ ];
1368
+ "type": {
1369
+ "defined": {
1370
+ "name": "bondStatus";
1371
+ };
1372
+ };
1373
+ },
1244
1374
  {
1245
1375
  "name": "bump";
1246
1376
  "docs": [
@@ -1251,6 +1381,20 @@ type Jbond = {
1251
1381
  ];
1252
1382
  };
1253
1383
  },
1384
+ {
1385
+ "name": "bondStatus";
1386
+ "type": {
1387
+ "kind": "enum";
1388
+ "variants": [
1389
+ {
1390
+ "name": "active";
1391
+ },
1392
+ {
1393
+ "name": "disabled";
1394
+ }
1395
+ ];
1396
+ };
1397
+ },
1254
1398
  {
1255
1399
  "name": "bondType";
1256
1400
  "docs": [
@@ -1260,7 +1404,7 @@ type Jbond = {
1260
1404
  "kind": "enum";
1261
1405
  "variants": [
1262
1406
  {
1263
- "name": "performance";
1407
+ "name": "standard";
1264
1408
  },
1265
1409
  {
1266
1410
  "name": "crowdfunding";
@@ -1386,15 +1530,6 @@ type Jbond = {
1386
1530
  "type": {
1387
1531
  "kind": "struct";
1388
1532
  "fields": [
1389
- {
1390
- "name": "bonds";
1391
- "docs": [
1392
- "List of all registered bonds"
1393
- ];
1394
- "type": {
1395
- "vec": "pubkey";
1396
- };
1397
- },
1398
1533
  {
1399
1534
  "name": "authority";
1400
1535
  "docs": [
@@ -1418,7 +1553,7 @@ type Jbond = {
1418
1553
  "kind": "struct";
1419
1554
  "fields": [
1420
1555
  {
1421
- "name": "bond";
1556
+ "name": "state";
1422
1557
  "type": "pubkey";
1423
1558
  },
1424
1559
  {
@@ -1439,26 +1574,10 @@ type Jbond = {
1439
1574
  "option": "pubkey";
1440
1575
  };
1441
1576
  },
1442
- {
1443
- "name": "totalCompensationAmount";
1444
- "type": "u64";
1445
- },
1446
- {
1447
- "name": "lastCompensationAmount";
1448
- "type": "u64";
1449
- },
1450
- {
1451
- "name": "lastCompensationEpoch";
1452
- "type": "u64";
1453
- },
1454
1577
  {
1455
1578
  "name": "createdAt";
1456
1579
  "type": "i64";
1457
1580
  },
1458
- {
1459
- "name": "isActive";
1460
- "type": "bool";
1461
- },
1462
1581
  {
1463
1582
  "name": "bump";
1464
1583
  "type": "u8";
@@ -1504,18 +1623,23 @@ type BondState = IdlAccounts<Jbond>['bondState'];
1504
1623
  type ValidatorBond = IdlAccounts<Jbond>['validatorBond'];
1505
1624
  type BondType = IdlTypes<Jbond>['bondType'];
1506
1625
  type CollateralType = IdlTypes<Jbond>['collateralType'];
1626
+ type BondStateStatus = IdlTypes<Jbond>['bondStatus'];
1507
1627
  type BondStateStats = {
1508
1628
  totalCollected: number;
1509
1629
  status: SessionStatus;
1510
1630
  };
1511
1631
  declare const bondTypeToSeed: {
1512
- performance: Seeds;
1632
+ standard: Seeds;
1513
1633
  crowdfunding: Seeds;
1514
1634
  };
1515
1635
  declare const BondTypeVariant: {
1516
- Performance: BondType;
1636
+ Standard: BondType;
1517
1637
  Crowdfunding: BondType;
1518
1638
  };
1639
+ declare const BondStateStatusVariant: {
1640
+ Active: BondStateStatus;
1641
+ Disabled: BondStateStatus;
1642
+ };
1519
1643
  type GlobalInitializeProps = {
1520
1644
  authority?: PublicKey;
1521
1645
  };
@@ -1573,6 +1697,7 @@ type BondConfigureProps = {
1573
1697
  bondType: BondType;
1574
1698
  name: string;
1575
1699
  authority?: PublicKey;
1700
+ bondStateStatus?: BondStateStatus;
1576
1701
  newAuthority?: PublicKey;
1577
1702
  newReserve?: PublicKey;
1578
1703
  };
@@ -1600,8 +1725,6 @@ type TransactionHistoryItem = {
1600
1725
  epoch: number;
1601
1726
  type: BondTransactionType;
1602
1727
  amount: number;
1603
- beforeBalance?: number;
1604
- afterBalance?: number;
1605
1728
  };
1606
1729
  declare enum BondTransactionType {
1607
1730
  Deposit = "deposit",
@@ -1778,10 +1901,20 @@ declare class JBondClient {
1778
1901
  buildWithdrawIx(props: WithdrawCollateralProps): Promise<TransactionInstruction>;
1779
1902
  buildClaimIx(props: ClaimProps): Promise<TransactionInstruction>;
1780
1903
  buildSetWithdrawAuthorityIx(props: SetWithdrawAuthorityProps): Promise<TransactionInstruction>;
1781
- buildBondFinishIx(_props: {
1904
+ buildBondFinishIx(props: {
1782
1905
  bondType: BondType;
1783
1906
  name: string;
1784
1907
  }): Promise<TransactionInstruction>;
1908
+ migrateBond(props: {
1909
+ bondType: BondType;
1910
+ name: string;
1911
+ voteAccount: PublicKeyInitData;
1912
+ }): Promise<string | undefined>;
1913
+ buildBondMigrateIx(props: {
1914
+ bondType: BondType;
1915
+ name: string;
1916
+ voteAccount: PublicKeyInitData;
1917
+ }): Promise<TransactionInstruction>;
1785
1918
  buildBondStartIx(props: {
1786
1919
  bondType: BondType;
1787
1920
  name: string;
@@ -1791,22 +1924,83 @@ declare class JBondClient {
1791
1924
  * Fetch global state or throw if not found
1792
1925
  */
1793
1926
  getGlobalState(): Promise<GlobalState>;
1794
- getBondState(bondType: BondType, bondName: string): Promise<BondState>;
1927
+ /**
1928
+ * Fetch bond state with stats
1929
+ * @param bondType - Type of the bond
1930
+ * @param bondName - Name of the bond
1931
+ * @param withStats
1932
+ */
1933
+ getBondState(bondType: BondType, bondName: string, withStats?: boolean): Promise<{
1934
+ bondState: BondState;
1935
+ stateStats: BondStateStats | null;
1936
+ }>;
1795
1937
  /**
1796
1938
  * Get all bond states with total collected collateral
1797
1939
  */
1798
- getAllBondStates(bondType: BondType): Promise<Array<[BondState, BondStateStats]>>;
1940
+ getAllBondStates(bondType: BondType, sessionStatus?: SessionStatus): Promise<{
1941
+ publicKey: PublicKey;
1942
+ bondState: {
1943
+ name: string;
1944
+ bondType: ({
1945
+ crowdfunding?: undefined;
1946
+ } & {
1947
+ standard: Record<string, never>;
1948
+ }) | ({
1949
+ standard?: undefined;
1950
+ } & {
1951
+ crowdfunding: Record<string, never>;
1952
+ });
1953
+ collateralType: ({
1954
+ native?: undefined;
1955
+ token?: undefined;
1956
+ } & {
1957
+ stakeAccount: Record<string, never>;
1958
+ }) | ({
1959
+ stakeAccount?: undefined;
1960
+ token?: undefined;
1961
+ } & {
1962
+ native: Record<string, never>;
1963
+ }) | ({
1964
+ stakeAccount?: undefined;
1965
+ native?: undefined;
1966
+ } & {
1967
+ token: {
1968
+ 0: PublicKey;
1969
+ };
1970
+ });
1971
+ reserve: PublicKey;
1972
+ authority: PublicKey;
1973
+ sessionId: number;
1974
+ totalMembers: number;
1975
+ totalCompensationAmount: bn_js;
1976
+ sessionStartTs: bn_js;
1977
+ sessionFinishTs: bn_js;
1978
+ status: ({
1979
+ disabled?: undefined;
1980
+ } & {
1981
+ active: Record<string, never>;
1982
+ }) | ({
1983
+ active?: undefined;
1984
+ } & {
1985
+ disabled: Record<string, never>;
1986
+ });
1987
+ bump: number;
1988
+ };
1989
+ stateStats: {
1990
+ totalCollected: number;
1991
+ status: SessionStatus;
1992
+ };
1993
+ }[]>;
1799
1994
  /**
1800
1995
  * Get session status for bond state
1801
1996
  */
1802
1997
  private getBondStateSessionStatus;
1803
- /** Get all validator bonds for a given bond state */
1998
+ /**
1999
+ * Get all validator bonds for a given bond state
2000
+ */
1804
2001
  private getValidatorBondsByState;
1805
2002
  /**
1806
2003
  * Fetch validator bond data or null if not found
1807
- * @param bondType
1808
- * @param bondName
1809
- * @param vote
1810
2004
  */
1811
2005
  getValidatorBond(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<ValidatorBond | null>;
1812
2006
  /**
@@ -1821,6 +2015,39 @@ declare class JBondClient {
1821
2015
  * @return Balance in lamports
1822
2016
  */
1823
2017
  getValidatorBondBalance(bondType: BondType, bondName: string, vote: PublicKeyInitData): Promise<number>;
2018
+ /**
2019
+ * Get total collected collateral for a bond state
2020
+ */
2021
+ getBondStateTotalCollected(bondType: BondType, bondName: string, votes: PublicKeyInitData[]): Promise<number>;
2022
+ /**
2023
+ * Get transaction history for a specific validator bond account
2024
+ */
2025
+ getHistory(bondType: BondType, bondName: string, vote: PublicKey, options?: {
2026
+ cluster?: 'mainnet-beta' | 'testnet' | 'devnet';
2027
+ limit?: number;
2028
+ before?: string;
2029
+ until?: string;
2030
+ }): Promise<TransactionHistoryItem[]>;
2031
+ /**
2032
+ * Get full transaction history by paginating through results
2033
+ * @param bondType
2034
+ * @param bondName
2035
+ * @param voteAccount
2036
+ * @param pageSize
2037
+ */
2038
+ getFullHistory(bondType: BondType, bondName: string, voteAccount: PublicKey, pageSize?: number): Promise<TransactionHistoryItem[]>;
2039
+ /**
2040
+ * Get instruction discriminator from IDL
2041
+ * @param instructionName
2042
+ * @private
2043
+ */
2044
+ private getInstructionDiscriminator;
2045
+ /**
2046
+ * Get bond state stats
2047
+ * @param state
2048
+ * @private
2049
+ */
2050
+ private getBondStateStats;
1824
2051
  /**
1825
2052
  * Load stake pool account and cache it if not already cached
1826
2053
  * @private
@@ -1841,4 +2068,4 @@ declare class JBondClient {
1841
2068
  private lamports;
1842
2069
  }
1843
2070
 
1844
- export { BondClientEnv, type BondCollateral, type BondConfigureProps, type BondInitializeProps, type BondState, type BondStateStats, BondTransactionType, type BondType, BondTypeVariant, type ClaimProps, type ClientOptions, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JPOOL_STAKE_POOL, type Jbond, NodeWallet, type RegisterValidatorProps, Seeds, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, bondTypeToSeed };
2071
+ export { BondClientEnv, type BondCollateral, type BondConfigureProps, type BondInitializeProps, type BondState, type BondStateStats, type BondStateStatus, BondStateStatusVariant, BondTransactionType, type BondType, BondTypeVariant, type ClaimProps, type ClientOptions, type CollateralType, ENV_PROGRAM_ID, type EpochHistoryItem, type GetHistoryGroupedProps, type GetHistoryProps, type GlobalConfigureProps, type GlobalInitializeProps, type GlobalState, JBondClient, JPOOL_STAKE_POOL, type Jbond, NodeWallet, type RegisterValidatorProps, Seeds, SessionStatus, type SetWithdrawAuthorityProps, type TopUpCollateralProps, type TransactionHistoryItem, type ValidatorBond, type WithdrawCollateralProps, bondTypeToSeed };