@drift-labs/sdk-browser 2.162.0-beta.2 → 2.163.0-beta.10
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/.prettierignore +1 -0
- package/.yarn/install-state.gz +0 -0
- package/README.md +2 -2
- package/VERSION +1 -1
- package/bun.lock +47 -79
- package/lib/browser/accounts/fetch.d.ts +6 -6
- package/lib/browser/accounts/fetch.js +4 -4
- package/lib/browser/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/browser/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/browser/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/browser/accounts/testBulkAccountLoader.js +3 -5
- package/lib/browser/accounts/types.d.ts +11 -14
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/browser/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/browser/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/browser/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/browser/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/browser/addresses/pda.d.ts +6 -2
- package/lib/browser/addresses/pda.js +7 -12
- package/lib/browser/adminClient.d.ts +11 -9
- package/lib/browser/adminClient.js +30 -72
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/browser/config.d.ts +7 -3
- package/lib/browser/config.js +9 -7
- package/lib/browser/constants/index.d.ts +5 -0
- package/lib/browser/constants/index.js +5 -0
- package/lib/browser/constants/numericConstants.d.ts +1 -1
- package/lib/browser/constants/numericConstants.js +3 -3
- package/lib/browser/constants/perpMarkets.js +3 -412
- package/lib/browser/constants/spotMarkets.js +7 -91
- package/lib/browser/constituentMap/constituentMap.js +2 -2
- package/lib/browser/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/browser/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/browser/decode/customCoder.d.ts +7 -9
- package/lib/browser/decode/customCoder.js +17 -28
- package/lib/browser/decode/user.js +7 -25
- package/lib/browser/dlob/DLOB.d.ts +12 -0
- package/lib/browser/dlob/DLOB.js +12 -0
- package/lib/browser/dlob/orderBookLevels.js +1 -1
- package/lib/browser/driftClient.d.ts +32 -59
- package/lib/browser/driftClient.js +85 -562
- package/lib/browser/driftClientConfig.d.ts +7 -0
- package/lib/browser/events/eventSubscriber.d.ts +8 -0
- package/lib/browser/events/eventSubscriber.js +5 -2
- package/lib/browser/events/parse.d.ts +1 -1
- package/lib/browser/factory/oracleClient.d.ts +2 -2
- package/lib/browser/factory/oracleClient.js +9 -21
- package/lib/browser/idl/drift.d.ts +21406 -0
- package/lib/browser/idl/drift.js +2 -0
- package/lib/browser/idl/drift.json +20850 -15287
- package/lib/browser/idl/pyth.d.ts +97 -0
- package/lib/browser/idl/pyth.js +2 -0
- package/lib/browser/idl/token_faucet.d.ts +197 -0
- package/lib/browser/idl/token_faucet.js +2 -0
- package/lib/browser/idl/token_faucet.json +148 -61
- package/lib/browser/index.d.ts +13 -6
- package/lib/browser/index.js +12 -5
- package/lib/browser/marinade/index.d.ts +1 -1
- package/lib/browser/marinade/index.js +2 -2
- package/lib/browser/math/amm.d.ts +4 -5
- package/lib/browser/math/amm.js +8 -35
- package/lib/browser/math/funding.js +6 -1
- package/lib/browser/math/margin.d.ts +3 -4
- package/lib/browser/math/margin.js +16 -47
- package/lib/browser/math/market.d.ts +2 -2
- package/lib/browser/math/market.js +10 -42
- package/lib/browser/math/oracles.js +14 -19
- package/lib/browser/math/position.js +1 -1
- package/lib/browser/math/trade.js +4 -4
- package/lib/browser/memcmp.js +8 -8
- package/lib/browser/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/browser/openbook/openbookV2Subscriber.js +3 -3
- package/lib/browser/oracles/oracleClientCache.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/browser/oracles/prelaunchOracleClient.js +1 -1
- package/lib/browser/oracles/pythLazerClient.js +3 -5
- package/lib/browser/oracles/types.d.ts +6 -0
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/orderParams.js +1 -5
- package/lib/browser/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/index.d.ts +5 -0
- package/lib/browser/orderSubscriber/index.js +5 -0
- package/lib/browser/priorityFee/index.d.ts +5 -0
- package/lib/browser/priorityFee/index.js +5 -0
- package/lib/browser/pyth/index.d.ts +2 -2
- package/lib/browser/pyth/types.d.ts +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/browser/swift/index.d.ts +7 -0
- package/lib/browser/swift/index.js +7 -0
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/browser/tokenFaucet.d.ts +2 -2
- package/lib/browser/tokenFaucet.js +4 -4
- package/lib/browser/tx/txHandler.d.ts +12 -0
- package/lib/browser/tx/txHandler.js +12 -0
- package/lib/browser/types.d.ts +19 -31
- package/lib/browser/types.js +6 -11
- package/lib/browser/user.d.ts +27 -18
- package/lib/browser/user.js +64 -100
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/browser/userMap/userMap.js +4 -5
- package/lib/browser/userMap/userStatsMap.js +2 -3
- package/lib/browser/userStats.d.ts +5 -0
- package/lib/node/accounts/fetch.d.ts +6 -6
- package/lib/node/accounts/fetch.d.ts.map +1 -1
- package/lib/node/accounts/fetch.js +4 -4
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/grpcUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/oneShotUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingInsuranceFundStakeAccountSubscriber.js +1 -1
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingOracleAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserAccountSubscriber.js +2 -2
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingUserStatsAccountSubscriber.js +1 -1
- package/lib/node/accounts/testBulkAccountLoader.d.ts.map +1 -1
- package/lib/node/accounts/testBulkAccountLoader.js +3 -5
- package/lib/node/accounts/types.d.ts +11 -14
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.js +1 -2
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +5 -5
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.js +2 -2
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriberV2.js +2 -2
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketInsuranceFundStakeAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts +3 -3
- package/lib/node/accounts/webSocketProgramAccountsSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts +3 -3
- package/lib/node/accounts/webSocketUserStatsAccountSubsriber.d.ts.map +1 -1
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts +2 -2
- package/lib/node/accounts/websocketProgramUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/addresses/pda.d.ts +6 -2
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +7 -12
- package/lib/node/adminClient.d.ts +11 -9
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +30 -72
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +1 -1
- package/lib/node/config.d.ts +7 -3
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +9 -7
- package/lib/node/constants/index.d.ts +5 -0
- package/lib/node/constants/index.d.ts.map +1 -1
- package/lib/node/constants/index.js +5 -0
- package/lib/node/constants/numericConstants.d.ts +1 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +3 -3
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +3 -412
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/constants/spotMarkets.js +7 -91
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +2 -2
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/pollingConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts +3 -3
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.d.ts.map +1 -1
- package/lib/node/constituentMap/webSocketConstituentAccountSubscriber.js +1 -1
- package/lib/node/decode/customCoder.d.ts +7 -9
- package/lib/node/decode/customCoder.d.ts.map +1 -1
- package/lib/node/decode/customCoder.js +17 -28
- package/lib/node/decode/user.d.ts.map +1 -1
- package/lib/node/decode/user.js +7 -25
- package/lib/node/dlob/DLOB.d.ts +12 -0
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +12 -0
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +1 -1
- package/lib/node/driftClient.d.ts +32 -59
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +85 -562
- package/lib/node/driftClientConfig.d.ts +7 -0
- package/lib/node/driftClientConfig.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +8 -0
- package/lib/node/events/eventSubscriber.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.js +5 -2
- package/lib/node/events/parse.d.ts +1 -1
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.d.ts +2 -2
- package/lib/node/factory/oracleClient.d.ts.map +1 -1
- package/lib/node/factory/oracleClient.js +9 -21
- package/lib/node/idl/drift.d.ts +21407 -0
- package/lib/node/idl/drift.d.ts.map +1 -0
- package/lib/node/idl/drift.js +2 -0
- package/lib/node/idl/drift.json +20850 -15287
- package/lib/node/idl/pyth.d.ts +98 -0
- package/lib/node/idl/pyth.d.ts.map +1 -0
- package/lib/node/idl/pyth.js +2 -0
- package/lib/node/idl/token_faucet.d.ts +198 -0
- package/lib/node/idl/token_faucet.d.ts.map +1 -0
- package/lib/node/idl/token_faucet.js +2 -0
- package/lib/node/idl/token_faucet.json +148 -61
- package/lib/node/index.d.ts +13 -6
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +12 -5
- package/lib/node/marinade/index.d.ts +1 -1
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +2 -2
- package/lib/node/math/amm.d.ts +4 -5
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +8 -35
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +6 -1
- package/lib/node/math/margin.d.ts +3 -4
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +16 -47
- package/lib/node/math/market.d.ts +2 -2
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +10 -42
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +14 -19
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +1 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +4 -4
- package/lib/node/memcmp.js +8 -8
- package/lib/node/openbook/openbookV2Subscriber.d.ts +1 -1
- package/lib/node/openbook/openbookV2Subscriber.d.ts.map +1 -1
- package/lib/node/openbook/openbookV2Subscriber.js +3 -3
- package/lib/node/oracles/oracleClientCache.d.ts +2 -2
- package/lib/node/oracles/oracleClientCache.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.d.ts +2 -2
- package/lib/node/oracles/prelaunchOracleClient.d.ts.map +1 -1
- package/lib/node/oracles/prelaunchOracleClient.js +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.js +3 -5
- package/lib/node/oracles/types.d.ts +6 -0
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/orderParams.js +1 -5
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +3 -4
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/index.d.ts +5 -0
- package/lib/node/orderSubscriber/index.d.ts.map +1 -1
- package/lib/node/orderSubscriber/index.js +5 -0
- package/lib/node/priorityFee/index.d.ts +5 -0
- package/lib/node/priorityFee/index.d.ts.map +1 -1
- package/lib/node/priorityFee/index.js +5 -0
- package/lib/node/pyth/index.d.ts +2 -2
- package/lib/node/pyth/index.d.ts.map +1 -1
- package/lib/node/pyth/types.d.ts +1 -1
- package/lib/node/pyth/types.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +1 -1
- package/lib/node/swift/index.d.ts +7 -0
- package/lib/node/swift/index.d.ts.map +1 -1
- package/lib/node/swift/index.js +7 -0
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +4 -3
- package/lib/node/tokenFaucet.d.ts +2 -2
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/tokenFaucet.js +4 -4
- package/lib/node/tx/txHandler.d.ts +12 -0
- package/lib/node/tx/txHandler.d.ts.map +1 -1
- package/lib/node/tx/txHandler.js +12 -0
- package/lib/node/types.d.ts +19 -31
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +6 -11
- package/lib/node/user.d.ts +27 -18
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +64 -100
- package/lib/node/userMap/WebsocketSubscription.js +1 -1
- package/lib/node/userMap/grpcSubscription.js +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +4 -4
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +4 -5
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +2 -3
- package/lib/node/userStats.d.ts +5 -0
- package/lib/node/userStats.d.ts.map +1 -1
- package/package.json +5 -7
- package/src/accounts/fetch.ts +18 -17
- package/src/accounts/grpcAccountSubscriber.ts +3 -3
- package/src/accounts/grpcDriftClientAccountSubscriber.ts +2 -3
- package/src/accounts/grpcDriftClientAccountSubscriberV2.ts +5 -6
- package/src/accounts/grpcInsuranceFundStakeAccountSubscriber.ts +2 -2
- package/src/accounts/grpcMultiAccountSubscriber.ts +4 -4
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +4 -4
- package/src/accounts/grpcProgramAccountSubscriber.ts +3 -3
- package/src/accounts/grpcUserAccountSubscriber.ts +2 -2
- package/src/accounts/grpcUserStatsAccountSubscriber.ts +2 -2
- package/src/accounts/laserProgramAccountSubscriber.ts +3 -3
- package/src/accounts/oneShotUserAccountSubscriber.ts +6 -7
- package/src/accounts/oneShotUserStatsAccountSubscriber.ts +10 -9
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +12 -11
- package/src/accounts/pollingInsuranceFundStakeAccountSubscriber.ts +11 -10
- package/src/accounts/pollingOracleAccountSubscriber.ts +2 -2
- package/src/accounts/pollingTokenAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserAccountSubscriber.ts +2 -2
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +14 -14
- package/src/accounts/testBulkAccountLoader.ts +3 -5
- package/src/accounts/types.ts +10 -25
- package/src/accounts/webSocketAccountSubscriber.ts +5 -5
- package/src/accounts/webSocketAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +9 -10
- package/src/accounts/webSocketDriftClientAccountSubscriberV2.ts +13 -10
- package/src/accounts/webSocketInsuranceFundStakeAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketProgramAccountSubscriber.ts +4 -3
- package/src/accounts/webSocketProgramAccountSubscriberV2.ts +4 -3
- package/src/accounts/webSocketProgramAccountsSubscriberV2.ts +4 -3
- package/src/accounts/webSocketUserAccountSubscriber.ts +3 -3
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +3 -3
- package/src/accounts/websocketProgramUserAccountSubscriber.ts +4 -4
- package/src/addresses/pda.ts +6 -22
- package/src/adminClient.ts +154 -239
- package/src/auctionSubscriber/auctionSubscriber.ts +5 -3
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +5 -3
- package/src/config.ts +24 -16
- package/src/constants/index.ts +5 -0
- package/src/constants/numericConstants.ts +2 -3
- package/src/constants/perpMarkets.ts +3 -445
- package/src/constants/spotMarkets.ts +7 -102
- package/src/constituentMap/constituentMap.ts +5 -6
- package/src/constituentMap/pollingConstituentAccountSubscriber.ts +3 -3
- package/src/constituentMap/webSocketConstituentAccountSubscriber.ts +6 -6
- package/src/decode/customCoder.ts +26 -35
- package/src/decode/user.ts +7 -25
- package/src/dlob/DLOB.ts +12 -0
- package/src/dlob/orderBookLevels.ts +0 -1
- package/src/driftClient.ts +245 -1091
- package/src/driftClientConfig.ts +7 -0
- package/src/events/eventSubscriber.ts +14 -2
- package/src/events/parse.ts +2 -2
- package/src/factory/oracleClient.ts +17 -28
- package/src/idl/drift.json +20850 -15287
- package/src/idl/drift.ts +21406 -0
- package/src/idl/pyth.ts +97 -0
- package/src/idl/token_faucet.json +148 -61
- package/src/idl/token_faucet.ts +197 -0
- package/src/index.ts +13 -12
- package/src/margin/README.md +0 -1
- package/src/marinade/index.ts +2 -2
- package/src/math/amm.ts +2 -48
- package/src/math/funding.ts +8 -3
- package/src/math/margin.ts +12 -67
- package/src/math/market.ts +15 -69
- package/src/math/oracles.ts +14 -30
- package/src/math/position.ts +0 -1
- package/src/math/trade.ts +0 -4
- package/src/memcmp.ts +1 -1
- package/src/openbook/openbookV2Subscriber.ts +1 -1
- package/src/oracles/oracleClientCache.ts +2 -2
- package/src/oracles/prelaunchOracleClient.ts +9 -8
- package/src/oracles/pythLazerClient.ts +10 -12
- package/src/oracles/types.ts +6 -0
- package/src/orderParams.ts +0 -5
- package/src/orderSubscriber/OrderSubscriber.ts +7 -6
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/index.ts +5 -0
- package/src/priorityFee/index.ts +5 -0
- package/src/pyth/index.ts +4 -4
- package/src/pyth/types.ts +1 -1
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +1 -1
- package/src/swift/index.ts +7 -0
- package/src/swift/signedMsgUserAccountSubscriber.ts +7 -4
- package/src/tokenFaucet.ts +8 -4
- package/src/tx/txHandler.ts +12 -0
- package/src/types.ts +16 -20
- package/src/user.ts +66 -144
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/revenueShareEscrowMap.ts +24 -20
- package/src/userMap/userMap.ts +8 -7
- package/src/userMap/userStatsMap.ts +6 -5
- package/src/userStats.ts +5 -0
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +5 -4
- package/tests/amm/test.ts +45 -64
- package/tests/ci/verifyConstants.ts +23 -26
- package/tests/decode/test.ts +2 -4
- package/tests/dlob/helpers.ts +8 -15
- package/tests/user/helpers.ts +0 -2
- package/tests/user/marginCalculations.test.ts +2 -3
- package/tests/user/test.ts +18 -15
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -29
- package/lib/browser/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -23
- package/lib/browser/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/browser/idl/pyth_solana_receiver.json +0 -628
- package/lib/browser/idl/switchboard.json +0 -8354
- package/lib/browser/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/browser/oracles/pythPullClient.d.ts +0 -19
- package/lib/browser/oracles/pythPullClient.js +0 -65
- package/lib/browser/oracles/switchboardClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardClient.js +0 -40
- package/lib/browser/oracles/switchboardOnDemandClient.d.ts +0 -12
- package/lib/browser/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/browser/util/pythOracleUtils.d.ts +0 -2
- package/lib/browser/util/pythOracleUtils.js +0 -15
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts +0 -30
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/pollingHighLeverageModeConfigAccountSubscriber.js +0 -111
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts +0 -24
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.d.ts.map +0 -1
- package/lib/node/accounts/webSocketHighLeverageModeConfigAccountSubscriber.js +0 -69
- package/lib/node/idl/pyth_solana_receiver.json +0 -628
- package/lib/node/idl/switchboard.json +0 -8354
- package/lib/node/idl/switchboard_on_demand_30.json +0 -5849
- package/lib/node/oracles/pythPullClient.d.ts +0 -20
- package/lib/node/oracles/pythPullClient.d.ts.map +0 -1
- package/lib/node/oracles/pythPullClient.js +0 -65
- package/lib/node/oracles/switchboardClient.d.ts +0 -13
- package/lib/node/oracles/switchboardClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardClient.js +0 -40
- package/lib/node/oracles/switchboardOnDemandClient.d.ts +0 -13
- package/lib/node/oracles/switchboardOnDemandClient.d.ts.map +0 -1
- package/lib/node/oracles/switchboardOnDemandClient.js +0 -33
- package/lib/node/util/pythOracleUtils.d.ts +0 -3
- package/lib/node/util/pythOracleUtils.d.ts.map +0 -1
- package/lib/node/util/pythOracleUtils.js +0 -15
- package/src/accounts/pollingHighLeverageModeConfigAccountSubscriber.ts +0 -189
- package/src/accounts/webSocketHighLeverageModeConfigAccountSubscriber.ts +0 -131
- package/src/idl/switchboard.json +0 -8354
- package/src/idl/switchboard_on_demand_30.json +0 -5849
- package/src/oracles/pythPullClient.ts +0 -112
- package/src/oracles/switchboardClient.ts +0 -77
- package/src/oracles/switchboardOnDemandClient.ts +0 -64
- package/src/util/pythOracleUtils.ts +0 -11
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
|
-
import { Idl,
|
|
5
|
-
|
|
6
|
-
import { BorshTypesCoder } from '@coral-xyz/anchor/dist/cjs/coder/borsh/types';
|
|
7
|
-
export declare class CustomBorshCoder<A extends string = string, T extends string = string> implements Coder {
|
|
4
|
+
import { Idl, BorshEventCoder, BorshInstructionCoder } from '@coral-xyz/anchor';
|
|
5
|
+
export declare class CustomBorshCoder<A extends string = string, _T extends string = string> {
|
|
8
6
|
readonly idl: Idl;
|
|
9
7
|
/**
|
|
10
8
|
* Instruction coder.
|
|
@@ -21,13 +19,13 @@ export declare class CustomBorshCoder<A extends string = string, T extends strin
|
|
|
21
19
|
/**
|
|
22
20
|
* Coder for user-defined types.
|
|
23
21
|
*/
|
|
24
|
-
readonly types:
|
|
22
|
+
readonly types: any;
|
|
25
23
|
constructor(idl: Idl);
|
|
26
24
|
}
|
|
27
25
|
/**
|
|
28
26
|
* Custom accounts coder that wraps BorshAccountsCoder to fix encode buffer sizing.
|
|
29
27
|
*/
|
|
30
|
-
export declare class CustomBorshAccountsCoder<A extends string = string>
|
|
28
|
+
export declare class CustomBorshAccountsCoder<A extends string = string> {
|
|
31
29
|
private baseCoder;
|
|
32
30
|
private idl;
|
|
33
31
|
constructor(idl: Idl);
|
|
@@ -36,11 +34,11 @@ export declare class CustomBorshAccountsCoder<A extends string = string> impleme
|
|
|
36
34
|
decodeAny<T = any>(data: Buffer): T;
|
|
37
35
|
decodeUnchecked<T = any>(accountName: A, ix: Buffer): T;
|
|
38
36
|
memcmp(accountName: A, appendData?: Buffer): any;
|
|
39
|
-
size(
|
|
37
|
+
size(accountName: A | string): number;
|
|
40
38
|
/**
|
|
41
39
|
* Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts.
|
|
42
40
|
*
|
|
43
|
-
* @param name The name of the account to
|
|
41
|
+
* @param name The name of the account to get the discriminator of.
|
|
44
42
|
*/
|
|
45
|
-
static accountDiscriminator(
|
|
43
|
+
static accountDiscriminator(_name: string): Buffer;
|
|
46
44
|
}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CustomBorshAccountsCoder = exports.CustomBorshCoder = void 0;
|
|
7
4
|
const buffer_1 = require("buffer");
|
|
8
|
-
const
|
|
9
|
-
const coder_1 = require("@coral-xyz/anchor/dist/cjs/coder");
|
|
10
|
-
const types_1 = require("@coral-xyz/anchor/dist/cjs/coder/borsh/types");
|
|
11
|
-
const discriminator_1 = require("@coral-xyz/anchor/dist/cjs/coder/borsh/discriminator");
|
|
5
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
12
6
|
class CustomBorshCoder {
|
|
13
7
|
constructor(idl) {
|
|
14
|
-
|
|
8
|
+
const baseCoder = new anchor_1.BorshCoder(idl);
|
|
9
|
+
this.instruction = baseCoder.instruction;
|
|
15
10
|
this.accounts = new CustomBorshAccountsCoder(idl);
|
|
16
|
-
this.events =
|
|
17
|
-
this.types =
|
|
11
|
+
this.events = baseCoder.events;
|
|
12
|
+
this.types = baseCoder.types;
|
|
18
13
|
this.idl = idl;
|
|
19
14
|
}
|
|
20
15
|
}
|
|
@@ -24,23 +19,20 @@ exports.CustomBorshCoder = CustomBorshCoder;
|
|
|
24
19
|
*/
|
|
25
20
|
class CustomBorshAccountsCoder {
|
|
26
21
|
constructor(idl) {
|
|
27
|
-
this.baseCoder = new
|
|
22
|
+
this.baseCoder = new anchor_1.BorshAccountsCoder(idl);
|
|
28
23
|
this.idl = idl;
|
|
29
24
|
}
|
|
30
25
|
async encode(accountName, account) {
|
|
31
|
-
var _a;
|
|
32
|
-
const idlAcc = (_a = this.idl.accounts) === null || _a === void 0 ? void 0 : _a.find((acc) => acc.name === accountName);
|
|
33
|
-
if (!idlAcc) {
|
|
34
|
-
throw new Error(`Unknown account not found in idl: ${accountName}`);
|
|
35
|
-
}
|
|
36
|
-
const buffer = buffer_1.Buffer.alloc(this.size(idlAcc)); // fix encode issue - use proper size instead of fixed 1000
|
|
37
26
|
const layout = this.baseCoder['accountLayouts'].get(accountName);
|
|
38
27
|
if (!layout) {
|
|
39
28
|
throw new Error(`Unknown account: ${accountName}`);
|
|
40
29
|
}
|
|
41
|
-
|
|
30
|
+
// Fix: compute proper buffer size instead of the hardcoded 1000 bytes
|
|
31
|
+
const size = this.baseCoder.size(accountName);
|
|
32
|
+
const buffer = buffer_1.Buffer.alloc(Math.max(size, 1000));
|
|
33
|
+
const len = layout.layout.encode(account, buffer);
|
|
42
34
|
const accountData = buffer.slice(0, len);
|
|
43
|
-
const discriminator =
|
|
35
|
+
const discriminator = buffer_1.Buffer.from(layout.discriminator);
|
|
44
36
|
return buffer_1.Buffer.concat([discriminator, accountData]);
|
|
45
37
|
}
|
|
46
38
|
// Delegate all other methods to the base coder
|
|
@@ -56,20 +48,17 @@ class CustomBorshAccountsCoder {
|
|
|
56
48
|
memcmp(accountName, appendData) {
|
|
57
49
|
return this.baseCoder.memcmp(accountName, appendData);
|
|
58
50
|
}
|
|
59
|
-
size(
|
|
60
|
-
return this.baseCoder.size(
|
|
51
|
+
size(accountName) {
|
|
52
|
+
return this.baseCoder.size(accountName);
|
|
61
53
|
}
|
|
62
54
|
/**
|
|
63
55
|
* Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts.
|
|
64
56
|
*
|
|
65
|
-
* @param name The name of the account to
|
|
57
|
+
* @param name The name of the account to get the discriminator of.
|
|
66
58
|
*/
|
|
67
|
-
static accountDiscriminator(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
preserveConsecutiveUppercase: true,
|
|
71
|
-
})}`;
|
|
72
|
-
return (0, discriminator_1.discriminator)(discriminatorPreimage);
|
|
59
|
+
static accountDiscriminator(_name) {
|
|
60
|
+
// Delegate to an instance method since anchor 0.32 uses IDL discriminators
|
|
61
|
+
throw new Error('accountDiscriminator requires an instance; use coder.accountDiscriminator(name)');
|
|
73
62
|
}
|
|
74
63
|
}
|
|
75
64
|
exports.CustomBorshAccountsCoder = CustomBorshAccountsCoder;
|
|
@@ -70,7 +70,7 @@ function decodeUser(buffer) {
|
|
|
70
70
|
const baseAssetAmount = readSignedBigInt64LE(buffer, offset + 8);
|
|
71
71
|
const quoteAssetAmount = readSignedBigInt64LE(buffer, offset + 16);
|
|
72
72
|
const lpShares = readUnsignedBigInt64LE(buffer, offset + 64);
|
|
73
|
-
const isolatedPositionScaledBalance =
|
|
73
|
+
const isolatedPositionScaledBalance = readUnsignedBigInt64LE(buffer, offset + 72);
|
|
74
74
|
const openOrders = buffer.readUInt8(offset + 94);
|
|
75
75
|
const positionFlag = buffer.readUInt8(offset + 95);
|
|
76
76
|
if (baseAssetAmount.eq(numericConstants_1.ZERO) &&
|
|
@@ -98,12 +98,11 @@ function decodeUser(buffer) {
|
|
|
98
98
|
offset += 24;
|
|
99
99
|
const lastQuoteAssetAmountPerLp = readSignedBigInt64LE(buffer, offset);
|
|
100
100
|
offset += 8;
|
|
101
|
-
|
|
102
|
-
offset
|
|
103
|
-
|
|
104
|
-
offset
|
|
105
|
-
|
|
106
|
-
offset += 1;
|
|
101
|
+
offset += 2; // skip padding[u8; 2]
|
|
102
|
+
const maxMarginRatio = buffer.readUInt16LE(offset); // offset+90
|
|
103
|
+
offset += 2;
|
|
104
|
+
const marketIndex = buffer.readUInt16LE(offset); // offset+92
|
|
105
|
+
offset += 4; // advance past marketIndex(2) + openOrders(1) + positionFlag(1)
|
|
107
106
|
perpPositions.push({
|
|
108
107
|
lastCumulativeFundingRate,
|
|
109
108
|
baseAssetAmount,
|
|
@@ -118,7 +117,6 @@ function decodeUser(buffer) {
|
|
|
118
117
|
lastQuoteAssetAmountPerLp,
|
|
119
118
|
marketIndex,
|
|
120
119
|
openOrders,
|
|
121
|
-
perLpBase,
|
|
122
120
|
maxMarginRatio,
|
|
123
121
|
positionFlag,
|
|
124
122
|
isolatedPositionScaledBalance,
|
|
@@ -308,22 +306,7 @@ function decodeUser(buffer) {
|
|
|
308
306
|
offset += 1;
|
|
309
307
|
const hasOpenAuction = buffer.readUInt8(offset) === 1;
|
|
310
308
|
offset += 1;
|
|
311
|
-
|
|
312
|
-
const marginModeNum = buffer.readUInt8(offset);
|
|
313
|
-
if (marginModeNum === 0) {
|
|
314
|
-
marginMode = types_1.MarginMode.DEFAULT;
|
|
315
|
-
}
|
|
316
|
-
else if (marginModeNum === 1) {
|
|
317
|
-
marginMode = types_1.MarginMode.HIGH_LEVERAGE;
|
|
318
|
-
}
|
|
319
|
-
else if (marginModeNum === 2) {
|
|
320
|
-
marginMode = types_1.MarginMode.HIGH_LEVERAGE_MAINTENANCE;
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
console.error(`Detected unknown margin mode: ${marginModeNum}. Please update @drift-labs/sdk for latest IDL.`);
|
|
324
|
-
marginMode = types_1.MarginMode.DEFAULT;
|
|
325
|
-
}
|
|
326
|
-
offset += 1;
|
|
309
|
+
offset += 1; // marginMode (removed)
|
|
327
310
|
const poolId = buffer.readUint8(offset);
|
|
328
311
|
offset += 1;
|
|
329
312
|
offset += 3; // padding
|
|
@@ -356,7 +339,6 @@ function decodeUser(buffer) {
|
|
|
356
339
|
hasOpenOrder,
|
|
357
340
|
openAuctions,
|
|
358
341
|
hasOpenAuction,
|
|
359
|
-
marginMode,
|
|
360
342
|
poolId,
|
|
361
343
|
lastFuelBonusUpdateTs,
|
|
362
344
|
};
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
|
+
/**
|
|
3
|
+
* DLOB — Decentralized Limit Order Book.
|
|
4
|
+
*
|
|
5
|
+
* Maintains an in-memory order book built from on-chain `User` accounts.
|
|
6
|
+
* Used by keeper bots to identify the best maker orders to match against taker fills.
|
|
7
|
+
*
|
|
8
|
+
* Key types:
|
|
9
|
+
* {@link DLOBNode} — a single order node with price/size/user info (DLOBNode.ts)
|
|
10
|
+
* {@link DLOBSubscriber} — subscribes to on-chain accounts and keeps the DLOB live (DLOBSubscriber.ts)
|
|
11
|
+
* {@link NodeList} — sorted linked list of DLOBNodes per side/market (NodeList.ts)
|
|
12
|
+
* `orderBookLevels.ts` — aggregated L2/L3 book level construction for quoting
|
|
13
|
+
*/
|
|
2
14
|
import { NodeList } from './NodeList';
|
|
3
15
|
import { BN } from '@coral-xyz/anchor';
|
|
4
16
|
import { DLOBNode, DLOBNodeType, TriggerOrderNode } from './DLOBNode';
|
package/lib/browser/dlob/DLOB.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DLOB = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* DLOB — Decentralized Limit Order Book.
|
|
6
|
+
*
|
|
7
|
+
* Maintains an in-memory order book built from on-chain `User` accounts.
|
|
8
|
+
* Used by keeper bots to identify the best maker orders to match against taker fills.
|
|
9
|
+
*
|
|
10
|
+
* Key types:
|
|
11
|
+
* {@link DLOBNode} — a single order node with price/size/user info (DLOBNode.ts)
|
|
12
|
+
* {@link DLOBSubscriber} — subscribes to on-chain accounts and keeps the DLOB live (DLOBSubscriber.ts)
|
|
13
|
+
* {@link NodeList} — sorted linked list of DLOBNodes per side/market (NodeList.ts)
|
|
14
|
+
* `orderBookLevels.ts` — aggregated L2/L3 book level construction for quoting
|
|
15
|
+
*/
|
|
4
16
|
const NodeList_1 = require("./NodeList");
|
|
5
17
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
18
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
@@ -111,7 +111,7 @@ function getVammL2Generator({ marketAccount, mmOraclePriceData, numOrders, now =
|
|
|
111
111
|
openBids = numericConstants_1.ZERO;
|
|
112
112
|
if (openAsks.abs().lt(marketAccount.amm.minOrderSize.muln(2)))
|
|
113
113
|
openAsks = numericConstants_1.ZERO;
|
|
114
|
-
const [bidReserves, askReserves] = (0, amm_1.calculateSpreadReserves)(updatedAmm, mmOraclePriceData, now,
|
|
114
|
+
const [bidReserves, askReserves] = (0, amm_1.calculateSpreadReserves)(updatedAmm, mmOraclePriceData, now, latestSlot);
|
|
115
115
|
const numBaseOrders = Math.max(1, numOrders - topOfBookQuoteAmounts.length);
|
|
116
116
|
const commonOpts = {
|
|
117
117
|
numOrders,
|
|
@@ -2,10 +2,23 @@
|
|
|
2
2
|
/// <reference types="bn.js" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
|
+
/**
|
|
6
|
+
* DriftClient — main SDK entry point for all trading and keeper operations.
|
|
7
|
+
*
|
|
8
|
+
* Responsibilities:
|
|
9
|
+
* - Builds and sends all on-chain instructions (place/cancel/fill orders, deposits, withdrawals,
|
|
10
|
+
* settle PnL, update funding rate, liquidations).
|
|
11
|
+
* - Manages the program account subscription lifecycle (markets, oracles, user accounts).
|
|
12
|
+
* - Provides oracle price reads, market config lookups, and PDA derivation helpers.
|
|
13
|
+
*
|
|
14
|
+
* Admin operations (market init, fee updates, oracle config) live in {@link AdminClient} (adminClient.ts).
|
|
15
|
+
* Read-only user account queries (margin, positions, PnL) live in {@link User} (user.ts).
|
|
16
|
+
*
|
|
17
|
+
* Instruction → on-chain handler mapping: see ARCHITECTURE.md § SDK↔Instruction Mapping.
|
|
18
|
+
*/
|
|
5
19
|
import * as anchor from '@coral-xyz/anchor';
|
|
6
|
-
import { AnchorProvider, BN,
|
|
7
|
-
import {
|
|
8
|
-
import { DriftClientMetricsEvents, HighLeverageModeConfig, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, ScaleOrderParams, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, PostOnlyParams, LPPoolAccount, ConstituentAccount, ConstituentTargetBaseAccount, AmmCache } from './types';
|
|
20
|
+
import { AnchorProvider, BN, ProgramAccount } from '@coral-xyz/anchor';
|
|
21
|
+
import { DriftClientMetricsEvents, IWallet, MakerInfo, MappedRecord, MarketType, ModifyOrderPolicy, OpenbookV2FulfillmentConfigAccount, OptionalOrderParams, OracleSource, Order, OrderParams, OrderTriggerCondition, PerpMarketAccount, PerpMarketExtendedInfo, PhoenixV1FulfillmentConfigAccount, PlaceAndTakeOrderSuccessCondition, PositionDirection, ReferrerInfo, ReferrerNameAccount, ScaleOrderParams, SerumV3FulfillmentConfigAccount, SettlePnlMode, SignedTxData, SpotMarketAccount, SpotPosition, StateAccount, SwapReduceOnly, SignedMsgOrderParamsMessage, TxParams, UserAccount, UserStatsAccount, ProtectedMakerModeConfig, SignedMsgOrderParamsDelegateMessage, PostOnlyParams, LPPoolAccount, ConstituentAccount, ConstituentTargetBaseAccount, AmmCache } from './types';
|
|
9
22
|
import { AccountMeta, AddressLookupTableAccount, BlockhashWithExpiryBlockHeight, ConfirmOptions, Connection, Keypair, PublicKey, Signer, Transaction, TransactionInstruction, TransactionSignature, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
|
|
10
23
|
import { TokenFaucet } from './tokenFaucet';
|
|
11
24
|
import { EventEmitter } from 'events';
|
|
@@ -16,20 +29,18 @@ import { MMOraclePriceData, OraclePriceData } from './oracles/types';
|
|
|
16
29
|
import { DriftClientConfig } from './driftClientConfig';
|
|
17
30
|
import { User } from './user';
|
|
18
31
|
import { UserSubscriptionConfig } from './userConfig';
|
|
19
|
-
import { DriftEnv } from './config';
|
|
32
|
+
import { DriftEnv, DriftProgram } from './config';
|
|
20
33
|
import { UserStats } from './userStats';
|
|
21
34
|
import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
22
35
|
import { SwapMode, UnifiedQuoteResponse } from './swap/UnifiedSwapClient';
|
|
23
36
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
24
37
|
import { TxHandler } from './tx/txHandler';
|
|
25
|
-
import { Slothash } from './slot/SlothashSubscriber';
|
|
26
38
|
import { SignedMsgOrderParams } from './types';
|
|
27
39
|
import { TakerInfo } from './types';
|
|
28
40
|
import { ConstituentMap } from './constituentMap/constituentMap';
|
|
29
41
|
import { RevenueShareEscrowMap } from './userMap/revenueShareEscrowMap';
|
|
30
42
|
import { TitanClient } from './titan/titanClient';
|
|
31
43
|
import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
|
|
32
|
-
import { WormholeCoreBridgeSolana, PythSolanaReceiver } from './pyth';
|
|
33
44
|
/**
|
|
34
45
|
* Union type for swap clients (Titan and Jupiter) - Legacy type
|
|
35
46
|
* @deprecated Use UnifiedSwapClient class instead
|
|
@@ -50,7 +61,7 @@ type RemainingAccountParams = {
|
|
|
50
61
|
export declare class DriftClient {
|
|
51
62
|
connection: Connection;
|
|
52
63
|
wallet: IWallet;
|
|
53
|
-
program:
|
|
64
|
+
program: DriftProgram;
|
|
54
65
|
provider: AnchorProvider;
|
|
55
66
|
env: DriftEnv;
|
|
56
67
|
opts?: ConfirmOptions;
|
|
@@ -83,11 +94,6 @@ export declare class DriftClient {
|
|
|
83
94
|
txParams: TxParams;
|
|
84
95
|
enableMetricsEvents?: boolean;
|
|
85
96
|
txHandler: TxHandler;
|
|
86
|
-
receiverProgram?: Program<PythSolanaReceiver>;
|
|
87
|
-
wormholeProgram?: Program<WormholeCoreBridgeSolana>;
|
|
88
|
-
sbOnDemandProgramdId: PublicKey;
|
|
89
|
-
sbOnDemandProgram?: Program30<Idl30>;
|
|
90
|
-
sbProgramFeedConfigs?: Map<string, any>;
|
|
91
97
|
get isSubscribed(): boolean;
|
|
92
98
|
private getPrePlaceOrderIxs;
|
|
93
99
|
set isSubscribed(val: boolean);
|
|
@@ -252,7 +258,7 @@ export declare class DriftClient {
|
|
|
252
258
|
authority?: PublicKey;
|
|
253
259
|
signingAuthority?: PublicKey;
|
|
254
260
|
}): Promise<TransactionInstruction>;
|
|
255
|
-
updateUserPerpPositionCustomMarginRatio(perpMarketIndex: number, marginRatio: number, subAccountId?: number, txParams?: TxParams
|
|
261
|
+
updateUserPerpPositionCustomMarginRatio(perpMarketIndex: number, marginRatio: number, subAccountId?: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
256
262
|
getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
257
263
|
updateUserMarginTradingEnabled(updates: {
|
|
258
264
|
marginTradingEnabled: boolean;
|
|
@@ -268,7 +274,7 @@ export declare class DriftClient {
|
|
|
268
274
|
advancedLp: boolean;
|
|
269
275
|
subAccountId: number;
|
|
270
276
|
}[]): Promise<TransactionSignature>;
|
|
271
|
-
getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<
|
|
277
|
+
getUpdateAdvancedDlpIx(advancedLp: boolean, subAccountId: number): Promise<any>;
|
|
272
278
|
updateUserReduceOnly(updates: {
|
|
273
279
|
reduceOnly: boolean;
|
|
274
280
|
subAccountId: number;
|
|
@@ -290,7 +296,7 @@ export declare class DriftClient {
|
|
|
290
296
|
forceDeleteUser(userAccountPublicKey: PublicKey, userAccount: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
291
297
|
getForceDeleteUserIx(userAccountPublicKey: PublicKey, userAccount: UserAccount): Promise<anchor.web3.TransactionInstruction>;
|
|
292
298
|
deleteSignedMsgUserOrders(txParams?: TxParams): Promise<TransactionSignature>;
|
|
293
|
-
getSignedMsgUserOrdersDeletionIx(authority: PublicKey): Promise<
|
|
299
|
+
getSignedMsgUserOrdersDeletionIx(authority: PublicKey): Promise<any>;
|
|
294
300
|
/**
|
|
295
301
|
* Checks if a SignedMsg User Orders account exists for the given authority.
|
|
296
302
|
* The account pubkey is derived using the program ID and authority as seeds.
|
|
@@ -593,15 +599,13 @@ export declare class DriftClient {
|
|
|
593
599
|
fillPerpOrder(userAccountPublicKey: PublicKey, user: UserAccount, order?: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, txParams?: TxParams, fillerSubAccountId?: number, fillerAuthority?: PublicKey, hasBuilderFee?: boolean): Promise<TransactionSignature>;
|
|
594
600
|
getFillPerpOrderIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, order: Pick<Order, 'marketIndex' | 'orderId'>, makerInfo?: MakerInfo | MakerInfo[], referrerInfo?: ReferrerInfo, fillerSubAccountId?: number, isSignedMsg?: boolean, fillerAuthority?: PublicKey, hasBuilderFee?: boolean): Promise<TransactionInstruction>;
|
|
595
601
|
getRevertFillIx(fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
596
|
-
placeSpotOrder(
|
|
597
|
-
preparePlaceSpotOrderTx(
|
|
598
|
-
|
|
599
|
-
}>;
|
|
600
|
-
getPlaceSpotOrderIx(orderParams: OptionalOrderParams, subAccountId?: number, overrides?: {
|
|
602
|
+
placeSpotOrder(_orderParams: OptionalOrderParams, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
603
|
+
preparePlaceSpotOrderTx(_orderParams: OptionalOrderParams, _txParams?: TxParams, _subAccountId?: number): Promise<void>;
|
|
604
|
+
getPlaceSpotOrderIx(_orderParams: OptionalOrderParams, _subAccountId?: number, _overrides?: {
|
|
601
605
|
authority?: PublicKey;
|
|
602
606
|
}): Promise<TransactionInstruction>;
|
|
603
|
-
fillSpotOrder(
|
|
604
|
-
getFillSpotOrderIx(
|
|
607
|
+
fillSpotOrder(_userAccountPublicKey: PublicKey, _user: UserAccount, _order?: Pick<Order, 'marketIndex' | 'orderId'>, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, _makerInfo?: MakerInfo | MakerInfo[], _referrerInfo?: ReferrerInfo, _txParams?: TxParams): Promise<TransactionSignature>;
|
|
608
|
+
getFillSpotOrderIx(_userAccountPublicKey: PublicKey, _userAccount: UserAccount, _order?: Pick<Order, 'marketIndex' | 'orderId'>, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount, _makerInfo?: MakerInfo | MakerInfo[], _referrerInfo?: ReferrerInfo, _fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
605
609
|
addSpotFulfillmentAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig?: SerumV3FulfillmentConfigAccount | PhoenixV1FulfillmentConfigAccount | OpenbookV2FulfillmentConfigAccount): void;
|
|
606
610
|
addSerumRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: SerumV3FulfillmentConfigAccount): void;
|
|
607
611
|
addPhoenixRemainingAccounts(marketIndex: number, remainingAccounts: AccountMeta[], fulfillmentConfig: PhoenixV1FulfillmentConfigAccount): void;
|
|
@@ -798,13 +802,11 @@ export declare class DriftClient {
|
|
|
798
802
|
takerUserAccount: UserAccount;
|
|
799
803
|
signingAuthority: PublicKey;
|
|
800
804
|
}, orderParams: OptionalOrderParams, referrerInfo?: ReferrerInfo, subAccountId?: number, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>;
|
|
801
|
-
preparePlaceAndTakeSpotOrder(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
placeAndMakeSpotOrder(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, txParams?: TxParams, subAccountId?: number): Promise<TransactionSignature>;
|
|
807
|
-
getPlaceAndMakeSpotOrderIx(orderParams: OptionalOrderParams, takerInfo: TakerInfo, fulfillmentConfig?: SerumV3FulfillmentConfigAccount, referrerInfo?: ReferrerInfo, subAccountId?: number): Promise<TransactionInstruction>;
|
|
805
|
+
preparePlaceAndTakeSpotOrder(_orderParams: OptionalOrderParams, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount, _makerInfo?: MakerInfo, _referrerInfo?: ReferrerInfo, _txParams?: TxParams, _subAccountId?: number): Promise<void>;
|
|
806
|
+
placeAndTakeSpotOrder(_orderParams: OptionalOrderParams, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount, _makerInfo?: MakerInfo, _referrerInfo?: ReferrerInfo, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
807
|
+
getPlaceAndTakeSpotOrderIx(_orderParams: OptionalOrderParams, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount, _makerInfo?: MakerInfo, _referrerInfo?: ReferrerInfo, _subAccountId?: number): Promise<TransactionInstruction>;
|
|
808
|
+
placeAndMakeSpotOrder(_orderParams: OptionalOrderParams, _takerInfo: TakerInfo, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount, _referrerInfo?: ReferrerInfo, _txParams?: TxParams, _subAccountId?: number): Promise<TransactionSignature>;
|
|
809
|
+
getPlaceAndMakeSpotOrderIx(_orderParams: OptionalOrderParams, _takerInfo: TakerInfo, _fulfillmentConfig?: SerumV3FulfillmentConfigAccount, _referrerInfo?: ReferrerInfo, _subAccountId?: number): Promise<TransactionInstruction>;
|
|
808
810
|
/**
|
|
809
811
|
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
810
812
|
*/
|
|
@@ -1118,7 +1120,7 @@ export declare class DriftClient {
|
|
|
1118
1120
|
* @param positionMarketIndex
|
|
1119
1121
|
* @returns : {takerFee: number, makerFee: number} Precision None
|
|
1120
1122
|
*/
|
|
1121
|
-
getMarketFees(marketType: MarketType, marketIndex?: number, user?: User
|
|
1123
|
+
getMarketFees(marketType: MarketType, marketIndex?: number, user?: User): {
|
|
1122
1124
|
takerFee: number;
|
|
1123
1125
|
makerFee: number;
|
|
1124
1126
|
};
|
|
@@ -1132,37 +1134,8 @@ export declare class DriftClient {
|
|
|
1132
1134
|
marketIndex: number;
|
|
1133
1135
|
marketType: MarketType;
|
|
1134
1136
|
} | undefined;
|
|
1135
|
-
getReceiverProgram(): Program<PythSolanaReceiver>;
|
|
1136
|
-
getSwitchboardOnDemandProgram(): Promise<Program30<Idl30>>;
|
|
1137
|
-
postPythPullOracleUpdateAtomic(vaaString: string, feedId: string): Promise<TransactionSignature>;
|
|
1138
|
-
postMultiPythPullOracleUpdatesAtomic(vaaString: string, feedIds: string[]): Promise<TransactionSignature>;
|
|
1139
|
-
getPostPythPullOracleUpdateAtomicIxs(vaaString: string, feedIds: string | string[], numSignatures?: number): Promise<TransactionInstruction[]>;
|
|
1140
|
-
private getSinglePostPythPullOracleAtomicIx;
|
|
1141
|
-
updatePythPullOracle(vaaString: string, feedId: string): Promise<TransactionSignature>;
|
|
1142
|
-
getUpdatePythPullOracleIxs(params: {
|
|
1143
|
-
merklePriceUpdate: {
|
|
1144
|
-
message: Buffer;
|
|
1145
|
-
proof: number[][];
|
|
1146
|
-
};
|
|
1147
|
-
}, feedId: string, encodedVaaAddress: PublicKey): Promise<TransactionInstruction>;
|
|
1148
1137
|
postPythLazerOracleUpdate(feedIds: number[], pythMessageHex: string): Promise<string>;
|
|
1149
1138
|
getPostPythLazerOracleUpdateIxs(feedIds: number[], pythMessageHex: string, precedingIxs?: TransactionInstruction[], overrideCustomIxIndex?: number): Promise<TransactionInstruction[]>;
|
|
1150
|
-
getPostManySwitchboardOnDemandUpdatesAtomicIxs(feeds: PublicKey[], recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionInstruction[] | undefined>;
|
|
1151
|
-
getPostSwitchboardOnDemandUpdateAtomicIx(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionInstruction | undefined>;
|
|
1152
|
-
postSwitchboardOnDemandUpdate(feed: PublicKey, recentSlothash?: Slothash, numSignatures?: number): Promise<TransactionSignature>;
|
|
1153
|
-
private getBuildEncodedVaaIxs;
|
|
1154
|
-
enableUserHighLeverageMode(subAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1155
|
-
getEnableHighLeverageModeIx(subAccountId: number, depositToTradeArgs?: {
|
|
1156
|
-
isMakingNewAccount: boolean;
|
|
1157
|
-
depositMarketIndex: number;
|
|
1158
|
-
orderMarketIndex: number;
|
|
1159
|
-
}, overrides?: {
|
|
1160
|
-
user?: User;
|
|
1161
|
-
signingAuthority?: PublicKey;
|
|
1162
|
-
}): Promise<TransactionInstruction>;
|
|
1163
|
-
disableUserHighLeverageMode(user: PublicKey, userAccount?: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1164
|
-
getDisableHighLeverageModeIx(user: PublicKey, userAccount?: UserAccount, maintenance?: boolean): Promise<TransactionInstruction>;
|
|
1165
|
-
fetchHighLeverageModeConfig(): Promise<HighLeverageModeConfig>;
|
|
1166
1139
|
fetchProtectedMakerModeConfig(): Promise<ProtectedMakerModeConfig>;
|
|
1167
1140
|
updateUserProtectedMakerOrders(subAccountId: number, protectedOrders: boolean, authority?: PublicKey, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1168
1141
|
getUpdateUserProtectedMakerOrdersIx(subAccountId: number, protectedOrders: boolean, authority?: PublicKey): Promise<TransactionInstruction>;
|