@velocity-exchange/sdk 0.0.3 → 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 +35 -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/decode/user.js +5 -5
- package/lib/browser/dlob/DLOB.d.ts +1 -1
- package/lib/browser/dlob/DLOB.js +7 -7
- package/lib/browser/dlob/DLOBNode.js +1 -2
- 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} +1043 -768
- package/lib/browser/idl/{drift.json → velocity.json} +1034 -759
- 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.d.ts +1 -1
- package/lib/browser/math/auction.js +18 -21
- 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 +12 -12
- 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 +81 -93
- 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 +59 -44
- package/lib/browser/velocityClient.js +259 -197
- 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/decode/user.js +5 -5
- 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 +7 -7
- package/lib/node/dlob/DLOBNode.js +1 -2
- 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} +1044 -769
- package/lib/node/idl/velocity.d.ts.map +1 -0
- package/lib/node/idl/{drift.json → velocity.json} +1034 -759
- 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 +1 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +18 -21
- 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 +12 -12
- 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 +81 -93
- 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 +59 -44
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +259 -197
- 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 -64
- 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/decode/user.ts +5 -5
- package/src/dlob/DLOB.ts +7 -7
- package/src/dlob/DLOBNode.ts +1 -1
- 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} +1034 -759
- package/src/idl/{drift.ts → velocity.ts} +1036 -761
- 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 +19 -22
- 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 +21 -11
- 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 +4 -9
- 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 +86 -104
- 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 +345 -231
- package/src/velocityClientConfig.ts +3 -11
- 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/auctions/test.ts +4 -4
- package/tests/ci/verifyConstants.ts +24 -27
- package/tests/decode/test.ts +3 -3
- package/tests/dlob/helpers.ts +5 -9
- package/tests/dlob/test.ts +5 -5
- package/tests/events/parseLogsForCuUsage.ts +15 -15
- package/tests/user/helpers.ts +10 -10
- 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 -25
- /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
package/src/math/trade.ts
CHANGED
|
@@ -113,6 +113,8 @@ export function calculateTradeSlippage(
|
|
|
113
113
|
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
|
|
114
114
|
calculateUpdatedAMMSpreadReserves(
|
|
115
115
|
market.amm,
|
|
116
|
+
market.marketStats,
|
|
117
|
+
market.totalExchangeFee,
|
|
116
118
|
direction,
|
|
117
119
|
mmOraclePriceData,
|
|
118
120
|
latestSlot
|
|
@@ -184,6 +186,8 @@ export function calculateTradeAcquiredAmounts(
|
|
|
184
186
|
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
|
|
185
187
|
calculateUpdatedAMMSpreadReserves(
|
|
186
188
|
market.amm,
|
|
189
|
+
market.marketStats,
|
|
190
|
+
market.totalExchangeFee,
|
|
187
191
|
direction,
|
|
188
192
|
mmOraclePriceData,
|
|
189
193
|
latestSlot
|
|
@@ -274,6 +278,8 @@ export function calculateTargetPriceTrade(
|
|
|
274
278
|
const { baseAssetReserve, quoteAssetReserve, newPeg } =
|
|
275
279
|
calculateUpdatedAMMSpreadReserves(
|
|
276
280
|
market.amm,
|
|
281
|
+
market.marketStats,
|
|
282
|
+
market.totalExchangeFee,
|
|
277
283
|
direction,
|
|
278
284
|
mmOraclePriceData,
|
|
279
285
|
latestSlot
|
|
@@ -436,6 +442,8 @@ export function calculateEstimatedPerpEntryPrice(
|
|
|
436
442
|
const { baseAssetReserve, quoteAssetReserve, sqrtK, newPeg } =
|
|
437
443
|
calculateUpdatedAMMSpreadReserves(
|
|
438
444
|
market.amm,
|
|
445
|
+
market.marketStats,
|
|
446
|
+
market.totalExchangeFee,
|
|
439
447
|
direction,
|
|
440
448
|
mmOraclePriceData,
|
|
441
449
|
new BN(slot)
|
|
@@ -451,7 +459,7 @@ export function calculateEstimatedPerpEntryPrice(
|
|
|
451
459
|
market.amm.baseAssetReserve,
|
|
452
460
|
market.amm.minBaseAssetReserve,
|
|
453
461
|
market.amm.maxBaseAssetReserve,
|
|
454
|
-
market.
|
|
462
|
+
market.orderStepSize
|
|
455
463
|
);
|
|
456
464
|
|
|
457
465
|
let ammLiquidity: BN;
|
package/src/math/utils.ts
CHANGED
|
@@ -104,7 +104,7 @@ export function isBNSafe(number: number): boolean {
|
|
|
104
104
|
/**
|
|
105
105
|
* Converts a number to BN makes sure the number is safe to convert to BN (that it does not overflow number after multiplying by precision)
|
|
106
106
|
* @param number the number to convert to BN
|
|
107
|
-
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from
|
|
107
|
+
* @param precision the BN precision to use (i.e. QUOTE_PRECISION and BASE_PRECISION from velocity sdk)
|
|
108
108
|
*/
|
|
109
109
|
export function numberToSafeBN(number: number, precision: BN): BN {
|
|
110
110
|
// check if number has decimals
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { OracleClient, OraclePriceData } from './types';
|
|
3
3
|
import { AnchorProvider, BN, Program } from '../isomorphic/anchor';
|
|
4
|
-
import {
|
|
4
|
+
import { Velocity } from '../idl/velocity';
|
|
5
5
|
import { VelocityProgram } from '../config';
|
|
6
6
|
import {
|
|
7
7
|
ONE,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
TEN,
|
|
11
11
|
} from '../constants/numericConstants';
|
|
12
12
|
import { Wallet } from '../wallet';
|
|
13
|
-
import
|
|
13
|
+
import velocityIDL from '../idl/velocity.json';
|
|
14
14
|
|
|
15
15
|
export class PythLazerClient implements OracleClient {
|
|
16
16
|
private connection: Connection;
|
|
@@ -35,7 +35,7 @@ export class PythLazerClient implements OracleClient {
|
|
|
35
35
|
commitment: connection.commitment,
|
|
36
36
|
}
|
|
37
37
|
);
|
|
38
|
-
this.program = new Program<
|
|
38
|
+
this.program = new Program<Velocity>(velocityIDL as Velocity, provider);
|
|
39
39
|
this.decodeFunc = (
|
|
40
40
|
this.program.account as any
|
|
41
41
|
).pythLazerOracle.coder.accounts.decodeUnchecked.bind(
|
|
@@ -21,10 +21,6 @@ import { ZERO } from '../constants/numericConstants';
|
|
|
21
21
|
|
|
22
22
|
export class OrderSubscriber {
|
|
23
23
|
velocityClient: VelocityClient;
|
|
24
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
25
|
-
public get driftClient(): VelocityClient {
|
|
26
|
-
return this.velocityClient;
|
|
27
|
-
}
|
|
28
24
|
usersAccounts = new Map<string, { slot: number; userAccount: UserAccount }>();
|
|
29
25
|
subscription: PollingSubscription | WebsocketSubscription | grpcSubscription;
|
|
30
26
|
commitment: Commitment;
|
|
@@ -40,11 +36,9 @@ export class OrderSubscriber {
|
|
|
40
36
|
fetchAllNonIdleUsers?: boolean;
|
|
41
37
|
|
|
42
38
|
constructor(config: OrderSubscriberConfig) {
|
|
43
|
-
const velocityClient = config.velocityClient
|
|
39
|
+
const velocityClient = config.velocityClient;
|
|
44
40
|
if (!velocityClient) {
|
|
45
|
-
throw new Error(
|
|
46
|
-
'OrderSubscriber: velocityClient (or deprecated driftClient) must be provided'
|
|
47
|
-
);
|
|
41
|
+
throw new Error('OrderSubscriber: velocityClient must be provided');
|
|
48
42
|
}
|
|
49
43
|
this.velocityClient = velocityClient;
|
|
50
44
|
this.commitment = config.subscriptionConfig.commitment || 'processed';
|
|
@@ -48,7 +48,7 @@ export class WebsocketSubscription {
|
|
|
48
48
|
this.subscriber = new WebSocketProgramAccountSubscriber<UserAccount>(
|
|
49
49
|
'OrderSubscriber',
|
|
50
50
|
'user',
|
|
51
|
-
this.orderSubscriber.
|
|
51
|
+
this.orderSubscriber.velocityClient.program,
|
|
52
52
|
this.orderSubscriber.decodeFn,
|
|
53
53
|
{
|
|
54
54
|
filters: [getUserFilter(), getNonIdleUserFilter()],
|
|
@@ -56,7 +56,7 @@ export class grpcSubscription {
|
|
|
56
56
|
this.grpcConfigs,
|
|
57
57
|
'OrderSubscriber',
|
|
58
58
|
'user',
|
|
59
|
-
this.orderSubscriber.
|
|
59
|
+
this.orderSubscriber.velocityClient.program,
|
|
60
60
|
this.orderSubscriber.decodeFn,
|
|
61
61
|
{
|
|
62
62
|
filters: [getUserFilter(), getNonIdleUserFilter()],
|
|
@@ -68,7 +68,7 @@ export class grpcSubscription {
|
|
|
68
68
|
this.grpcConfigs,
|
|
69
69
|
'OrderSubscriber',
|
|
70
70
|
'user',
|
|
71
|
-
this.orderSubscriber.
|
|
71
|
+
this.orderSubscriber.velocityClient.program,
|
|
72
72
|
this.orderSubscriber.decodeFn,
|
|
73
73
|
{
|
|
74
74
|
filters: [getUserFilter(), getNonIdleUserFilter()],
|
|
@@ -5,8 +5,6 @@ import { GrpcConfigs } from '../accounts/types';
|
|
|
5
5
|
|
|
6
6
|
export type OrderSubscriberConfig = {
|
|
7
7
|
velocityClient?: VelocityClient;
|
|
8
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
9
|
-
driftClient?: VelocityClient;
|
|
10
8
|
subscriptionConfig:
|
|
11
9
|
| {
|
|
12
10
|
type: 'polling';
|
|
@@ -23,10 +23,6 @@ export class PriorityFeeSubscriber {
|
|
|
23
23
|
frequencyMs: number;
|
|
24
24
|
addresses: string[];
|
|
25
25
|
velocityMarkets?: VelocityMarketInfo[];
|
|
26
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
27
|
-
public get driftMarkets(): VelocityMarketInfo[] | undefined {
|
|
28
|
-
return this.velocityMarkets;
|
|
29
|
-
}
|
|
30
26
|
customStrategy?: PriorityFeeStrategy;
|
|
31
27
|
averageStrategy = new AverageOverSlotsStrategy();
|
|
32
28
|
maxStrategy = new MaxOverSlotsStrategy();
|
|
@@ -36,10 +32,6 @@ export class PriorityFeeSubscriber {
|
|
|
36
32
|
priorityFeeMultiplier?: number;
|
|
37
33
|
|
|
38
34
|
velocityPriorityFeeEndpoint?: string;
|
|
39
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
40
|
-
public get driftPriorityFeeEndpoint(): string | undefined {
|
|
41
|
-
return this.velocityPriorityFeeEndpoint;
|
|
42
|
-
}
|
|
43
35
|
heliusRpcUrl?: string;
|
|
44
36
|
lastHeliusSample?: HeliusPriorityFeeLevels;
|
|
45
37
|
|
|
@@ -58,7 +50,7 @@ export class PriorityFeeSubscriber {
|
|
|
58
50
|
this.addresses = config.addresses
|
|
59
51
|
? config.addresses.map((address) => address.toBase58())
|
|
60
52
|
: [];
|
|
61
|
-
this.velocityMarkets = config.velocityMarkets
|
|
53
|
+
this.velocityMarkets = config.velocityMarkets;
|
|
62
54
|
|
|
63
55
|
if (config.customStrategy) {
|
|
64
56
|
this.customStrategy = config.customStrategy;
|
|
@@ -84,7 +76,8 @@ export class PriorityFeeSubscriber {
|
|
|
84
76
|
}
|
|
85
77
|
} else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
|
|
86
78
|
this.velocityPriorityFeeEndpoint =
|
|
87
|
-
config.velocityPriorityFeeEndpoint ??
|
|
79
|
+
config.velocityPriorityFeeEndpoint ??
|
|
80
|
+
config.velocityPriorityFeeEndpoint;
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
83
|
|
|
@@ -146,7 +139,7 @@ export class PriorityFeeSubscriber {
|
|
|
146
139
|
}
|
|
147
140
|
}
|
|
148
141
|
|
|
149
|
-
private async
|
|
142
|
+
private async loadForVelocity(): Promise<void> {
|
|
150
143
|
if (!this.velocityMarkets) {
|
|
151
144
|
return;
|
|
152
145
|
}
|
|
@@ -228,7 +221,7 @@ export class PriorityFeeSubscriber {
|
|
|
228
221
|
} else if (this.priorityFeeMethod === PriorityFeeMethod.HELIUS) {
|
|
229
222
|
await this.loadForHelius();
|
|
230
223
|
} else if (this.priorityFeeMethod === PriorityFeeMethod.VELOCITY) {
|
|
231
|
-
await this.
|
|
224
|
+
await this.loadForVelocity();
|
|
232
225
|
} else {
|
|
233
226
|
throw new Error(`${this.priorityFeeMethod} load not implemented`);
|
|
234
227
|
}
|
|
@@ -17,15 +17,7 @@ export class PriorityFeeSubscriberMap {
|
|
|
17
17
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
18
18
|
|
|
19
19
|
velocityMarkets?: VelocityMarketInfo[];
|
|
20
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
21
|
-
public get driftMarkets(): VelocityMarketInfo[] | undefined {
|
|
22
|
-
return this.velocityMarkets;
|
|
23
|
-
}
|
|
24
20
|
velocityPriorityFeeEndpoint: string;
|
|
25
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
26
|
-
public get driftPriorityFeeEndpoint(): string {
|
|
27
|
-
return this.velocityPriorityFeeEndpoint;
|
|
28
|
-
}
|
|
29
21
|
feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>; // marketType -> marketIndex -> priority fee
|
|
30
22
|
|
|
31
23
|
public constructor(config: PriorityFeeSubscriberMapConfig) {
|
|
@@ -33,8 +25,8 @@ export class PriorityFeeSubscriberMap {
|
|
|
33
25
|
config.frequencyMs ?? DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
|
|
34
26
|
// Type-system guarantees at least one of the two is supplied.
|
|
35
27
|
this.velocityPriorityFeeEndpoint = (config.velocityPriorityFeeEndpoint ??
|
|
36
|
-
config.
|
|
37
|
-
this.velocityMarkets = config.velocityMarkets
|
|
28
|
+
config.velocityPriorityFeeEndpoint)!;
|
|
29
|
+
this.velocityMarkets = config.velocityMarkets;
|
|
38
30
|
this.feesMap = new Map<string, Map<number, VelocityPriorityFeeLevels>>();
|
|
39
31
|
this.feesMap.set('perp', new Map<number, VelocityPriorityFeeLevels>());
|
|
40
32
|
this.feesMap.set('spot', new Map<number, VelocityPriorityFeeLevels>());
|
package/src/priorityFee/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
VelocityMarketInfo,
|
|
6
6
|
VelocityPriorityFeeResponse,
|
|
7
7
|
} from './velocityPriorityFeeMethod';
|
|
8
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
9
8
|
|
|
10
9
|
export const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10_000;
|
|
11
10
|
|
|
@@ -35,8 +34,6 @@ export type PriorityFeeSubscriberConfig = {
|
|
|
35
34
|
addresses?: PublicKey[];
|
|
36
35
|
/// market type and index, optionally provide at initialization time if using priorityFeeMethod.VELOCITY
|
|
37
36
|
velocityMarkets?: VelocityMarketInfo[];
|
|
38
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
39
|
-
driftMarkets?: VelocityMarketInfo[];
|
|
40
37
|
/// custom strategy to calculate priority fees, defaults to AVERAGE
|
|
41
38
|
customStrategy?: PriorityFeeStrategy;
|
|
42
39
|
/// method for fetching priority fee samples
|
|
@@ -47,8 +44,6 @@ export type PriorityFeeSubscriberConfig = {
|
|
|
47
44
|
heliusRpcUrl?: string;
|
|
48
45
|
/// url for Velocity cached priority fee endpoint, required if using priorityFeeMethod.VELOCITY
|
|
49
46
|
velocityPriorityFeeEndpoint?: string;
|
|
50
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
51
|
-
driftPriorityFeeEndpoint?: string;
|
|
52
47
|
/// clamp any returned priority fee value to this value.
|
|
53
48
|
maxFeeMicroLamports?: number;
|
|
54
49
|
/// multiplier applied to priority fee before maxFeeMicroLamports, defaults to 1.0
|
|
@@ -60,10 +55,10 @@ type PriorityFeeSubscriberMapConfigBase = {
|
|
|
60
55
|
frequencyMs?: number;
|
|
61
56
|
/// market type and associated market index to query
|
|
62
57
|
velocityMarkets?: VelocityMarketInfo[];
|
|
63
|
-
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
64
|
-
driftMarkets?: VelocityMarketInfo[];
|
|
65
58
|
};
|
|
66
59
|
|
|
67
60
|
/// url for Velocity cached priority fee endpoint
|
|
68
|
-
export type PriorityFeeSubscriberMapConfig =
|
|
69
|
-
|
|
61
|
+
export type PriorityFeeSubscriberMapConfig =
|
|
62
|
+
PriorityFeeSubscriberMapConfigBase & {
|
|
63
|
+
velocityPriorityFeeEndpoint: string;
|
|
64
|
+
};
|
|
@@ -6,9 +6,6 @@ export type VelocityMarketInfo = {
|
|
|
6
6
|
marketIndex: number;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
/** @deprecated Use `VelocityMarketInfo` instead. `DriftMarketInfo` will be removed in a future major. */
|
|
10
|
-
export type DriftMarketInfo = VelocityMarketInfo;
|
|
11
|
-
|
|
12
9
|
export type VelocityPriorityFeeLevels = {
|
|
13
10
|
[key in HeliusPriorityLevel]: number;
|
|
14
11
|
} & {
|
|
@@ -16,14 +13,8 @@ export type VelocityPriorityFeeLevels = {
|
|
|
16
13
|
marketIndex: number;
|
|
17
14
|
};
|
|
18
15
|
|
|
19
|
-
/** @deprecated Use `VelocityPriorityFeeLevels` instead. `DriftPriorityFeeLevels` will be removed in a future major. */
|
|
20
|
-
export type DriftPriorityFeeLevels = VelocityPriorityFeeLevels;
|
|
21
|
-
|
|
22
16
|
export type VelocityPriorityFeeResponse = VelocityPriorityFeeLevels[];
|
|
23
17
|
|
|
24
|
-
/** @deprecated Use `VelocityPriorityFeeResponse` instead. `DriftPriorityFeeResponse` will be removed in a future major. */
|
|
25
|
-
export type DriftPriorityFeeResponse = VelocityPriorityFeeResponse;
|
|
26
|
-
|
|
27
18
|
export async function fetchVelocityPriorityFee(
|
|
28
19
|
url: string,
|
|
29
20
|
marketTypes: string[],
|
|
@@ -49,6 +40,3 @@ export async function fetchVelocityPriorityFee(
|
|
|
49
40
|
|
|
50
41
|
return [];
|
|
51
42
|
}
|
|
52
|
-
|
|
53
|
-
/** @deprecated Use `fetchVelocityPriorityFee` instead. `fetchDriftPriorityFee` will be removed in a future major. */
|
|
54
|
-
export const fetchDriftPriorityFee = fetchVelocityPriorityFee;
|
|
@@ -50,7 +50,7 @@ export class PythLazerSubscriber {
|
|
|
50
50
|
* @param endpoints - Array of WebSocket endpoint URLs for Pyth Lazer
|
|
51
51
|
* @param token - Authentication token for Pyth Lazer API
|
|
52
52
|
* @param priceFeedArrays - Array of price feed configurations to subscribe to
|
|
53
|
-
* @param env -
|
|
53
|
+
* @param env - Velocity environment (mainnet-beta, devnet, etc.)
|
|
54
54
|
* @param resubTimeoutMs - Milliseconds to wait before resubscribing on data timeout
|
|
55
55
|
* @param sdkLogging - Whether to log Pyth SDK logs to the console. This is very noisy but could be useful for debugging.
|
|
56
56
|
* @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.
|
|
@@ -270,7 +270,7 @@ export class UnifiedSwapClient {
|
|
|
270
270
|
slippageBps,
|
|
271
271
|
swapMode: isExactOut ? TitanSwapMode.ExactOut : TitanSwapMode.ExactIn,
|
|
272
272
|
onlyDirectRoutes,
|
|
273
|
-
sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for
|
|
273
|
+
sizeConstraint: sizeConstraint || 1280 - 375, // MAX_TX_BYTE_SIZE - buffer for velocity instructions
|
|
274
274
|
});
|
|
275
275
|
|
|
276
276
|
swapInstructions = titanClient.getTitanInstructions({
|
|
@@ -4,7 +4,6 @@ import { SignedMsgOrderId, SignedMsgUserOrdersAccount } from '../types';
|
|
|
4
4
|
import { Commitment, Context, PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { ResubOpts } from '../accounts/types';
|
|
6
6
|
import { VelocityClient } from '../velocityClient';
|
|
7
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
8
7
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
9
8
|
import { EventEmitter } from 'events';
|
|
10
9
|
|
|
@@ -13,7 +12,7 @@ export type SignedMsgUserOrdersAccountSubscriberConfig = {
|
|
|
13
12
|
resubOpts?: ResubOpts;
|
|
14
13
|
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
15
14
|
resyncIntervalMs?: number;
|
|
16
|
-
} &
|
|
15
|
+
} & { velocityClient: VelocityClient };
|
|
17
16
|
|
|
18
17
|
export interface SignedMsgUserOrdersAccountSubscriberEvents {
|
|
19
18
|
onAccountUpdate: (
|
|
@@ -31,10 +30,6 @@ export interface SignedMsgUserOrdersAccountSubscriberEvents {
|
|
|
31
30
|
|
|
32
31
|
export class SignedMsgUserOrdersAccountSubscriber {
|
|
33
32
|
protected velocityClient: VelocityClient;
|
|
34
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
35
|
-
protected get driftClient(): VelocityClient {
|
|
36
|
-
return this.velocityClient;
|
|
37
|
-
}
|
|
38
33
|
protected commitment: Commitment;
|
|
39
34
|
protected resubOpts?: ResubOpts;
|
|
40
35
|
protected resyncTimeoutId?: ReturnType<typeof setTimeout>;
|
|
@@ -60,7 +55,6 @@ export class SignedMsgUserOrdersAccountSubscriber {
|
|
|
60
55
|
|
|
61
56
|
constructor({
|
|
62
57
|
velocityClient,
|
|
63
|
-
driftClient,
|
|
64
58
|
commitment,
|
|
65
59
|
resubOpts,
|
|
66
60
|
decodeFn,
|
|
@@ -69,7 +63,7 @@ export class SignedMsgUserOrdersAccountSubscriber {
|
|
|
69
63
|
this.commitment = commitment ?? 'confirmed';
|
|
70
64
|
this.resubOpts = resubOpts;
|
|
71
65
|
// Type-system guarantees at least one of the two is supplied.
|
|
72
|
-
this.velocityClient =
|
|
66
|
+
this.velocityClient = velocityClient!;
|
|
73
67
|
this.decodeFn =
|
|
74
68
|
decodeFn ??
|
|
75
69
|
(
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
} from '../constants/perpMarkets';
|
|
5
5
|
import { VelocityClient } from '../velocityClient';
|
|
6
6
|
import { VelocityEnv } from '../config';
|
|
7
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
8
7
|
import {
|
|
9
8
|
getUserAccountPublicKey,
|
|
10
9
|
getUserStatsAccountPublicKey,
|
|
@@ -33,16 +32,16 @@ type SwiftOrderSubscriberConfigBase = {
|
|
|
33
32
|
endpoint?: string;
|
|
34
33
|
marketIndexes: number[];
|
|
35
34
|
/**
|
|
36
|
-
In the future, this will be used for verifying $
|
|
35
|
+
In the future, this will be used for verifying $VELOCITY stake as we add
|
|
37
36
|
authentication for delegate signers
|
|
38
37
|
For now, pass a new keypair or a keypair to an empty wallet
|
|
39
38
|
*/
|
|
40
39
|
keypair: Keypair;
|
|
41
40
|
};
|
|
42
41
|
|
|
43
|
-
export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase &
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
export type SwiftOrderSubscriberConfig = SwiftOrderSubscriberConfigBase & {
|
|
43
|
+
velocityEnv: VelocityEnv;
|
|
44
|
+
} & { velocityClient: VelocityClient };
|
|
46
45
|
|
|
47
46
|
/**
|
|
48
47
|
* Swift order message received from WebSocket
|
|
@@ -74,10 +73,6 @@ export class SwiftOrderSubscriber {
|
|
|
74
73
|
private readonly heartbeatIntervalMs = 60000;
|
|
75
74
|
private ws: WebSocket | null = null;
|
|
76
75
|
private velocityClient: VelocityClient;
|
|
77
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
78
|
-
private get driftClient(): VelocityClient {
|
|
79
|
-
return this.velocityClient;
|
|
80
|
-
}
|
|
81
76
|
public userAccountGetter?: AccountGetter; // In practice, this for now is just an OrderSubscriber or a UserMap
|
|
82
77
|
public onOrder: (
|
|
83
78
|
orderMessageRaw: SwiftOrderMessage,
|
|
@@ -91,7 +86,7 @@ export class SwiftOrderSubscriber {
|
|
|
91
86
|
|
|
92
87
|
constructor(private config: SwiftOrderSubscriberConfig) {
|
|
93
88
|
// Type-system guarantees at least one of the two is supplied.
|
|
94
|
-
this.velocityClient =
|
|
89
|
+
this.velocityClient = config.velocityClient!;
|
|
95
90
|
this.userAccountGetter = config.userAccountGetter;
|
|
96
91
|
}
|
|
97
92
|
|
|
@@ -105,7 +100,7 @@ export class SwiftOrderSubscriber {
|
|
|
105
100
|
}
|
|
106
101
|
|
|
107
102
|
getSymbolForMarketIndex(marketIndex: number): string {
|
|
108
|
-
const env = this.config.velocityEnv
|
|
103
|
+
const env = this.config.velocityEnv;
|
|
109
104
|
const markets = env === 'devnet' ? DevnetPerpMarkets : MainnetPerpMarkets;
|
|
110
105
|
return markets[marketIndex].symbol;
|
|
111
106
|
}
|
|
@@ -162,7 +157,7 @@ export class SwiftOrderSubscriber {
|
|
|
162
157
|
): Promise<void> {
|
|
163
158
|
this.onOrder = onOrder;
|
|
164
159
|
|
|
165
|
-
const env = this.config.velocityEnv
|
|
160
|
+
const env = this.config.velocityEnv;
|
|
166
161
|
const endpoint =
|
|
167
162
|
this.config.endpoint ??
|
|
168
163
|
(env === 'devnet'
|