@drift-labs/sdk 2.145.0-beta.1 → 2.145.0-beta.3
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/VERSION +1 -1
- package/lib/browser/accounts/types.d.ts +13 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +53 -0
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.js +453 -0
- package/lib/browser/addresses/pda.d.ts +9 -0
- package/lib/browser/addresses/pda.js +60 -1
- package/lib/browser/adminClient.d.ts +160 -8
- package/lib/browser/adminClient.js +754 -18
- package/lib/browser/constituentMap/constituentMap.d.ts +64 -0
- package/lib/browser/constituentMap/constituentMap.js +170 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +24 -0
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/browser/driftClient.d.ts +89 -2
- package/lib/browser/driftClient.js +497 -30
- package/lib/browser/driftClientConfig.d.ts +2 -7
- package/lib/browser/idl/drift.json +3513 -577
- package/lib/browser/index.d.ts +1 -4
- package/lib/browser/index.js +2 -9
- package/lib/browser/memcmp.d.ts +3 -1
- package/lib/browser/memcmp.js +19 -1
- package/lib/browser/types.d.ts +149 -0
- package/lib/browser/types.js +13 -1
- package/lib/node/accounts/types.d.ts +13 -1
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +54 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -0
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.js +453 -0
- package/lib/node/addresses/pda.d.ts +9 -0
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +60 -1
- package/lib/node/adminClient.d.ts +160 -8
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +754 -18
- package/lib/node/constituentMap/constituentMap.d.ts +65 -0
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -0
- package/lib/node/constituentMap/constituentMap.js +170 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.js +60 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +25 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -0
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +58 -0
- package/lib/node/driftClient.d.ts +89 -2
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +497 -30
- package/lib/node/driftClientConfig.d.ts +2 -7
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/idl/drift.json +3513 -577
- package/lib/node/index.d.ts +1 -4
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +2 -9
- package/lib/node/memcmp.d.ts +3 -1
- package/lib/node/memcmp.d.ts.map +1 -1
- package/lib/node/memcmp.js +19 -1
- package/lib/node/types.d.ts +149 -0
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +13 -1
- package/package.json +1 -1
- package/src/accounts/types.ts +20 -0
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +596 -0
- package/src/addresses/pda.ts +115 -1
- package/src/adminClient.ts +1612 -41
- package/src/constituentMap/constituentMap.ts +285 -0
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +97 -0
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +112 -0
- package/src/driftClient.ts +1114 -23
- package/src/driftClientConfig.ts +8 -15
- package/src/idl/drift.json +3513 -577
- package/src/index.ts +1 -4
- package/src/memcmp.ts +23 -1
- package/src/types.ts +162 -0
package/src/index.ts
CHANGED
|
@@ -12,10 +12,6 @@ export * from './accounts/webSocketDriftClientAccountSubscriber';
|
|
|
12
12
|
export * from './accounts/webSocketInsuranceFundStakeAccountSubscriber';
|
|
13
13
|
export * from './accounts/webSocketHighLeverageModeConfigAccountSubscriber';
|
|
14
14
|
export { WebSocketAccountSubscriberV2 } from './accounts/webSocketAccountSubscriberV2';
|
|
15
|
-
export { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber';
|
|
16
|
-
export { WebSocketProgramUserAccountSubscriber } from './accounts/websocketProgramUserAccountSubscriber';
|
|
17
|
-
export { WebSocketProgramAccountsSubscriberV2 } from './accounts/webSocketProgramAccountsSubscriberV2';
|
|
18
|
-
export { WebSocketDriftClientAccountSubscriberV2 } from './accounts/webSocketDriftClientAccountSubscriberV2';
|
|
19
15
|
export * from './accounts/bulkAccountLoader';
|
|
20
16
|
export * from './accounts/bulkUserSubscription';
|
|
21
17
|
export * from './accounts/bulkUserStatsSubscription';
|
|
@@ -141,5 +137,6 @@ export * from './clock/clockSubscriber';
|
|
|
141
137
|
export * from './math/userStatus';
|
|
142
138
|
export * from './indicative-quotes/indicativeQuotesSender';
|
|
143
139
|
export * from './constants';
|
|
140
|
+
export * from './constituentMap/constituentMap';
|
|
144
141
|
|
|
145
142
|
export { BN, PublicKey, pyth };
|
package/src/memcmp.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MemcmpFilter } from '@solana/web3.js';
|
|
1
|
+
import { MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import bs58 from 'bs58';
|
|
3
3
|
import { BorshAccountsCoder } from '@coral-xyz/anchor';
|
|
4
4
|
import { encodeName } from './userName';
|
|
@@ -140,3 +140,25 @@ export function getRevenueShareEscrowFilter(): MemcmpFilter {
|
|
|
140
140
|
},
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
+
|
|
144
|
+
export function getConstituentFilter(): MemcmpFilter {
|
|
145
|
+
return {
|
|
146
|
+
memcmp: {
|
|
147
|
+
offset: 0,
|
|
148
|
+
bytes: bs58.encode(
|
|
149
|
+
BorshAccountsCoder.accountDiscriminator('Constituent')
|
|
150
|
+
),
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function getConstituentLpPoolFilter(
|
|
156
|
+
lpPoolPublicKey: PublicKey
|
|
157
|
+
): MemcmpFilter {
|
|
158
|
+
return {
|
|
159
|
+
memcmp: {
|
|
160
|
+
offset: 72,
|
|
161
|
+
bytes: lpPoolPublicKey.toBase58(),
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -895,6 +895,7 @@ export type PerpMarketAccount = {
|
|
|
895
895
|
protectedMakerDynamicDivisor: number;
|
|
896
896
|
lastFillPrice: BN;
|
|
897
897
|
|
|
898
|
+
lpPoolId: number;
|
|
898
899
|
lpFeeTransferScalar: number;
|
|
899
900
|
lpExchangeFeeExcluscionScalar: number;
|
|
900
901
|
lpStatus: number;
|
|
@@ -1337,6 +1338,7 @@ export type SignedMsgOrderParamsMessage = {
|
|
|
1337
1338
|
maxMarginRatio?: number | null;
|
|
1338
1339
|
builderIdx?: number | null;
|
|
1339
1340
|
builderFeeTenthBps?: number | null;
|
|
1341
|
+
isolatedPositionDeposit?: BN | null;
|
|
1340
1342
|
};
|
|
1341
1343
|
|
|
1342
1344
|
export type SignedMsgOrderParamsDelegateMessage = {
|
|
@@ -1349,6 +1351,7 @@ export type SignedMsgOrderParamsDelegateMessage = {
|
|
|
1349
1351
|
maxMarginRatio?: number | null;
|
|
1350
1352
|
builderIdx?: number | null;
|
|
1351
1353
|
builderFeeTenthBps?: number | null;
|
|
1354
|
+
isolatedPositionDeposit?: BN | null;
|
|
1352
1355
|
};
|
|
1353
1356
|
|
|
1354
1357
|
export type SignedMsgTriggerOrderParams = {
|
|
@@ -1732,3 +1735,162 @@ export type RevenueShareSettleRecord = {
|
|
|
1732
1735
|
builderTotalBuilderRewards: BN;
|
|
1733
1736
|
builderSubAccountId: number;
|
|
1734
1737
|
};
|
|
1738
|
+
|
|
1739
|
+
export type AddAmmConstituentMappingDatum = {
|
|
1740
|
+
constituentIndex: number;
|
|
1741
|
+
perpMarketIndex: number;
|
|
1742
|
+
weight: BN;
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
export type AmmConstituentDatum = AddAmmConstituentMappingDatum & {
|
|
1746
|
+
lastSlot: BN;
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
export type AmmConstituentMapping = {
|
|
1750
|
+
lpPool: PublicKey;
|
|
1751
|
+
bump: number;
|
|
1752
|
+
weights: AmmConstituentDatum[];
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
export type TargetDatum = {
|
|
1756
|
+
costToTradeBps: number;
|
|
1757
|
+
lastOracleSlot: BN;
|
|
1758
|
+
lastPositionSlot: BN;
|
|
1759
|
+
targetBase: BN;
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
export type ConstituentTargetBaseAccount = {
|
|
1763
|
+
lpPool: PublicKey;
|
|
1764
|
+
bump: number;
|
|
1765
|
+
targets: TargetDatum[];
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
export type ConstituentCorrelations = {
|
|
1769
|
+
lpPool: PublicKey;
|
|
1770
|
+
bump: number;
|
|
1771
|
+
correlations: BN[];
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
export type LPPoolAccount = {
|
|
1775
|
+
lpPoolId: number;
|
|
1776
|
+
pubkey: PublicKey;
|
|
1777
|
+
mint: PublicKey;
|
|
1778
|
+
whitelistMint: PublicKey;
|
|
1779
|
+
constituentTargetBase: PublicKey;
|
|
1780
|
+
constituentCorrelations: PublicKey;
|
|
1781
|
+
maxAum: BN;
|
|
1782
|
+
lastAum: BN;
|
|
1783
|
+
cumulativeQuoteSentToPerpMarkets: BN;
|
|
1784
|
+
cumulativeQuoteReceivedFromPerpMarkets: BN;
|
|
1785
|
+
totalMintRedeemFeesPaid: BN;
|
|
1786
|
+
lastAumSlot: BN;
|
|
1787
|
+
maxSettleQuoteAmount: BN;
|
|
1788
|
+
mintRedeemId: BN;
|
|
1789
|
+
settleId: BN;
|
|
1790
|
+
minMintFee: BN;
|
|
1791
|
+
tokenSupply: BN;
|
|
1792
|
+
volatility: BN;
|
|
1793
|
+
constituents: number;
|
|
1794
|
+
quoteConstituentIndex: number;
|
|
1795
|
+
bump: number;
|
|
1796
|
+
gammaExecution: number;
|
|
1797
|
+
xi: number;
|
|
1798
|
+
};
|
|
1799
|
+
|
|
1800
|
+
export type ConstituentSpotBalance = {
|
|
1801
|
+
scaledBalance: BN;
|
|
1802
|
+
cumulativeDeposits: BN;
|
|
1803
|
+
marketIndex: number;
|
|
1804
|
+
balanceType: SpotBalanceType;
|
|
1805
|
+
};
|
|
1806
|
+
|
|
1807
|
+
export type InitializeConstituentParams = {
|
|
1808
|
+
spotMarketIndex: number;
|
|
1809
|
+
decimals: number;
|
|
1810
|
+
maxWeightDeviation: BN;
|
|
1811
|
+
swapFeeMin: BN;
|
|
1812
|
+
swapFeeMax: BN;
|
|
1813
|
+
maxBorrowTokenAmount: BN;
|
|
1814
|
+
oracleStalenessThreshold: BN;
|
|
1815
|
+
costToTrade: number;
|
|
1816
|
+
derivativeWeight: BN;
|
|
1817
|
+
constituentDerivativeIndex?: number;
|
|
1818
|
+
constituentDerivativeDepegThreshold?: BN;
|
|
1819
|
+
constituentCorrelations: BN[];
|
|
1820
|
+
volatility: BN;
|
|
1821
|
+
gammaExecution?: number;
|
|
1822
|
+
gammaInventory?: number;
|
|
1823
|
+
xi?: number;
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
export enum ConstituentStatus {
|
|
1827
|
+
ACTIVE = 0,
|
|
1828
|
+
REDUCE_ONLY = 1,
|
|
1829
|
+
DECOMMISSIONED = 2,
|
|
1830
|
+
}
|
|
1831
|
+
export enum ConstituentLpOperation {
|
|
1832
|
+
Swap = 0b00000001,
|
|
1833
|
+
Deposit = 0b00000010,
|
|
1834
|
+
Withdraw = 0b00000100,
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
export type ConstituentAccount = {
|
|
1838
|
+
pubkey: PublicKey;
|
|
1839
|
+
mint: PublicKey;
|
|
1840
|
+
lpPool: PublicKey;
|
|
1841
|
+
vault: PublicKey;
|
|
1842
|
+
totalSwapFees: BN;
|
|
1843
|
+
spotBalance: ConstituentSpotBalance;
|
|
1844
|
+
lastSpotBalanceTokenAmount: BN;
|
|
1845
|
+
cumulativeSpotInterestAccruedTokenAmount: BN;
|
|
1846
|
+
maxWeightDeviation: BN;
|
|
1847
|
+
swapFeeMin: BN;
|
|
1848
|
+
swapFeeMax: BN;
|
|
1849
|
+
maxBorrowTokenAmount: BN;
|
|
1850
|
+
vaultTokenBalance: BN;
|
|
1851
|
+
lastOraclePrice: BN;
|
|
1852
|
+
lastOracleSlot: BN;
|
|
1853
|
+
oracleStalenessThreshold: BN;
|
|
1854
|
+
flashLoanInitialTokenAmount: BN;
|
|
1855
|
+
nextSwapId: BN;
|
|
1856
|
+
derivativeWeight: BN;
|
|
1857
|
+
volatility: BN;
|
|
1858
|
+
constituentDerivativeDepegThreshold: BN;
|
|
1859
|
+
constituentDerivativeIndex: number;
|
|
1860
|
+
spotMarketIndex: number;
|
|
1861
|
+
constituentIndex: number;
|
|
1862
|
+
decimals: number;
|
|
1863
|
+
bump: number;
|
|
1864
|
+
vaultBump: number;
|
|
1865
|
+
gammaInventory: number;
|
|
1866
|
+
gammaExecution: number;
|
|
1867
|
+
xi: number;
|
|
1868
|
+
status: number;
|
|
1869
|
+
pausedOperations: number;
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
export type CacheInfo = {
|
|
1873
|
+
oracle: PublicKey;
|
|
1874
|
+
lastFeePoolTokenAmount: BN;
|
|
1875
|
+
lastNetPnlPoolTokenAmount: BN;
|
|
1876
|
+
lastExchangeFees: BN;
|
|
1877
|
+
lastSettleAmmExFees: BN;
|
|
1878
|
+
lastSettleAmmPnl: BN;
|
|
1879
|
+
position: BN;
|
|
1880
|
+
slot: BN;
|
|
1881
|
+
lastSettleAmount: BN;
|
|
1882
|
+
lastSettleSlot: BN;
|
|
1883
|
+
lastSettleTs: BN;
|
|
1884
|
+
quoteOwedFromLpPool: BN;
|
|
1885
|
+
ammInventoryLimit: BN;
|
|
1886
|
+
oraclePrice: BN;
|
|
1887
|
+
oracleSlot: BN;
|
|
1888
|
+
oracleSource: number;
|
|
1889
|
+
oracleValidity: number;
|
|
1890
|
+
lpStatusForPerpMarket: number;
|
|
1891
|
+
ammPositionScalar: number;
|
|
1892
|
+
};
|
|
1893
|
+
|
|
1894
|
+
export type AmmCache = {
|
|
1895
|
+
cache: CacheInfo[];
|
|
1896
|
+
};
|