@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/types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared TypeScript types for the
|
|
2
|
+
* Shared TypeScript types for the Velocity SDK.
|
|
3
3
|
*
|
|
4
4
|
* Contains TypeScript mirrors of all on-chain account structs (UserAccount, PerpMarketAccount,
|
|
5
5
|
* SpotMarketAccount, StateAccount, OracleData, etc.), instruction parameter types (OrderParams,
|
|
6
6
|
* ModifyOrderParams), enums (MarketType, OrderType, PositionDirection, OracleSource), and
|
|
7
7
|
* precision constants used throughout the SDK.
|
|
8
8
|
*
|
|
9
|
-
* The authoritative layout source is `sdk/src/idl/
|
|
9
|
+
* The authoritative layout source is `sdk/src/idl/velocity.json` (generated from the program).
|
|
10
10
|
* Do not edit struct shapes here without a corresponding on-chain change.
|
|
11
11
|
*/
|
|
12
12
|
import {
|
|
@@ -385,9 +385,8 @@ export type SpotInterestRecord = {
|
|
|
385
385
|
maxBorrowRate: number;
|
|
386
386
|
};
|
|
387
387
|
|
|
388
|
-
export type
|
|
388
|
+
export type AmmCurveChanged = {
|
|
389
389
|
ts: BN;
|
|
390
|
-
recordId: BN;
|
|
391
390
|
marketIndex: number;
|
|
392
391
|
pegMultiplierBefore: BN;
|
|
393
392
|
baseAssetReserveBefore: BN;
|
|
@@ -397,15 +396,9 @@ export type CurveRecord = {
|
|
|
397
396
|
baseAssetReserveAfter: BN;
|
|
398
397
|
quoteAssetReserveAfter: BN;
|
|
399
398
|
sqrtKAfter: BN;
|
|
400
|
-
baseAssetAmountLong: BN;
|
|
401
|
-
baseAssetAmountShort: BN;
|
|
402
|
-
baseAssetAmountWithAmm: BN;
|
|
403
|
-
totalFee: BN;
|
|
404
|
-
totalFeeMinusDistributions: BN;
|
|
405
399
|
adjustmentCost: BN;
|
|
406
|
-
|
|
400
|
+
totalFeeMinusDistributionsAfter: BN;
|
|
407
401
|
oraclePrice: BN;
|
|
408
|
-
fillRecord: BN;
|
|
409
402
|
};
|
|
410
403
|
|
|
411
404
|
export declare type InsuranceFundRecord = {
|
|
@@ -447,7 +440,6 @@ export type FundingRateRecord = {
|
|
|
447
440
|
cumulativeFundingRateShort: BN;
|
|
448
441
|
oraclePriceTwap: BN;
|
|
449
442
|
markPriceTwap: BN;
|
|
450
|
-
periodRevenue: BN;
|
|
451
443
|
baseAssetAmountWithAmm: BN;
|
|
452
444
|
};
|
|
453
445
|
|
|
@@ -816,13 +808,13 @@ export type PerpMarketAccount = {
|
|
|
816
808
|
pubkey: PublicKey;
|
|
817
809
|
name: number[];
|
|
818
810
|
amm: AMM;
|
|
811
|
+
marketStats: MarketStats;
|
|
819
812
|
numberOfUsersWithBase: number;
|
|
820
813
|
numberOfUsers: number;
|
|
821
814
|
marginRatioInitial: number;
|
|
822
815
|
marginRatioMaintenance: number;
|
|
823
816
|
nextFillRecordId: BN;
|
|
824
817
|
nextFundingRateRecordId: BN;
|
|
825
|
-
nextCurveRecordId: BN;
|
|
826
818
|
pnlPool: PoolBalance;
|
|
827
819
|
liquidatorFee: number;
|
|
828
820
|
ifLiquidationFee: number;
|
|
@@ -844,12 +836,41 @@ export type PerpMarketAccount = {
|
|
|
844
836
|
|
|
845
837
|
lastFillPrice: BN;
|
|
846
838
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
839
|
+
hedgeConfig: {
|
|
840
|
+
poolId: number;
|
|
841
|
+
status: number;
|
|
842
|
+
pausedOperations: number;
|
|
843
|
+
exchangeFeeExclusionScalar: number;
|
|
844
|
+
feeTransferScalar: number;
|
|
845
|
+
};
|
|
852
846
|
marketConfig: number;
|
|
847
|
+
|
|
848
|
+
// Fields migrated off AMM to top-level PerpMarket
|
|
849
|
+
oracle: PublicKey;
|
|
850
|
+
oracleSource: OracleSource;
|
|
851
|
+
oracleSlotDelayOverride: number;
|
|
852
|
+
oracleLowRiskSlotDelayOverride: number;
|
|
853
|
+
baseAssetAmountLong: BN;
|
|
854
|
+
baseAssetAmountShort: BN;
|
|
855
|
+
quoteAssetAmount: BN;
|
|
856
|
+
quoteEntryAmountLong: BN;
|
|
857
|
+
quoteEntryAmountShort: BN;
|
|
858
|
+
quoteBreakEvenAmountLong: BN;
|
|
859
|
+
quoteBreakEvenAmountShort: BN;
|
|
860
|
+
totalSocialLoss: BN;
|
|
861
|
+
maxOpenInterest: BN;
|
|
862
|
+
totalExchangeFee: BN;
|
|
863
|
+
totalLiquidationFee: BN;
|
|
864
|
+
cumulativeFundingRateLong: BN;
|
|
865
|
+
cumulativeFundingRateShort: BN;
|
|
866
|
+
lastFundingRate: BN;
|
|
867
|
+
lastFundingRateLong: BN;
|
|
868
|
+
lastFundingRateShort: BN;
|
|
869
|
+
lastFundingRateTs: BN;
|
|
870
|
+
netUnsettledFundingPnl: BN;
|
|
871
|
+
lastFundingOracleTwap: BN;
|
|
872
|
+
orderStepSize: BN;
|
|
873
|
+
orderTickSize: BN;
|
|
853
874
|
};
|
|
854
875
|
|
|
855
876
|
export type HistoricalOracleData = {
|
|
@@ -960,97 +981,58 @@ export type PoolBalance = {
|
|
|
960
981
|
};
|
|
961
982
|
|
|
962
983
|
export type AMM = {
|
|
984
|
+
feePool: PoolBalance;
|
|
963
985
|
baseAssetReserve: BN;
|
|
964
|
-
sqrtK: BN;
|
|
965
|
-
cumulativeFundingRate: BN;
|
|
966
|
-
lastFundingRate: BN;
|
|
967
|
-
lastFundingRateTs: BN;
|
|
968
|
-
lastMarkPriceTwap: BN;
|
|
969
|
-
lastMarkPriceTwap5Min: BN;
|
|
970
|
-
lastMarkPriceTwapTs: BN;
|
|
971
|
-
lastTradeTs: BN;
|
|
972
|
-
|
|
973
|
-
oracle: PublicKey;
|
|
974
|
-
oracleSource: OracleSource;
|
|
975
|
-
historicalOracleData: HistoricalOracleData;
|
|
976
|
-
|
|
977
|
-
lastOracleReservePriceSpreadPct: BN;
|
|
978
|
-
lastOracleConfPct: BN;
|
|
979
|
-
|
|
980
|
-
fundingPeriod: BN;
|
|
981
986
|
quoteAssetReserve: BN;
|
|
987
|
+
concentrationCoef: BN;
|
|
988
|
+
minBaseAssetReserve: BN;
|
|
989
|
+
maxBaseAssetReserve: BN;
|
|
990
|
+
sqrtK: BN;
|
|
982
991
|
pegMultiplier: BN;
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
lastFundingRateLong: BN;
|
|
988
|
-
|
|
989
|
-
totalLiquidationFee: BN;
|
|
992
|
+
terminalQuoteAssetReserve: BN;
|
|
993
|
+
baseAssetAmountWithAmm: BN;
|
|
994
|
+
totalFee: BN;
|
|
995
|
+
totalMmFee: BN;
|
|
990
996
|
totalFeeMinusDistributions: BN;
|
|
991
997
|
totalFeeWithdrawn: BN;
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
998
|
+
lastUpdateSlot: BN;
|
|
999
|
+
netRevenueSinceLastFunding: BN;
|
|
1000
|
+
lastCumulativeFundingRateLong: BN;
|
|
1001
|
+
lastCumulativeFundingRateShort: BN;
|
|
1002
|
+
baseSpread: number;
|
|
1003
|
+
maxSpread: number;
|
|
996
1004
|
maxFillReserveFraction: number;
|
|
997
1005
|
maxSlippageRatio: number;
|
|
998
|
-
baseSpread: number;
|
|
999
1006
|
curveUpdateIntensity: number;
|
|
1000
|
-
baseAssetAmountWithAmm: BN;
|
|
1001
|
-
baseAssetAmountLong: BN;
|
|
1002
|
-
baseAssetAmountShort: BN;
|
|
1003
|
-
quoteAssetAmount: BN;
|
|
1004
|
-
terminalQuoteAssetReserve: BN;
|
|
1005
|
-
concentrationCoef: BN;
|
|
1006
|
-
feePool: PoolBalance;
|
|
1007
|
-
totalExchangeFee: BN;
|
|
1008
|
-
totalMmFee: BN;
|
|
1009
|
-
netRevenueSinceLastFunding: BN;
|
|
1010
|
-
lastUpdateSlot: BN;
|
|
1011
|
-
lastOracleNormalisedPrice: BN;
|
|
1012
|
-
lastOracleValid: boolean;
|
|
1013
|
-
lastBidPriceTwap: BN;
|
|
1014
|
-
lastAskPriceTwap: BN;
|
|
1015
|
-
longSpread: number;
|
|
1016
|
-
shortSpread: number;
|
|
1017
|
-
maxSpread: number;
|
|
1018
|
-
|
|
1019
1007
|
ammJitIntensity: number;
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
quoteBreakEvenAmountLong: BN;
|
|
1026
|
-
quoteBreakEvenAmountShort: BN;
|
|
1027
|
-
quoteEntryAmountLong: BN;
|
|
1028
|
-
quoteEntryAmountShort: BN;
|
|
1008
|
+
ammSpreadAdjustment: number;
|
|
1009
|
+
ammInventorySpreadAdjustment: number;
|
|
1010
|
+
referencePriceOffsetDeadbandPct: number;
|
|
1011
|
+
};
|
|
1029
1012
|
|
|
1013
|
+
export type MarketStats = {
|
|
1014
|
+
lastMarkPriceTwap: BN;
|
|
1015
|
+
lastMarkPriceTwap5Min: BN;
|
|
1016
|
+
lastMarkPriceTwapTs: BN;
|
|
1017
|
+
lastBidPriceTwap: BN;
|
|
1018
|
+
lastAskPriceTwap: BN;
|
|
1030
1019
|
markStd: BN;
|
|
1031
1020
|
oracleStd: BN;
|
|
1021
|
+
lastOracleConfPct: BN;
|
|
1022
|
+
volume24H: BN;
|
|
1032
1023
|
longIntensityVolume: BN;
|
|
1033
1024
|
shortIntensityVolume: BN;
|
|
1034
|
-
|
|
1025
|
+
lastTradeTs: BN;
|
|
1026
|
+
last24HAvgFundingRate: BN;
|
|
1027
|
+
fundingPeriod: BN;
|
|
1035
1028
|
minOrderSize: BN;
|
|
1036
1029
|
mmOraclePrice: BN;
|
|
1037
1030
|
mmOracleSlot: BN;
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
netUnsettledFundingPnl: BN;
|
|
1045
|
-
referencePriceOffset: number;
|
|
1046
|
-
|
|
1047
|
-
oracleLowRiskSlotDelayOverride: number;
|
|
1048
|
-
oracleSlotDelayOverride: number;
|
|
1049
|
-
ammSpreadAdjustment: number;
|
|
1050
|
-
ammInventorySpreadAdjustment: number;
|
|
1051
|
-
|
|
1052
|
-
lastFundingOracleTwap: BN;
|
|
1053
|
-
referencePriceOffsetDeadbandPct: number;
|
|
1031
|
+
mmOracleSequenceId: BN;
|
|
1032
|
+
lastOracleNormalisedPrice: BN;
|
|
1033
|
+
lastReferencePriceOffset: number;
|
|
1034
|
+
lastOracleValid: boolean;
|
|
1035
|
+
historicalOracleData: HistoricalOracleData;
|
|
1054
1036
|
};
|
|
1055
1037
|
|
|
1056
1038
|
// # User Account Types
|
|
@@ -1086,14 +1068,13 @@ export type UserStatsAccount = {
|
|
|
1086
1068
|
totalFeeRebate: BN;
|
|
1087
1069
|
totalTokenDiscount: BN;
|
|
1088
1070
|
totalRefereeDiscount: BN;
|
|
1089
|
-
totalReferrerReward: BN;
|
|
1090
|
-
current_epoch_referrer_reward: BN;
|
|
1091
1071
|
};
|
|
1092
1072
|
referrer: PublicKey;
|
|
1093
1073
|
referrerStatus: number;
|
|
1094
1074
|
authority: PublicKey;
|
|
1095
1075
|
ifStakedQuoteAssetAmount: BN;
|
|
1096
1076
|
ifStakedGovTokenAmount: BN;
|
|
1077
|
+
delegatePermissions: number;
|
|
1097
1078
|
};
|
|
1098
1079
|
|
|
1099
1080
|
export type UserAccount = {
|
|
@@ -1156,7 +1137,7 @@ export type Order = {
|
|
|
1156
1137
|
existingPositionDirection: PositionDirection;
|
|
1157
1138
|
postOnly: boolean;
|
|
1158
1139
|
immediateOrCancel: boolean;
|
|
1159
|
-
oraclePriceOffset:
|
|
1140
|
+
oraclePriceOffset: BN;
|
|
1160
1141
|
auctionDuration: number;
|
|
1161
1142
|
auctionStartPrice: BN;
|
|
1162
1143
|
auctionEndPrice: BN;
|
|
@@ -1178,11 +1159,15 @@ export type OrderParams = {
|
|
|
1178
1159
|
bitFlags: number;
|
|
1179
1160
|
triggerPrice: BN | null;
|
|
1180
1161
|
triggerCondition: OrderTriggerCondition;
|
|
1181
|
-
oraclePriceOffset:
|
|
1162
|
+
oraclePriceOffset: BN | null;
|
|
1182
1163
|
auctionDuration: number | null;
|
|
1183
1164
|
maxTs: BN | null;
|
|
1184
1165
|
auctionStartPrice: BN | null;
|
|
1185
1166
|
auctionEndPrice: BN | null;
|
|
1167
|
+
/** index into the placing user's RevenueShareEscrow.approved_builders list (non-swift builder codes) */
|
|
1168
|
+
builderIdx?: number | null;
|
|
1169
|
+
/** builder fee on this order, in tenths of a bps, e.g. 100 = 0.01% */
|
|
1170
|
+
builderFeeTenthBps?: number | null;
|
|
1186
1171
|
};
|
|
1187
1172
|
|
|
1188
1173
|
export class PostOnlyParams {
|
|
@@ -1276,6 +1261,8 @@ export const DefaultOrderParams: OrderParams = {
|
|
|
1276
1261
|
maxTs: null,
|
|
1277
1262
|
auctionStartPrice: null,
|
|
1278
1263
|
auctionEndPrice: null,
|
|
1264
|
+
builderIdx: null,
|
|
1265
|
+
builderFeeTenthBps: null,
|
|
1279
1266
|
};
|
|
1280
1267
|
|
|
1281
1268
|
export type SignedMsgOrderParamsMessage = {
|
|
@@ -1331,6 +1318,8 @@ export type ReferrerInfo = {
|
|
|
1331
1318
|
export enum ReferrerStatus {
|
|
1332
1319
|
IsReferrer = 1,
|
|
1333
1320
|
IsReferred = 2,
|
|
1321
|
+
/** set when the user's RevenueShareEscrow was initialized with a referrer */
|
|
1322
|
+
BuilderReferral = 4,
|
|
1334
1323
|
}
|
|
1335
1324
|
|
|
1336
1325
|
export enum PlaceAndTakeOrderSuccessCondition {
|
|
@@ -1508,9 +1497,6 @@ export interface VelocityClientMetricsEvents {
|
|
|
1508
1497
|
preTxSigned: void;
|
|
1509
1498
|
}
|
|
1510
1499
|
|
|
1511
|
-
/** @deprecated Use `VelocityClientMetricsEvents` instead. `DriftClientMetricsEvents` will be removed in a future major. */
|
|
1512
|
-
export interface DriftClientMetricsEvents extends VelocityClientMetricsEvents {}
|
|
1513
|
-
|
|
1514
1500
|
export type SignedTxData = {
|
|
1515
1501
|
txSig: string;
|
|
1516
1502
|
signedTx: Transaction | VersionedTransaction;
|
|
@@ -1547,7 +1533,7 @@ export type IfRebalanceConfigParams = {
|
|
|
1547
1533
|
};
|
|
1548
1534
|
|
|
1549
1535
|
/* Represents proof of a signed msg taker order
|
|
1550
|
-
* It can be provided to
|
|
1536
|
+
* It can be provided to velocity program to fill a signed msg order
|
|
1551
1537
|
*/
|
|
1552
1538
|
export interface SignedMsgOrderParams {
|
|
1553
1539
|
/**
|
|
@@ -1581,10 +1567,6 @@ export type RevenueShareAccount = {
|
|
|
1581
1567
|
export type RevenueShareEscrowAccount = {
|
|
1582
1568
|
authority: PublicKey;
|
|
1583
1569
|
referrer: PublicKey;
|
|
1584
|
-
referrerBoostExpireTs: number;
|
|
1585
|
-
referrerRewardOffset: number;
|
|
1586
|
-
refereeFeeNumeratorOffset: number;
|
|
1587
|
-
referrerBoostNumerator: number;
|
|
1588
1570
|
reservedFixed: number[];
|
|
1589
1571
|
orders: RevenueShareOrder[];
|
|
1590
1572
|
approvedBuilders: BuilderInfo[];
|
package/src/user.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* User — read-oriented abstraction over the on-chain `User` account.
|
|
3
3
|
*
|
|
4
4
|
* Responsibilities:
|
|
5
|
-
* - Margin and free-collateral calculations (mirrors `programs/
|
|
5
|
+
* - Margin and free-collateral calculations (mirrors `programs/velocity/src/math/margin.rs`).
|
|
6
6
|
* - Position accessors: perp positions, spot positions, unrealized PnL, leverage.
|
|
7
7
|
* - Open order queries and filtering.
|
|
8
8
|
* - Health factor and liquidation threshold checks.
|
|
@@ -129,10 +129,6 @@ export type MarginType = 'Cross' | 'Isolated';
|
|
|
129
129
|
|
|
130
130
|
export class User {
|
|
131
131
|
velocityClient: VelocityClient;
|
|
132
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
133
|
-
public get driftClient(): VelocityClient {
|
|
134
|
-
return this.velocityClient;
|
|
135
|
-
}
|
|
136
132
|
userAccountPublicKey: PublicKey;
|
|
137
133
|
accountSubscriber: UserAccountSubscriber;
|
|
138
134
|
_isSubscribed = false;
|
|
@@ -148,7 +144,7 @@ export class User {
|
|
|
148
144
|
|
|
149
145
|
public constructor(config: UserConfig) {
|
|
150
146
|
// Type-system guarantees at least one of the two is supplied.
|
|
151
|
-
const velocityClient =
|
|
147
|
+
const velocityClient = config.velocityClient!;
|
|
152
148
|
this.velocityClient = velocityClient;
|
|
153
149
|
this.userAccountPublicKey = config.userAccountPublicKey;
|
|
154
150
|
if (config.accountSubscription?.type === 'polling') {
|
|
@@ -2093,10 +2089,10 @@ export class User {
|
|
|
2093
2089
|
userPosition.marketIndex
|
|
2094
2090
|
);
|
|
2095
2091
|
if (
|
|
2096
|
-
market.
|
|
2092
|
+
market.cumulativeFundingRateLong.eq(
|
|
2097
2093
|
userPosition.lastCumulativeFundingRate
|
|
2098
2094
|
) ||
|
|
2099
|
-
market.
|
|
2095
|
+
market.cumulativeFundingRateShort.eq(
|
|
2100
2096
|
userPosition.lastCumulativeFundingRate
|
|
2101
2097
|
)
|
|
2102
2098
|
) {
|
|
@@ -2153,7 +2149,7 @@ export class User {
|
|
|
2153
2149
|
const oracle = market.oracle;
|
|
2154
2150
|
const perpMarketWithSameOracle = this.velocityClient
|
|
2155
2151
|
.getPerpMarketAccounts()
|
|
2156
|
-
.find((market) => market.
|
|
2152
|
+
.find((market) => market.oracle.equals(oracle));
|
|
2157
2153
|
const oraclePrice =
|
|
2158
2154
|
this.velocityClient.getOracleDataForSpotMarket(marketIndex).price;
|
|
2159
2155
|
if (perpMarketWithSameOracle) {
|
|
@@ -2172,7 +2168,7 @@ export class User {
|
|
|
2172
2168
|
if (freeCollateralDeltaForPerp) {
|
|
2173
2169
|
const { numerator, denominator } = getMultipleBetweenOracleSources(
|
|
2174
2170
|
market.oracleSource,
|
|
2175
|
-
perpMarketWithSameOracle.
|
|
2171
|
+
perpMarketWithSameOracle.oracleSource
|
|
2176
2172
|
);
|
|
2177
2173
|
freeCollateralDeltaForPerp = freeCollateralDeltaForPerp
|
|
2178
2174
|
.mul(numerator)
|
|
@@ -2223,8 +2219,7 @@ export class User {
|
|
|
2223
2219
|
): BN {
|
|
2224
2220
|
const market = this.velocityClient.getPerpMarketAccount(marketIndex);
|
|
2225
2221
|
|
|
2226
|
-
const oracle =
|
|
2227
|
-
this.velocityClient.getPerpMarketAccount(marketIndex).amm.oracle;
|
|
2222
|
+
const oracle = this.velocityClient.getPerpMarketAccount(marketIndex).oracle;
|
|
2228
2223
|
|
|
2229
2224
|
const oraclePrice =
|
|
2230
2225
|
this.velocityClient.getOracleDataForPerpMarket(marketIndex).price;
|
|
@@ -2292,7 +2287,7 @@ export class User {
|
|
|
2292
2287
|
|
|
2293
2288
|
positionBaseSizeChange = standardizeBaseAssetAmount(
|
|
2294
2289
|
positionBaseSizeChange,
|
|
2295
|
-
market.
|
|
2290
|
+
market.orderStepSize
|
|
2296
2291
|
);
|
|
2297
2292
|
|
|
2298
2293
|
const freeCollateralChangeFromNewPosition =
|
|
@@ -2345,7 +2340,7 @@ export class User {
|
|
|
2345
2340
|
|
|
2346
2341
|
if (spotFreeCollateralDelta) {
|
|
2347
2342
|
const { numerator, denominator } = getMultipleBetweenOracleSources(
|
|
2348
|
-
market.
|
|
2343
|
+
market.oracleSource,
|
|
2349
2344
|
spotMarketWithSameOracle.oracleSource
|
|
2350
2345
|
);
|
|
2351
2346
|
spotFreeCollateralDelta = spotFreeCollateralDelta
|
package/src/userConfig.ts
CHANGED
|
@@ -5,15 +5,13 @@ import { GrpcConfigs, UserAccountSubscriber } from './accounts/types';
|
|
|
5
5
|
import { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber';
|
|
6
6
|
import { UserAccount } from './types';
|
|
7
7
|
import { grpcMultiUserAccountSubscriber } from './accounts/grpcMultiUserAccountSubscriber';
|
|
8
|
-
import { AtLeastOne } from './util/deprecatedAlias';
|
|
9
8
|
|
|
10
9
|
type UserConfigBase = {
|
|
11
10
|
accountSubscription?: UserSubscriptionConfig;
|
|
12
11
|
userAccountPublicKey: PublicKey;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
export type UserConfig = UserConfigBase &
|
|
16
|
-
AtLeastOne<'velocityClient', 'driftClient', VelocityClient>;
|
|
14
|
+
export type UserConfig = UserConfigBase & { velocityClient: VelocityClient };
|
|
17
15
|
|
|
18
16
|
export type UserSubscriptionConfig =
|
|
19
17
|
| {
|
|
@@ -29,10 +29,6 @@ export class ReferrerMap {
|
|
|
29
29
|
*/
|
|
30
30
|
private referrerReferrerInfoMap = new Map<string, ReferrerInfo>();
|
|
31
31
|
private velocityClient: VelocityClient;
|
|
32
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
33
|
-
private get driftClient(): VelocityClient {
|
|
34
|
-
return this.velocityClient;
|
|
35
|
-
}
|
|
36
32
|
private parallelSync: boolean;
|
|
37
33
|
|
|
38
34
|
private fetchPromise?: Promise<void>;
|
|
@@ -10,10 +10,6 @@ export class RevenueShareEscrowMap {
|
|
|
10
10
|
*/
|
|
11
11
|
private authorityEscrowMap = new Map<string, RevenueShareEscrowAccount>();
|
|
12
12
|
private velocityClient: VelocityClient;
|
|
13
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
-
private get driftClient(): VelocityClient {
|
|
15
|
-
return this.velocityClient;
|
|
16
|
-
}
|
|
17
13
|
private parallelSync: boolean;
|
|
18
14
|
|
|
19
15
|
private fetchPromise?: Promise<void>;
|
package/src/userMap/userMap.ts
CHANGED
|
@@ -78,10 +78,6 @@ export interface UserMapInterface {
|
|
|
78
78
|
export class UserMap implements UserMapInterface {
|
|
79
79
|
private userMap = new Map<string, DataAndSlot<User>>();
|
|
80
80
|
velocityClient: VelocityClient;
|
|
81
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
82
|
-
public get driftClient(): VelocityClient {
|
|
83
|
-
return this.velocityClient;
|
|
84
|
-
}
|
|
85
81
|
eventEmitter: StrictEventEmitter<EventEmitter, UserEvents>;
|
|
86
82
|
private connection: Connection;
|
|
87
83
|
private commitment: Commitment;
|
|
@@ -114,7 +110,7 @@ export class UserMap implements UserMapInterface {
|
|
|
114
110
|
*/
|
|
115
111
|
constructor(config: UserMapConfig) {
|
|
116
112
|
// Type-system guarantees at least one of the two is supplied.
|
|
117
|
-
this.velocityClient =
|
|
113
|
+
this.velocityClient = config.velocityClient!;
|
|
118
114
|
if (config.connection) {
|
|
119
115
|
this.connection = config.connection;
|
|
120
116
|
} else {
|
|
@@ -420,7 +416,7 @@ export class UserMap implements UserMapInterface {
|
|
|
420
416
|
|
|
421
417
|
/**
|
|
422
418
|
* Syncs the UserMap using the default sync method (single getProgramAccounts call with filters).
|
|
423
|
-
* This method may fail when
|
|
419
|
+
* This method may fail when velocity has too many users. (nodejs response size limits)
|
|
424
420
|
* @returns
|
|
425
421
|
*/
|
|
426
422
|
private async defaultSync() {
|
|
@@ -517,7 +513,7 @@ export class UserMap implements UserMapInterface {
|
|
|
517
513
|
|
|
518
514
|
/**
|
|
519
515
|
* Syncs the UserMap using the paginated sync method (multiple getMultipleAccounts calls with filters).
|
|
520
|
-
* This method is more reliable when
|
|
516
|
+
* This method is more reliable when velocity has many users.
|
|
521
517
|
* @returns
|
|
522
518
|
*/
|
|
523
519
|
private async paginatedSync() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Commitment, Connection, MemcmpFilter } from '@solana/web3.js';
|
|
2
2
|
import { VelocityClient } from '../velocityClient';
|
|
3
3
|
import { GrpcConfigs } from '../accounts/types';
|
|
4
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
5
4
|
|
|
6
5
|
// passed into UserMap.getUniqueAuthorities to filter users
|
|
7
6
|
export type UserAccountFilterCriteria = {
|
|
@@ -65,5 +64,6 @@ type UserMapConfigBase = {
|
|
|
65
64
|
additionalFilters?: MemcmpFilter[];
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
export type UserMapConfig = UserMapConfigBase &
|
|
69
|
-
|
|
67
|
+
export type UserMapConfig = UserMapConfigBase & {
|
|
68
|
+
velocityClient: VelocityClient;
|
|
69
|
+
};
|
|
@@ -27,10 +27,6 @@ export class UserStatsMap {
|
|
|
27
27
|
*/
|
|
28
28
|
private userStatsMap = new Map<string, UserStats>();
|
|
29
29
|
private velocityClient: VelocityClient;
|
|
30
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
31
|
-
private get driftClient(): VelocityClient {
|
|
32
|
-
return this.velocityClient;
|
|
33
|
-
}
|
|
34
30
|
private bulkAccountLoader: BulkAccountLoader;
|
|
35
31
|
private decode;
|
|
36
32
|
private syncConfig: SyncConfig;
|
package/src/userStats.ts
CHANGED
|
@@ -18,17 +18,13 @@ import { grpcUserStatsAccountSubscriber } from './accounts/grpcUserStatsAccountS
|
|
|
18
18
|
|
|
19
19
|
export class UserStats {
|
|
20
20
|
velocityClient: VelocityClient;
|
|
21
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
22
|
-
public get driftClient(): VelocityClient {
|
|
23
|
-
return this.velocityClient;
|
|
24
|
-
}
|
|
25
21
|
userStatsAccountPublicKey: PublicKey;
|
|
26
22
|
accountSubscriber: UserStatsAccountSubscriber;
|
|
27
23
|
isSubscribed: boolean;
|
|
28
24
|
|
|
29
25
|
public constructor(config: UserStatsConfig) {
|
|
30
26
|
// Type-system guarantees at least one of the two is supplied.
|
|
31
|
-
const velocityClient =
|
|
27
|
+
const velocityClient = config.velocityClient!;
|
|
32
28
|
this.velocityClient = velocityClient;
|
|
33
29
|
this.userStatsAccountPublicKey = config.userStatsAccountPublicKey;
|
|
34
30
|
if (config.accountSubscription?.type === 'polling') {
|
package/src/userStatsConfig.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { VelocityClient } from './velocityClient';
|
|
|
2
2
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
4
4
|
import { GrpcConfigs, UserStatsAccountSubscriber } from './accounts/types';
|
|
5
|
-
import { AtLeastOne } from './util/deprecatedAlias';
|
|
6
5
|
|
|
7
6
|
type UserStatsConfigBase = {
|
|
8
7
|
accountSubscription?: UserStatsSubscriptionConfig;
|
|
9
8
|
userStatsAccountPublicKey: PublicKey;
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
export type UserStatsConfig = UserStatsConfigBase &
|
|
13
|
-
|
|
11
|
+
export type UserStatsConfig = UserStatsConfigBase & {
|
|
12
|
+
velocityClient: VelocityClient;
|
|
13
|
+
};
|
|
14
14
|
|
|
15
15
|
export type UserStatsSubscriptionConfig =
|
|
16
16
|
| {
|
package/src/util/ed25519Utils.ts
CHANGED
|
@@ -37,7 +37,7 @@ const ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct<
|
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Constructs a minimal Ed25519 verification instruction that references the data
|
|
40
|
-
* inside the
|
|
40
|
+
* inside the velocity custom instruction (e.g. postPythLazerOracleUpdate, placeSignedMsgTakerOrder).
|
|
41
41
|
*
|
|
42
42
|
* @param customInstructionIndex The index of the custom instruction in the transaction (e.g. if tx contains compute budget limit, compute budget price, ed25519 verify, custom ix, this would be 3).
|
|
43
43
|
* @param messageOffset The offset within the custom instruction data where the signed message begins.
|