@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/adminClient.ts
CHANGED
|
@@ -95,7 +95,7 @@ export class AdminClient extends VelocityClient {
|
|
|
95
95
|
throw new Error('Clearing house already initialized');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
const [
|
|
98
|
+
const [velocityStatePublicKey] =
|
|
99
99
|
await getVelocityStateAccountPublicKeyAndNonce(this.program.programId);
|
|
100
100
|
|
|
101
101
|
const initializeIx = await this.program.instruction.initialize({
|
|
@@ -103,10 +103,10 @@ export class AdminClient extends VelocityClient {
|
|
|
103
103
|
admin: this.isSubscribed
|
|
104
104
|
? this.getStateAccount().coldAdmin
|
|
105
105
|
: this.wallet.publicKey,
|
|
106
|
-
state:
|
|
106
|
+
state: velocityStatePublicKey,
|
|
107
107
|
quoteAssetMint: usdcMint,
|
|
108
108
|
rent: SYSVAR_RENT_PUBKEY,
|
|
109
|
-
|
|
109
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
110
110
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
111
111
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
112
112
|
},
|
|
@@ -260,7 +260,7 @@ export class AdminClient extends VelocityClient {
|
|
|
260
260
|
spotMarket,
|
|
261
261
|
spotMarketVault,
|
|
262
262
|
insuranceFundVault,
|
|
263
|
-
|
|
263
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
264
264
|
spotMarketMint: mint,
|
|
265
265
|
oracle,
|
|
266
266
|
rent: SYSVAR_RENT_PUBKEY,
|
|
@@ -315,7 +315,7 @@ export class AdminClient extends VelocityClient {
|
|
|
315
315
|
spotMarket: spotMarketPublicKey,
|
|
316
316
|
spotMarketVault: spotMarketVaultPublicKey,
|
|
317
317
|
insuranceFundVault: insuranceFundVaultPublicKey,
|
|
318
|
-
|
|
318
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
319
319
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
320
320
|
},
|
|
321
321
|
}
|
|
@@ -797,7 +797,7 @@ export class AdminClient extends VelocityClient {
|
|
|
797
797
|
this.program.programId,
|
|
798
798
|
perpMarketIndex
|
|
799
799
|
),
|
|
800
|
-
oracle: this.getPerpMarketAccount(perpMarketIndex).
|
|
800
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
|
|
801
801
|
},
|
|
802
802
|
});
|
|
803
803
|
}
|
|
@@ -881,7 +881,7 @@ export class AdminClient extends VelocityClient {
|
|
|
881
881
|
this.program.programId,
|
|
882
882
|
QUOTE_SPOT_MARKET_INDEX
|
|
883
883
|
),
|
|
884
|
-
oracle: this.getPerpMarketAccount(perpMarketIndex).
|
|
884
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
|
|
885
885
|
},
|
|
886
886
|
}
|
|
887
887
|
);
|
|
@@ -1078,7 +1078,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1078
1078
|
this.program.programId,
|
|
1079
1079
|
perpMarketIndex
|
|
1080
1080
|
);
|
|
1081
|
-
const
|
|
1081
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
1082
1082
|
|
|
1083
1083
|
return await this.program.instruction.repegAmmCurve(newPeg, {
|
|
1084
1084
|
accounts: {
|
|
@@ -1086,7 +1086,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1086
1086
|
admin: this.isSubscribed
|
|
1087
1087
|
? this.getStateAccount().coldAdmin
|
|
1088
1088
|
: this.wallet.publicKey,
|
|
1089
|
-
oracle:
|
|
1089
|
+
oracle: perpMarketAccount.oracle,
|
|
1090
1090
|
perpMarket: perpMarketPublicKey,
|
|
1091
1091
|
},
|
|
1092
1092
|
});
|
|
@@ -1108,7 +1108,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1108
1108
|
public async getUpdatePerpMarketAmmOracleTwapIx(
|
|
1109
1109
|
perpMarketIndex: number
|
|
1110
1110
|
): Promise<TransactionInstruction> {
|
|
1111
|
-
const
|
|
1111
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
1112
1112
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1113
1113
|
this.program.programId,
|
|
1114
1114
|
perpMarketIndex
|
|
@@ -1120,7 +1120,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1120
1120
|
admin: this.isSubscribed
|
|
1121
1121
|
? this.getStateAccount().coldAdmin
|
|
1122
1122
|
: this.wallet.publicKey,
|
|
1123
|
-
oracle:
|
|
1123
|
+
oracle: perpMarketAccount.oracle,
|
|
1124
1124
|
perpMarket: perpMarketPublicKey,
|
|
1125
1125
|
},
|
|
1126
1126
|
});
|
|
@@ -1142,7 +1142,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1142
1142
|
public async getResetPerpMarketAmmOracleTwapIx(
|
|
1143
1143
|
perpMarketIndex: number
|
|
1144
1144
|
): Promise<TransactionInstruction> {
|
|
1145
|
-
const
|
|
1145
|
+
const perpMarketAccount = this.getPerpMarketAccount(perpMarketIndex);
|
|
1146
1146
|
const perpMarketPublicKey = await getPerpMarketPublicKey(
|
|
1147
1147
|
this.program.programId,
|
|
1148
1148
|
perpMarketIndex
|
|
@@ -1154,7 +1154,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1154
1154
|
admin: this.isSubscribed
|
|
1155
1155
|
? this.getStateAccount().coldAdmin
|
|
1156
1156
|
: this.wallet.publicKey,
|
|
1157
|
-
oracle:
|
|
1157
|
+
oracle: perpMarketAccount.oracle,
|
|
1158
1158
|
perpMarket: perpMarketPublicKey,
|
|
1159
1159
|
},
|
|
1160
1160
|
});
|
|
@@ -1204,7 +1204,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1204
1204
|
perpMarketIndex
|
|
1205
1205
|
),
|
|
1206
1206
|
sourceVault,
|
|
1207
|
-
|
|
1207
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
1208
1208
|
quoteSpotMarket: spotMarket.pubkey,
|
|
1209
1209
|
spotMarketVault: spotMarket.vault,
|
|
1210
1210
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
@@ -1469,7 +1469,7 @@ export class AdminClient extends VelocityClient {
|
|
|
1469
1469
|
this.program.programId,
|
|
1470
1470
|
QUOTE_SPOT_MARKET_INDEX
|
|
1471
1471
|
),
|
|
1472
|
-
oracle: this.getPerpMarketAccount(perpMarketIndex).
|
|
1472
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
|
|
1473
1473
|
},
|
|
1474
1474
|
}
|
|
1475
1475
|
);
|
|
@@ -2368,7 +2368,7 @@ export class AdminClient extends VelocityClient {
|
|
|
2368
2368
|
perpMarketIndex
|
|
2369
2369
|
),
|
|
2370
2370
|
oracle: oracle,
|
|
2371
|
-
oldOracle: this.getPerpMarketAccount(perpMarketIndex).
|
|
2371
|
+
oldOracle: this.getPerpMarketAccount(perpMarketIndex).oracle,
|
|
2372
2372
|
ammCache: getAmmCachePublicKey(this.program.programId),
|
|
2373
2373
|
},
|
|
2374
2374
|
}
|
|
@@ -3722,7 +3722,7 @@ export class AdminClient extends VelocityClient {
|
|
|
3722
3722
|
outMarketIndex
|
|
3723
3723
|
),
|
|
3724
3724
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
3725
|
-
|
|
3725
|
+
velocitySigner: this.getStateAccount().signer,
|
|
3726
3726
|
},
|
|
3727
3727
|
remainingAccounts,
|
|
3728
3728
|
}
|
|
@@ -3779,7 +3779,7 @@ export class AdminClient extends VelocityClient {
|
|
|
3779
3779
|
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
3780
3780
|
recipientTokenAccount,
|
|
3781
3781
|
tokenProgram: tokenProgramId,
|
|
3782
|
-
|
|
3782
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
3783
3783
|
},
|
|
3784
3784
|
remainingAccounts,
|
|
3785
3785
|
}
|
|
@@ -4405,7 +4405,7 @@ export class AdminClient extends VelocityClient {
|
|
|
4405
4405
|
insuranceFundVault: spotMarket.insuranceFund.vault,
|
|
4406
4406
|
userTokenAccount: userTokenAccountPublicKey,
|
|
4407
4407
|
tokenProgram: this.getTokenProgramForSpotMarket(spotMarket),
|
|
4408
|
-
|
|
4408
|
+
velocitySigner: this.getSignerPublicKey(),
|
|
4409
4409
|
},
|
|
4410
4410
|
}
|
|
4411
4411
|
);
|
|
@@ -5094,7 +5094,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5094
5094
|
}
|
|
5095
5095
|
|
|
5096
5096
|
/**
|
|
5097
|
-
* Get the
|
|
5097
|
+
* Get the velocity begin_swap and end_swap instructions
|
|
5098
5098
|
*
|
|
5099
5099
|
* @param outMarketIndex the market index of the token you're buying
|
|
5100
5100
|
* @param inMarketIndex the market index of the token you're selling
|
|
@@ -5573,7 +5573,7 @@ export class AdminClient extends VelocityClient {
|
|
|
5573
5573
|
spotMarketVault: withdrawSpotMarket.vault,
|
|
5574
5574
|
tokenProgram: withdrawTokenProgram,
|
|
5575
5575
|
mint: withdrawSpotMarket.mint,
|
|
5576
|
-
|
|
5576
|
+
velocitySigner: getVelocitySignerPublicKey(this.program.programId),
|
|
5577
5577
|
oracle: withdrawSpotMarket.oracle,
|
|
5578
5578
|
},
|
|
5579
5579
|
}
|
|
@@ -10,10 +10,6 @@ import { ResubOpts } from '../accounts/types';
|
|
|
10
10
|
|
|
11
11
|
export class AuctionSubscriber {
|
|
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 opts: ConfirmOptions;
|
|
18
14
|
private resubOpts?: ResubOpts;
|
|
19
15
|
|
|
@@ -22,13 +18,12 @@ export class AuctionSubscriber {
|
|
|
22
18
|
|
|
23
19
|
constructor({
|
|
24
20
|
velocityClient,
|
|
25
|
-
driftClient,
|
|
26
21
|
opts,
|
|
27
22
|
resubTimeoutMs,
|
|
28
23
|
logResubMessages,
|
|
29
24
|
}: AuctionSubscriberConfig) {
|
|
30
25
|
// Type-system guarantees at least one of the two is supplied.
|
|
31
|
-
this.velocityClient =
|
|
26
|
+
this.velocityClient = velocityClient!;
|
|
32
27
|
this.opts = opts || this.velocityClient.opts;
|
|
33
28
|
this.eventEmitter = new EventEmitter();
|
|
34
29
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
@@ -11,10 +11,6 @@ import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubs
|
|
|
11
11
|
|
|
12
12
|
export class AuctionSubscriberGrpc {
|
|
13
13
|
private velocityClient: VelocityClient;
|
|
14
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
15
|
-
private get driftClient(): VelocityClient {
|
|
16
|
-
return this.velocityClient;
|
|
17
|
-
}
|
|
18
14
|
private opts: ConfirmOptions;
|
|
19
15
|
private resubOpts?: ResubOpts;
|
|
20
16
|
private grpcConfigs?: GrpcConfigs;
|
|
@@ -24,14 +20,13 @@ export class AuctionSubscriberGrpc {
|
|
|
24
20
|
|
|
25
21
|
constructor({
|
|
26
22
|
velocityClient,
|
|
27
|
-
driftClient,
|
|
28
23
|
opts,
|
|
29
24
|
grpcConfigs,
|
|
30
25
|
resubTimeoutMs,
|
|
31
26
|
logResubMessages,
|
|
32
27
|
}: AuctionSubscriberConfig) {
|
|
33
28
|
// Type-system guarantees at least one of the two is supplied.
|
|
34
|
-
this.velocityClient =
|
|
29
|
+
this.velocityClient = velocityClient!;
|
|
35
30
|
this.opts = opts || this.velocityClient.opts;
|
|
36
31
|
this.eventEmitter = new EventEmitter();
|
|
37
32
|
this.resubOpts = { resubTimeoutMs, logResubMessages };
|
|
@@ -2,7 +2,6 @@ import { GrpcConfigs } from '../accounts/types';
|
|
|
2
2
|
import { VelocityClient } from '../velocityClient';
|
|
3
3
|
import { UserAccount } from '../types';
|
|
4
4
|
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
|
|
5
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
6
5
|
|
|
7
6
|
type AuctionSubscriberConfigBase = {
|
|
8
7
|
opts?: ConfirmOptions;
|
|
@@ -11,8 +10,9 @@ type AuctionSubscriberConfigBase = {
|
|
|
11
10
|
grpcConfigs?: GrpcConfigs;
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase &
|
|
15
|
-
|
|
13
|
+
export type AuctionSubscriberConfig = AuctionSubscriberConfigBase & {
|
|
14
|
+
velocityClient: VelocityClient;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
17
|
export interface AuctionSubscriberEvents {
|
|
18
18
|
onAccountUpdate: (
|
package/src/config.ts
CHANGED
|
@@ -15,18 +15,12 @@ import {
|
|
|
15
15
|
import { OracleInfo } from './oracles/types';
|
|
16
16
|
import { Program, ProgramAccount } from './isomorphic/anchor';
|
|
17
17
|
import { getOracleId } from './oracles/oracleId';
|
|
18
|
-
import {
|
|
18
|
+
import { Velocity } from './idl/velocity';
|
|
19
19
|
|
|
20
|
-
export type VelocityProgram = Program<
|
|
21
|
-
|
|
22
|
-
/** @deprecated Use `VelocityProgram` instead. `DriftProgram` will be removed in a future major. */
|
|
23
|
-
export type DriftProgram = VelocityProgram;
|
|
20
|
+
export type VelocityProgram = Program<Velocity>;
|
|
24
21
|
|
|
25
22
|
export type VelocityEnv = 'devnet' | 'mainnet-beta';
|
|
26
23
|
|
|
27
|
-
/** @deprecated Use `VelocityEnv` instead. `DriftEnv` will be removed in a future major. */
|
|
28
|
-
export type DriftEnv = VelocityEnv;
|
|
29
|
-
|
|
30
24
|
/** Widened env type accepted by `initialize()`; `'master'` is a legacy alias for `'devnet'`. */
|
|
31
25
|
export type LegacyVelocityEnv = VelocityEnv | 'master';
|
|
32
26
|
|
|
@@ -34,12 +28,8 @@ export interface VelocityConfig {
|
|
|
34
28
|
ENV: VelocityEnv;
|
|
35
29
|
PYTH_ORACLE_MAPPING_ADDRESS: string;
|
|
36
30
|
VELOCITY_PROGRAM_ID: string;
|
|
37
|
-
/** @deprecated Use `VELOCITY_PROGRAM_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
|
|
38
|
-
DRIFT_PROGRAM_ID: string;
|
|
39
31
|
JIT_PROXY_PROGRAM_ID?: string;
|
|
40
32
|
VELOCITY_ORACLE_RECEIVER_ID: string;
|
|
41
|
-
/** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. Kept on the config shape so existing callers reading this field continue to work; will be removed in a future major. */
|
|
42
|
-
DRIFT_ORACLE_RECEIVER_ID: string;
|
|
43
33
|
QUOTE_MINT_ADDRESS: string;
|
|
44
34
|
V2_ALPHA_TICKET_MINT_ADDRESS: string;
|
|
45
35
|
PERP_MARKETS: PerpMarketConfig[];
|
|
@@ -50,26 +40,15 @@ export interface VelocityConfig {
|
|
|
50
40
|
SB_ON_DEMAND_PID: PublicKey;
|
|
51
41
|
}
|
|
52
42
|
|
|
53
|
-
/** @deprecated Use `VelocityConfig` instead. `DriftConfig` will be removed in a future major. */
|
|
54
|
-
export type DriftConfig = VelocityConfig;
|
|
55
|
-
|
|
56
43
|
export const VELOCITY_PROGRAM_ID =
|
|
57
|
-
'
|
|
58
|
-
|
|
59
|
-
/** @deprecated Use `VELOCITY_PROGRAM_ID` instead. `DRIFT_PROGRAM_ID` will be removed in a future major. */
|
|
60
|
-
export const DRIFT_PROGRAM_ID = VELOCITY_PROGRAM_ID;
|
|
44
|
+
'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
|
|
61
45
|
|
|
62
46
|
export const VELOCITY_DEVNET_PROGRAM_ID =
|
|
63
47
|
'vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P';
|
|
64
48
|
|
|
65
|
-
/** @deprecated Use `VELOCITY_DEVNET_PROGRAM_ID` instead. `DRIFT_DEVNET_PROGRAM_ID` will be removed in a future major. */
|
|
66
|
-
export const DRIFT_DEVNET_PROGRAM_ID = VELOCITY_DEVNET_PROGRAM_ID;
|
|
67
|
-
|
|
68
49
|
export const VELOCITY_ORACLE_RECEIVER_ID =
|
|
69
50
|
'G6EoTTTgpkNBtVXo96EQp2m6uwwVh2Kt6YidjkmQqoha';
|
|
70
51
|
|
|
71
|
-
/** @deprecated Use `VELOCITY_ORACLE_RECEIVER_ID` instead. `DRIFT_ORACLE_RECEIVER_ID` will be removed in a future major. */
|
|
72
|
-
export const DRIFT_ORACLE_RECEIVER_ID = VELOCITY_ORACLE_RECEIVER_ID;
|
|
73
52
|
export const PTYH_LAZER_PROGRAM_ID =
|
|
74
53
|
'pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt';
|
|
75
54
|
export const SB_ON_DEMAND_DEVNET_PID = new PublicKey(
|
|
@@ -92,8 +71,6 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
92
71
|
ENV: 'devnet',
|
|
93
72
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
94
73
|
VELOCITY_PROGRAM_ID: VELOCITY_DEVNET_PROGRAM_ID,
|
|
95
|
-
/** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
|
|
96
|
-
DRIFT_PROGRAM_ID: VELOCITY_DEVNET_PROGRAM_ID,
|
|
97
74
|
JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
|
|
98
75
|
QUOTE_MINT_ADDRESS: '8FfvSRKMZRDHrCBy142XMUXrKEkXnxDQ4YmJv7xbAw8Q',
|
|
99
76
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
@@ -104,16 +81,12 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
104
81
|
MARKET_LOOKUP_TABLE: 'FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb',
|
|
105
82
|
MARKET_LOOKUP_TABLES: ['FaMS3U4uBojvGn5FSDEPimddcXsCfwkKsFgMVVnDdxGb'],
|
|
106
83
|
VELOCITY_ORACLE_RECEIVER_ID,
|
|
107
|
-
/** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
|
|
108
|
-
DRIFT_ORACLE_RECEIVER_ID: VELOCITY_ORACLE_RECEIVER_ID,
|
|
109
84
|
SB_ON_DEMAND_PID: SB_ON_DEMAND_DEVNET_PID,
|
|
110
85
|
},
|
|
111
86
|
'mainnet-beta': {
|
|
112
87
|
ENV: 'mainnet-beta',
|
|
113
88
|
PYTH_ORACLE_MAPPING_ADDRESS: 'AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J',
|
|
114
89
|
VELOCITY_PROGRAM_ID,
|
|
115
|
-
/** @deprecated Read `VELOCITY_PROGRAM_ID` instead. */
|
|
116
|
-
DRIFT_PROGRAM_ID: VELOCITY_PROGRAM_ID,
|
|
117
90
|
JIT_PROXY_PROGRAM_ID: 'J1TnP8zvVxbtF5KFp5xRmWuvG9McnhzmBd9XGfCyuxFP',
|
|
118
91
|
QUOTE_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
119
92
|
V2_ALPHA_TICKET_MINT_ADDRESS:
|
|
@@ -127,8 +100,6 @@ export const configs: { [key in VelocityEnv]: VelocityConfig } = {
|
|
|
127
100
|
'EiWSskK5HXnBTptiS5DH6gpAJRVNQ3cAhTKBGaiaysAb',
|
|
128
101
|
],
|
|
129
102
|
VELOCITY_ORACLE_RECEIVER_ID,
|
|
130
|
-
/** @deprecated Read `VELOCITY_ORACLE_RECEIVER_ID` instead. */
|
|
131
|
-
DRIFT_ORACLE_RECEIVER_ID: VELOCITY_ORACLE_RECEIVER_ID,
|
|
132
103
|
SB_ON_DEMAND_PID: SB_ON_DEMAND_MAINNET_PID,
|
|
133
104
|
},
|
|
134
105
|
};
|
|
@@ -144,21 +115,6 @@ export const getConfig = (): VelocityConfig => currentConfig;
|
|
|
144
115
|
* @param props
|
|
145
116
|
* @returns
|
|
146
117
|
*/
|
|
147
|
-
/**
|
|
148
|
-
* Mirror a canonical/deprecated alias pair so the resolved config carries the
|
|
149
|
-
* same value under both keys regardless of which one the caller overrode.
|
|
150
|
-
*/
|
|
151
|
-
const mirrorAlias = <K1 extends keyof VelocityConfig, K2 extends keyof VelocityConfig>(
|
|
152
|
-
merged: VelocityConfig,
|
|
153
|
-
override: Partial<VelocityConfig>,
|
|
154
|
-
canon: K1,
|
|
155
|
-
deprecated: K2
|
|
156
|
-
): void => {
|
|
157
|
-
const value = override[canon] ?? override[deprecated] ?? merged[canon];
|
|
158
|
-
(merged[canon] as VelocityConfig[K1]) = value as VelocityConfig[K1];
|
|
159
|
-
(merged[deprecated] as VelocityConfig[K2]) = value as VelocityConfig[K2];
|
|
160
|
-
};
|
|
161
|
-
|
|
162
118
|
export const initialize = (props: {
|
|
163
119
|
env: LegacyVelocityEnv;
|
|
164
120
|
overrideEnv?: Partial<VelocityConfig>;
|
|
@@ -166,17 +122,8 @@ export const initialize = (props: {
|
|
|
166
122
|
const override = props.overrideEnv ?? {};
|
|
167
123
|
const normalizedEnv: VelocityEnv =
|
|
168
124
|
props.env === 'master' ? 'devnet' : props.env;
|
|
169
|
-
const merged: VelocityConfig = { ...configs[normalizedEnv], ...override };
|
|
170
|
-
|
|
171
|
-
mirrorAlias(merged, override, 'VELOCITY_PROGRAM_ID', 'DRIFT_PROGRAM_ID');
|
|
172
|
-
mirrorAlias(
|
|
173
|
-
merged,
|
|
174
|
-
override,
|
|
175
|
-
'VELOCITY_ORACLE_RECEIVER_ID',
|
|
176
|
-
'DRIFT_ORACLE_RECEIVER_ID'
|
|
177
|
-
);
|
|
178
125
|
|
|
179
|
-
currentConfig =
|
|
126
|
+
currentConfig = { ...configs[normalizedEnv], ...override };
|
|
180
127
|
return currentConfig;
|
|
181
128
|
};
|
|
182
129
|
|
|
@@ -244,13 +191,10 @@ export async function findAllMarketAndOracles(
|
|
|
244
191
|
for (const perpMarketProgramAccount of perpMarketProgramAccounts) {
|
|
245
192
|
const perpMarket = perpMarketProgramAccount.account as PerpMarketAccount;
|
|
246
193
|
perpMarketIndexes.push(perpMarket.marketIndex);
|
|
247
|
-
oracleInfos.set(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
source: perpMarket.amm.oracleSource,
|
|
252
|
-
}
|
|
253
|
-
);
|
|
194
|
+
oracleInfos.set(getOracleId(perpMarket.oracle, perpMarket.oracleSource), {
|
|
195
|
+
publicKey: perpMarket.oracle,
|
|
196
|
+
source: perpMarket.oracleSource,
|
|
197
|
+
});
|
|
254
198
|
}
|
|
255
199
|
|
|
256
200
|
for (const spotMarketProgramAccount of spotMarketProgramAccounts) {
|
|
@@ -2,7 +2,7 @@ import { PERCENTAGE_PRECISION } from './numericConstants';
|
|
|
2
2
|
|
|
3
3
|
// follows program constant MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV in math/constants.rs
|
|
4
4
|
/**
|
|
5
|
-
* Max APR for
|
|
5
|
+
* Max APR for VELOCITY IF vault.
|
|
6
6
|
*/
|
|
7
7
|
export const MAX_APR_PER_REVENUE_SETTLE_TO_INSURANCE_FUND_VAULT_GOV =
|
|
8
8
|
PERCENTAGE_PRECISION.divn(22);
|
|
@@ -18,8 +18,6 @@ const MAX_CONSTITUENT_SIZE_BYTES = 480; // TODO: update this when account is fin
|
|
|
18
18
|
|
|
19
19
|
export type ConstituentMapConfig = {
|
|
20
20
|
velocityClient?: VelocityClient;
|
|
21
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
22
|
-
driftClient?: VelocityClient;
|
|
23
21
|
connection?: Connection;
|
|
24
22
|
subscriptionConfig:
|
|
25
23
|
| {
|
|
@@ -71,11 +69,9 @@ export class ConstituentMap implements ConstituentMapInterface {
|
|
|
71
69
|
private decoder: 'base64' | 'base64+zstd';
|
|
72
70
|
|
|
73
71
|
constructor(config: ConstituentMapConfig) {
|
|
74
|
-
const velocityClient = config.velocityClient
|
|
72
|
+
const velocityClient = config.velocityClient;
|
|
75
73
|
if (!velocityClient) {
|
|
76
|
-
throw new Error(
|
|
77
|
-
'ConstituentMap: velocityClient (or deprecated driftClient) must be provided'
|
|
78
|
-
);
|
|
74
|
+
throw new Error('ConstituentMap: velocityClient must be provided');
|
|
79
75
|
}
|
|
80
76
|
this.velocityClient = velocityClient;
|
|
81
77
|
this.additionalFilters = config.additionalFilters;
|
package/src/core/VelocityCore.ts
CHANGED
|
@@ -9,8 +9,8 @@ import * as pdas from '../addresses/pda';
|
|
|
9
9
|
import * as constants from '../constants';
|
|
10
10
|
import { decodeUser } from '../decode/user';
|
|
11
11
|
import { CustomBorshCoder } from '../decode/customCoder';
|
|
12
|
-
import
|
|
13
|
-
import type {
|
|
12
|
+
import velocityIDL from '../idl/velocity.json';
|
|
13
|
+
import type { Velocity } from '../idl/velocity';
|
|
14
14
|
import type { UserAccount } from '../types';
|
|
15
15
|
import type { VelocityProgram } from '../config';
|
|
16
16
|
import { fetchAccount } from '../accounts/fetch';
|
|
@@ -40,16 +40,13 @@ import * as remainingAccounts from './remainingAccounts';
|
|
|
40
40
|
import * as signedMsg from './signedMsg';
|
|
41
41
|
|
|
42
42
|
export type VelocityCoreContext = {
|
|
43
|
-
/**
|
|
43
|
+
/** Velocity program id. */
|
|
44
44
|
programId: PublicKey;
|
|
45
45
|
|
|
46
|
-
/** Anchor IDL json for
|
|
47
|
-
idl?:
|
|
46
|
+
/** Anchor IDL json for Velocity (defaults to bundled `idl/velocity.json`). */
|
|
47
|
+
idl?: Velocity;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
/** @deprecated Use `VelocityCoreContext` instead. `DriftCoreContext` will be removed in a future major. */
|
|
51
|
-
export type DriftCoreContext = VelocityCoreContext;
|
|
52
|
-
|
|
53
50
|
/**
|
|
54
51
|
* VelocityCore is the minimal, core SDK surface:
|
|
55
52
|
* - No subscriptions / polling / websockets.
|
|
@@ -68,20 +65,20 @@ export class VelocityCore {
|
|
|
68
65
|
static readonly remainingAccounts = remainingAccounts;
|
|
69
66
|
static readonly signedMsg = signedMsg;
|
|
70
67
|
|
|
71
|
-
static defaultIdl():
|
|
72
|
-
return
|
|
68
|
+
static defaultIdl(): Velocity {
|
|
69
|
+
return velocityIDL as unknown as Velocity;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
static coder(idl:
|
|
72
|
+
static coder(idl: Velocity = VelocityCore.defaultIdl()): CustomBorshCoder {
|
|
76
73
|
return new CustomBorshCoder(idl as any);
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
/** Decode a
|
|
76
|
+
/** Decode a Velocity `User` account buffer without creating a Program. */
|
|
80
77
|
static decodeUserAccount(buffer: Buffer): UserAccount {
|
|
81
78
|
return decodeUser(buffer);
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
/** Fetch and decode a
|
|
81
|
+
/** Fetch and decode a Velocity `User` account. */
|
|
85
82
|
static async fetchUserAccount(
|
|
86
83
|
connection: Connection,
|
|
87
84
|
userAccountPublicKey: PublicKey
|
|
@@ -116,7 +113,7 @@ export class VelocityCore {
|
|
|
116
113
|
state: PublicKey;
|
|
117
114
|
spotMarket: PublicKey;
|
|
118
115
|
spotMarketVault: PublicKey;
|
|
119
|
-
|
|
116
|
+
velocitySigner: PublicKey;
|
|
120
117
|
user: PublicKey;
|
|
121
118
|
userStats: PublicKey;
|
|
122
119
|
userTokenAccount: PublicKey;
|
|
@@ -329,9 +326,3 @@ export class VelocityCore {
|
|
|
329
326
|
return [];
|
|
330
327
|
}
|
|
331
328
|
}
|
|
332
|
-
|
|
333
|
-
/** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
|
|
334
|
-
export const DriftCore = VelocityCore;
|
|
335
|
-
|
|
336
|
-
/** @deprecated Use `VelocityCore` instead. `DriftCore` will be removed in a future major. */
|
|
337
|
-
export type DriftCore = VelocityCore;
|
|
@@ -14,7 +14,7 @@ export async function buildWithdrawInstruction(args: {
|
|
|
14
14
|
state: PublicKey;
|
|
15
15
|
spotMarket: PublicKey;
|
|
16
16
|
spotMarketVault: PublicKey;
|
|
17
|
-
|
|
17
|
+
velocitySigner: PublicKey;
|
|
18
18
|
user: PublicKey;
|
|
19
19
|
userStats: PublicKey;
|
|
20
20
|
userTokenAccount: PublicKey;
|
|
@@ -31,7 +31,7 @@ export async function buildWithdrawInstruction(args: {
|
|
|
31
31
|
state: args.state,
|
|
32
32
|
spotMarket: args.spotMarket,
|
|
33
33
|
spotMarketVault: args.spotMarketVault,
|
|
34
|
-
|
|
34
|
+
velocitySigner: args.velocitySigner,
|
|
35
35
|
user: args.user,
|
|
36
36
|
userStats: args.userStats,
|
|
37
37
|
userTokenAccount: args.userTokenAccount,
|
|
@@ -184,9 +184,9 @@ function addPerpMarketToRemainingAccountMaps(
|
|
|
184
184
|
isWritable: writable,
|
|
185
185
|
});
|
|
186
186
|
const oracleWritable =
|
|
187
|
-
writable && isVariant(perpMarketAccount.
|
|
188
|
-
oracleAccountMap.set(perpMarketAccount.
|
|
189
|
-
pubkey: perpMarketAccount.
|
|
187
|
+
writable && isVariant(perpMarketAccount.oracleSource, 'prelaunch');
|
|
188
|
+
oracleAccountMap.set(perpMarketAccount.oracle.toString(), {
|
|
189
|
+
pubkey: perpMarketAccount.oracle,
|
|
190
190
|
isSigner: false,
|
|
191
191
|
isWritable: oracleWritable,
|
|
192
192
|
});
|
package/src/decode/user.ts
CHANGED
|
@@ -143,8 +143,8 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
143
143
|
const orders: Order[] = [];
|
|
144
144
|
for (let i = 0; i < 32; i++) {
|
|
145
145
|
// skip order if it's not open
|
|
146
|
-
if (buffer.readUint8(offset +
|
|
147
|
-
offset +=
|
|
146
|
+
if (buffer.readUint8(offset + 86) !== 1) {
|
|
147
|
+
offset += 104;
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -166,8 +166,8 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
166
166
|
offset += 8;
|
|
167
167
|
const maxTs = readSignedBigInt64LE(buffer, offset);
|
|
168
168
|
offset += 8;
|
|
169
|
-
const oraclePriceOffset = buffer
|
|
170
|
-
offset +=
|
|
169
|
+
const oraclePriceOffset = readSignedBigInt64LE(buffer, offset);
|
|
170
|
+
offset += 8;
|
|
171
171
|
const orderId = buffer.readUInt32LE(offset);
|
|
172
172
|
offset += 4;
|
|
173
173
|
const marketIndex = buffer.readUInt16LE(offset);
|
|
@@ -245,7 +245,7 @@ export function decodeUser(buffer: Buffer): UserAccount {
|
|
|
245
245
|
offset += 1;
|
|
246
246
|
const bitFlags = buffer.readUint8(offset);
|
|
247
247
|
offset += 1;
|
|
248
|
-
offset +=
|
|
248
|
+
offset += 5; // padding
|
|
249
249
|
orders.push({
|
|
250
250
|
slot,
|
|
251
251
|
price,
|
package/src/dlob/DLOB.ts
CHANGED
|
@@ -333,7 +333,7 @@ export class DLOB {
|
|
|
333
333
|
isOneOfVariant(order.orderType, ['market', 'triggerMarket', 'oracle'])
|
|
334
334
|
) {
|
|
335
335
|
type = 'market';
|
|
336
|
-
} else if (order.oraclePriceOffset
|
|
336
|
+
} else if (!order.oraclePriceOffset.eq(ZERO)) {
|
|
337
337
|
type = 'floatingLimit';
|
|
338
338
|
} else {
|
|
339
339
|
const isResting = isRestingLimitOrder(order, slot);
|
|
@@ -483,7 +483,7 @@ export class DLOB {
|
|
|
483
483
|
);
|
|
484
484
|
|
|
485
485
|
const stepSize = isVariant(marketType, 'perp')
|
|
486
|
-
? (marketAccount as PerpMarketAccount).
|
|
486
|
+
? (marketAccount as PerpMarketAccount).orderStepSize
|
|
487
487
|
: (marketAccount as SpotMarketAccount).orderStepSize;
|
|
488
488
|
|
|
489
489
|
const cancelReduceOnlyNodesToFill =
|
|
@@ -1702,7 +1702,7 @@ export class DLOB {
|
|
|
1702
1702
|
}
|
|
1703
1703
|
|
|
1704
1704
|
public printTop(
|
|
1705
|
-
|
|
1705
|
+
velocityClient: VelocityClient,
|
|
1706
1706
|
slotSubscriber: SlotSubscriber,
|
|
1707
1707
|
marketIndex: number,
|
|
1708
1708
|
marketType: MarketType
|
|
@@ -1710,7 +1710,7 @@ export class DLOB {
|
|
|
1710
1710
|
if (isVariant(marketType, 'perp')) {
|
|
1711
1711
|
const slot = slotSubscriber.getSlot();
|
|
1712
1712
|
const oraclePriceData =
|
|
1713
|
-
|
|
1713
|
+
velocityClient.getMMOracleDataForPerpMarket(marketIndex);
|
|
1714
1714
|
|
|
1715
1715
|
const bestAsk = this.getBestAsk(
|
|
1716
1716
|
marketIndex,
|
|
@@ -1738,7 +1738,7 @@ export class DLOB {
|
|
|
1738
1738
|
100.0;
|
|
1739
1739
|
|
|
1740
1740
|
const name = decodeName(
|
|
1741
|
-
|
|
1741
|
+
velocityClient.getPerpMarketAccount(marketIndex).name
|
|
1742
1742
|
);
|
|
1743
1743
|
console.log(`Market ${name} Orders`);
|
|
1744
1744
|
console.log(
|
|
@@ -1755,7 +1755,7 @@ export class DLOB {
|
|
|
1755
1755
|
} else if (isVariant(marketType, 'spot')) {
|
|
1756
1756
|
const slot = slotSubscriber.getSlot();
|
|
1757
1757
|
const oraclePriceData =
|
|
1758
|
-
|
|
1758
|
+
velocityClient.getOracleDataForSpotMarket(marketIndex);
|
|
1759
1759
|
|
|
1760
1760
|
const bestAsk = this.getBestAsk(
|
|
1761
1761
|
marketIndex,
|
|
@@ -1783,7 +1783,7 @@ export class DLOB {
|
|
|
1783
1783
|
100.0;
|
|
1784
1784
|
|
|
1785
1785
|
const name = decodeName(
|
|
1786
|
-
|
|
1786
|
+
velocityClient.getSpotMarketAccount(marketIndex).name
|
|
1787
1787
|
);
|
|
1788
1788
|
console.log(`Market ${name} Orders`);
|
|
1789
1789
|
console.log(
|
package/src/dlob/DLOBNode.ts
CHANGED
|
@@ -21,10 +21,6 @@ import { BN } from '../isomorphic/anchor';
|
|
|
21
21
|
|
|
22
22
|
export class DLOBSubscriber {
|
|
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
|
dlobSource: DLOBSource;
|
|
29
25
|
slotSource: SlotSource;
|
|
30
26
|
updateFrequency: number;
|
|
@@ -32,11 +28,9 @@ export class DLOBSubscriber {
|
|
|
32
28
|
dlob: DLOB;
|
|
33
29
|
public eventEmitter: StrictEventEmitter<EventEmitter, DLOBSubscriberEvents>;
|
|
34
30
|
constructor(config: DLOBSubscriptionConfig) {
|
|
35
|
-
const velocityClient = config.velocityClient
|
|
31
|
+
const velocityClient = config.velocityClient;
|
|
36
32
|
if (!velocityClient) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
'DLOBSubscriber: velocityClient (or deprecated driftClient) must be provided'
|
|
39
|
-
);
|
|
33
|
+
throw new Error('DLOBSubscriber: velocityClient must be provided');
|
|
40
34
|
}
|
|
41
35
|
this.velocityClient = velocityClient;
|
|
42
36
|
this.dlobSource = config.dlobSource;
|