@drift-labs/sdk-browser 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
|
@@ -27,12 +27,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.DriftClient = void 0;
|
|
30
|
+
/**
|
|
31
|
+
* DriftClient — main SDK entry point for all trading and keeper operations.
|
|
32
|
+
*
|
|
33
|
+
* Responsibilities:
|
|
34
|
+
* - Builds and sends all on-chain instructions (place/cancel/fill orders, deposits, withdrawals,
|
|
35
|
+
* settle PnL, update funding rate, liquidations).
|
|
36
|
+
* - Manages the program account subscription lifecycle (markets, oracles, user accounts).
|
|
37
|
+
* - Provides oracle price reads, market config lookups, and PDA derivation helpers.
|
|
38
|
+
*
|
|
39
|
+
* Admin operations (market init, fee updates, oracle config) live in {@link AdminClient} (adminClient.ts).
|
|
40
|
+
* Read-only user account queries (margin, positions, PnL) live in {@link User} (user.ts).
|
|
41
|
+
*
|
|
42
|
+
* Instruction → on-chain handler mapping: see ARCHITECTURE.md § SDK↔Instruction Mapping.
|
|
43
|
+
*/
|
|
30
44
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
31
45
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
32
46
|
const bs58_1 = __importDefault(require("bs58"));
|
|
33
47
|
const spl_token_1 = require("@solana/spl-token");
|
|
34
48
|
const types_1 = require("./types");
|
|
35
49
|
const drift_json_1 = __importDefault(require("./idl/drift.json"));
|
|
50
|
+
/** Client-side guardrail; mirrors on-chain `ErrorCode::SpotDlobTradingDisabled`. */
|
|
51
|
+
const SPOT_DLOB_TRADING_DISABLED_MSG = 'Spot DLOB trading is disabled; spot balances, deposits, and swaps remain available.';
|
|
36
52
|
const web3_js_1 = require("@solana/web3.js");
|
|
37
53
|
const events_1 = require("events");
|
|
38
54
|
const pda_1 = require("./addresses/pda");
|
|
@@ -60,12 +76,8 @@ const utils_1 = require("./math/utils");
|
|
|
60
76
|
const txParamProcessor_1 = require("./tx/txParamProcessor");
|
|
61
77
|
const oracles_1 = require("./math/oracles");
|
|
62
78
|
const txHandler_1 = require("./tx/txHandler");
|
|
63
|
-
const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
|
|
64
|
-
const pythOracleUtils_1 = require("./util/pythOracleUtils");
|
|
65
79
|
const ed25519Utils_1 = require("./util/ed25519Utils");
|
|
66
80
|
const utils_2 = require("./tx/utils");
|
|
67
|
-
const pyth_solana_receiver_json_1 = __importDefault(require("./idl/pyth_solana_receiver.json"));
|
|
68
|
-
const on_demand_1 = require("@switchboard-xyz/on-demand");
|
|
69
81
|
const grpcDriftClientAccountSubscriber_1 = require("./accounts/grpcDriftClientAccountSubscriber");
|
|
70
82
|
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
71
83
|
const oracleId_1 = require("./oracles/oracleId");
|
|
@@ -76,7 +88,6 @@ const orders_1 = require("./math/orders");
|
|
|
76
88
|
const builder_1 = require("./math/builder");
|
|
77
89
|
const titanClient_1 = require("./titan/titanClient");
|
|
78
90
|
const UnifiedSwapClient_1 = require("./swap/UnifiedSwapClient");
|
|
79
|
-
const pyth_1 = require("./pyth");
|
|
80
91
|
/**
|
|
81
92
|
* # DriftClient
|
|
82
93
|
* This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
|
|
@@ -105,7 +116,7 @@ class DriftClient {
|
|
|
105
116
|
this._isSubscribed = val;
|
|
106
117
|
}
|
|
107
118
|
constructor(config) {
|
|
108
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
|
|
109
120
|
this.users = new Map();
|
|
110
121
|
this._isSubscribed = false;
|
|
111
122
|
this.perpMarketLastSlotCache = new Map();
|
|
@@ -127,18 +138,18 @@ class DriftClient {
|
|
|
127
138
|
this.provider = new anchor_1.AnchorProvider(config.connection,
|
|
128
139
|
// @ts-ignore
|
|
129
140
|
config.wallet, this.opts);
|
|
130
|
-
this.program = new anchor_1.Program(drift_json_1.default,
|
|
131
|
-
this.authority = (
|
|
132
|
-
this.activeSubAccountId = (
|
|
133
|
-
this.skipLoadUsers = (
|
|
141
|
+
this.program = new anchor_1.Program(drift_json_1.default, this.provider, config.coder);
|
|
142
|
+
this.authority = (_d = config.authority) !== null && _d !== void 0 ? _d : this.wallet.publicKey;
|
|
143
|
+
this.activeSubAccountId = (_e = config.activeSubAccountId) !== null && _e !== void 0 ? _e : 0;
|
|
144
|
+
this.skipLoadUsers = (_f = config.skipLoadUsers) !== null && _f !== void 0 ? _f : false;
|
|
134
145
|
this.txVersion =
|
|
135
|
-
(
|
|
146
|
+
(_g = config.txVersion) !== null && _g !== void 0 ? _g : this.getTxVersionForNewWallet(config.wallet);
|
|
136
147
|
this.txParams = {
|
|
137
|
-
computeUnits: (
|
|
138
|
-
computeUnitsPrice: (
|
|
148
|
+
computeUnits: (_j = (_h = config.txParams) === null || _h === void 0 ? void 0 : _h.computeUnits) !== null && _j !== void 0 ? _j : 600000,
|
|
149
|
+
computeUnitsPrice: (_l = (_k = config.txParams) === null || _k === void 0 ? void 0 : _k.computeUnitsPrice) !== null && _l !== void 0 ? _l : 0,
|
|
139
150
|
};
|
|
140
151
|
this.txHandler =
|
|
141
|
-
(
|
|
152
|
+
(_m = config === null || config === void 0 ? void 0 : config.txHandler) !== null && _m !== void 0 ? _m : new txHandler_1.TxHandler({
|
|
142
153
|
connection: this.connection,
|
|
143
154
|
// @ts-ignore
|
|
144
155
|
wallet: this.provider.wallet,
|
|
@@ -164,8 +175,8 @@ class DriftClient {
|
|
|
164
175
|
: config.subAccountIds
|
|
165
176
|
? new Map([[this.authority.toString(), config.subAccountIds]])
|
|
166
177
|
: new Map();
|
|
167
|
-
this.includeDelegates = (
|
|
168
|
-
if (((
|
|
178
|
+
this.includeDelegates = (_o = config.includeDelegates) !== null && _o !== void 0 ? _o : false;
|
|
179
|
+
if (((_p = config.accountSubscription) === null || _p === void 0 ? void 0 : _p.type) === 'polling') {
|
|
169
180
|
this.userAccountSubscriptionConfig = {
|
|
170
181
|
type: 'polling',
|
|
171
182
|
accountLoader: config.accountSubscription.accountLoader,
|
|
@@ -175,34 +186,34 @@ class DriftClient {
|
|
|
175
186
|
accountLoader: config.accountSubscription.accountLoader,
|
|
176
187
|
};
|
|
177
188
|
}
|
|
178
|
-
else if (((
|
|
189
|
+
else if (((_q = config.accountSubscription) === null || _q === void 0 ? void 0 : _q.type) === 'grpc') {
|
|
179
190
|
this.userAccountSubscriptionConfig = {
|
|
180
191
|
type: 'grpc',
|
|
181
|
-
resubTimeoutMs: (
|
|
182
|
-
logResubMessages: (
|
|
183
|
-
grpcConfigs: (
|
|
184
|
-
grpcMultiUserAccountSubscriber: (
|
|
192
|
+
resubTimeoutMs: (_r = config.accountSubscription) === null || _r === void 0 ? void 0 : _r.resubTimeoutMs,
|
|
193
|
+
logResubMessages: (_s = config.accountSubscription) === null || _s === void 0 ? void 0 : _s.logResubMessages,
|
|
194
|
+
grpcConfigs: (_t = config.accountSubscription) === null || _t === void 0 ? void 0 : _t.grpcConfigs,
|
|
195
|
+
grpcMultiUserAccountSubscriber: (_u = config.accountSubscription) === null || _u === void 0 ? void 0 : _u.grpcMultiUserAccountSubscriber,
|
|
185
196
|
};
|
|
186
197
|
this.userStatsAccountSubscriptionConfig = {
|
|
187
198
|
type: 'grpc',
|
|
188
|
-
grpcConfigs: (
|
|
189
|
-
resubTimeoutMs: (
|
|
190
|
-
logResubMessages: (
|
|
199
|
+
grpcConfigs: (_v = config.accountSubscription) === null || _v === void 0 ? void 0 : _v.grpcConfigs,
|
|
200
|
+
resubTimeoutMs: (_w = config.accountSubscription) === null || _w === void 0 ? void 0 : _w.resubTimeoutMs,
|
|
201
|
+
logResubMessages: (_x = config.accountSubscription) === null || _x === void 0 ? void 0 : _x.logResubMessages,
|
|
191
202
|
};
|
|
192
203
|
}
|
|
193
204
|
else {
|
|
194
205
|
this.userAccountSubscriptionConfig = {
|
|
195
206
|
type: 'websocket',
|
|
196
|
-
resubTimeoutMs: (
|
|
197
|
-
logResubMessages: (
|
|
198
|
-
commitment: (
|
|
199
|
-
programUserAccountSubscriber: (
|
|
207
|
+
resubTimeoutMs: (_y = config.accountSubscription) === null || _y === void 0 ? void 0 : _y.resubTimeoutMs,
|
|
208
|
+
logResubMessages: (_z = config.accountSubscription) === null || _z === void 0 ? void 0 : _z.logResubMessages,
|
|
209
|
+
commitment: (_0 = config.accountSubscription) === null || _0 === void 0 ? void 0 : _0.commitment,
|
|
210
|
+
programUserAccountSubscriber: (_1 = config.accountSubscription) === null || _1 === void 0 ? void 0 : _1.programUserAccountSubscriber,
|
|
200
211
|
};
|
|
201
212
|
this.userStatsAccountSubscriptionConfig = {
|
|
202
213
|
type: 'websocket',
|
|
203
|
-
resubTimeoutMs: (
|
|
204
|
-
logResubMessages: (
|
|
205
|
-
commitment: (
|
|
214
|
+
resubTimeoutMs: (_2 = config.accountSubscription) === null || _2 === void 0 ? void 0 : _2.resubTimeoutMs,
|
|
215
|
+
logResubMessages: (_3 = config.accountSubscription) === null || _3 === void 0 ? void 0 : _3.logResubMessages,
|
|
216
|
+
commitment: (_4 = config.accountSubscription) === null || _4 === void 0 ? void 0 : _4.commitment,
|
|
206
217
|
};
|
|
207
218
|
}
|
|
208
219
|
if (config.userStats) {
|
|
@@ -224,22 +235,22 @@ class DriftClient {
|
|
|
224
235
|
const noMarketsAndOraclesSpecified = config.perpMarketIndexes === undefined &&
|
|
225
236
|
config.spotMarketIndexes === undefined &&
|
|
226
237
|
config.oracleInfos === undefined;
|
|
227
|
-
if (((
|
|
228
|
-
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (
|
|
229
|
-
}
|
|
230
|
-
else if (((
|
|
231
|
-
const accountSubscriberClass = (
|
|
232
|
-
this.accountSubscriber = new accountSubscriberClass(config.accountSubscription.grpcConfigs, this.program, (
|
|
233
|
-
resubTimeoutMs: (
|
|
234
|
-
logResubMessages: (
|
|
238
|
+
if (((_5 = config.accountSubscription) === null || _5 === void 0 ? void 0 : _5.type) === 'polling') {
|
|
239
|
+
this.accountSubscriber = new pollingDriftClientAccountSubscriber_1.PollingDriftClientAccountSubscriber(this.program, config.accountSubscription.accountLoader, (_6 = config.perpMarketIndexes) !== null && _6 !== void 0 ? _6 : [], (_7 = config.spotMarketIndexes) !== null && _7 !== void 0 ? _7 : [], (_8 = config.oracleInfos) !== null && _8 !== void 0 ? _8 : [], noMarketsAndOraclesSpecified, delistedMarketSetting);
|
|
240
|
+
}
|
|
241
|
+
else if (((_9 = config.accountSubscription) === null || _9 === void 0 ? void 0 : _9.type) === 'grpc') {
|
|
242
|
+
const accountSubscriberClass = (_11 = (_10 = config.accountSubscription) === null || _10 === void 0 ? void 0 : _10.driftClientAccountSubscriber) !== null && _11 !== void 0 ? _11 : grpcDriftClientAccountSubscriber_1.grpcDriftClientAccountSubscriber;
|
|
243
|
+
this.accountSubscriber = new accountSubscriberClass(config.accountSubscription.grpcConfigs, this.program, (_12 = config.perpMarketIndexes) !== null && _12 !== void 0 ? _12 : [], (_13 = config.spotMarketIndexes) !== null && _13 !== void 0 ? _13 : [], (_14 = config.oracleInfos) !== null && _14 !== void 0 ? _14 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
244
|
+
resubTimeoutMs: (_15 = config.accountSubscription) === null || _15 === void 0 ? void 0 : _15.resubTimeoutMs,
|
|
245
|
+
logResubMessages: (_16 = config.accountSubscription) === null || _16 === void 0 ? void 0 : _16.logResubMessages,
|
|
235
246
|
});
|
|
236
247
|
}
|
|
237
248
|
else {
|
|
238
|
-
const accountSubscriberClass = (
|
|
239
|
-
this.accountSubscriber = new accountSubscriberClass(this.program, (
|
|
240
|
-
resubTimeoutMs: (
|
|
241
|
-
logResubMessages: (
|
|
242
|
-
}, (
|
|
249
|
+
const accountSubscriberClass = (_18 = (_17 = config.accountSubscription) === null || _17 === void 0 ? void 0 : _17.driftClientAccountSubscriber) !== null && _18 !== void 0 ? _18 : webSocketDriftClientAccountSubscriber_1.WebSocketDriftClientAccountSubscriber;
|
|
250
|
+
this.accountSubscriber = new accountSubscriberClass(this.program, (_19 = config.perpMarketIndexes) !== null && _19 !== void 0 ? _19 : [], (_20 = config.spotMarketIndexes) !== null && _20 !== void 0 ? _20 : [], (_21 = config.oracleInfos) !== null && _21 !== void 0 ? _21 : [], noMarketsAndOraclesSpecified, delistedMarketSetting, {
|
|
251
|
+
resubTimeoutMs: (_22 = config.accountSubscription) === null || _22 === void 0 ? void 0 : _22.resubTimeoutMs,
|
|
252
|
+
logResubMessages: (_23 = config.accountSubscription) === null || _23 === void 0 ? void 0 : _23.logResubMessages,
|
|
253
|
+
}, (_24 = config.accountSubscription) === null || _24 === void 0 ? void 0 : _24.commitment);
|
|
243
254
|
}
|
|
244
255
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
245
256
|
this.metricsEventEmitter = new events_1.EventEmitter();
|
|
@@ -247,13 +258,12 @@ class DriftClient {
|
|
|
247
258
|
this.enableMetricsEvents = true;
|
|
248
259
|
}
|
|
249
260
|
this.txSender =
|
|
250
|
-
(
|
|
261
|
+
(_25 = config.txSender) !== null && _25 !== void 0 ? _25 : new retryTxSender_1.RetryTxSender({
|
|
251
262
|
connection: this.connection,
|
|
252
263
|
wallet: this.wallet,
|
|
253
264
|
opts: this.opts,
|
|
254
265
|
txHandler: this.txHandler,
|
|
255
266
|
});
|
|
256
|
-
this.sbOnDemandProgramdId = config_1.configs[this.env].SB_ON_DEMAND_PID;
|
|
257
267
|
}
|
|
258
268
|
getUserMapKey(subAccountId, authority) {
|
|
259
269
|
return `${subAccountId}_${authority.toString()}`;
|
|
@@ -444,7 +454,7 @@ class DriftClient {
|
|
|
444
454
|
const newProvider = new anchor_1.AnchorProvider(this.connection,
|
|
445
455
|
// @ts-ignore
|
|
446
456
|
newWallet, this.opts);
|
|
447
|
-
const newProgram = new anchor_1.Program(drift_json_1.default,
|
|
457
|
+
const newProgram = new anchor_1.Program(drift_json_1.default, newProvider);
|
|
448
458
|
this.skipLoadUsers = false;
|
|
449
459
|
// Update provider for txSender with new wallet details
|
|
450
460
|
this.txSender.wallet = newWallet;
|
|
@@ -1030,15 +1040,9 @@ class DriftClient {
|
|
|
1030
1040
|
});
|
|
1031
1041
|
return ix;
|
|
1032
1042
|
}
|
|
1033
|
-
async updateUserPerpPositionCustomMarginRatio(perpMarketIndex, marginRatio, subAccountId = 0, txParams
|
|
1034
|
-
const ixs = [];
|
|
1035
|
-
if (enterHighLeverageMode) {
|
|
1036
|
-
const enableIx = await this.getEnableHighLeverageModeIx(subAccountId);
|
|
1037
|
-
ixs.push(enableIx);
|
|
1038
|
-
}
|
|
1043
|
+
async updateUserPerpPositionCustomMarginRatio(perpMarketIndex, marginRatio, subAccountId = 0, txParams) {
|
|
1039
1044
|
const updateIx = await this.getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex, marginRatio, subAccountId);
|
|
1040
|
-
|
|
1041
|
-
const tx = await this.buildTransaction(ixs, txParams !== null && txParams !== void 0 ? txParams : this.txParams);
|
|
1045
|
+
const tx = await this.buildTransaction(updateIx, txParams !== null && txParams !== void 0 ? txParams : this.txParams);
|
|
1042
1046
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
1043
1047
|
return txSig;
|
|
1044
1048
|
}
|
|
@@ -2542,13 +2546,6 @@ class DriftClient {
|
|
|
2542
2546
|
? [depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.depositMarketIndex]
|
|
2543
2547
|
: undefined,
|
|
2544
2548
|
});
|
|
2545
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(orderParams.bitFlags)) {
|
|
2546
|
-
remainingAccounts.push({
|
|
2547
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
2548
|
-
isWritable: true,
|
|
2549
|
-
isSigner: false,
|
|
2550
|
-
});
|
|
2551
|
-
}
|
|
2552
2549
|
return await this.program.instruction.placePerpOrder(orderParams, {
|
|
2553
2550
|
accounts: {
|
|
2554
2551
|
state: await this.getStatePublicKey(),
|
|
@@ -2802,15 +2799,6 @@ class DriftClient {
|
|
|
2802
2799
|
readableSpotMarketIndexes,
|
|
2803
2800
|
useMarketLastSlotCache: true,
|
|
2804
2801
|
});
|
|
2805
|
-
for (const param of params) {
|
|
2806
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(param.bitFlags)) {
|
|
2807
|
-
remainingAccounts.push({
|
|
2808
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
2809
|
-
isWritable: true,
|
|
2810
|
-
isSigner: false,
|
|
2811
|
-
});
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
2802
|
const formattedParams = params.map((item) => (0, orderParams_1.getOrderParams)(item));
|
|
2815
2803
|
const authority = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.authority) !== null && _a !== void 0 ? _a : this.wallet.publicKey;
|
|
2816
2804
|
return await this.program.instruction.placeOrders(formattedParams, {
|
|
@@ -2844,15 +2832,6 @@ class DriftClient {
|
|
|
2844
2832
|
readableSpotMarketIndexes,
|
|
2845
2833
|
useMarketLastSlotCache: true,
|
|
2846
2834
|
});
|
|
2847
|
-
for (const param of params) {
|
|
2848
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(param.bitFlags)) {
|
|
2849
|
-
remainingAccounts.push({
|
|
2850
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
2851
|
-
isWritable: true,
|
|
2852
|
-
isSigner: false,
|
|
2853
|
-
});
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
2835
|
const formattedParams = params.map((item) => (0, orderParams_1.getOrderParams)(item));
|
|
2857
2836
|
const placeOrdersIxs = await this.program.instruction.placeOrders(formattedParams, {
|
|
2858
2837
|
accounts: {
|
|
@@ -2896,13 +2875,6 @@ class DriftClient {
|
|
|
2896
2875
|
readableSpotMarketIndexes: isPerp ? [] : [params.marketIndex],
|
|
2897
2876
|
useMarketLastSlotCache: true,
|
|
2898
2877
|
});
|
|
2899
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(params.bitFlags)) {
|
|
2900
|
-
remainingAccounts.push({
|
|
2901
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
2902
|
-
isWritable: true,
|
|
2903
|
-
isSigner: false,
|
|
2904
|
-
});
|
|
2905
|
-
}
|
|
2906
2878
|
const formattedParams = {
|
|
2907
2879
|
marketType: params.marketType,
|
|
2908
2880
|
direction: params.direction,
|
|
@@ -3041,91 +3013,20 @@ class DriftClient {
|
|
|
3041
3013
|
},
|
|
3042
3014
|
});
|
|
3043
3015
|
}
|
|
3044
|
-
async placeSpotOrder(
|
|
3045
|
-
|
|
3046
|
-
.placeSpotOrderTx, [], this.opts, false);
|
|
3047
|
-
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
3048
|
-
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
3049
|
-
return txSig;
|
|
3016
|
+
async placeSpotOrder(_orderParams, _txParams, _subAccountId) {
|
|
3017
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
3050
3018
|
}
|
|
3051
|
-
async preparePlaceSpotOrderTx(
|
|
3052
|
-
|
|
3053
|
-
return {
|
|
3054
|
-
placeSpotOrderTx: tx,
|
|
3055
|
-
};
|
|
3019
|
+
async preparePlaceSpotOrderTx(_orderParams, _txParams, _subAccountId) {
|
|
3020
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
3056
3021
|
}
|
|
3057
|
-
async getPlaceSpotOrderIx(
|
|
3058
|
-
|
|
3059
|
-
orderParams = (0, orderParams_1.getOrderParams)(orderParams, { marketType: types_1.MarketType.SPOT });
|
|
3060
|
-
const userAccountPublicKey = await this.getUserAccountPublicKey(subAccountId);
|
|
3061
|
-
const authority = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.authority) !== null && _a !== void 0 ? _a : this.wallet.publicKey;
|
|
3062
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
3063
|
-
userAccounts: [this.getUserAccount(subAccountId)],
|
|
3064
|
-
useMarketLastSlotCache: true,
|
|
3065
|
-
readableSpotMarketIndexes: [
|
|
3066
|
-
orderParams.marketIndex,
|
|
3067
|
-
numericConstants_1.QUOTE_SPOT_MARKET_INDEX,
|
|
3068
|
-
],
|
|
3069
|
-
});
|
|
3070
|
-
return await this.program.instruction.placeSpotOrder(orderParams, {
|
|
3071
|
-
accounts: {
|
|
3072
|
-
state: await this.getStatePublicKey(),
|
|
3073
|
-
user: userAccountPublicKey,
|
|
3074
|
-
userStats: this.getUserStatsAccountPublicKey(),
|
|
3075
|
-
authority,
|
|
3076
|
-
},
|
|
3077
|
-
remainingAccounts,
|
|
3078
|
-
});
|
|
3022
|
+
async getPlaceSpotOrderIx(_orderParams, _subAccountId, _overrides) {
|
|
3023
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
3079
3024
|
}
|
|
3080
|
-
async fillSpotOrder(
|
|
3081
|
-
|
|
3082
|
-
return txSig;
|
|
3025
|
+
async fillSpotOrder(_userAccountPublicKey, _user, _order, _fulfillmentConfig, _makerInfo, _referrerInfo, _txParams) {
|
|
3026
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
3083
3027
|
}
|
|
3084
|
-
async getFillSpotOrderIx(
|
|
3085
|
-
|
|
3086
|
-
const filler = fillerPublicKey !== null && fillerPublicKey !== void 0 ? fillerPublicKey : (await this.getUserAccountPublicKey());
|
|
3087
|
-
const fillerStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
3088
|
-
const marketIndex = order
|
|
3089
|
-
? order.marketIndex
|
|
3090
|
-
: userAccount.orders.find((order) => order.orderId === userAccount.nextOrderId - 1).marketIndex;
|
|
3091
|
-
makerInfo = Array.isArray(makerInfo)
|
|
3092
|
-
? makerInfo
|
|
3093
|
-
: makerInfo
|
|
3094
|
-
? [makerInfo]
|
|
3095
|
-
: [];
|
|
3096
|
-
const userAccounts = [userAccount];
|
|
3097
|
-
for (const maker of makerInfo) {
|
|
3098
|
-
userAccounts.push(maker.makerUserAccount);
|
|
3099
|
-
}
|
|
3100
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
3101
|
-
userAccounts,
|
|
3102
|
-
writableSpotMarketIndexes: [marketIndex, numericConstants_1.QUOTE_SPOT_MARKET_INDEX],
|
|
3103
|
-
});
|
|
3104
|
-
for (const maker of makerInfo) {
|
|
3105
|
-
remainingAccounts.push({
|
|
3106
|
-
pubkey: maker.maker,
|
|
3107
|
-
isWritable: true,
|
|
3108
|
-
isSigner: false,
|
|
3109
|
-
});
|
|
3110
|
-
remainingAccounts.push({
|
|
3111
|
-
pubkey: maker.makerStats,
|
|
3112
|
-
isWritable: true,
|
|
3113
|
-
isSigner: false,
|
|
3114
|
-
});
|
|
3115
|
-
}
|
|
3116
|
-
const orderId = order.orderId;
|
|
3117
|
-
this.addSpotFulfillmentAccounts(marketIndex, remainingAccounts, fulfillmentConfig);
|
|
3118
|
-
return await this.program.instruction.fillSpotOrder(orderId, fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null, null, {
|
|
3119
|
-
accounts: {
|
|
3120
|
-
state: await this.getStatePublicKey(),
|
|
3121
|
-
filler,
|
|
3122
|
-
fillerStats: fillerStatsPublicKey,
|
|
3123
|
-
user: userAccountPublicKey,
|
|
3124
|
-
userStats: userStatsPublicKey,
|
|
3125
|
-
authority: this.wallet.publicKey,
|
|
3126
|
-
},
|
|
3127
|
-
remainingAccounts,
|
|
3128
|
-
});
|
|
3028
|
+
async getFillSpotOrderIx(_userAccountPublicKey, _userAccount, _order, _fulfillmentConfig, _makerInfo, _referrerInfo, _fillerPublicKey) {
|
|
3029
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
3129
3030
|
}
|
|
3130
3031
|
addSpotFulfillmentAccounts(marketIndex, remainingAccounts, fulfillmentConfig) {
|
|
3131
3032
|
if (fulfillmentConfig) {
|
|
@@ -4065,13 +3966,6 @@ class DriftClient {
|
|
|
4065
3966
|
});
|
|
4066
3967
|
}
|
|
4067
3968
|
}
|
|
4068
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(orderParams.bitFlags)) {
|
|
4069
|
-
remainingAccounts.push({
|
|
4070
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
4071
|
-
isWritable: true,
|
|
4072
|
-
isSigner: false,
|
|
4073
|
-
});
|
|
4074
|
-
}
|
|
4075
3969
|
let optionalParams = null;
|
|
4076
3970
|
if (auctionDurationPercentage || successCondition) {
|
|
4077
3971
|
optionalParams =
|
|
@@ -4191,8 +4085,8 @@ class DriftClient {
|
|
|
4191
4085
|
const buf = Buffer.concat([
|
|
4192
4086
|
prefix,
|
|
4193
4087
|
delegateSigner
|
|
4194
|
-
? this.program.coder.types.encode('
|
|
4195
|
-
: this.program.coder.types.encode('
|
|
4088
|
+
? this.program.coder.types.encode('signedMsgOrderParamsDelegateMessage', withBuilderDefaults)
|
|
4089
|
+
: this.program.coder.types.encode('signedMsgOrderParamsMessage', withBuilderDefaults),
|
|
4196
4090
|
]);
|
|
4197
4091
|
return buf;
|
|
4198
4092
|
}
|
|
@@ -4204,8 +4098,8 @@ class DriftClient {
|
|
|
4204
4098
|
*/
|
|
4205
4099
|
decodeSignedMsgOrderParamsMessage(encodedMessage, delegateSigner) {
|
|
4206
4100
|
const decodeStr = delegateSigner
|
|
4207
|
-
? '
|
|
4208
|
-
: '
|
|
4101
|
+
? 'signedMsgOrderParamsDelegateMessage'
|
|
4102
|
+
: 'signedMsgOrderParamsMessage';
|
|
4209
4103
|
return this.program.coder.types.decode(decodeStr, Buffer.concat([
|
|
4210
4104
|
encodedMessage.slice(8), // strip out discriminator
|
|
4211
4105
|
Buffer.alloc(128), // pad on 128 bytes, this is most efficient way to messages that are too small
|
|
@@ -4233,13 +4127,6 @@ class DriftClient {
|
|
|
4233
4127
|
readablePerpMarketIndex: marketIndex,
|
|
4234
4128
|
writableSpotMarketIndexes,
|
|
4235
4129
|
});
|
|
4236
|
-
if ((0, orderParams_1.isUpdateHighLeverageMode)(signedMessage.signedMsgOrderParams.bitFlags)) {
|
|
4237
|
-
remainingAccounts.push({
|
|
4238
|
-
pubkey: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
4239
|
-
isWritable: true,
|
|
4240
|
-
isSigner: false,
|
|
4241
|
-
});
|
|
4242
|
-
}
|
|
4243
4130
|
if (signedMessage.builderFeeTenthBps !== null &&
|
|
4244
4131
|
signedMessage.builderIdx !== null) {
|
|
4245
4132
|
remainingAccounts.push({
|
|
@@ -4330,117 +4217,20 @@ class DriftClient {
|
|
|
4330
4217
|
placeAndMakeIx,
|
|
4331
4218
|
];
|
|
4332
4219
|
}
|
|
4333
|
-
async preparePlaceAndTakeSpotOrder(
|
|
4334
|
-
|
|
4335
|
-
return {
|
|
4336
|
-
placeAndTakeSpotOrderTx: tx,
|
|
4337
|
-
};
|
|
4220
|
+
async preparePlaceAndTakeSpotOrder(_orderParams, _fulfillmentConfig, _makerInfo, _referrerInfo, _txParams, _subAccountId) {
|
|
4221
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
4338
4222
|
}
|
|
4339
|
-
async placeAndTakeSpotOrder(
|
|
4340
|
-
|
|
4341
|
-
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
4342
|
-
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
4343
|
-
return txSig;
|
|
4223
|
+
async placeAndTakeSpotOrder(_orderParams, _fulfillmentConfig, _makerInfo, _referrerInfo, _txParams, _subAccountId) {
|
|
4224
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
4344
4225
|
}
|
|
4345
|
-
async getPlaceAndTakeSpotOrderIx(
|
|
4346
|
-
|
|
4347
|
-
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
4348
|
-
const user = await this.getUserAccountPublicKey(subAccountId);
|
|
4349
|
-
const userAccounts = [this.getUserAccount(subAccountId)];
|
|
4350
|
-
if (makerInfo !== undefined) {
|
|
4351
|
-
userAccounts.push(makerInfo.makerUserAccount);
|
|
4352
|
-
}
|
|
4353
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
4354
|
-
userAccounts,
|
|
4355
|
-
useMarketLastSlotCache: true,
|
|
4356
|
-
writableSpotMarketIndexes: [
|
|
4357
|
-
orderParams.marketIndex,
|
|
4358
|
-
numericConstants_1.QUOTE_SPOT_MARKET_INDEX,
|
|
4359
|
-
],
|
|
4360
|
-
});
|
|
4361
|
-
let makerOrderId = null;
|
|
4362
|
-
if (makerInfo) {
|
|
4363
|
-
makerOrderId = makerInfo.order.orderId;
|
|
4364
|
-
remainingAccounts.push({
|
|
4365
|
-
pubkey: makerInfo.maker,
|
|
4366
|
-
isSigner: false,
|
|
4367
|
-
isWritable: true,
|
|
4368
|
-
});
|
|
4369
|
-
remainingAccounts.push({
|
|
4370
|
-
pubkey: makerInfo.makerStats,
|
|
4371
|
-
isSigner: false,
|
|
4372
|
-
isWritable: true,
|
|
4373
|
-
});
|
|
4374
|
-
}
|
|
4375
|
-
if (referrerInfo) {
|
|
4376
|
-
remainingAccounts.push({
|
|
4377
|
-
pubkey: referrerInfo.referrer,
|
|
4378
|
-
isWritable: true,
|
|
4379
|
-
isSigner: false,
|
|
4380
|
-
});
|
|
4381
|
-
remainingAccounts.push({
|
|
4382
|
-
pubkey: referrerInfo.referrerStats,
|
|
4383
|
-
isWritable: true,
|
|
4384
|
-
isSigner: false,
|
|
4385
|
-
});
|
|
4386
|
-
}
|
|
4387
|
-
this.addSpotFulfillmentAccounts(orderParams.marketIndex, remainingAccounts, fulfillmentConfig);
|
|
4388
|
-
return await this.program.instruction.placeAndTakeSpotOrder(orderParams, fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null, makerOrderId, {
|
|
4389
|
-
accounts: {
|
|
4390
|
-
state: await this.getStatePublicKey(),
|
|
4391
|
-
user,
|
|
4392
|
-
userStats: userStatsPublicKey,
|
|
4393
|
-
authority: this.wallet.publicKey,
|
|
4394
|
-
},
|
|
4395
|
-
remainingAccounts,
|
|
4396
|
-
});
|
|
4226
|
+
async getPlaceAndTakeSpotOrderIx(_orderParams, _fulfillmentConfig, _makerInfo, _referrerInfo, _subAccountId) {
|
|
4227
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
4397
4228
|
}
|
|
4398
|
-
async placeAndMakeSpotOrder(
|
|
4399
|
-
|
|
4400
|
-
this.spotMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
4401
|
-
this.spotMarketLastSlotCache.set(numericConstants_1.QUOTE_SPOT_MARKET_INDEX, slot);
|
|
4402
|
-
return txSig;
|
|
4229
|
+
async placeAndMakeSpotOrder(_orderParams, _takerInfo, _fulfillmentConfig, _referrerInfo, _txParams, _subAccountId) {
|
|
4230
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
4403
4231
|
}
|
|
4404
|
-
async getPlaceAndMakeSpotOrderIx(
|
|
4405
|
-
|
|
4406
|
-
const userStatsPublicKey = this.getUserStatsAccountPublicKey();
|
|
4407
|
-
const user = await this.getUserAccountPublicKey(subAccountId);
|
|
4408
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
4409
|
-
userAccounts: [
|
|
4410
|
-
this.getUserAccount(subAccountId),
|
|
4411
|
-
takerInfo.takerUserAccount,
|
|
4412
|
-
],
|
|
4413
|
-
useMarketLastSlotCache: true,
|
|
4414
|
-
writableSpotMarketIndexes: [
|
|
4415
|
-
orderParams.marketIndex,
|
|
4416
|
-
numericConstants_1.QUOTE_SPOT_MARKET_INDEX,
|
|
4417
|
-
],
|
|
4418
|
-
});
|
|
4419
|
-
if (referrerInfo) {
|
|
4420
|
-
remainingAccounts.push({
|
|
4421
|
-
pubkey: referrerInfo.referrer,
|
|
4422
|
-
isWritable: true,
|
|
4423
|
-
isSigner: false,
|
|
4424
|
-
});
|
|
4425
|
-
remainingAccounts.push({
|
|
4426
|
-
pubkey: referrerInfo.referrerStats,
|
|
4427
|
-
isWritable: true,
|
|
4428
|
-
isSigner: false,
|
|
4429
|
-
});
|
|
4430
|
-
}
|
|
4431
|
-
this.addSpotFulfillmentAccounts(orderParams.marketIndex, remainingAccounts, fulfillmentConfig);
|
|
4432
|
-
const takerOrderId = takerInfo.order.orderId;
|
|
4433
|
-
return await this.program.instruction.placeAndMakeSpotOrder(orderParams, takerOrderId, fulfillmentConfig ? fulfillmentConfig.fulfillmentType : null, {
|
|
4434
|
-
accounts: {
|
|
4435
|
-
state: await this.getStatePublicKey(),
|
|
4436
|
-
user,
|
|
4437
|
-
userStats: userStatsPublicKey,
|
|
4438
|
-
taker: takerInfo.taker,
|
|
4439
|
-
takerStats: takerInfo.takerStats,
|
|
4440
|
-
authority: this.wallet.publicKey,
|
|
4441
|
-
},
|
|
4442
|
-
remainingAccounts,
|
|
4443
|
-
});
|
|
4232
|
+
async getPlaceAndMakeSpotOrderIx(_orderParams, _takerInfo, _fulfillmentConfig, _referrerInfo, _subAccountId) {
|
|
4233
|
+
throw new Error(SPOT_DLOB_TRADING_DISABLED_MSG);
|
|
4444
4234
|
}
|
|
4445
4235
|
/**
|
|
4446
4236
|
* @deprecated use {@link placePerpOrder} or {@link placeAndTakePerpOrder} instead
|
|
@@ -5765,12 +5555,9 @@ class DriftClient {
|
|
|
5765
5555
|
* @param positionMarketIndex
|
|
5766
5556
|
* @returns : {takerFee: number, makerFee: number} Precision None
|
|
5767
5557
|
*/
|
|
5768
|
-
getMarketFees(marketType, marketIndex, user
|
|
5769
|
-
var _a;
|
|
5558
|
+
getMarketFees(marketType, marketIndex, user) {
|
|
5770
5559
|
let feeTier;
|
|
5771
|
-
|
|
5772
|
-
enteringHighLeverageMode;
|
|
5773
|
-
if (user && !userHLM) {
|
|
5560
|
+
if (user) {
|
|
5774
5561
|
feeTier = user.getUserFeeTier(marketType);
|
|
5775
5562
|
}
|
|
5776
5563
|
else {
|
|
@@ -5790,9 +5577,6 @@ class DriftClient {
|
|
|
5790
5577
|
marketAccount = this.getSpotMarketAccount(marketIndex);
|
|
5791
5578
|
}
|
|
5792
5579
|
takerFee += (takerFee * marketAccount.feeAdjustment) / 100;
|
|
5793
|
-
if (userHLM) {
|
|
5794
|
-
takerFee *= 2;
|
|
5795
|
-
}
|
|
5796
5580
|
makerFee += (makerFee * marketAccount.feeAdjustment) / 100;
|
|
5797
5581
|
}
|
|
5798
5582
|
return {
|
|
@@ -5826,112 +5610,6 @@ class DriftClient {
|
|
|
5826
5610
|
}
|
|
5827
5611
|
return undefined;
|
|
5828
5612
|
}
|
|
5829
|
-
getReceiverProgram() {
|
|
5830
|
-
if (this.receiverProgram === undefined) {
|
|
5831
|
-
this.receiverProgram = new anchor_1.Program(pyth_solana_receiver_json_1.default, pyth_1.DEFAULT_RECEIVER_PROGRAM_ID, this.provider);
|
|
5832
|
-
}
|
|
5833
|
-
return this.receiverProgram;
|
|
5834
|
-
}
|
|
5835
|
-
async getSwitchboardOnDemandProgram() {
|
|
5836
|
-
if (this.sbOnDemandProgram === undefined) {
|
|
5837
|
-
this.sbOnDemandProgram = await on_demand_1.AnchorUtils.loadProgramFromConnection(this.connection);
|
|
5838
|
-
}
|
|
5839
|
-
return this.sbOnDemandProgram;
|
|
5840
|
-
}
|
|
5841
|
-
async postPythPullOracleUpdateAtomic(vaaString, feedId) {
|
|
5842
|
-
const postIxs = await this.getPostPythPullOracleUpdateAtomicIxs(vaaString, feedId);
|
|
5843
|
-
const tx = await this.buildTransaction(postIxs);
|
|
5844
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
5845
|
-
return txSig;
|
|
5846
|
-
}
|
|
5847
|
-
async postMultiPythPullOracleUpdatesAtomic(vaaString, feedIds) {
|
|
5848
|
-
const postIxs = await this.getPostPythPullOracleUpdateAtomicIxs(vaaString, feedIds);
|
|
5849
|
-
const tx = await this.buildTransaction(postIxs);
|
|
5850
|
-
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
5851
|
-
return txSig;
|
|
5852
|
-
}
|
|
5853
|
-
async getPostPythPullOracleUpdateAtomicIxs(vaaString, feedIds, numSignatures = 2) {
|
|
5854
|
-
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(vaaString, 'base64'));
|
|
5855
|
-
const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
|
|
5856
|
-
const guardianSet = (0, pyth_1.getGuardianSetPda)(guardianSetIndex, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID);
|
|
5857
|
-
const trimmedVaa = (0, oracles_1.trimVaaSignatures)(accumulatorUpdateData.vaa, numSignatures);
|
|
5858
|
-
const postIxs = [];
|
|
5859
|
-
if (accumulatorUpdateData.updates.length > 1) {
|
|
5860
|
-
const encodedParams = this.getReceiverProgram().coder.types.encode('PostMultiUpdatesAtomicParams', {
|
|
5861
|
-
vaa: trimmedVaa,
|
|
5862
|
-
merklePriceUpdates: accumulatorUpdateData.updates,
|
|
5863
|
-
});
|
|
5864
|
-
const feedIdsToUse = typeof feedIds === 'string' ? [feedIds] : feedIds;
|
|
5865
|
-
const pubkeys = feedIdsToUse.map((feedId) => {
|
|
5866
|
-
return (0, pda_1.getPythPullOraclePublicKey)(this.program.programId, (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId));
|
|
5867
|
-
});
|
|
5868
|
-
const remainingAccounts = pubkeys.map((pubkey) => {
|
|
5869
|
-
return {
|
|
5870
|
-
pubkey,
|
|
5871
|
-
isSigner: false,
|
|
5872
|
-
isWritable: true,
|
|
5873
|
-
};
|
|
5874
|
-
});
|
|
5875
|
-
postIxs.push(this.program.instruction.postMultiPythPullOracleUpdatesAtomic(encodedParams, {
|
|
5876
|
-
accounts: {
|
|
5877
|
-
keeper: this.wallet.publicKey,
|
|
5878
|
-
pythSolanaReceiver: config_1.DRIFT_ORACLE_RECEIVER_ID,
|
|
5879
|
-
guardianSet,
|
|
5880
|
-
},
|
|
5881
|
-
remainingAccounts,
|
|
5882
|
-
}));
|
|
5883
|
-
}
|
|
5884
|
-
else {
|
|
5885
|
-
let feedIdToUse = typeof feedIds === 'string' ? feedIds : feedIds[0];
|
|
5886
|
-
feedIdToUse = (0, pythOracleUtils_1.trimFeedId)(feedIdToUse);
|
|
5887
|
-
postIxs.push(await this.getSinglePostPythPullOracleAtomicIx({
|
|
5888
|
-
vaa: trimmedVaa,
|
|
5889
|
-
merklePriceUpdate: accumulatorUpdateData.updates[0],
|
|
5890
|
-
}, feedIdToUse, guardianSet));
|
|
5891
|
-
}
|
|
5892
|
-
return postIxs;
|
|
5893
|
-
}
|
|
5894
|
-
async getSinglePostPythPullOracleAtomicIx(params, feedId, guardianSet) {
|
|
5895
|
-
const feedIdBuffer = (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId);
|
|
5896
|
-
const receiverProgram = this.getReceiverProgram();
|
|
5897
|
-
const encodedParams = receiverProgram.coder.types.encode('PostUpdateAtomicParams', params);
|
|
5898
|
-
return this.program.instruction.postPythPullOracleUpdateAtomic(feedIdBuffer, encodedParams, {
|
|
5899
|
-
accounts: {
|
|
5900
|
-
keeper: this.wallet.publicKey,
|
|
5901
|
-
pythSolanaReceiver: config_1.DRIFT_ORACLE_RECEIVER_ID,
|
|
5902
|
-
guardianSet,
|
|
5903
|
-
priceFeed: (0, pda_1.getPythPullOraclePublicKey)(this.program.programId, feedIdBuffer),
|
|
5904
|
-
},
|
|
5905
|
-
});
|
|
5906
|
-
}
|
|
5907
|
-
async updatePythPullOracle(vaaString, feedId) {
|
|
5908
|
-
feedId = (0, pythOracleUtils_1.trimFeedId)(feedId);
|
|
5909
|
-
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(vaaString, 'base64'));
|
|
5910
|
-
const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
|
|
5911
|
-
const guardianSet = (0, pyth_1.getGuardianSetPda)(guardianSetIndex, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID);
|
|
5912
|
-
const [postIxs, encodedVaaAddress] = await this.getBuildEncodedVaaIxs(accumulatorUpdateData.vaa, guardianSet);
|
|
5913
|
-
for (const update of accumulatorUpdateData.updates) {
|
|
5914
|
-
postIxs.push(await this.getUpdatePythPullOracleIxs({
|
|
5915
|
-
merklePriceUpdate: update,
|
|
5916
|
-
}, feedId, encodedVaaAddress.publicKey));
|
|
5917
|
-
}
|
|
5918
|
-
const tx = await this.buildTransaction(postIxs);
|
|
5919
|
-
const { txSig } = await this.sendTransaction(tx, [encodedVaaAddress], this.opts);
|
|
5920
|
-
return txSig;
|
|
5921
|
-
}
|
|
5922
|
-
async getUpdatePythPullOracleIxs(params, feedId, encodedVaaAddress) {
|
|
5923
|
-
const feedIdBuffer = (0, pythOracleUtils_1.getFeedIdUint8Array)(feedId);
|
|
5924
|
-
const receiverProgram = this.getReceiverProgram();
|
|
5925
|
-
const encodedParams = receiverProgram.coder.types.encode('PostUpdateParams', params);
|
|
5926
|
-
return this.program.instruction.updatePythPullOracle(feedIdBuffer, encodedParams, {
|
|
5927
|
-
accounts: {
|
|
5928
|
-
keeper: this.wallet.publicKey,
|
|
5929
|
-
pythSolanaReceiver: config_1.DRIFT_ORACLE_RECEIVER_ID,
|
|
5930
|
-
encodedVaa: encodedVaaAddress,
|
|
5931
|
-
priceFeed: (0, pda_1.getPythPullOraclePublicKey)(this.program.programId, feedIdBuffer),
|
|
5932
|
-
},
|
|
5933
|
-
});
|
|
5934
|
-
}
|
|
5935
5613
|
async postPythLazerOracleUpdate(feedIds, pythMessageHex) {
|
|
5936
5614
|
const postIxs = await this.getPostPythLazerOracleUpdateIxs(feedIds, pythMessageHex, undefined, 2);
|
|
5937
5615
|
const tx = await this.buildTransaction(postIxs);
|
|
@@ -5958,161 +5636,6 @@ class DriftClient {
|
|
|
5958
5636
|
});
|
|
5959
5637
|
return [verifyIx, ix];
|
|
5960
5638
|
}
|
|
5961
|
-
async getPostManySwitchboardOnDemandUpdatesAtomicIxs(feeds, recentSlothash, numSignatures = 3) {
|
|
5962
|
-
const program = await this.getSwitchboardOnDemandProgram();
|
|
5963
|
-
const [pullIxs, _luts, _rawResponse] = await on_demand_1.PullFeed.fetchUpdateManyLightIx(program, {
|
|
5964
|
-
feeds,
|
|
5965
|
-
numSignatures,
|
|
5966
|
-
recentSlothashes: recentSlothash
|
|
5967
|
-
? [[new anchor_1.BN(recentSlothash.slot), recentSlothash.hash]]
|
|
5968
|
-
: undefined,
|
|
5969
|
-
chain: 'solana',
|
|
5970
|
-
network: this.env,
|
|
5971
|
-
});
|
|
5972
|
-
if (!pullIxs) {
|
|
5973
|
-
return undefined;
|
|
5974
|
-
}
|
|
5975
|
-
return pullIxs;
|
|
5976
|
-
}
|
|
5977
|
-
// @deprecated use getPostManySwitchboardOnDemandUpdatesAtomicIxs instead. This function no longer returns the required ixs due to upstream sdk changes.
|
|
5978
|
-
async getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures = 3) {
|
|
5979
|
-
const program = await this.getSwitchboardOnDemandProgram();
|
|
5980
|
-
const feedAccount = new on_demand_1.PullFeed(program, feed);
|
|
5981
|
-
if (!this.sbProgramFeedConfigs) {
|
|
5982
|
-
this.sbProgramFeedConfigs = new Map();
|
|
5983
|
-
}
|
|
5984
|
-
if (!this.sbProgramFeedConfigs.has(feedAccount.pubkey.toString())) {
|
|
5985
|
-
const feedConfig = await feedAccount.loadConfigs();
|
|
5986
|
-
this.sbProgramFeedConfigs.set(feed.toString(), feedConfig);
|
|
5987
|
-
}
|
|
5988
|
-
const [pullIx, _responses, success] = await on_demand_1.PullFeed.fetchUpdateManyIx(program, {
|
|
5989
|
-
feeds: [feed],
|
|
5990
|
-
numSignatures,
|
|
5991
|
-
recentSlothashes: recentSlothash
|
|
5992
|
-
? [[new anchor_1.BN(recentSlothash.slot), recentSlothash.hash]]
|
|
5993
|
-
: undefined,
|
|
5994
|
-
});
|
|
5995
|
-
if (!success) {
|
|
5996
|
-
return undefined;
|
|
5997
|
-
}
|
|
5998
|
-
return pullIx[0];
|
|
5999
|
-
}
|
|
6000
|
-
async postSwitchboardOnDemandUpdate(feed, recentSlothash, numSignatures = 3) {
|
|
6001
|
-
const pullIx = await this.getPostSwitchboardOnDemandUpdateAtomicIx(feed, recentSlothash, numSignatures);
|
|
6002
|
-
if (!pullIx) {
|
|
6003
|
-
return undefined;
|
|
6004
|
-
}
|
|
6005
|
-
const tx = await (0, on_demand_1.asV0Tx)({
|
|
6006
|
-
connection: this.connection,
|
|
6007
|
-
ixs: [pullIx],
|
|
6008
|
-
payer: this.wallet.publicKey,
|
|
6009
|
-
computeUnitLimitMultiple: 1.3,
|
|
6010
|
-
lookupTables: await this.fetchAllLookupTableAccounts(),
|
|
6011
|
-
});
|
|
6012
|
-
const { txSig } = await this.sendTransaction(tx, [], {
|
|
6013
|
-
commitment: 'processed',
|
|
6014
|
-
skipPreflight: true,
|
|
6015
|
-
maxRetries: 0,
|
|
6016
|
-
});
|
|
6017
|
-
return txSig;
|
|
6018
|
-
}
|
|
6019
|
-
async getBuildEncodedVaaIxs(vaa, guardianSet) {
|
|
6020
|
-
const postIxs = [];
|
|
6021
|
-
if (this.wormholeProgram === undefined) {
|
|
6022
|
-
this.wormholeProgram = new anchor_1.Program(pyth_1.WORMHOLE_CORE_BRIDGE_SOLANA_IDL, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID, this.provider);
|
|
6023
|
-
}
|
|
6024
|
-
const encodedVaaKeypair = new web3_js_1.Keypair();
|
|
6025
|
-
postIxs.push(await this.wormholeProgram.account.encodedVaa.createInstruction(encodedVaaKeypair, vaa.length + 46));
|
|
6026
|
-
// Why do we need this too?
|
|
6027
|
-
postIxs.push(await this.wormholeProgram.methods
|
|
6028
|
-
.initEncodedVaa()
|
|
6029
|
-
.accounts({
|
|
6030
|
-
encodedVaa: encodedVaaKeypair.publicKey,
|
|
6031
|
-
})
|
|
6032
|
-
.instruction());
|
|
6033
|
-
// Split the write into two ixs
|
|
6034
|
-
postIxs.push(await this.wormholeProgram.methods
|
|
6035
|
-
.writeEncodedVaa({
|
|
6036
|
-
index: 0,
|
|
6037
|
-
data: vaa.subarray(0, 755),
|
|
6038
|
-
})
|
|
6039
|
-
.accounts({
|
|
6040
|
-
draftVaa: encodedVaaKeypair.publicKey,
|
|
6041
|
-
})
|
|
6042
|
-
.instruction());
|
|
6043
|
-
postIxs.push(await this.wormholeProgram.methods
|
|
6044
|
-
.writeEncodedVaa({
|
|
6045
|
-
index: 755,
|
|
6046
|
-
data: vaa.subarray(755),
|
|
6047
|
-
})
|
|
6048
|
-
.accounts({
|
|
6049
|
-
draftVaa: encodedVaaKeypair.publicKey,
|
|
6050
|
-
})
|
|
6051
|
-
.instruction());
|
|
6052
|
-
// Verify
|
|
6053
|
-
postIxs.push(await this.wormholeProgram.methods
|
|
6054
|
-
.verifyEncodedVaaV1()
|
|
6055
|
-
.accounts({
|
|
6056
|
-
guardianSet,
|
|
6057
|
-
draftVaa: encodedVaaKeypair.publicKey,
|
|
6058
|
-
})
|
|
6059
|
-
.instruction());
|
|
6060
|
-
return [postIxs, encodedVaaKeypair];
|
|
6061
|
-
}
|
|
6062
|
-
async enableUserHighLeverageMode(subAccountId, txParams) {
|
|
6063
|
-
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getEnableHighLeverageModeIx(subAccountId), txParams), [], this.opts);
|
|
6064
|
-
return txSig;
|
|
6065
|
-
}
|
|
6066
|
-
async getEnableHighLeverageModeIx(subAccountId, depositToTradeArgs, overrides) {
|
|
6067
|
-
var _a, _b, _c, _d;
|
|
6068
|
-
const isDepositToTradeTx = depositToTradeArgs !== undefined;
|
|
6069
|
-
const userAccountPublicKey = (_b = (_a = overrides === null || overrides === void 0 ? void 0 : overrides.user) === null || _a === void 0 ? void 0 : _a.getUserAccountPublicKey()) !== null && _b !== void 0 ? _b : (0, pda_1.getUserAccountPublicKeySync)(this.program.programId, this.wallet.publicKey, subAccountId);
|
|
6070
|
-
const signingAuthority = (_c = overrides === null || overrides === void 0 ? void 0 : overrides.signingAuthority) !== null && _c !== void 0 ? _c : this.wallet.publicKey;
|
|
6071
|
-
const userAccount = (_d = overrides === null || overrides === void 0 ? void 0 : overrides.user.getUserAccount()) !== null && _d !== void 0 ? _d : this.getUserAccount(subAccountId);
|
|
6072
|
-
const remainingAccounts = this.getRemainingAccounts({
|
|
6073
|
-
userAccounts: (depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.isMakingNewAccount) ? [] : [userAccount],
|
|
6074
|
-
useMarketLastSlotCache: false,
|
|
6075
|
-
readablePerpMarketIndex: depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.orderMarketIndex,
|
|
6076
|
-
readableSpotMarketIndexes: isDepositToTradeTx
|
|
6077
|
-
? [depositToTradeArgs === null || depositToTradeArgs === void 0 ? void 0 : depositToTradeArgs.depositMarketIndex]
|
|
6078
|
-
: undefined,
|
|
6079
|
-
});
|
|
6080
|
-
const ix = await this.program.instruction.enableUserHighLeverageMode(subAccountId, {
|
|
6081
|
-
accounts: {
|
|
6082
|
-
state: await this.getStatePublicKey(),
|
|
6083
|
-
user: userAccountPublicKey,
|
|
6084
|
-
authority: signingAuthority,
|
|
6085
|
-
highLeverageModeConfig: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
6086
|
-
},
|
|
6087
|
-
remainingAccounts,
|
|
6088
|
-
});
|
|
6089
|
-
return ix;
|
|
6090
|
-
}
|
|
6091
|
-
async disableUserHighLeverageMode(user, userAccount, txParams) {
|
|
6092
|
-
const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getDisableHighLeverageModeIx(user, userAccount), txParams), [], this.opts);
|
|
6093
|
-
return txSig;
|
|
6094
|
-
}
|
|
6095
|
-
async getDisableHighLeverageModeIx(user, userAccount, maintenance = false) {
|
|
6096
|
-
const remainingAccounts = userAccount
|
|
6097
|
-
? this.getRemainingAccounts({
|
|
6098
|
-
userAccounts: [userAccount],
|
|
6099
|
-
})
|
|
6100
|
-
: undefined;
|
|
6101
|
-
const ix = await this.program.instruction.disableUserHighLeverageMode(maintenance, {
|
|
6102
|
-
accounts: {
|
|
6103
|
-
state: await this.getStatePublicKey(),
|
|
6104
|
-
user,
|
|
6105
|
-
authority: this.wallet.publicKey,
|
|
6106
|
-
highLeverageModeConfig: (0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId),
|
|
6107
|
-
},
|
|
6108
|
-
remainingAccounts,
|
|
6109
|
-
});
|
|
6110
|
-
return ix;
|
|
6111
|
-
}
|
|
6112
|
-
async fetchHighLeverageModeConfig() {
|
|
6113
|
-
const config = await this.program.account.highLeverageModeConfig.fetch((0, pda_1.getHighLeverageModeConfigPublicKey)(this.program.programId));
|
|
6114
|
-
return config;
|
|
6115
|
-
}
|
|
6116
5639
|
async fetchProtectedMakerModeConfig() {
|
|
6117
5640
|
const config = await this.program.account.protectedMakerModeConfig.fetch((0, pda_1.getProtectedMakerModeConfigPublicKey)(this.program.programId));
|
|
6118
5641
|
return config;
|