@drift-labs/sdk 2.162.0-beta.2 → 2.163.0-beta.9
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 +25708 -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 +25709 -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 +25708 -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
|
@@ -36,125 +36,30 @@ export const WRAPPED_SOL_MINT = new PublicKey(
|
|
|
36
36
|
'So11111111111111111111111111111111111111112'
|
|
37
37
|
);
|
|
38
38
|
|
|
39
|
+
// Reflects what is actually deployed on devnet (per on-chain enumeration of
|
|
40
|
+
// State.numberOfSpotMarkets). Update when devnet adds/changes a spot market.
|
|
39
41
|
export const DevnetSpotMarkets: SpotMarketConfig[] = [
|
|
40
42
|
{
|
|
41
|
-
symbol: '
|
|
43
|
+
symbol: 'dUSDT',
|
|
42
44
|
marketIndex: 0,
|
|
43
45
|
poolId: 0,
|
|
44
|
-
oracle: new PublicKey('
|
|
46
|
+
oracle: new PublicKey('Gkiwe1rmbnAMCAiBiaQWhqfDtb1tAefuQY8uJp2siVs'),
|
|
45
47
|
oracleSource: OracleSource.PYTH_LAZER_STABLE_COIN,
|
|
46
|
-
mint: new PublicKey('
|
|
48
|
+
mint: new PublicKey('8FfvSRKMZRDHrCBy142XMUXrKEkXnxDQ4YmJv7xbAw8Q'),
|
|
47
49
|
precision: new BN(10).pow(SIX),
|
|
48
50
|
precisionExp: SIX,
|
|
49
|
-
pythFeedId:
|
|
50
|
-
'0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
51
|
-
pythLazerId: 7,
|
|
52
51
|
},
|
|
53
52
|
{
|
|
54
53
|
symbol: 'SOL',
|
|
55
54
|
marketIndex: 1,
|
|
56
55
|
poolId: 0,
|
|
57
|
-
oracle: new PublicKey('
|
|
56
|
+
oracle: new PublicKey('57ZE6W8mGWPQokUHjyfTAexvVLK8xuMbWn9HGg6fG7oW'),
|
|
58
57
|
oracleSource: OracleSource.PYTH_LAZER,
|
|
59
|
-
mint:
|
|
58
|
+
mint: WRAPPED_SOL_MINT,
|
|
60
59
|
precision: LAMPORTS_PRECISION,
|
|
61
60
|
precisionExp: LAMPORTS_EXP,
|
|
62
|
-
serumMarket: new PublicKey('8N37SsnTu8RYxtjrV9SStjkkwVhmU8aCWhLvwduAPEKW'),
|
|
63
|
-
phoenixMarket: new PublicKey(
|
|
64
|
-
'78ehDnHgbkFxqXZwdFxa8HK7saX58GymeX2wNGdkqYLp'
|
|
65
|
-
),
|
|
66
|
-
pythFeedId:
|
|
67
|
-
'0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
|
|
68
61
|
pythLazerId: 6,
|
|
69
62
|
},
|
|
70
|
-
{
|
|
71
|
-
symbol: 'BTC',
|
|
72
|
-
marketIndex: 2,
|
|
73
|
-
poolId: 0,
|
|
74
|
-
oracle: new PublicKey('486kr3pmFPfTsS4aZgcsQ7kS4i9rjMsYYZup6HQNSTT4'),
|
|
75
|
-
oracleSource: OracleSource.PYTH_PULL,
|
|
76
|
-
mint: new PublicKey('3BZPwbcqB5kKScF3TEXxwNfx5ipV13kbRVDvfVp5c6fv'),
|
|
77
|
-
precision: new BN(10).pow(SIX),
|
|
78
|
-
precisionExp: SIX,
|
|
79
|
-
serumMarket: new PublicKey('AGsmbVu3MS9u68GEYABWosQQCZwmLcBHu4pWEuBYH7Za'),
|
|
80
|
-
pythFeedId:
|
|
81
|
-
'0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
|
|
82
|
-
pythLazerId: 1,
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
symbol: 'PYUSD',
|
|
86
|
-
marketIndex: 3,
|
|
87
|
-
poolId: 0,
|
|
88
|
-
oracle: new PublicKey('HpMoKp3TCd3QT4MWYUKk2zCBwmhr5Df45fB6wdxYqEeh'),
|
|
89
|
-
oracleSource: OracleSource.PYTH_PULL,
|
|
90
|
-
mint: new PublicKey('GLfF72ZCUnS6N9iDJw8kedHzd6WFVf3VbpwdKKy76FRk'),
|
|
91
|
-
precision: new BN(10).pow(SIX),
|
|
92
|
-
precisionExp: SIX,
|
|
93
|
-
pythFeedId:
|
|
94
|
-
'0xc1da1b73d7f01e7ddd54b3766cf7fcd644395ad14f70aa706ec5384c59e76692',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
symbol: 'Bonk',
|
|
98
|
-
marketIndex: 4,
|
|
99
|
-
poolId: 0,
|
|
100
|
-
oracle: new PublicKey('GojbSnJuPdKDT1ZuHuAM5t9oz6bxTo1xhUKpTua2F72p'),
|
|
101
|
-
oracleSource: OracleSource.PYTH_PULL,
|
|
102
|
-
mint: new PublicKey('7SekVZDmKCCDgTP8m6Hk4CfexFSru9RkwDCczmcwcsP6'),
|
|
103
|
-
precision: new BN(10).pow(FIVE),
|
|
104
|
-
precisionExp: FIVE,
|
|
105
|
-
pythFeedId:
|
|
106
|
-
'0x72b021217ca3fe68922a19aaf990109cb9d84e9ad004b4d2025ad6f529314419',
|
|
107
|
-
pythLazerId: 9,
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
symbol: 'JLP',
|
|
111
|
-
marketIndex: 5,
|
|
112
|
-
poolId: 1,
|
|
113
|
-
oracle: new PublicKey('5Mb11e5rt1Sp6A286B145E4TmgMzsM2UX9nCF2vas5bs'),
|
|
114
|
-
oracleSource: OracleSource.PYTH_PULL,
|
|
115
|
-
mint: new PublicKey('HGe9FejFyhWSx6zdvx2RjynX7rmoEXFiJiLU437NXemZ'),
|
|
116
|
-
precision: new BN(10).pow(SIX),
|
|
117
|
-
precisionExp: SIX,
|
|
118
|
-
pythFeedId:
|
|
119
|
-
'0xc811abc82b4bad1f9bd711a2773ccaa935b03ecef974236942cec5e0eb845a3a',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
symbol: 'USDC',
|
|
123
|
-
marketIndex: 6,
|
|
124
|
-
poolId: 1,
|
|
125
|
-
oracle: new PublicKey('En8hkHLkRe9d9DraYmBTrus518BvmVH448YcvmrFM6Ce'),
|
|
126
|
-
oracleSource: OracleSource.PYTH_STABLE_COIN_PULL,
|
|
127
|
-
mint: new PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
|
|
128
|
-
precision: new BN(10).pow(SIX),
|
|
129
|
-
precisionExp: SIX,
|
|
130
|
-
pythFeedId:
|
|
131
|
-
'0xeaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
132
|
-
pythLazerId: 7,
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
symbol: 'GLXY',
|
|
136
|
-
marketIndex: 7,
|
|
137
|
-
poolId: 2,
|
|
138
|
-
oracle: new PublicKey('4wFrjUQHzRBc6qjVtMDbt28aEVgn6GaNiWR6vEff4KxR'),
|
|
139
|
-
oracleSource: OracleSource.Prelaunch,
|
|
140
|
-
mint: new PublicKey('2vVfXmcWXEaFzp7iaTVnQ4y1gR41S6tJQQMo1S5asJyC'),
|
|
141
|
-
precision: new BN(10).pow(SIX),
|
|
142
|
-
precisionExp: SIX,
|
|
143
|
-
pythFeedId:
|
|
144
|
-
'0x67e031d1723e5c89e4a826d80b2f3b41a91b05ef6122d523b8829a02e0f563aa',
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
symbol: 'GLXY',
|
|
148
|
-
marketIndex: 8,
|
|
149
|
-
poolId: 2,
|
|
150
|
-
oracle: new PublicKey('4wFrjUQHzRBc6qjVtMDbt28aEVgn6GaNiWR6vEff4KxR'),
|
|
151
|
-
oracleSource: OracleSource.Prelaunch,
|
|
152
|
-
mint: new PublicKey('2vVfXmcWXEaFzp7iaTVnQ4y1gR41S6tJQQMo1S5asJyC'),
|
|
153
|
-
precision: new BN(10).pow(SIX),
|
|
154
|
-
precisionExp: SIX,
|
|
155
|
-
pythFeedId:
|
|
156
|
-
'0x67e031d1723e5c89e4a826d80b2f3b41a91b05ef6122d523b8829a02e0f563aa',
|
|
157
|
-
},
|
|
158
63
|
];
|
|
159
64
|
|
|
160
65
|
export const MainnetSpotMarkets: SpotMarketConfig[] = [
|
|
@@ -119,10 +119,9 @@ export class ConstituentMap implements ConstituentMapInterface {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
private decode(name: string, buffer: Buffer): ConstituentAccount {
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
);
|
|
122
|
+
return (
|
|
123
|
+
this.driftClient.program.account as any
|
|
124
|
+
).constituent.coder.accounts.decodeUnchecked(name, buffer);
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
public async sync(): Promise<void> {
|
|
@@ -170,11 +169,11 @@ export class ConstituentMap implements ConstituentMapInterface {
|
|
|
170
169
|
|
|
171
170
|
if (currAccountWithSlot) {
|
|
172
171
|
if (slot >= currAccountWithSlot.slot) {
|
|
173
|
-
const constituentAcc = this.decode('
|
|
172
|
+
const constituentAcc = this.decode('constituent', buffer);
|
|
174
173
|
this.updateConstituentAccount(key, constituentAcc, slot);
|
|
175
174
|
}
|
|
176
175
|
} else {
|
|
177
|
-
const constituentAcc = this.decode('
|
|
176
|
+
const constituentAcc = this.decode('constituent', buffer);
|
|
178
177
|
this.updateConstituentAccount(key, constituentAcc, slot);
|
|
179
178
|
}
|
|
180
179
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ConstituentAccountEvents,
|
|
4
4
|
ConstituentAccountSubscriber,
|
|
5
5
|
} from '../accounts/types';
|
|
6
|
-
import {
|
|
6
|
+
import { DriftProgram } from '../config';
|
|
7
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import { Commitment, MemcmpFilter } from '@solana/web3.js';
|
|
@@ -13,7 +13,7 @@ export class PollingConstituentAccountSubscriber
|
|
|
13
13
|
implements ConstituentAccountSubscriber
|
|
14
14
|
{
|
|
15
15
|
isSubscribed: boolean;
|
|
16
|
-
program:
|
|
16
|
+
program: DriftProgram;
|
|
17
17
|
frequency: number;
|
|
18
18
|
commitment?: Commitment;
|
|
19
19
|
additionalFilters?: MemcmpFilter[];
|
|
@@ -24,7 +24,7 @@ export class PollingConstituentAccountSubscriber
|
|
|
24
24
|
|
|
25
25
|
public constructor(
|
|
26
26
|
constituentMap: ConstituentMap,
|
|
27
|
-
program:
|
|
27
|
+
program: DriftProgram,
|
|
28
28
|
frequency: number,
|
|
29
29
|
commitment?: Commitment,
|
|
30
30
|
additionalFilters?: MemcmpFilter[]
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ConstituentAccountEvents,
|
|
4
4
|
ConstituentAccountSubscriber,
|
|
5
5
|
} from '../accounts/types';
|
|
6
|
-
import {
|
|
6
|
+
import { DriftProgram } from '../config';
|
|
7
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import { Commitment, Context, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
@@ -18,7 +18,7 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
18
18
|
isSubscribed: boolean;
|
|
19
19
|
resubTimeoutMs?: number;
|
|
20
20
|
commitment?: Commitment;
|
|
21
|
-
program:
|
|
21
|
+
program: DriftProgram;
|
|
22
22
|
eventEmitter: StrictEventEmitter<EventEmitter, ConstituentAccountEvents>;
|
|
23
23
|
|
|
24
24
|
constituentDataAccountSubscriber: WebSocketProgramAccountSubscriber<ConstituentAccount>;
|
|
@@ -27,7 +27,7 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
27
27
|
|
|
28
28
|
public constructor(
|
|
29
29
|
constituentMap: ConstituentMap,
|
|
30
|
-
program:
|
|
30
|
+
program: DriftProgram,
|
|
31
31
|
resubTimeoutMs?: number,
|
|
32
32
|
commitment?: Commitment,
|
|
33
33
|
additionalFilters?: MemcmpFilter[]
|
|
@@ -48,10 +48,10 @@ export class WebSocketConstituentAccountSubscriber
|
|
|
48
48
|
this.constituentDataAccountSubscriber =
|
|
49
49
|
new WebSocketProgramAccountSubscriber<ConstituentAccount>(
|
|
50
50
|
'LpPoolConstituent',
|
|
51
|
-
'
|
|
51
|
+
'constituent',
|
|
52
52
|
this.program,
|
|
53
|
-
this.program.account.constituent.coder.accounts.decode.bind(
|
|
54
|
-
this.program.account.constituent.coder.accounts
|
|
53
|
+
(this.program.account as any).constituent.coder.accounts.decode.bind(
|
|
54
|
+
(this.program.account as any).constituent.coder.accounts
|
|
55
55
|
),
|
|
56
56
|
{
|
|
57
57
|
filters: [getConstituentFilter(), ...(this.additionalFilters || [])],
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
-
import camelcase from 'camelcase';
|
|
3
|
-
import { Idl, IdlTypeDef } from '@coral-xyz/anchor/dist/cjs/idl';
|
|
4
2
|
import {
|
|
5
|
-
|
|
3
|
+
Idl,
|
|
6
4
|
BorshAccountsCoder,
|
|
7
5
|
BorshEventCoder,
|
|
8
6
|
BorshInstructionCoder,
|
|
9
|
-
|
|
10
|
-
} from '@coral-xyz/anchor
|
|
11
|
-
import { BorshTypesCoder } from '@coral-xyz/anchor/dist/cjs/coder/borsh/types';
|
|
12
|
-
import { discriminator } from '@coral-xyz/anchor/dist/cjs/coder/borsh/discriminator';
|
|
7
|
+
BorshCoder,
|
|
8
|
+
} from '@coral-xyz/anchor';
|
|
13
9
|
|
|
14
10
|
export class CustomBorshCoder<
|
|
15
11
|
A extends string = string,
|
|
16
|
-
|
|
17
|
-
>
|
|
18
|
-
{
|
|
12
|
+
_T extends string = string,
|
|
13
|
+
> {
|
|
19
14
|
readonly idl: Idl;
|
|
20
15
|
|
|
21
16
|
/**
|
|
@@ -36,13 +31,14 @@ export class CustomBorshCoder<
|
|
|
36
31
|
/**
|
|
37
32
|
* Coder for user-defined types.
|
|
38
33
|
*/
|
|
39
|
-
readonly types:
|
|
34
|
+
readonly types: any;
|
|
40
35
|
|
|
41
36
|
constructor(idl: Idl) {
|
|
42
|
-
|
|
37
|
+
const baseCoder = new BorshCoder(idl);
|
|
38
|
+
this.instruction = baseCoder.instruction as BorshInstructionCoder;
|
|
43
39
|
this.accounts = new CustomBorshAccountsCoder(idl);
|
|
44
|
-
this.events =
|
|
45
|
-
this.types =
|
|
40
|
+
this.events = baseCoder.events as BorshEventCoder;
|
|
41
|
+
this.types = baseCoder.types;
|
|
46
42
|
this.idl = idl;
|
|
47
43
|
}
|
|
48
44
|
}
|
|
@@ -50,9 +46,7 @@ export class CustomBorshCoder<
|
|
|
50
46
|
/**
|
|
51
47
|
* Custom accounts coder that wraps BorshAccountsCoder to fix encode buffer sizing.
|
|
52
48
|
*/
|
|
53
|
-
export class CustomBorshAccountsCoder<A extends string = string>
|
|
54
|
-
implements AccountsCoder
|
|
55
|
-
{
|
|
49
|
+
export class CustomBorshAccountsCoder<A extends string = string> {
|
|
56
50
|
private baseCoder: BorshAccountsCoder<A>;
|
|
57
51
|
private idl: Idl;
|
|
58
52
|
|
|
@@ -62,19 +56,17 @@ export class CustomBorshAccountsCoder<A extends string = string>
|
|
|
62
56
|
}
|
|
63
57
|
|
|
64
58
|
public async encode<T = any>(accountName: A, account: T): Promise<Buffer> {
|
|
65
|
-
const
|
|
66
|
-
if (!idlAcc) {
|
|
67
|
-
throw new Error(`Unknown account not found in idl: ${accountName}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const buffer = Buffer.alloc(this.size(idlAcc)); // fix encode issue - use proper size instead of fixed 1000
|
|
71
|
-
const layout = this.baseCoder['accountLayouts'].get(accountName);
|
|
59
|
+
const layout = (this.baseCoder as any)['accountLayouts'].get(accountName);
|
|
72
60
|
if (!layout) {
|
|
73
61
|
throw new Error(`Unknown account: ${accountName}`);
|
|
74
62
|
}
|
|
75
|
-
|
|
63
|
+
|
|
64
|
+
// Fix: compute proper buffer size instead of the hardcoded 1000 bytes
|
|
65
|
+
const size = this.baseCoder.size(accountName);
|
|
66
|
+
const buffer = Buffer.alloc(Math.max(size, 1000));
|
|
67
|
+
const len = layout.layout.encode(account, buffer);
|
|
76
68
|
const accountData = buffer.slice(0, len);
|
|
77
|
-
const discriminator =
|
|
69
|
+
const discriminator = Buffer.from(layout.discriminator);
|
|
78
70
|
return Buffer.concat([discriminator, accountData]);
|
|
79
71
|
}
|
|
80
72
|
|
|
@@ -95,20 +87,19 @@ export class CustomBorshAccountsCoder<A extends string = string>
|
|
|
95
87
|
return this.baseCoder.memcmp(accountName, appendData);
|
|
96
88
|
}
|
|
97
89
|
|
|
98
|
-
public size(
|
|
99
|
-
return this.baseCoder.size(
|
|
90
|
+
public size(accountName: A | string): number {
|
|
91
|
+
return this.baseCoder.size(accountName as A);
|
|
100
92
|
}
|
|
101
93
|
|
|
102
94
|
/**
|
|
103
95
|
* Calculates and returns a unique 8 byte discriminator prepended to all anchor accounts.
|
|
104
96
|
*
|
|
105
|
-
* @param name The name of the account to
|
|
97
|
+
* @param name The name of the account to get the discriminator of.
|
|
106
98
|
*/
|
|
107
|
-
public static accountDiscriminator(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return discriminator(discriminatorPreimage);
|
|
99
|
+
public static accountDiscriminator(_name: string): Buffer {
|
|
100
|
+
// Delegate to an instance method since anchor 0.32 uses IDL discriminators
|
|
101
|
+
throw new Error(
|
|
102
|
+
'accountDiscriminator requires an instance; use coder.accountDiscriminator(name)'
|
|
103
|
+
);
|
|
113
104
|
}
|
|
114
105
|
}
|
package/src/decode/user.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BN } from '@coral-xyz/anchor';
|
|
2
2
|
import {
|
|
3
|
-
MarginMode,
|
|
4
3
|
MarketType,
|
|
5
4
|
Order,
|
|
6
5
|
OrderStatus,
|
|
@@ -84,7 +83,7 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
84
83
|
const baseAssetAmount = readSignedBigInt64LE(buffer, offset + 8);
|
|
85
84
|
const quoteAssetAmount = readSignedBigInt64LE(buffer, offset + 16);
|
|
86
85
|
const lpShares = readUnsignedBigInt64LE(buffer, offset + 64);
|
|
87
|
-
const isolatedPositionScaledBalance =
|
|
86
|
+
const isolatedPositionScaledBalance = readUnsignedBigInt64LE(
|
|
88
87
|
buffer,
|
|
89
88
|
offset + 72
|
|
90
89
|
);
|
|
@@ -121,12 +120,11 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
121
120
|
offset += 24;
|
|
122
121
|
const lastQuoteAssetAmountPerLp = readSignedBigInt64LE(buffer, offset);
|
|
123
122
|
offset += 8;
|
|
124
|
-
|
|
125
|
-
offset
|
|
126
|
-
|
|
127
|
-
offset
|
|
128
|
-
|
|
129
|
-
offset += 1;
|
|
123
|
+
offset += 2; // skip padding[u8; 2]
|
|
124
|
+
const maxMarginRatio = buffer.readUInt16LE(offset); // offset+90
|
|
125
|
+
offset += 2;
|
|
126
|
+
const marketIndex = buffer.readUInt16LE(offset); // offset+92
|
|
127
|
+
offset += 4; // advance past marketIndex(2) + openOrders(1) + positionFlag(1)
|
|
130
128
|
perpPositions.push({
|
|
131
129
|
lastCumulativeFundingRate,
|
|
132
130
|
baseAssetAmount,
|
|
@@ -141,7 +139,6 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
141
139
|
lastQuoteAssetAmountPerLp,
|
|
142
140
|
marketIndex,
|
|
143
141
|
openOrders,
|
|
144
|
-
perLpBase,
|
|
145
142
|
maxMarginRatio,
|
|
146
143
|
positionFlag,
|
|
147
144
|
isolatedPositionScaledBalance,
|
|
@@ -344,21 +341,7 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
344
341
|
const hasOpenAuction = buffer.readUInt8(offset) === 1;
|
|
345
342
|
offset += 1;
|
|
346
343
|
|
|
347
|
-
|
|
348
|
-
const marginModeNum = buffer.readUInt8(offset);
|
|
349
|
-
if (marginModeNum === 0) {
|
|
350
|
-
marginMode = MarginMode.DEFAULT;
|
|
351
|
-
} else if (marginModeNum === 1) {
|
|
352
|
-
marginMode = MarginMode.HIGH_LEVERAGE;
|
|
353
|
-
} else if (marginModeNum === 2) {
|
|
354
|
-
marginMode = MarginMode.HIGH_LEVERAGE_MAINTENANCE;
|
|
355
|
-
} else {
|
|
356
|
-
console.error(
|
|
357
|
-
`Detected unknown margin mode: ${marginModeNum}. Please update @drift-labs/sdk for latest IDL.`
|
|
358
|
-
);
|
|
359
|
-
marginMode = MarginMode.DEFAULT;
|
|
360
|
-
}
|
|
361
|
-
offset += 1;
|
|
344
|
+
offset += 1; // marginMode (removed)
|
|
362
345
|
|
|
363
346
|
const poolId = buffer.readUint8(offset);
|
|
364
347
|
offset += 1;
|
|
@@ -393,7 +376,6 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
393
376
|
hasOpenOrder,
|
|
394
377
|
openAuctions,
|
|
395
378
|
hasOpenAuction,
|
|
396
|
-
marginMode,
|
|
397
379
|
poolId,
|
|
398
380
|
lastFuelBonusUpdateTs,
|
|
399
381
|
};
|
package/src/dlob/DLOB.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DLOB — Decentralized Limit Order Book.
|
|
3
|
+
*
|
|
4
|
+
* Maintains an in-memory order book built from on-chain `User` accounts.
|
|
5
|
+
* Used by keeper bots to identify the best maker orders to match against taker fills.
|
|
6
|
+
*
|
|
7
|
+
* Key types:
|
|
8
|
+
* {@link DLOBNode} — a single order node with price/size/user info (DLOBNode.ts)
|
|
9
|
+
* {@link DLOBSubscriber} — subscribes to on-chain accounts and keeps the DLOB live (DLOBSubscriber.ts)
|
|
10
|
+
* {@link NodeList} — sorted linked list of DLOBNodes per side/market (NodeList.ts)
|
|
11
|
+
* `orderBookLevels.ts` — aggregated L2/L3 book level construction for quoting
|
|
12
|
+
*/
|
|
1
13
|
import { getOrderSignature, NodeList } from './NodeList';
|
|
2
14
|
import { BN } from '@coral-xyz/anchor';
|
|
3
15
|
import {
|