@velocity-exchange/sdk 0.0.5 → 0.1.0
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 -1
- package/CHANGELOG.md +20 -0
- package/README.md +30 -30
- package/bun.lock +1 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +1 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
- package/lib/browser/accounts/types.d.ts +2 -8
- package/lib/browser/accounts/utils.js +2 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/browser/addresses/pda.d.ts +1 -7
- package/lib/browser/addresses/pda.js +4 -10
- package/lib/browser/adminClient.d.ts +1 -1
- package/lib/browser/adminClient.js +21 -21
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -3
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +2 -6
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
- package/lib/browser/auctionSubscriber/types.d.ts +3 -2
- package/lib/browser/config.d.ts +10 -19
- package/lib/browser/config.js +6 -33
- package/lib/browser/constants/insuranceFund.d.ts +1 -1
- package/lib/browser/constants/insuranceFund.js +1 -1
- package/lib/browser/constituentMap/constituentMap.d.ts +0 -2
- package/lib/browser/constituentMap/constituentMap.js +5 -5
- package/lib/browser/core/VelocityCore.d.ts +9 -15
- package/lib/browser/core/VelocityCore.js +5 -7
- package/lib/browser/core/instructions/withdraw.d.ts +1 -1
- package/lib/browser/core/instructions/withdraw.js +1 -1
- package/lib/browser/core/remainingAccounts.js +3 -3
- package/lib/browser/dlob/DLOB.d.ts +1 -1
- package/lib/browser/dlob/DLOB.js +6 -6
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
- package/lib/browser/dlob/DLOBSubscriber.js +2 -7
- package/lib/browser/dlob/orderBookLevels.js +7 -7
- package/lib/browser/dlob/types.d.ts +0 -2
- package/lib/browser/events/eventSubscriber.d.ts +1 -1
- package/lib/browser/events/eventsServerLogProvider.js +2 -2
- package/lib/browser/events/parse.js +14 -14
- package/lib/browser/events/types.d.ts +3 -5
- package/lib/browser/events/types.js +1 -1
- package/lib/browser/idl/{drift.d.ts → velocity.d.ts} +1042 -767
- package/lib/browser/idl/{drift.json → velocity.json} +1033 -758
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -2
- package/lib/browser/math/amm.d.ts +10 -10
- package/lib/browser/math/amm.js +29 -28
- package/lib/browser/math/auction.js +16 -12
- package/lib/browser/math/builder.d.ts +18 -1
- package/lib/browser/math/builder.js +32 -1
- package/lib/browser/math/funding.js +26 -26
- package/lib/browser/math/margin.d.ts +4 -4
- package/lib/browser/math/margin.js +15 -15
- package/lib/browser/math/market.js +13 -13
- package/lib/browser/math/oracles.d.ts +4 -4
- package/lib/browser/math/oracles.js +23 -23
- package/lib/browser/math/orders.d.ts +2 -2
- package/lib/browser/math/orders.js +9 -9
- package/lib/browser/math/position.js +4 -4
- package/lib/browser/math/superStake.d.ts +8 -10
- package/lib/browser/math/superStake.js +18 -20
- package/lib/browser/math/trade.js +5 -5
- package/lib/browser/math/utils.d.ts +1 -1
- package/lib/browser/math/utils.js +1 -1
- package/lib/browser/oracles/pythLazerClient.js +2 -2
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +0 -2
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -12
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/types.d.ts +0 -2
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -5
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +7 -15
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/browser/priorityFee/types.d.ts +3 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/browser/pyth/pythLazerSubscriber.js +1 -1
- package/lib/browser/swap/UnifiedSwapClient.js +1 -1
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +2 -6
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +6 -5
- package/lib/browser/swift/swiftOrderSubscriber.js +5 -11
- package/lib/browser/types.d.ts +79 -91
- package/lib/browser/types.js +4 -0
- package/lib/browser/user.d.ts +1 -3
- package/lib/browser/user.js +19 -23
- package/lib/browser/userConfig.d.ts +3 -2
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/referrerMap.d.ts +0 -2
- package/lib/browser/userMap/referrerMap.js +0 -4
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/browser/userMap/revenueShareEscrowMap.js +0 -4
- package/lib/browser/userMap/userMap.d.ts +2 -4
- package/lib/browser/userMap/userMap.js +10 -14
- package/lib/browser/userMap/userMapConfig.d.ts +3 -2
- package/lib/browser/userMap/userStatsMap.d.ts +0 -2
- package/lib/browser/userMap/userStatsMap.js +0 -4
- package/lib/browser/userStats.d.ts +0 -2
- package/lib/browser/userStats.js +10 -14
- package/lib/browser/userStatsConfig.d.ts +3 -2
- package/lib/browser/util/ed25519Utils.d.ts +1 -1
- package/lib/browser/util/ed25519Utils.js +1 -1
- package/lib/browser/velocityClient.d.ts +53 -38
- package/lib/browser/velocityClient.js +258 -196
- package/lib/browser/velocityClientConfig.d.ts +0 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/node/accounts/laserProgramAccountSubscriber.js +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
- package/lib/node/accounts/types.d.ts +2 -8
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +2 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/node/addresses/pda.d.ts +1 -7
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +4 -10
- package/lib/node/adminClient.d.ts +1 -1
- package/lib/node/adminClient.js +21 -21
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -3
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +2 -6
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
- package/lib/node/auctionSubscriber/types.d.ts +3 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/config.d.ts +10 -19
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +6 -33
- package/lib/node/constants/insuranceFund.d.ts +1 -1
- package/lib/node/constants/insuranceFund.js +1 -1
- package/lib/node/constituentMap/constituentMap.d.ts +0 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -5
- package/lib/node/core/VelocityCore.d.ts +9 -15
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +5 -7
- package/lib/node/core/instructions/withdraw.d.ts +1 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +1 -1
- package/lib/node/core/remainingAccounts.js +3 -3
- package/lib/node/dlob/DLOB.d.ts +1 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +6 -6
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -2
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +2 -7
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +7 -7
- package/lib/node/dlob/types.d.ts +0 -2
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +1 -1
- package/lib/node/events/eventsServerLogProvider.js +2 -2
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +14 -14
- package/lib/node/events/types.d.ts +3 -5
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +1 -1
- package/lib/node/idl/{drift.d.ts → velocity.d.ts} +1043 -768
- package/lib/node/idl/velocity.d.ts.map +1 -0
- package/lib/node/idl/{drift.json → velocity.json} +1033 -758
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -2
- package/lib/node/math/amm.d.ts +10 -10
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +29 -28
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +16 -12
- package/lib/node/math/builder.d.ts +18 -1
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +32 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +26 -26
- package/lib/node/math/margin.d.ts +4 -4
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +15 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +13 -13
- package/lib/node/math/oracles.d.ts +4 -4
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +23 -23
- package/lib/node/math/orders.d.ts +2 -2
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +9 -9
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +4 -4
- package/lib/node/math/superStake.d.ts +8 -10
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +18 -20
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +5 -5
- package/lib/node/math/utils.d.ts +1 -1
- package/lib/node/math/utils.js +1 -1
- package/lib/node/oracles/pythLazerClient.js +2 -2
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +0 -2
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -12
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/types.d.ts +0 -2
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -5
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +7 -15
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/node/priorityFee/types.d.ts +3 -8
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/node/pyth/pythLazerSubscriber.js +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +2 -6
- package/lib/node/swift/swiftOrderSubscriber.d.ts +6 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +5 -11
- package/lib/node/types.d.ts +79 -91
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +4 -0
- package/lib/node/user.d.ts +1 -3
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +19 -23
- package/lib/node/userConfig.d.ts +3 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +1 -1
- package/lib/node/userMap/grpcSubscription.js +1 -1
- package/lib/node/userMap/referrerMap.d.ts +0 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +0 -4
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +0 -4
- package/lib/node/userMap/userMap.d.ts +2 -4
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +10 -14
- package/lib/node/userMap/userMapConfig.d.ts +3 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +0 -2
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +0 -4
- package/lib/node/userStats.d.ts +0 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +10 -14
- package/lib/node/userStatsConfig.d.ts +3 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.d.ts +1 -1
- package/lib/node/util/ed25519Utils.js +1 -1
- package/lib/node/velocityClient.d.ts +53 -38
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +258 -196
- package/lib/node/velocityClientConfig.d.ts +0 -8
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +6 -7
- package/scripts/deposit-isolated-positions.ts +2 -2
- package/scripts/find-flagged-users.ts +1 -1
- package/scripts/grpc-client-test-comparison.ts +4 -4
- package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
- package/scripts/single-grpc-client-test.ts +3 -3
- package/scripts/updateVersion.js +4 -4
- package/scripts/withdraw-isolated-positions.ts +2 -2
- package/src/accounts/grpcProgramAccountSubscriber.ts +1 -1
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +0 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +4 -11
- package/src/accounts/laserProgramAccountSubscriber.ts +1 -1
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +4 -11
- package/src/accounts/types.ts +2 -9
- package/src/accounts/utils.ts +2 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +4 -11
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +4 -11
- package/src/addresses/pda.ts +3 -13
- package/src/adminClient.ts +21 -21
- package/src/auctionSubscriber/auctionSubscriber.ts +1 -6
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +1 -6
- package/src/auctionSubscriber/types.ts +3 -3
- package/src/config.ts +8 -67
- package/src/constants/insuranceFund.ts +1 -1
- package/src/constituentMap/constituentMap.ts +2 -6
- package/src/core/VelocityCore.ts +11 -20
- package/src/core/instructions/withdraw.ts +2 -2
- package/src/core/remainingAccounts.ts +3 -3
- package/src/dlob/DLOB.ts +6 -6
- package/src/dlob/DLOBSubscriber.ts +2 -8
- package/src/dlob/orderBookLevels.ts +12 -6
- package/src/dlob/types.ts +0 -2
- package/src/events/eventSubscriber.ts +1 -1
- package/src/events/eventsServerLogProvider.ts +2 -2
- package/src/events/parse.ts +14 -14
- package/src/events/types.ts +4 -7
- package/src/idl/{drift.json → velocity.json} +1033 -758
- package/src/idl/{drift.ts → velocity.ts} +1035 -760
- package/src/index.ts +1 -4
- package/src/margin/README.md +2 -2
- package/src/math/amm.ts +43 -21
- package/src/math/auction.ts +16 -12
- package/src/math/builder.ts +45 -1
- package/src/math/funding.ts +46 -43
- package/src/math/margin.ts +15 -15
- package/src/math/market.ts +21 -13
- package/src/math/oracles.ts +29 -26
- package/src/math/orders.ts +18 -5
- package/src/math/position.ts +9 -3
- package/src/math/superStake.ts +21 -24
- package/src/math/trade.ts +9 -1
- package/src/math/utils.ts +1 -1
- package/src/oracles/pythLazerClient.ts +3 -3
- package/src/orderSubscriber/OrderSubscriber.ts +2 -8
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/types.ts +0 -2
- package/src/priorityFee/priorityFeeSubscriber.ts +5 -12
- package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
- package/src/priorityFee/types.ts +3 -13
- package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
- package/src/pyth/pythLazerSubscriber.ts +1 -1
- package/src/swap/UnifiedSwapClient.ts +1 -1
- package/src/swift/signedMsgUserAccountSubscriber.ts +2 -8
- package/src/swift/swiftOrderSubscriber.ts +7 -12
- package/src/types.ts +84 -102
- package/src/user.ts +9 -14
- package/src/userConfig.ts +1 -3
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +0 -4
- package/src/userMap/revenueShareEscrowMap.ts +0 -4
- package/src/userMap/userMap.ts +3 -7
- package/src/userMap/userMapConfig.ts +3 -3
- package/src/userMap/userStatsMap.ts +0 -4
- package/src/userStats.ts +1 -5
- package/src/userStatsConfig.ts +3 -3
- package/src/util/ed25519Utils.ts +1 -1
- package/src/velocityClient.ts +339 -225
- package/src/velocityClientConfig.ts +0 -10
- package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
- package/tests/ci/verifyConstants.ts +24 -27
- package/tests/decode/test.ts +2 -2
- package/tests/dlob/helpers.ts +5 -9
- package/tests/events/parseLogsForCuUsage.ts +15 -15
- package/tests/user/helpers.ts +9 -9
- package/tests/user/test.ts +13 -10
- package/lib/browser/util/deprecatedAlias.d.ts +0 -26
- package/lib/browser/util/deprecatedAlias.js +0 -10
- package/lib/node/idl/drift.d.ts.map +0 -1
- package/lib/node/util/deprecatedAlias.d.ts +0 -27
- package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
- package/lib/node/util/deprecatedAlias.js +0 -10
- package/src/util/deprecatedAlias.ts +0 -21
- /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
- /package/lib/node/idl/{drift.js → velocity.js} +0 -0
- /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
|
@@ -19,12 +19,12 @@ class grpcSubscription {
|
|
|
19
19
|
}
|
|
20
20
|
if (this.grpcConfigs.client === 'laser') {
|
|
21
21
|
this.subscriber =
|
|
22
|
-
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.
|
|
22
|
+
await laserProgramAccountSubscriber_1.LaserstreamProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.velocityClient.program, this.orderSubscriber.decodeFn, {
|
|
23
23
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
24
24
|
}, this.resubOpts);
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
|
-
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.
|
|
27
|
+
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'OrderSubscriber', 'user', this.orderSubscriber.velocityClient.program, this.orderSubscriber.decodeFn, {
|
|
28
28
|
filters: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getNonIdleUserFilter)()],
|
|
29
29
|
}, this.resubOpts);
|
|
30
30
|
}
|
|
@@ -4,8 +4,6 @@ import { VelocityClient } from '../velocityClient';
|
|
|
4
4
|
import { GrpcConfigs } from '../accounts/types';
|
|
5
5
|
export type OrderSubscriberConfig = {
|
|
6
6
|
velocityClient?: VelocityClient;
|
|
7
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
-
driftClient?: VelocityClient;
|
|
9
7
|
subscriptionConfig: {
|
|
10
8
|
type: 'polling';
|
|
11
9
|
frequency: number;
|
|
@@ -9,8 +9,6 @@ export declare class PriorityFeeSubscriber {
|
|
|
9
9
|
frequencyMs: number;
|
|
10
10
|
addresses: string[];
|
|
11
11
|
velocityMarkets?: VelocityMarketInfo[];
|
|
12
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
13
|
-
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
14
12
|
customStrategy?: PriorityFeeStrategy;
|
|
15
13
|
averageStrategy: AverageOverSlotsStrategy;
|
|
16
14
|
maxStrategy: MaxOverSlotsStrategy;
|
|
@@ -19,8 +17,6 @@ export declare class PriorityFeeSubscriber {
|
|
|
19
17
|
maxFeeMicroLamports?: number;
|
|
20
18
|
priorityFeeMultiplier?: number;
|
|
21
19
|
velocityPriorityFeeEndpoint?: string;
|
|
22
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
23
|
-
get driftPriorityFeeEndpoint(): string | undefined;
|
|
24
20
|
heliusRpcUrl?: string;
|
|
25
21
|
lastHeliusSample?: HeliusPriorityFeeLevels;
|
|
26
22
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
@@ -33,7 +29,7 @@ export declare class PriorityFeeSubscriber {
|
|
|
33
29
|
subscribe(): Promise<void>;
|
|
34
30
|
private loadForSolana;
|
|
35
31
|
private loadForHelius;
|
|
36
|
-
private
|
|
32
|
+
private loadForVelocity;
|
|
37
33
|
getMaxPriorityFee(): number | undefined;
|
|
38
34
|
updateMaxPriorityFee(newMaxFee: number | undefined): void;
|
|
39
35
|
getPriorityFeeMultiplier(): number;
|
|
@@ -8,16 +8,8 @@ const solanaPriorityFeeMethod_1 = require("./solanaPriorityFeeMethod");
|
|
|
8
8
|
const heliusPriorityFeeMethod_1 = require("./heliusPriorityFeeMethod");
|
|
9
9
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
10
10
|
class PriorityFeeSubscriber {
|
|
11
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
12
|
-
get driftMarkets() {
|
|
13
|
-
return this.velocityMarkets;
|
|
14
|
-
}
|
|
15
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
16
|
-
get driftPriorityFeeEndpoint() {
|
|
17
|
-
return this.velocityPriorityFeeEndpoint;
|
|
18
|
-
}
|
|
19
11
|
constructor(config) {
|
|
20
|
-
var _a, _b, _c, _d
|
|
12
|
+
var _a, _b, _c, _d;
|
|
21
13
|
this.averageStrategy = new averageOverSlotsStrategy_1.AverageOverSlotsStrategy();
|
|
22
14
|
this.maxStrategy = new maxOverSlotsStrategy_1.MaxOverSlotsStrategy();
|
|
23
15
|
this.priorityFeeMethod = types_1.PriorityFeeMethod.SOLANA;
|
|
@@ -32,14 +24,14 @@ class PriorityFeeSubscriber {
|
|
|
32
24
|
this.addresses = config.addresses
|
|
33
25
|
? config.addresses.map((address) => address.toBase58())
|
|
34
26
|
: [];
|
|
35
|
-
this.velocityMarkets =
|
|
27
|
+
this.velocityMarkets = config.velocityMarkets;
|
|
36
28
|
if (config.customStrategy) {
|
|
37
29
|
this.customStrategy = config.customStrategy;
|
|
38
30
|
}
|
|
39
31
|
else {
|
|
40
32
|
this.customStrategy = this.averageStrategy;
|
|
41
33
|
}
|
|
42
|
-
this.lookbackDistance = (
|
|
34
|
+
this.lookbackDistance = (_b = config.slotsToCheck) !== null && _b !== void 0 ? _b : 50;
|
|
43
35
|
if (config.priorityFeeMethod) {
|
|
44
36
|
this.priorityFeeMethod = config.priorityFeeMethod;
|
|
45
37
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
@@ -57,7 +49,7 @@ class PriorityFeeSubscriber {
|
|
|
57
49
|
}
|
|
58
50
|
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
59
51
|
this.velocityPriorityFeeEndpoint =
|
|
60
|
-
(
|
|
52
|
+
(_c = config.velocityPriorityFeeEndpoint) !== null && _c !== void 0 ? _c : config.velocityPriorityFeeEndpoint;
|
|
61
53
|
}
|
|
62
54
|
}
|
|
63
55
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.SOLANA) {
|
|
@@ -66,7 +58,7 @@ class PriorityFeeSubscriber {
|
|
|
66
58
|
}
|
|
67
59
|
}
|
|
68
60
|
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
69
|
-
this.priorityFeeMultiplier = (
|
|
61
|
+
this.priorityFeeMultiplier = (_d = config.priorityFeeMultiplier) !== null && _d !== void 0 ? _d : 1.0;
|
|
70
62
|
}
|
|
71
63
|
async subscribe() {
|
|
72
64
|
if (this.intervalId) {
|
|
@@ -101,7 +93,7 @@ class PriorityFeeSubscriber {
|
|
|
101
93
|
}
|
|
102
94
|
}
|
|
103
95
|
}
|
|
104
|
-
async
|
|
96
|
+
async loadForVelocity() {
|
|
105
97
|
if (!this.velocityMarkets) {
|
|
106
98
|
return;
|
|
107
99
|
}
|
|
@@ -169,7 +161,7 @@ class PriorityFeeSubscriber {
|
|
|
169
161
|
await this.loadForHelius();
|
|
170
162
|
}
|
|
171
163
|
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
172
|
-
await this.
|
|
164
|
+
await this.loadForVelocity();
|
|
173
165
|
}
|
|
174
166
|
else {
|
|
175
167
|
throw new Error(`${this.priorityFeeMethod} load not implemented`);
|
|
@@ -7,11 +7,7 @@ export declare class PriorityFeeSubscriberMap {
|
|
|
7
7
|
frequencyMs: number;
|
|
8
8
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
9
9
|
velocityMarkets?: VelocityMarketInfo[];
|
|
10
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
-
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
12
10
|
velocityPriorityFeeEndpoint: string;
|
|
13
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
14
|
-
get driftPriorityFeeEndpoint(): string;
|
|
15
11
|
feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>;
|
|
16
12
|
constructor(config: PriorityFeeSubscriberMapConfig);
|
|
17
13
|
private updateFeesMap;
|
|
@@ -7,21 +7,13 @@ const types_1 = require("./types");
|
|
|
7
7
|
* takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
|
|
8
8
|
*/
|
|
9
9
|
class PriorityFeeSubscriberMap {
|
|
10
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
-
get driftMarkets() {
|
|
12
|
-
return this.velocityMarkets;
|
|
13
|
-
}
|
|
14
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
15
|
-
get driftPriorityFeeEndpoint() {
|
|
16
|
-
return this.velocityPriorityFeeEndpoint;
|
|
17
|
-
}
|
|
18
10
|
constructor(config) {
|
|
19
|
-
var _a, _b
|
|
11
|
+
var _a, _b;
|
|
20
12
|
this.frequencyMs =
|
|
21
13
|
(_a = config.frequencyMs) !== null && _a !== void 0 ? _a : types_1.DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
|
|
22
14
|
// Type-system guarantees at least one of the two is supplied.
|
|
23
|
-
this.velocityPriorityFeeEndpoint = ((_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.
|
|
24
|
-
this.velocityMarkets =
|
|
15
|
+
this.velocityPriorityFeeEndpoint = ((_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.velocityPriorityFeeEndpoint);
|
|
16
|
+
this.velocityMarkets = config.velocityMarkets;
|
|
25
17
|
this.feesMap = new Map();
|
|
26
18
|
this.feesMap.set('perp', new Map());
|
|
27
19
|
this.feesMap.set('spot', new Map());
|
|
@@ -2,7 +2,6 @@ import { Connection, PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import { SolanaPriorityFeeResponse } from './solanaPriorityFeeMethod';
|
|
3
3
|
import { HeliusPriorityFeeResponse } from './heliusPriorityFeeMethod';
|
|
4
4
|
import { VelocityMarketInfo, VelocityPriorityFeeResponse } from './velocityPriorityFeeMethod';
|
|
5
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
6
5
|
export declare const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10000;
|
|
7
6
|
export interface PriorityFeeStrategy {
|
|
8
7
|
calculate(samples: SolanaPriorityFeeResponse[] | HeliusPriorityFeeResponse | VelocityPriorityFeeResponse): number;
|
|
@@ -17,23 +16,19 @@ export type PriorityFeeSubscriberConfig = {
|
|
|
17
16
|
frequencyMs?: number;
|
|
18
17
|
addresses?: PublicKey[];
|
|
19
18
|
velocityMarkets?: VelocityMarketInfo[];
|
|
20
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
21
|
-
driftMarkets?: VelocityMarketInfo[];
|
|
22
19
|
customStrategy?: PriorityFeeStrategy;
|
|
23
20
|
priorityFeeMethod?: PriorityFeeMethod;
|
|
24
21
|
slotsToCheck?: number;
|
|
25
22
|
heliusRpcUrl?: string;
|
|
26
23
|
velocityPriorityFeeEndpoint?: string;
|
|
27
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
28
|
-
driftPriorityFeeEndpoint?: string;
|
|
29
24
|
maxFeeMicroLamports?: number;
|
|
30
25
|
priorityFeeMultiplier?: number;
|
|
31
26
|
};
|
|
32
27
|
type PriorityFeeSubscriberMapConfigBase = {
|
|
33
28
|
frequencyMs?: number;
|
|
34
29
|
velocityMarkets?: VelocityMarketInfo[];
|
|
35
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
36
|
-
driftMarkets?: VelocityMarketInfo[];
|
|
37
30
|
};
|
|
38
|
-
export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase &
|
|
31
|
+
export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase & {
|
|
32
|
+
velocityPriorityFeeEndpoint: string;
|
|
33
|
+
};
|
|
39
34
|
export {};
|
|
@@ -3,19 +3,11 @@ export type VelocityMarketInfo = {
|
|
|
3
3
|
marketType: string;
|
|
4
4
|
marketIndex: number;
|
|
5
5
|
};
|
|
6
|
-
/** @deprecated Use `VelocityMarketInfo` instead. `DriftMarketInfo` will be removed in a future major. */
|
|
7
|
-
export type DriftMarketInfo = VelocityMarketInfo;
|
|
8
6
|
export type VelocityPriorityFeeLevels = {
|
|
9
7
|
[key in HeliusPriorityLevel]: number;
|
|
10
8
|
} & {
|
|
11
9
|
marketType: 'perp' | 'spot';
|
|
12
10
|
marketIndex: number;
|
|
13
11
|
};
|
|
14
|
-
/** @deprecated Use `VelocityPriorityFeeLevels` instead. `DriftPriorityFeeLevels` will be removed in a future major. */
|
|
15
|
-
export type DriftPriorityFeeLevels = VelocityPriorityFeeLevels;
|
|
16
12
|
export type VelocityPriorityFeeResponse = VelocityPriorityFeeLevels[];
|
|
17
|
-
/** @deprecated Use `VelocityPriorityFeeResponse` instead. `DriftPriorityFeeResponse` will be removed in a future major. */
|
|
18
|
-
export type DriftPriorityFeeResponse = VelocityPriorityFeeResponse;
|
|
19
13
|
export declare function fetchVelocityPriorityFee(url: string, marketTypes: string[], marketIndexes: number[]): Promise<VelocityPriorityFeeResponse>;
|
|
20
|
-
/** @deprecated Use `fetchVelocityPriorityFee` instead. `fetchDriftPriorityFee` will be removed in a future major. */
|
|
21
|
-
export declare const fetchDriftPriorityFee: typeof fetchVelocityPriorityFee;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.fetchVelocityPriorityFee = void 0;
|
|
7
7
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
8
|
async function fetchVelocityPriorityFee(url, marketTypes, marketIndexes) {
|
|
9
9
|
try {
|
|
@@ -24,5 +24,3 @@ async function fetchVelocityPriorityFee(url, marketTypes, marketIndexes) {
|
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
26
|
exports.fetchVelocityPriorityFee = fetchVelocityPriorityFee;
|
|
27
|
-
/** @deprecated Use `fetchVelocityPriorityFee` instead. `fetchDriftPriorityFee` will be removed in a future major. */
|
|
28
|
-
exports.fetchDriftPriorityFee = fetchVelocityPriorityFee;
|
|
@@ -39,7 +39,7 @@ export declare class PythLazerSubscriber {
|
|
|
39
39
|
* @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
|
|
40
40
|
* @param token - Authentication token for Pyth Lazer API
|
|
41
41
|
* @param priceFeedArrays - Array of price feed configurations to subscribe to
|
|
42
|
-
* @param env -
|
|
42
|
+
* @param env - Velocity environment (mainnet-beta, devnet, etc.)
|
|
43
43
|
* @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
|
|
44
44
|
* @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
|
|
45
45
|
* @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
|
|
@@ -13,7 +13,7 @@ class PythLazerSubscriber {
|
|
|
13
13
|
* @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
|
|
14
14
|
* @param token - Authentication token for Pyth Lazer API
|
|
15
15
|
* @param priceFeedArrays - Array of price feed configurations to subscribe to
|
|
16
|
-
* @param env -
|
|
16
|
+
* @param env - Velocity environment (mainnet-beta, devnet, etc.)
|
|
17
17
|
* @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
|
|
18
18
|
* @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
|
|
19
19
|
* @param feedProperties - Price feed properties to request. Must include both 'price' and 'exponent' (required for getPriceFromMarketIndex). Defaults to ['price', 'bestAskPrice', 'bestBidPrice', 'exponent']. Stored by copy so caller mutation does not affect this instance.
|
|
@@ -140,7 +140,7 @@ class UnifiedSwapClient {
|
|
|
140
140
|
slippageBps,
|
|
141
141
|
swapMode: isExactOut ? titanClient_1.SwapMode.ExactOut : titanClient_1.SwapMode.ExactIn,
|
|
142
142
|
onlyDirectRoutes,
|
|
143
|
-
sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for
|
|
143
|
+
sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for velocity instructions
|
|
144
144
|
});
|
|
145
145
|
swapInstructions = titanClient.getTitanInstructions({
|
|
146
146
|
transactionMessage,
|
|
@@ -6,7 +6,6 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
|
|
|
6
6
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
7
7
|
import { ResubOpts } from '../accounts/types';
|
|
8
8
|
import { VelocityClient } from '../velocityClient';
|
|
9
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
10
9
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
11
10
|
import { EventEmitter } from 'events';
|
|
12
11
|
export type SignedMsgUserOrdersAccountSubscriberConfig = {
|
|
@@ -14,15 +13,15 @@ export type SignedMsgUserOrdersAccountSubscriberConfig = {
|
|
|
14
13
|
resubOpts?: ResubOpts;
|
|
15
14
|
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
16
15
|
resyncIntervalMs?: number;
|
|
17
|
-
} &
|
|
16
|
+
} & {
|
|
17
|
+
velocityClient: VelocityClient;
|
|
18
|
+
};
|
|
18
19
|
export interface SignedMsgUserOrdersAccountSubscriberEvents {
|
|
19
20
|
onAccountUpdate: (activeSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
|
|
20
21
|
newSignedMsgOrderIds: (newSignedMsgOrderIds: SignedMsgOrderId[], authorityPubkey: PublicKey, slot: number) => void;
|
|
21
22
|
}
|
|
22
23
|
export declare class SignedMsgUserOrdersAccountSubscriber {
|
|
23
24
|
protected velocityClient: VelocityClient;
|
|
24
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
25
|
-
protected get driftClient(): VelocityClient;
|
|
26
25
|
protected commitment: Commitment;
|
|
27
26
|
protected resubOpts?: ResubOpts;
|
|
28
27
|
protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
|
|
@@ -37,7 +36,7 @@ export declare class SignedMsgUserOrdersAccountSubscriber {
|
|
|
37
36
|
fetchPromiseResolver: () => void;
|
|
38
37
|
protected subscriber: WebSocketProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
39
38
|
eventEmitter: StrictEventEmitter<EventEmitter, SignedMsgUserOrdersAccountSubscriberEvents>;
|
|
40
|
-
constructor({ velocityClient,
|
|
39
|
+
constructor({ velocityClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }: SignedMsgUserOrdersAccountSubscriberConfig);
|
|
41
40
|
subscribe(): Promise<void>;
|
|
42
41
|
fetch(): Promise<void>;
|
|
43
42
|
tryUpdateSignedMsgUserOrdersAccount(data: Buffer | SignedMsgUserOrdersAccount, dataType: 'buffer' | 'decoded', slot: number, skipEventEmitting?: boolean): void;
|
|
@@ -5,16 +5,12 @@ const memcmp_1 = require("../memcmp");
|
|
|
5
5
|
const webSocketProgramAccountSubscriber_1 = require("../accounts/webSocketProgramAccountSubscriber");
|
|
6
6
|
const events_1 = require("events");
|
|
7
7
|
class SignedMsgUserOrdersAccountSubscriber {
|
|
8
|
-
|
|
9
|
-
get driftClient() {
|
|
10
|
-
return this.velocityClient;
|
|
11
|
-
}
|
|
12
|
-
constructor({ velocityClient, driftClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
|
|
8
|
+
constructor({ velocityClient, commitment, resubOpts, decodeFn, resyncIntervalMs, }) {
|
|
13
9
|
this.signedMsgUserOrderAccounts = new Map();
|
|
14
10
|
this.commitment = commitment !== null && commitment !== void 0 ? commitment : 'confirmed';
|
|
15
11
|
this.resubOpts = resubOpts;
|
|
16
12
|
// Type-system guarantees at least one of the two is supplied.
|
|
17
|
-
this.velocityClient =
|
|
13
|
+
this.velocityClient = velocityClient;
|
|
18
14
|
this.decodeFn =
|
|
19
15
|
decodeFn !== null && decodeFn !== void 0 ? decodeFn : this.velocityClient.program.account.signedMsgUserOrders.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.signedMsgUserOrders.coder
|
|
20
16
|
.accounts);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { VelocityClient } from '../velocityClient';
|
|
2
2
|
import { VelocityEnv } from '../config';
|
|
3
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
4
3
|
import { OptionalOrderParams, SignedMsgOrderParamsDelegateMessage, SignedMsgOrderParamsMessage, UserAccount } from '../types';
|
|
5
4
|
import { Keypair, TransactionInstruction } from '@solana/web3.js';
|
|
6
5
|
export interface AccountGetter {
|
|
@@ -11,13 +10,17 @@ type SwiftOrderSubscriberConfigBase = {
|
|
|
11
10
|
endpoint?: string;
|
|
12
11
|
marketIndexes: number[];
|
|
13
12
|
/**
|
|
14
|
-
In the future, this will be used for verifying $
|
|
13
|
+
In the future, this will be used for verifying $VELOCITY stake as we add
|
|
15
14
|
authentication for delegate signers
|
|
16
15
|
For now, pass a new keypair or a keypair to an empty wallet
|
|
17
16
|
*/
|
|
18
17
|
keypair: Keypair;
|
|
19
18
|
};
|
|
20
|
-
export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase &
|
|
19
|
+
export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase & {
|
|
20
|
+
velocityEnv: VelocityEnv;
|
|
21
|
+
} & {
|
|
22
|
+
velocityClient: VelocityClient;
|
|
23
|
+
};
|
|
21
24
|
/**
|
|
22
25
|
* Swift order message received from WebSocket
|
|
23
26
|
*/
|
|
@@ -48,8 +51,6 @@ export declare class SwiftOrderSubscriber {
|
|
|
48
51
|
private readonly heartbeatIntervalMs;
|
|
49
52
|
private ws;
|
|
50
53
|
private velocityClient;
|
|
51
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
52
|
-
private get driftClient();
|
|
53
54
|
userAccountGetter?: AccountGetter;
|
|
54
55
|
onOrder: (orderMessageRaw: SwiftOrderMessage, signedMessage: SignedMsgOrderParamsMessage | SignedMsgOrderParamsDelegateMessage, isDelegateSigner?: boolean) => Promise<void>;
|
|
55
56
|
subscribed: boolean;
|
|
@@ -13,19 +13,14 @@ const tweetnacl_util_1 = require("tweetnacl-util");
|
|
|
13
13
|
const ws_1 = __importDefault(require("ws"));
|
|
14
14
|
const sha256_1 = require("@noble/hashes/sha256");
|
|
15
15
|
class SwiftOrderSubscriber {
|
|
16
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
17
|
-
get driftClient() {
|
|
18
|
-
return this.velocityClient;
|
|
19
|
-
}
|
|
20
16
|
constructor(config) {
|
|
21
|
-
var _a;
|
|
22
17
|
this.config = config;
|
|
23
18
|
this.heartbeatTimeout = null;
|
|
24
19
|
this.heartbeatIntervalMs = 60000;
|
|
25
20
|
this.ws = null;
|
|
26
21
|
this.subscribed = false;
|
|
27
22
|
// Type-system guarantees at least one of the two is supplied.
|
|
28
|
-
this.velocityClient =
|
|
23
|
+
this.velocityClient = config.velocityClient;
|
|
29
24
|
this.userAccountGetter = config.userAccountGetter;
|
|
30
25
|
}
|
|
31
26
|
unsubscribe() {
|
|
@@ -37,8 +32,7 @@ class SwiftOrderSubscriber {
|
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
getSymbolForMarketIndex(marketIndex) {
|
|
40
|
-
|
|
41
|
-
const env = (_a = this.config.velocityEnv) !== null && _a !== void 0 ? _a : this.config.driftEnv;
|
|
35
|
+
const env = this.config.velocityEnv;
|
|
42
36
|
const markets = env === 'devnet' ? perpMarkets_1.DevnetPerpMarkets : perpMarkets_1.MainnetPerpMarkets;
|
|
43
37
|
return markets[marketIndex].symbol;
|
|
44
38
|
}
|
|
@@ -72,10 +66,10 @@ class SwiftOrderSubscriber {
|
|
|
72
66
|
}
|
|
73
67
|
}
|
|
74
68
|
async subscribe(onOrder, acceptSanitized = false, acceptDepositTrade = false) {
|
|
75
|
-
var _a
|
|
69
|
+
var _a;
|
|
76
70
|
this.onOrder = onOrder;
|
|
77
|
-
const env =
|
|
78
|
-
const endpoint = (
|
|
71
|
+
const env = this.config.velocityEnv;
|
|
72
|
+
const endpoint = (_a = this.config.endpoint) !== null && _a !== void 0 ? _a : (env === 'devnet'
|
|
79
73
|
? 'wss://master.swift.drift.trade/ws'
|
|
80
74
|
: 'wss://swift.drift.trade/ws');
|
|
81
75
|
const ws = new ws_1.default(endpoint + '?pubkey=' + this.config.keypair.publicKey.toBase58());
|