@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
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="bn.js" />
|
|
4
|
-
import { Connection, PublicKey } from '@solana/web3.js';
|
|
5
|
-
import { OracleClient, OraclePriceData } from './types';
|
|
6
|
-
import { BN, Program } from '@coral-xyz/anchor';
|
|
7
|
-
import { PythSolanaReceiver as PythSolanaReceiverProgram } from '../pyth';
|
|
8
|
-
import { PriceUpdateAccount } from '../pyth';
|
|
9
|
-
export declare class PythPullClient implements OracleClient {
|
|
10
|
-
private connection;
|
|
11
|
-
private multiple;
|
|
12
|
-
private stableCoin;
|
|
13
|
-
readonly receiver: Program<PythSolanaReceiverProgram>;
|
|
14
|
-
readonly decodeFunc: (name: string, data: Buffer) => PriceUpdateAccount;
|
|
15
|
-
constructor(connection: Connection, multiple?: BN, stableCoin?: boolean);
|
|
16
|
-
getOraclePriceData(pricePublicKey: PublicKey): Promise<OraclePriceData>;
|
|
17
|
-
getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData;
|
|
18
|
-
}
|
|
19
|
-
export declare function convertPythPrice(price: BN, exponent: number, multiple: BN): BN;
|
|
20
|
-
//# sourceMappingURL=pythPullClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pythPullClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/pythPullClient.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,UAAU,EAAW,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAkB,EAAE,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAShE,OAAO,EAAE,kBAAkB,IAAI,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAG1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,cAAe,YAAW,YAAY;IAClD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,UAAU,CAAU;IAC5B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACtD,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,kBAAkB,CAAC;gBAGvE,UAAU,EAAE,UAAU,EACtB,QAAQ,KAAM,EACd,UAAU,UAAQ;IAwBN,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAmCpE;AAED,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,EAAE,EACT,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,EAAE,GACV,EAAE,CAIJ"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.convertPythPrice = exports.PythPullClient = void 0;
|
|
7
|
-
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
10
|
-
const pyth_solana_receiver_json_1 = __importDefault(require("../idl/pyth_solana_receiver.json"));
|
|
11
|
-
const config_1 = require("../config");
|
|
12
|
-
const wallet_1 = require("../wallet");
|
|
13
|
-
class PythPullClient {
|
|
14
|
-
constructor(connection, multiple = numericConstants_1.ONE, stableCoin = false) {
|
|
15
|
-
this.connection = connection;
|
|
16
|
-
this.multiple = multiple;
|
|
17
|
-
this.stableCoin = stableCoin;
|
|
18
|
-
const provider = new anchor_1.AnchorProvider(this.connection,
|
|
19
|
-
//@ts-ignore
|
|
20
|
-
new wallet_1.Wallet(new web3_js_1.Keypair()), {
|
|
21
|
-
commitment: connection.commitment,
|
|
22
|
-
});
|
|
23
|
-
this.receiver = new anchor_1.Program(pyth_solana_receiver_json_1.default, config_1.DRIFT_ORACLE_RECEIVER_ID, provider);
|
|
24
|
-
this.decodeFunc =
|
|
25
|
-
this.receiver.account.priceUpdateV2.coder.accounts.decodeUnchecked.bind(this.receiver.account.priceUpdateV2.coder.accounts);
|
|
26
|
-
}
|
|
27
|
-
async getOraclePriceData(pricePublicKey) {
|
|
28
|
-
const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
|
|
29
|
-
return this.getOraclePriceDataFromBuffer(accountInfo.data);
|
|
30
|
-
}
|
|
31
|
-
getOraclePriceDataFromBuffer(buffer) {
|
|
32
|
-
const message = this.decodeFunc('priceUpdateV2', buffer);
|
|
33
|
-
const priceData = message.priceMessage;
|
|
34
|
-
const confidence = convertPythPrice(priceData.conf, priceData.exponent, this.multiple);
|
|
35
|
-
let price = convertPythPrice(priceData.price, priceData.exponent, this.multiple);
|
|
36
|
-
if (this.stableCoin) {
|
|
37
|
-
price = getStableCoinPrice(price, confidence);
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
price,
|
|
41
|
-
slot: message.postedSlot,
|
|
42
|
-
confidence,
|
|
43
|
-
twap: convertPythPrice(priceData.price, priceData.exponent, this.multiple),
|
|
44
|
-
twapConfidence: convertPythPrice(priceData.price, priceData.exponent, this.multiple),
|
|
45
|
-
hasSufficientNumberOfDataPoints: true,
|
|
46
|
-
sequenceId: priceData.publishTime,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
exports.PythPullClient = PythPullClient;
|
|
51
|
-
function convertPythPrice(price, exponent, multiple) {
|
|
52
|
-
exponent = Math.abs(exponent);
|
|
53
|
-
const pythPrecision = numericConstants_1.TEN.pow(new anchor_1.BN(exponent).abs()).div(multiple);
|
|
54
|
-
return price.mul(numericConstants_1.PRICE_PRECISION).div(pythPrecision);
|
|
55
|
-
}
|
|
56
|
-
exports.convertPythPrice = convertPythPrice;
|
|
57
|
-
const fiveBPS = new anchor_1.BN(500);
|
|
58
|
-
function getStableCoinPrice(price, confidence) {
|
|
59
|
-
if (price.sub(numericConstants_1.QUOTE_PRECISION).abs().lt(anchor_1.BN.min(confidence, fiveBPS))) {
|
|
60
|
-
return numericConstants_1.QUOTE_PRECISION;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
return price;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { OracleClient, OraclePriceData } from './types';
|
|
5
|
-
import { BorshAccountsCoder } from '@coral-xyz/anchor';
|
|
6
|
-
export declare class SwitchboardClient implements OracleClient {
|
|
7
|
-
connection: Connection;
|
|
8
|
-
coder: BorshAccountsCoder;
|
|
9
|
-
constructor(connection: Connection);
|
|
10
|
-
getOraclePriceData(pricePublicKey: PublicKey): Promise<OraclePriceData>;
|
|
11
|
-
getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=switchboardClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchboardClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/switchboardClient.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAW,MAAM,mBAAmB,CAAC;AAiBhE,qBAAa,iBAAkB,YAAW,YAAY;IACrD,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,kBAAkB,CAAC;gBAEP,UAAU,EAAE,UAAU;IAK5B,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CA6BpE"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SwitchboardClient = void 0;
|
|
7
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
8
|
-
const switchboard_json_1 = __importDefault(require("../idl/switchboard.json"));
|
|
9
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
10
|
-
class SwitchboardClient {
|
|
11
|
-
constructor(connection) {
|
|
12
|
-
this.connection = connection;
|
|
13
|
-
this.coder = new anchor_1.BorshAccountsCoder(switchboard_json_1.default);
|
|
14
|
-
}
|
|
15
|
-
async getOraclePriceData(pricePublicKey) {
|
|
16
|
-
const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
|
|
17
|
-
return this.getOraclePriceDataFromBuffer(accountInfo.data);
|
|
18
|
-
}
|
|
19
|
-
getOraclePriceDataFromBuffer(buffer) {
|
|
20
|
-
const aggregatorAccountData = this.coder.decodeUnchecked('AggregatorAccountData', buffer);
|
|
21
|
-
const price = convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound.result);
|
|
22
|
-
const confidence = anchor_1.BN.max(convertSwitchboardDecimal(aggregatorAccountData.latestConfirmedRound.stdDeviation), price.divn(1000));
|
|
23
|
-
const hasSufficientNumberOfDataPoints = aggregatorAccountData.latestConfirmedRound.numSuccess >=
|
|
24
|
-
aggregatorAccountData.minOracleResults;
|
|
25
|
-
const slot = aggregatorAccountData.latestConfirmedRound.roundOpenSlot;
|
|
26
|
-
return {
|
|
27
|
-
price,
|
|
28
|
-
slot,
|
|
29
|
-
confidence,
|
|
30
|
-
hasSufficientNumberOfDataPoints,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.SwitchboardClient = SwitchboardClient;
|
|
35
|
-
function convertSwitchboardDecimal(switchboardDecimal) {
|
|
36
|
-
const switchboardPrecision = numericConstants_1.TEN.pow(new anchor_1.BN(switchboardDecimal.scale));
|
|
37
|
-
return switchboardDecimal.mantissa
|
|
38
|
-
.mul(numericConstants_1.PRICE_PRECISION)
|
|
39
|
-
.div(switchboardPrecision);
|
|
40
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Connection, PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { OracleClient, OraclePriceData } from './types';
|
|
5
|
-
import { BorshAccountsCoder as BorshAccountsCoder30 } from '@coral-xyz/anchor-30';
|
|
6
|
-
export declare class SwitchboardOnDemandClient implements OracleClient {
|
|
7
|
-
connection: Connection;
|
|
8
|
-
coder: BorshAccountsCoder30;
|
|
9
|
-
constructor(connection: Connection);
|
|
10
|
-
getOraclePriceData(pricePublicKey: PublicKey): Promise<OraclePriceData>;
|
|
11
|
-
getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=switchboardOnDemandClient.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"switchboardOnDemandClient.d.ts","sourceRoot":"","sources":["../../../src/oracles/switchboardOnDemandClient.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAIxD,OAAO,EACN,kBAAkB,IAAI,oBAAoB,EAE1C,MAAM,sBAAsB,CAAC;AAsB9B,qBAAa,yBAA0B,YAAW,YAAY;IAC7D,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,EAAE,oBAAoB,CAAC;gBAET,UAAU,EAAE,UAAU;IAK5B,kBAAkB,CAC9B,cAAc,EAAE,SAAS,GACvB,OAAO,CAAC,eAAe,CAAC;IAKpB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;CAiBpE"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SwitchboardOnDemandClient = void 0;
|
|
7
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
8
|
-
const switchboard_on_demand_30_json_1 = __importDefault(require("../idl/switchboard_on_demand_30.json"));
|
|
9
|
-
const numericConstants_1 = require("../constants/numericConstants");
|
|
10
|
-
const anchor_30_1 = require("@coral-xyz/anchor-30");
|
|
11
|
-
const SB_PRECISION_EXP = new anchor_1.BN(18);
|
|
12
|
-
const SB_PRECISION = new anchor_1.BN(10).pow(SB_PRECISION_EXP.sub(numericConstants_1.PRICE_PRECISION_EXP));
|
|
13
|
-
class SwitchboardOnDemandClient {
|
|
14
|
-
constructor(connection) {
|
|
15
|
-
this.connection = connection;
|
|
16
|
-
this.coder = new anchor_30_1.BorshAccountsCoder(switchboard_on_demand_30_json_1.default);
|
|
17
|
-
}
|
|
18
|
-
async getOraclePriceData(pricePublicKey) {
|
|
19
|
-
const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
|
|
20
|
-
return this.getOraclePriceDataFromBuffer(accountInfo.data);
|
|
21
|
-
}
|
|
22
|
-
getOraclePriceDataFromBuffer(buffer) {
|
|
23
|
-
const pullFeedAccountData = this.coder.decodeUnchecked('PullFeedAccountData', buffer);
|
|
24
|
-
const landedAt = pullFeedAccountData.submissions.reduce((max, s) => anchor_1.BN.max(max, s.landed_at), new anchor_1.BN(0));
|
|
25
|
-
return {
|
|
26
|
-
price: pullFeedAccountData.result.value.div(SB_PRECISION),
|
|
27
|
-
slot: landedAt,
|
|
28
|
-
confidence: pullFeedAccountData.result.range.div(SB_PRECISION),
|
|
29
|
-
hasSufficientNumberOfDataPoints: true,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.SwitchboardOnDemandClient = SwitchboardOnDemandClient;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pythOracleUtils.d.ts","sourceRoot":"","sources":["../../../src/util/pythOracleUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAG9D"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFeedIdUint8Array = exports.trimFeedId = void 0;
|
|
4
|
-
function trimFeedId(feedId) {
|
|
5
|
-
if (feedId.startsWith('0x')) {
|
|
6
|
-
return feedId.slice(2);
|
|
7
|
-
}
|
|
8
|
-
return feedId;
|
|
9
|
-
}
|
|
10
|
-
exports.trimFeedId = trimFeedId;
|
|
11
|
-
function getFeedIdUint8Array(feedId) {
|
|
12
|
-
const trimmedFeedId = trimFeedId(feedId);
|
|
13
|
-
return Uint8Array.from(Buffer.from(trimmedFeedId, 'hex'));
|
|
14
|
-
}
|
|
15
|
-
exports.getFeedIdUint8Array = getFeedIdUint8Array;
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataAndSlot,
|
|
3
|
-
NotSubscribedError,
|
|
4
|
-
HighLeverageModeConfigAccountEvents,
|
|
5
|
-
HighLeverageModeConfigAccountSubscriber,
|
|
6
|
-
} from './types';
|
|
7
|
-
import { Program } from '@coral-xyz/anchor';
|
|
8
|
-
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
|
-
import { EventEmitter } from 'events';
|
|
10
|
-
import { PublicKey } from '@solana/web3.js';
|
|
11
|
-
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
12
|
-
import { HighLeverageModeConfig } from '../types';
|
|
13
|
-
|
|
14
|
-
export class PollingHighLeverageModeConfigAccountSubscriber
|
|
15
|
-
implements HighLeverageModeConfigAccountSubscriber
|
|
16
|
-
{
|
|
17
|
-
isSubscribed: boolean;
|
|
18
|
-
program: Program;
|
|
19
|
-
eventEmitter: StrictEventEmitter<
|
|
20
|
-
EventEmitter,
|
|
21
|
-
HighLeverageModeConfigAccountEvents
|
|
22
|
-
>;
|
|
23
|
-
highLeverageModeConfigAccountPublicKey: PublicKey;
|
|
24
|
-
|
|
25
|
-
accountLoader: BulkAccountLoader;
|
|
26
|
-
callbackId?: string;
|
|
27
|
-
errorCallbackId?: string;
|
|
28
|
-
|
|
29
|
-
highLeverageModeConfigAccountAndSlot?: DataAndSlot<HighLeverageModeConfig>;
|
|
30
|
-
|
|
31
|
-
public constructor(
|
|
32
|
-
program: Program,
|
|
33
|
-
publicKey: PublicKey,
|
|
34
|
-
accountLoader: BulkAccountLoader
|
|
35
|
-
) {
|
|
36
|
-
this.isSubscribed = false;
|
|
37
|
-
this.program = program;
|
|
38
|
-
this.highLeverageModeConfigAccountPublicKey = publicKey;
|
|
39
|
-
this.accountLoader = accountLoader;
|
|
40
|
-
this.eventEmitter = new EventEmitter();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async subscribe(
|
|
44
|
-
highLeverageModeConfig?: HighLeverageModeConfig
|
|
45
|
-
): Promise<boolean> {
|
|
46
|
-
if (this.isSubscribed) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (highLeverageModeConfig) {
|
|
51
|
-
this.highLeverageModeConfigAccountAndSlot = {
|
|
52
|
-
data: highLeverageModeConfig,
|
|
53
|
-
slot: undefined,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await this.addToAccountLoader();
|
|
58
|
-
|
|
59
|
-
await this.fetchIfUnloaded();
|
|
60
|
-
|
|
61
|
-
if (this.doesAccountExist()) {
|
|
62
|
-
this.eventEmitter.emit('update');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this.isSubscribed = true;
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async addToAccountLoader(): Promise<void> {
|
|
70
|
-
if (this.callbackId) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.callbackId = await this.accountLoader.addAccount(
|
|
75
|
-
this.highLeverageModeConfigAccountPublicKey,
|
|
76
|
-
(buffer, slot: number) => {
|
|
77
|
-
if (!buffer) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
this.highLeverageModeConfigAccountAndSlot &&
|
|
83
|
-
this.highLeverageModeConfigAccountAndSlot.slot > slot
|
|
84
|
-
) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const account = this.program.account.user.coder.accounts.decode(
|
|
89
|
-
'HighLeverageModeConfig',
|
|
90
|
-
buffer
|
|
91
|
-
);
|
|
92
|
-
this.highLeverageModeConfigAccountAndSlot = { data: account, slot };
|
|
93
|
-
this.eventEmitter.emit('highLeverageModeConfigAccountUpdate', account);
|
|
94
|
-
this.eventEmitter.emit('update');
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
|
|
99
|
-
this.eventEmitter.emit('error', error);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async fetchIfUnloaded(): Promise<void> {
|
|
104
|
-
if (this.highLeverageModeConfigAccountAndSlot === undefined) {
|
|
105
|
-
await this.fetch();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async fetch(): Promise<void> {
|
|
110
|
-
try {
|
|
111
|
-
const dataAndContext =
|
|
112
|
-
await this.program.account.highLeverageModeConfig.fetchAndContext(
|
|
113
|
-
this.highLeverageModeConfigAccountPublicKey,
|
|
114
|
-
this.accountLoader.commitment
|
|
115
|
-
);
|
|
116
|
-
if (
|
|
117
|
-
dataAndContext.context.slot >
|
|
118
|
-
(this.highLeverageModeConfigAccountAndSlot?.slot ?? 0)
|
|
119
|
-
) {
|
|
120
|
-
this.highLeverageModeConfigAccountAndSlot = {
|
|
121
|
-
data: dataAndContext.data as HighLeverageModeConfig,
|
|
122
|
-
slot: dataAndContext.context.slot,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
} catch (e) {
|
|
126
|
-
console.log(
|
|
127
|
-
`PollingHighLeverageModeConfigAccountSubscriber.fetch() HighLeverageModeConfig does not exist: ${e.message}`
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
doesAccountExist(): boolean {
|
|
133
|
-
return this.highLeverageModeConfigAccountAndSlot !== undefined;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async unsubscribe(): Promise<void> {
|
|
137
|
-
if (!this.isSubscribed) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.accountLoader.removeAccount(
|
|
142
|
-
this.highLeverageModeConfigAccountPublicKey,
|
|
143
|
-
this.callbackId
|
|
144
|
-
);
|
|
145
|
-
this.callbackId = undefined;
|
|
146
|
-
|
|
147
|
-
this.accountLoader.removeErrorCallbacks(this.errorCallbackId);
|
|
148
|
-
this.errorCallbackId = undefined;
|
|
149
|
-
|
|
150
|
-
this.isSubscribed = false;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
assertIsSubscribed(): void {
|
|
154
|
-
if (!this.isSubscribed) {
|
|
155
|
-
throw new NotSubscribedError(
|
|
156
|
-
'You must call `subscribe` before using this function'
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
public getHighLeverageModeConfigAccountAndSlot(): DataAndSlot<HighLeverageModeConfig> {
|
|
162
|
-
this.assertIsSubscribed();
|
|
163
|
-
return this.highLeverageModeConfigAccountAndSlot;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
didSubscriptionSucceed(): boolean {
|
|
167
|
-
return !!this.highLeverageModeConfigAccountAndSlot;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public updateData(
|
|
171
|
-
highLeverageModeConfig: HighLeverageModeConfig,
|
|
172
|
-
slot: number
|
|
173
|
-
): void {
|
|
174
|
-
if (
|
|
175
|
-
!this.highLeverageModeConfigAccountAndSlot ||
|
|
176
|
-
this.highLeverageModeConfigAccountAndSlot.slot < slot
|
|
177
|
-
) {
|
|
178
|
-
this.highLeverageModeConfigAccountAndSlot = {
|
|
179
|
-
data: highLeverageModeConfig,
|
|
180
|
-
slot,
|
|
181
|
-
};
|
|
182
|
-
this.eventEmitter.emit(
|
|
183
|
-
'highLeverageModeConfigAccountUpdate',
|
|
184
|
-
highLeverageModeConfig
|
|
185
|
-
);
|
|
186
|
-
this.eventEmitter.emit('update');
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DataAndSlot,
|
|
3
|
-
AccountSubscriber,
|
|
4
|
-
NotSubscribedError,
|
|
5
|
-
HighLeverageModeConfigAccountEvents,
|
|
6
|
-
HighLeverageModeConfigAccountSubscriber,
|
|
7
|
-
} from './types';
|
|
8
|
-
import { Program } from '@coral-xyz/anchor';
|
|
9
|
-
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
10
|
-
import { EventEmitter } from 'events';
|
|
11
|
-
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
12
|
-
import { WebSocketAccountSubscriber } from './webSocketAccountSubscriber';
|
|
13
|
-
import { HighLeverageModeConfig } from '../types';
|
|
14
|
-
|
|
15
|
-
export class WebSocketHighLeverageModeConfigAccountSubscriber
|
|
16
|
-
implements HighLeverageModeConfigAccountSubscriber
|
|
17
|
-
{
|
|
18
|
-
isSubscribed: boolean;
|
|
19
|
-
resubTimeoutMs?: number;
|
|
20
|
-
commitment?: Commitment;
|
|
21
|
-
program: Program;
|
|
22
|
-
eventEmitter: StrictEventEmitter<
|
|
23
|
-
EventEmitter,
|
|
24
|
-
HighLeverageModeConfigAccountEvents
|
|
25
|
-
>;
|
|
26
|
-
highLeverageModeConfigAccountPublicKey: PublicKey;
|
|
27
|
-
|
|
28
|
-
highLeverageModeConfigDataAccountSubscriber: AccountSubscriber<HighLeverageModeConfig>;
|
|
29
|
-
|
|
30
|
-
public constructor(
|
|
31
|
-
program: Program,
|
|
32
|
-
highLeverageModeConfigAccountPublicKey: PublicKey,
|
|
33
|
-
resubTimeoutMs?: number,
|
|
34
|
-
commitment?: Commitment
|
|
35
|
-
) {
|
|
36
|
-
this.isSubscribed = false;
|
|
37
|
-
this.program = program;
|
|
38
|
-
this.highLeverageModeConfigAccountPublicKey =
|
|
39
|
-
highLeverageModeConfigAccountPublicKey;
|
|
40
|
-
this.eventEmitter = new EventEmitter();
|
|
41
|
-
this.resubTimeoutMs = resubTimeoutMs;
|
|
42
|
-
this.commitment = commitment;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async subscribe(
|
|
46
|
-
highLeverageModeConfigAccount?: HighLeverageModeConfig
|
|
47
|
-
): Promise<boolean> {
|
|
48
|
-
if (this.isSubscribed) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.highLeverageModeConfigDataAccountSubscriber =
|
|
53
|
-
new WebSocketAccountSubscriber(
|
|
54
|
-
'highLeverageModeConfig',
|
|
55
|
-
this.program,
|
|
56
|
-
this.highLeverageModeConfigAccountPublicKey,
|
|
57
|
-
undefined,
|
|
58
|
-
{
|
|
59
|
-
resubTimeoutMs: this.resubTimeoutMs,
|
|
60
|
-
},
|
|
61
|
-
this.commitment
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (highLeverageModeConfigAccount) {
|
|
65
|
-
this.highLeverageModeConfigDataAccountSubscriber.setData(
|
|
66
|
-
highLeverageModeConfigAccount
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await this.highLeverageModeConfigDataAccountSubscriber.subscribe(
|
|
71
|
-
(data: HighLeverageModeConfig) => {
|
|
72
|
-
this.eventEmitter.emit('highLeverageModeConfigAccountUpdate', data);
|
|
73
|
-
this.eventEmitter.emit('update');
|
|
74
|
-
}
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
this.eventEmitter.emit('update');
|
|
78
|
-
this.isSubscribed = true;
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async fetch(): Promise<void> {
|
|
83
|
-
await Promise.all([
|
|
84
|
-
this.highLeverageModeConfigDataAccountSubscriber.fetch(),
|
|
85
|
-
]);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async unsubscribe(): Promise<void> {
|
|
89
|
-
if (!this.isSubscribed) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
await Promise.all([
|
|
94
|
-
this.highLeverageModeConfigDataAccountSubscriber.unsubscribe(),
|
|
95
|
-
]);
|
|
96
|
-
|
|
97
|
-
this.isSubscribed = false;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
assertIsSubscribed(): void {
|
|
101
|
-
if (!this.isSubscribed) {
|
|
102
|
-
throw new NotSubscribedError(
|
|
103
|
-
'You must call `subscribe` before using this function'
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public getHighLeverageModeConfigAccountAndSlot(): DataAndSlot<HighLeverageModeConfig> {
|
|
109
|
-
this.assertIsSubscribed();
|
|
110
|
-
return this.highLeverageModeConfigDataAccountSubscriber.dataAndSlot;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
public updateData(
|
|
114
|
-
highLeverageModeConfig: HighLeverageModeConfig,
|
|
115
|
-
slot: number
|
|
116
|
-
): void {
|
|
117
|
-
const currentDataSlot =
|
|
118
|
-
this.highLeverageModeConfigDataAccountSubscriber.dataAndSlot?.slot || 0;
|
|
119
|
-
if (currentDataSlot <= slot) {
|
|
120
|
-
this.highLeverageModeConfigDataAccountSubscriber.setData(
|
|
121
|
-
highLeverageModeConfig,
|
|
122
|
-
slot
|
|
123
|
-
);
|
|
124
|
-
this.eventEmitter.emit(
|
|
125
|
-
'highLeverageModeConfigAccountUpdate',
|
|
126
|
-
highLeverageModeConfig
|
|
127
|
-
);
|
|
128
|
-
this.eventEmitter.emit('update');
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|