@velocity-exchange/sdk 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +1 -1
- package/CHANGELOG.md +20 -0
- package/README.md +30 -30
- package/bun.lock +1 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/browser/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/browser/accounts/laserProgramAccountSubscriber.js +1 -1
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
- package/lib/browser/accounts/types.d.ts +2 -8
- package/lib/browser/accounts/utils.js +2 -2
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/browser/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/browser/addresses/pda.d.ts +1 -7
- package/lib/browser/addresses/pda.js +4 -10
- package/lib/browser/adminClient.d.ts +1 -1
- package/lib/browser/adminClient.js +21 -21
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +1 -3
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +2 -6
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
- package/lib/browser/auctionSubscriber/types.d.ts +3 -2
- package/lib/browser/config.d.ts +10 -19
- package/lib/browser/config.js +6 -33
- package/lib/browser/constants/insuranceFund.d.ts +1 -1
- package/lib/browser/constants/insuranceFund.js +1 -1
- package/lib/browser/constituentMap/constituentMap.d.ts +0 -2
- package/lib/browser/constituentMap/constituentMap.js +5 -5
- package/lib/browser/core/VelocityCore.d.ts +9 -15
- package/lib/browser/core/VelocityCore.js +5 -7
- package/lib/browser/core/instructions/withdraw.d.ts +1 -1
- package/lib/browser/core/instructions/withdraw.js +1 -1
- package/lib/browser/core/remainingAccounts.js +3 -3
- package/lib/browser/dlob/DLOB.d.ts +1 -1
- package/lib/browser/dlob/DLOB.js +6 -6
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -2
- package/lib/browser/dlob/DLOBSubscriber.js +2 -7
- package/lib/browser/dlob/orderBookLevels.js +7 -7
- package/lib/browser/dlob/types.d.ts +0 -2
- package/lib/browser/events/eventSubscriber.d.ts +1 -1
- package/lib/browser/events/eventsServerLogProvider.js +2 -2
- package/lib/browser/events/parse.js +14 -14
- package/lib/browser/events/types.d.ts +3 -5
- package/lib/browser/events/types.js +1 -1
- package/lib/browser/idl/{drift.d.ts → velocity.d.ts} +1042 -767
- package/lib/browser/idl/{drift.json → velocity.json} +1033 -758
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/index.js +1 -2
- package/lib/browser/math/amm.d.ts +10 -10
- package/lib/browser/math/amm.js +29 -28
- package/lib/browser/math/auction.js +16 -12
- package/lib/browser/math/builder.d.ts +18 -1
- package/lib/browser/math/builder.js +32 -1
- package/lib/browser/math/funding.js +26 -26
- package/lib/browser/math/margin.d.ts +4 -4
- package/lib/browser/math/margin.js +15 -15
- package/lib/browser/math/market.js +13 -13
- package/lib/browser/math/oracles.d.ts +4 -4
- package/lib/browser/math/oracles.js +23 -23
- package/lib/browser/math/orders.d.ts +2 -2
- package/lib/browser/math/orders.js +9 -9
- package/lib/browser/math/position.js +4 -4
- package/lib/browser/math/superStake.d.ts +8 -10
- package/lib/browser/math/superStake.js +18 -20
- package/lib/browser/math/trade.js +5 -5
- package/lib/browser/math/utils.d.ts +1 -1
- package/lib/browser/math/utils.js +1 -1
- package/lib/browser/oracles/pythLazerClient.js +2 -2
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +0 -2
- package/lib/browser/orderSubscriber/OrderSubscriber.js +8 -12
- package/lib/browser/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/browser/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/browser/orderSubscriber/types.d.ts +0 -2
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +1 -5
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +7 -15
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/browser/priorityFee/types.d.ts +3 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/browser/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/browser/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/browser/pyth/pythLazerSubscriber.js +1 -1
- package/lib/browser/swap/UnifiedSwapClient.js +1 -1
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +2 -6
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +6 -5
- package/lib/browser/swift/swiftOrderSubscriber.js +5 -11
- package/lib/browser/types.d.ts +79 -91
- package/lib/browser/types.js +4 -0
- package/lib/browser/user.d.ts +1 -3
- package/lib/browser/user.js +19 -23
- package/lib/browser/userConfig.d.ts +3 -2
- package/lib/browser/userMap/WebsocketSubscription.js +1 -1
- package/lib/browser/userMap/grpcSubscription.js +1 -1
- package/lib/browser/userMap/referrerMap.d.ts +0 -2
- package/lib/browser/userMap/referrerMap.js +0 -4
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/browser/userMap/revenueShareEscrowMap.js +0 -4
- package/lib/browser/userMap/userMap.d.ts +2 -4
- package/lib/browser/userMap/userMap.js +10 -14
- package/lib/browser/userMap/userMapConfig.d.ts +3 -2
- package/lib/browser/userMap/userStatsMap.d.ts +0 -2
- package/lib/browser/userMap/userStatsMap.js +0 -4
- package/lib/browser/userStats.d.ts +0 -2
- package/lib/browser/userStats.js +10 -14
- package/lib/browser/userStatsConfig.d.ts +3 -2
- package/lib/browser/util/ed25519Utils.d.ts +1 -1
- package/lib/browser/util/ed25519Utils.js +1 -1
- package/lib/browser/velocityClient.d.ts +53 -38
- package/lib/browser/velocityClient.js +258 -196
- package/lib/browser/velocityClientConfig.d.ts +0 -8
- package/lib/node/accounts/grpcProgramAccountSubscriber.js +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriber.js +1 -3
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/grpcVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/node/accounts/laserProgramAccountSubscriber.js +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/pollingVelocityClientAccountSubscriber.js +5 -7
- package/lib/node/accounts/types.d.ts +2 -8
- package/lib/node/accounts/types.d.ts.map +1 -1
- package/lib/node/accounts/utils.js +2 -2
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts +0 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriber.js +5 -7
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts +0 -4
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.d.ts.map +1 -1
- package/lib/node/accounts/webSocketVelocityClientAccountSubscriberV2.js +5 -7
- package/lib/node/addresses/pda.d.ts +1 -7
- package/lib/node/addresses/pda.d.ts.map +1 -1
- package/lib/node/addresses/pda.js +4 -10
- package/lib/node/adminClient.d.ts +1 -1
- package/lib/node/adminClient.js +21 -21
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +1 -3
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +2 -6
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +1 -3
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +2 -6
- package/lib/node/auctionSubscriber/types.d.ts +3 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/config.d.ts +10 -19
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +6 -33
- package/lib/node/constants/insuranceFund.d.ts +1 -1
- package/lib/node/constants/insuranceFund.js +1 -1
- package/lib/node/constituentMap/constituentMap.d.ts +0 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +5 -5
- package/lib/node/core/VelocityCore.d.ts +9 -15
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +5 -7
- package/lib/node/core/instructions/withdraw.d.ts +1 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.js +1 -1
- package/lib/node/core/remainingAccounts.js +3 -3
- package/lib/node/dlob/DLOB.d.ts +1 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.js +6 -6
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -2
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +2 -7
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.js +7 -7
- package/lib/node/dlob/types.d.ts +0 -2
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/events/eventSubscriber.d.ts +1 -1
- package/lib/node/events/eventsServerLogProvider.js +2 -2
- package/lib/node/events/parse.d.ts.map +1 -1
- package/lib/node/events/parse.js +14 -14
- package/lib/node/events/types.d.ts +3 -5
- package/lib/node/events/types.d.ts.map +1 -1
- package/lib/node/events/types.js +1 -1
- package/lib/node/idl/{drift.d.ts → velocity.d.ts} +1043 -768
- package/lib/node/idl/velocity.d.ts.map +1 -0
- package/lib/node/idl/{drift.json → velocity.json} +1033 -758
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -2
- package/lib/node/math/amm.d.ts +10 -10
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/amm.js +29 -28
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +16 -12
- package/lib/node/math/builder.d.ts +18 -1
- package/lib/node/math/builder.d.ts.map +1 -1
- package/lib/node/math/builder.js +32 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/funding.js +26 -26
- package/lib/node/math/margin.d.ts +4 -4
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +15 -15
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/market.js +13 -13
- package/lib/node/math/oracles.d.ts +4 -4
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/oracles.js +23 -23
- package/lib/node/math/orders.d.ts +2 -2
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +9 -9
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/position.js +4 -4
- package/lib/node/math/superStake.d.ts +8 -10
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +18 -20
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/trade.js +5 -5
- package/lib/node/math/utils.d.ts +1 -1
- package/lib/node/math/utils.js +1 -1
- package/lib/node/oracles/pythLazerClient.js +2 -2
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +0 -2
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +8 -12
- package/lib/node/orderSubscriber/WebsocketSubscription.js +1 -1
- package/lib/node/orderSubscriber/grpcSubscription.js +2 -2
- package/lib/node/orderSubscriber/types.d.ts +0 -2
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +1 -5
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +7 -15
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +0 -4
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +3 -11
- package/lib/node/priorityFee/types.d.ts +3 -8
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts +0 -8
- package/lib/node/priorityFee/velocityPriorityFeeMethod.d.ts.map +1 -1
- package/lib/node/priorityFee/velocityPriorityFeeMethod.js +1 -3
- package/lib/node/pyth/pythLazerSubscriber.d.ts +1 -1
- package/lib/node/pyth/pythLazerSubscriber.js +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +4 -5
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +2 -6
- package/lib/node/swift/swiftOrderSubscriber.d.ts +6 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +5 -11
- package/lib/node/types.d.ts +79 -91
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +4 -0
- package/lib/node/user.d.ts +1 -3
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +19 -23
- package/lib/node/userConfig.d.ts +3 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/WebsocketSubscription.js +1 -1
- package/lib/node/userMap/grpcSubscription.js +1 -1
- package/lib/node/userMap/referrerMap.d.ts +0 -2
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +0 -4
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +0 -2
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +0 -4
- package/lib/node/userMap/userMap.d.ts +2 -4
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +10 -14
- package/lib/node/userMap/userMapConfig.d.ts +3 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +0 -2
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +0 -4
- package/lib/node/userStats.d.ts +0 -2
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +10 -14
- package/lib/node/userStatsConfig.d.ts +3 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- package/lib/node/util/ed25519Utils.d.ts +1 -1
- package/lib/node/util/ed25519Utils.js +1 -1
- package/lib/node/velocityClient.d.ts +53 -38
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +258 -196
- package/lib/node/velocityClientConfig.d.ts +0 -8
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +6 -7
- package/scripts/deposit-isolated-positions.ts +2 -2
- package/scripts/find-flagged-users.ts +1 -1
- package/scripts/grpc-client-test-comparison.ts +4 -4
- package/scripts/grpc-multiuser-client-test-comparison.ts +2 -2
- package/scripts/single-grpc-client-test.ts +3 -3
- package/scripts/updateVersion.js +4 -4
- package/scripts/withdraw-isolated-positions.ts +2 -2
- package/src/accounts/grpcProgramAccountSubscriber.ts +1 -1
- package/src/accounts/grpcVelocityClientAccountSubscriber.ts +0 -7
- package/src/accounts/grpcVelocityClientAccountSubscriberV2.ts +4 -11
- package/src/accounts/laserProgramAccountSubscriber.ts +1 -1
- package/src/accounts/pollingVelocityClientAccountSubscriber.ts +4 -11
- package/src/accounts/types.ts +2 -9
- package/src/accounts/utils.ts +2 -2
- package/src/accounts/webSocketVelocityClientAccountSubscriber.ts +4 -11
- package/src/accounts/webSocketVelocityClientAccountSubscriberV2.ts +4 -11
- package/src/addresses/pda.ts +3 -13
- package/src/adminClient.ts +21 -21
- package/src/auctionSubscriber/auctionSubscriber.ts +1 -6
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +1 -6
- package/src/auctionSubscriber/types.ts +3 -3
- package/src/config.ts +8 -67
- package/src/constants/insuranceFund.ts +1 -1
- package/src/constituentMap/constituentMap.ts +2 -6
- package/src/core/VelocityCore.ts +11 -20
- package/src/core/instructions/withdraw.ts +2 -2
- package/src/core/remainingAccounts.ts +3 -3
- package/src/dlob/DLOB.ts +6 -6
- package/src/dlob/DLOBSubscriber.ts +2 -8
- package/src/dlob/orderBookLevels.ts +12 -6
- package/src/dlob/types.ts +0 -2
- package/src/events/eventSubscriber.ts +1 -1
- package/src/events/eventsServerLogProvider.ts +2 -2
- package/src/events/parse.ts +14 -14
- package/src/events/types.ts +4 -7
- package/src/idl/{drift.json → velocity.json} +1033 -758
- package/src/idl/{drift.ts → velocity.ts} +1035 -760
- package/src/index.ts +1 -4
- package/src/margin/README.md +2 -2
- package/src/math/amm.ts +43 -21
- package/src/math/auction.ts +16 -12
- package/src/math/builder.ts +45 -1
- package/src/math/funding.ts +46 -43
- package/src/math/margin.ts +15 -15
- package/src/math/market.ts +21 -13
- package/src/math/oracles.ts +29 -26
- package/src/math/orders.ts +18 -5
- package/src/math/position.ts +9 -3
- package/src/math/superStake.ts +21 -24
- package/src/math/trade.ts +9 -1
- package/src/math/utils.ts +1 -1
- package/src/oracles/pythLazerClient.ts +3 -3
- package/src/orderSubscriber/OrderSubscriber.ts +2 -8
- package/src/orderSubscriber/WebsocketSubscription.ts +1 -1
- package/src/orderSubscriber/grpcSubscription.ts +2 -2
- package/src/orderSubscriber/types.ts +0 -2
- package/src/priorityFee/priorityFeeSubscriber.ts +5 -12
- package/src/priorityFee/priorityFeeSubscriberMap.ts +2 -10
- package/src/priorityFee/types.ts +3 -13
- package/src/priorityFee/velocityPriorityFeeMethod.ts +0 -12
- package/src/pyth/pythLazerSubscriber.ts +1 -1
- package/src/swap/UnifiedSwapClient.ts +1 -1
- package/src/swift/signedMsgUserAccountSubscriber.ts +2 -8
- package/src/swift/swiftOrderSubscriber.ts +7 -12
- package/src/types.ts +84 -102
- package/src/user.ts +9 -14
- package/src/userConfig.ts +1 -3
- package/src/userMap/WebsocketSubscription.ts +1 -1
- package/src/userMap/grpcSubscription.ts +1 -1
- package/src/userMap/referrerMap.ts +0 -4
- package/src/userMap/revenueShareEscrowMap.ts +0 -4
- package/src/userMap/userMap.ts +3 -7
- package/src/userMap/userMapConfig.ts +3 -3
- package/src/userMap/userStatsMap.ts +0 -4
- package/src/userStats.ts +1 -5
- package/src/userStatsConfig.ts +3 -3
- package/src/util/ed25519Utils.ts +1 -1
- package/src/velocityClient.ts +339 -225
- package/src/velocityClientConfig.ts +0 -10
- package/tests/{DriftCore → VelocityCore}/decode.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/fill_trigger.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/instructions.test.ts +1 -1
- package/tests/{DriftCore → VelocityCore}/pdas.test.ts +4 -2
- package/tests/ci/verifyConstants.ts +24 -27
- package/tests/decode/test.ts +2 -2
- package/tests/dlob/helpers.ts +5 -9
- package/tests/events/parseLogsForCuUsage.ts +15 -15
- package/tests/user/helpers.ts +9 -9
- package/tests/user/test.ts +13 -10
- package/lib/browser/util/deprecatedAlias.d.ts +0 -26
- package/lib/browser/util/deprecatedAlias.js +0 -10
- package/lib/node/idl/drift.d.ts.map +0 -1
- package/lib/node/util/deprecatedAlias.d.ts +0 -27
- package/lib/node/util/deprecatedAlias.d.ts.map +0 -1
- package/lib/node/util/deprecatedAlias.js +0 -10
- package/src/util/deprecatedAlias.ts +0 -21
- /package/lib/browser/idl/{drift.js → velocity.js} +0 -0
- /package/lib/node/idl/{drift.js → velocity.js} +0 -0
- /package/tests/{DriftCore → VelocityCore}/perp_orders.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/remainingAccounts.test.ts +0 -0
- /package/tests/{DriftCore → VelocityCore}/settlement_liquidation.test.ts +0 -0
package/.prettierignore
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
src/idl/
|
|
1
|
+
src/idl/velocity.ts
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.0](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.5...sdk-v0.1.0) (2026-06-11)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add builder codes on non swift ([#68](https://github.com/drift-labs/protocol-v2-shadow/issues/68)) ([2df4034](https://github.com/drift-labs/protocol-v2-shadow/commit/2df4034b2162f0df060b21453a16566f9de24f4f))
|
|
9
|
+
* add transfer deposit by delegate ([16386ca](https://github.com/drift-labs/protocol-v2-shadow/commit/16386cad98a2a48d9a8a249ff75c9ce646e9fcac))
|
|
10
|
+
* decouple AMM from rest of codebase ([84aba6d](https://github.com/drift-labs/protocol-v2-shadow/commit/84aba6d0c17ef97069185d82b74671bde6619919))
|
|
11
|
+
* rebrand drift to velocity ([9c330b1](https://github.com/drift-labs/protocol-v2-shadow/commit/9c330b17cda7170482cc8b75ad3d1b3c137a8d32))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* resolve eslint unused-var and prettier formatting failures ([a3a1e3e](https://github.com/drift-labs/protocol-v2-shadow/commit/a3a1e3e1cbf68f35a7c39ea335927d0136c5bce1))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Refactors
|
|
20
|
+
|
|
21
|
+
* gather vAMM and hedge into a single VLP module ([905edc3](https://github.com/drift-labs/protocol-v2-shadow/commit/905edc338b453a1ce0ebb4dd9a13be97c66aa66d))
|
|
22
|
+
|
|
3
23
|
## [0.0.5](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.4...sdk-v0.0.5) (2026-05-28)
|
|
4
24
|
|
|
5
25
|
|
package/README.md
CHANGED
|
@@ -19,20 +19,20 @@ npm i @velocity-exchange/sdk
|
|
|
19
19
|
|
|
20
20
|
## Getting Started
|
|
21
21
|
|
|
22
|
-
_Start here if you're integrating with
|
|
22
|
+
_Start here if you're integrating with Velocity!_
|
|
23
23
|
|
|
24
|
-
- [
|
|
24
|
+
- [Velocity v2-teacher + API Docs](https://drift-labs.github.io/v2-teacher/)
|
|
25
25
|
- Docs and examples for using the SDK in Typescript and Python
|
|
26
|
-
- Useful concepts and examples when integrating
|
|
27
|
-
- Docs for
|
|
26
|
+
- Useful concepts and examples when integrating Velocity
|
|
27
|
+
- Docs for Velocity's "Data API"
|
|
28
28
|
- [Typescript API docs](https://drift-labs.github.io/protocol-v2/sdk/)
|
|
29
|
-
- JSDoc automated documentation for the
|
|
30
|
-
- [
|
|
31
|
-
- Comprehensive universal docs for
|
|
29
|
+
- JSDoc automated documentation for the Velocity v2 Typescript SDK
|
|
30
|
+
- [Velocity docs](https://docs.drift.trade/)
|
|
31
|
+
- Comprehensive universal docs for Velocity
|
|
32
32
|
|
|
33
33
|
---
|
|
34
34
|
|
|
35
|
-
The below is a light overview of using Solana and
|
|
35
|
+
The below is a light overview of using Solana and Velocity's typescript sdk. If you want comprehensive docs with examples of how to integrate with Velocity you should use the [v2-teacher docs](https://drift-labs.github.io/v2-teacher/).
|
|
36
36
|
|
|
37
37
|
### Setting up a wallet for your program
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ The below is a light overview of using Solana and Drift's typescript sdk. If you
|
|
|
40
40
|
# Generate a keypair
|
|
41
41
|
solana-keygen new
|
|
42
42
|
|
|
43
|
-
# Get the pubkey for the new wallet (You will need to send USDC to this address to Deposit into
|
|
43
|
+
# Get the pubkey for the new wallet (You will need to send USDC to this address to Deposit into Velocity (only on mainnet - devnet has a faucet for USDC))
|
|
44
44
|
solana address
|
|
45
45
|
|
|
46
46
|
# Put the private key into your .env to be used by your bot
|
|
@@ -52,14 +52,14 @@ echo BOT_PRIVATE_KEY=`cat ~/.config/solana/id.json` >> .env
|
|
|
52
52
|
|
|
53
53
|
### BN / Precision
|
|
54
54
|
|
|
55
|
-
The
|
|
55
|
+
The Velocity SDK uses BigNum (BN), using [this package](https://github.com/indutny/bn.js/), to represent numerical values. This is because Solana tokens tend to use levels of precision which are too precise for standard Javascript floating point numbers to handle. All numbers in BN are represented as integers, and we will often denote the `precision` of the number so that it can be converted back down to a regular number.
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
Example:
|
|
59
59
|
a BigNum: 10,500,000, with precision 10^6, is equal to 10.5 because 10,500,000 / 10^6 = 10.5.
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
The
|
|
62
|
+
The Velocity SDK uses some common precisions, which are available as constants to import from the SDK.
|
|
63
63
|
|
|
64
64
|
| Precision Name | Value |
|
|
65
65
|
| --------------------- | ----- |
|
|
@@ -99,7 +99,7 @@ import { getAssociatedTokenAddress, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
|
99
99
|
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
100
100
|
import {
|
|
101
101
|
calculateReservePrice,
|
|
102
|
-
|
|
102
|
+
VelocityClient,
|
|
103
103
|
User,
|
|
104
104
|
initialize,
|
|
105
105
|
PositionDirection,
|
|
@@ -132,7 +132,7 @@ const main = async () => {
|
|
|
132
132
|
const env = 'devnet';
|
|
133
133
|
// const env = 'mainnet-beta';
|
|
134
134
|
|
|
135
|
-
// Initialize
|
|
135
|
+
// Initialize Velocity SDK
|
|
136
136
|
const sdkConfig = initialize({ env });
|
|
137
137
|
|
|
138
138
|
// Set up the Wallet and Provider
|
|
@@ -169,30 +169,30 @@ const main = async () => {
|
|
|
169
169
|
provider.wallet.publicKey.toString()
|
|
170
170
|
);
|
|
171
171
|
|
|
172
|
-
// Set up the
|
|
173
|
-
const
|
|
172
|
+
// Set up the Velocity Client
|
|
173
|
+
const velocityPublicKey = new PublicKey(sdkConfig.VELOCITY_PROGRAM_ID);
|
|
174
174
|
const bulkAccountLoader = new BulkAccountLoader(
|
|
175
175
|
provider.connection,
|
|
176
176
|
'confirmed',
|
|
177
177
|
1000
|
|
178
178
|
);
|
|
179
|
-
const
|
|
179
|
+
const velocityClient = new VelocityClient({
|
|
180
180
|
connection: provider.connection,
|
|
181
181
|
wallet: provider.wallet,
|
|
182
|
-
programID:
|
|
182
|
+
programID: velocityPublicKey,
|
|
183
183
|
accountSubscription: {
|
|
184
184
|
type: 'polling',
|
|
185
185
|
accountLoader: bulkAccountLoader,
|
|
186
186
|
},
|
|
187
187
|
});
|
|
188
|
-
await
|
|
188
|
+
await velocityClient.subscribe();
|
|
189
189
|
|
|
190
|
-
console.log('subscribed to
|
|
190
|
+
console.log('subscribed to velocityClient');
|
|
191
191
|
|
|
192
192
|
// Set up user client
|
|
193
193
|
const user = new User({
|
|
194
|
-
|
|
195
|
-
userAccountPublicKey: await
|
|
194
|
+
velocityClient: velocityClient,
|
|
195
|
+
userAccountPublicKey: await velocityClient.getUserAccountPublicKey(),
|
|
196
196
|
accountSubscription: {
|
|
197
197
|
type: 'polling',
|
|
198
198
|
accountLoader: bulkAccountLoader,
|
|
@@ -206,13 +206,13 @@ const main = async () => {
|
|
|
206
206
|
console.log(
|
|
207
207
|
'initializing to',
|
|
208
208
|
env,
|
|
209
|
-
'
|
|
209
|
+
' velocity account for',
|
|
210
210
|
provider.wallet.publicKey.toString()
|
|
211
211
|
);
|
|
212
212
|
|
|
213
|
-
//// Create a
|
|
213
|
+
//// Create a Velocity V2 account by Depositing some USDC ($10,000 in this case)
|
|
214
214
|
const depositAmount = new BN(10000).mul(QUOTE_PRECISION);
|
|
215
|
-
await
|
|
215
|
+
await velocityClient.initializeUserAccountAndDepositCollateral(
|
|
216
216
|
depositAmount,
|
|
217
217
|
await getTokenAddress(
|
|
218
218
|
usdcTokenAddress.toString(),
|
|
@@ -232,8 +232,8 @@ const main = async () => {
|
|
|
232
232
|
|
|
233
233
|
// Get vAMM bid and ask price
|
|
234
234
|
const [bid, ask] = calculateBidAskPrice(
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
velocityClient.getPerpMarketAccount(marketIndex).amm,
|
|
236
|
+
velocityClient.getOracleDataForPerpMarket(marketIndex)
|
|
237
237
|
);
|
|
238
238
|
|
|
239
239
|
const formattedBidPrice = convertToNumber(bid, PRICE_PRECISION);
|
|
@@ -244,12 +244,12 @@ const main = async () => {
|
|
|
244
244
|
`vAMM bid: $${formattedBidPrice} and ask: $${formattedAskPrice}`
|
|
245
245
|
);
|
|
246
246
|
|
|
247
|
-
const solMarketAccount =
|
|
247
|
+
const solMarketAccount = velocityClient.getPerpMarketAccount(
|
|
248
248
|
solMarketInfo.marketIndex
|
|
249
249
|
);
|
|
250
250
|
console.log(env, `Placing a 1 SOL-PERP LONG order`);
|
|
251
251
|
|
|
252
|
-
const txSig = await
|
|
252
|
+
const txSig = await velocityClient.placePerpOrder(
|
|
253
253
|
getMarketOrderParams({
|
|
254
254
|
baseAssetAmount: new BN(1).mul(BASE_PRECISION),
|
|
255
255
|
direction: PositionDirection.LONG,
|
|
@@ -267,8 +267,8 @@ main();
|
|
|
267
267
|
|
|
268
268
|
## License
|
|
269
269
|
|
|
270
|
-
|
|
270
|
+
Velocity Protocol v2 is licensed under [Apache 2.0](./LICENSE).
|
|
271
271
|
|
|
272
272
|
Unless you explicitly state otherwise, any contribution intentionally submitted
|
|
273
|
-
for inclusion in
|
|
273
|
+
for inclusion in Velocity SDK by you, as defined in the Apache-2.0 license, shall be
|
|
274
274
|
licensed as above, without any additional terms or conditions.
|
package/bun.lock
CHANGED
|
@@ -10,7 +10,3 @@ export declare class grpcVelocityClientAccountSubscriber extends WebSocketVeloci
|
|
|
10
10
|
subscribeToPerpMarketAccount(marketIndex: number): Promise<boolean>;
|
|
11
11
|
subscribeToOracle(oracleInfo: OracleInfo): Promise<boolean>;
|
|
12
12
|
}
|
|
13
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
|
|
14
|
-
export declare const grpcDriftClientAccountSubscriber: typeof grpcVelocityClientAccountSubscriber;
|
|
15
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
|
|
16
|
-
export type grpcDriftClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.grpcVelocityClientAccountSubscriber = void 0;
|
|
4
4
|
const webSocketVelocityClientAccountSubscriber_1 = require("./webSocketVelocityClientAccountSubscriber");
|
|
5
5
|
const config_1 = require("../config");
|
|
6
6
|
const pda_1 = require("../addresses/pda");
|
|
@@ -97,5 +97,3 @@ class grpcVelocityClientAccountSubscriber extends webSocketVelocityClientAccount
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
exports.grpcVelocityClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
|
|
100
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriber` instead. `grpcDriftClientAccountSubscriber` will be removed in a future major. */
|
|
101
|
-
exports.grpcDriftClientAccountSubscriber = grpcVelocityClientAccountSubscriber;
|
|
@@ -63,7 +63,3 @@ export declare class grpcVelocityClientAccountSubscriberV2 implements VelocityCl
|
|
|
63
63
|
unsubscribeFromOracles(): Promise<void>;
|
|
64
64
|
unsubscribe(): Promise<void>;
|
|
65
65
|
}
|
|
66
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
67
|
-
export declare const grpcDriftClientAccountSubscriberV2: typeof grpcVelocityClientAccountSubscriberV2;
|
|
68
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
69
|
-
export type grpcDriftClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.grpcVelocityClientAccountSubscriberV2 = void 0;
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const config_1 = require("../config");
|
|
@@ -206,7 +206,7 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
206
206
|
if (!perpMarketAccount || !oracleId) {
|
|
207
207
|
return undefined;
|
|
208
208
|
}
|
|
209
|
-
if (!perpMarketAccount.data.
|
|
209
|
+
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
210
210
|
// If the oracle has changed, we need to update the oracle map in background
|
|
211
211
|
this.setPerpOracleMap();
|
|
212
212
|
}
|
|
@@ -236,12 +236,12 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
236
236
|
}
|
|
237
237
|
const perpMarketAccount = perpMarket.data;
|
|
238
238
|
const perpMarketIndex = perpMarketAccount.marketIndex;
|
|
239
|
-
const oracle = perpMarketAccount.
|
|
240
|
-
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.
|
|
239
|
+
const oracle = perpMarketAccount.oracle;
|
|
240
|
+
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
|
|
241
241
|
if (!((_c = this.oracleMultiSubscriber) === null || _c === void 0 ? void 0 : _c.getAccountDataMap().has(oracleId))) {
|
|
242
242
|
addOraclePromises.push(this.addOracle({
|
|
243
243
|
publicKey: oracle,
|
|
244
|
-
source: perpMarket.data.
|
|
244
|
+
source: perpMarket.data.oracleSource,
|
|
245
245
|
}));
|
|
246
246
|
}
|
|
247
247
|
this.perpOracleMap.set(perpMarketIndex, oracle);
|
|
@@ -453,5 +453,3 @@ class grpcVelocityClientAccountSubscriberV2 {
|
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
exports.grpcVelocityClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
|
|
456
|
-
/** @deprecated Use `grpcVelocityClientAccountSubscriberV2` instead. `grpcDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
457
|
-
exports.grpcDriftClientAccountSubscriberV2 = grpcVelocityClientAccountSubscriberV2;
|
|
@@ -67,7 +67,3 @@ export declare class PollingVelocityClientAccountSubscriber implements VelocityC
|
|
|
67
67
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
68
68
|
updateAccountLoaderPollingFrequency(pollingFrequency: number): void;
|
|
69
69
|
}
|
|
70
|
-
/** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
|
|
71
|
-
export declare const PollingDriftClientAccountSubscriber: typeof PollingVelocityClientAccountSubscriber;
|
|
72
|
-
/** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
|
|
73
|
-
export type PollingDriftClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PollingVelocityClientAccountSubscriber = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const types_2 = require("../types");
|
|
@@ -300,12 +300,12 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
300
300
|
for (const perpMarket of perpMarkets) {
|
|
301
301
|
const perpMarketAccount = perpMarket.data;
|
|
302
302
|
const perpMarketIndex = perpMarketAccount.marketIndex;
|
|
303
|
-
const oracle = perpMarketAccount.
|
|
304
|
-
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarketAccount.
|
|
303
|
+
const oracle = perpMarketAccount.oracle;
|
|
304
|
+
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarketAccount.oracleSource);
|
|
305
305
|
if (!this.oracles.has(oracleId)) {
|
|
306
306
|
oraclePromises.push(this.addOracle({
|
|
307
307
|
publicKey: oracle,
|
|
308
|
-
source: perpMarketAccount.
|
|
308
|
+
source: perpMarketAccount.oracleSource,
|
|
309
309
|
}));
|
|
310
310
|
}
|
|
311
311
|
this.perpOracleMap.set(perpMarketIndex, oracle);
|
|
@@ -392,7 +392,7 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
392
392
|
if (!perpMarketAccount || !oracle) {
|
|
393
393
|
return undefined;
|
|
394
394
|
}
|
|
395
|
-
if (!perpMarketAccount.data.
|
|
395
|
+
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
396
396
|
// If the oracle has changed, we need to update the oracle map in background
|
|
397
397
|
this.setPerpOracleMap();
|
|
398
398
|
}
|
|
@@ -416,5 +416,3 @@ class PollingVelocityClientAccountSubscriber {
|
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
exports.PollingVelocityClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
|
|
419
|
-
/** @deprecated Use `PollingVelocityClientAccountSubscriber` instead. `PollingDriftClientAccountSubscriber` will be removed in a future major. */
|
|
420
|
-
exports.PollingDriftClientAccountSubscriber = PollingVelocityClientAccountSubscriber;
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* market, oracle, and state accounts cached in memory. `User` uses a `UserAccountSubscriber`
|
|
9
9
|
* for the individual User account. All subscribers implement the interfaces defined here.
|
|
10
10
|
*
|
|
11
|
-
* Implementations: `
|
|
12
|
-
* `
|
|
11
|
+
* Implementations: `webSocketVelocityClientAccountSubscriber.ts` (default),
|
|
12
|
+
* `pollingVelocityClientAccountSubscriber.ts`, `bulkAccountLoader.ts` (batched RPC).
|
|
13
13
|
*/
|
|
14
14
|
import { SpotMarketAccount, PerpMarketAccount, OracleSource, StateAccount, UserAccount, UserStatsAccount, InsuranceFundStake, ConstituentAccount } from '../types';
|
|
15
15
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
@@ -42,9 +42,6 @@ export interface VelocityClientAccountEvents {
|
|
|
42
42
|
update: void;
|
|
43
43
|
error: (e: Error) => void;
|
|
44
44
|
}
|
|
45
|
-
/** @deprecated Use `VelocityClientAccountEvents` instead. `DriftClientAccountEvents` will be removed in a future major. */
|
|
46
|
-
export interface DriftClientAccountEvents extends VelocityClientAccountEvents {
|
|
47
|
-
}
|
|
48
45
|
export interface VelocityClientAccountSubscriber {
|
|
49
46
|
eventEmitter: StrictEventEmitter<EventEmitter, VelocityClientAccountEvents>;
|
|
50
47
|
isSubscribed: boolean;
|
|
@@ -66,9 +63,6 @@ export interface VelocityClientAccountSubscriber {
|
|
|
66
63
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
67
64
|
updateAccountLoaderPollingFrequency?: (pollingFrequency: number) => void;
|
|
68
65
|
}
|
|
69
|
-
/** @deprecated Use `VelocityClientAccountSubscriber` instead. `DriftClientAccountSubscriber` will be removed in a future major. */
|
|
70
|
-
export interface DriftClientAccountSubscriber extends VelocityClientAccountSubscriber {
|
|
71
|
-
}
|
|
72
66
|
export declare enum DelistedMarketSetting {
|
|
73
67
|
Unsubscribe = 0,
|
|
74
68
|
Subscribe = 1,
|
|
@@ -17,8 +17,8 @@ function findDelistedPerpMarketsAndOracles(perpMarkets, spotMarkets) {
|
|
|
17
17
|
if ((0, types_1.isVariant)(perpMarket.data.status, 'delisted')) {
|
|
18
18
|
delistedPerpMarketIndexes.push(perpMarket.data.marketIndex);
|
|
19
19
|
delistedOracles.push({
|
|
20
|
-
publicKey: perpMarket.data.
|
|
21
|
-
source: perpMarket.data.
|
|
20
|
+
publicKey: perpMarket.data.oracle,
|
|
21
|
+
source: perpMarket.data.oracleSource,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -71,7 +71,3 @@ export declare class WebSocketVelocityClientAccountSubscriber implements Velocit
|
|
|
71
71
|
getOraclePriceDataAndSlotForPerpMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
72
72
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
73
73
|
}
|
|
74
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
|
|
75
|
-
export declare const WebSocketDriftClientAccountSubscriber: typeof WebSocketVelocityClientAccountSubscriber;
|
|
76
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
|
|
77
|
-
export type WebSocketDriftClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebSocketVelocityClientAccountSubscriber = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const events_1 = require("events");
|
|
6
6
|
const pda_1 = require("../addresses/pda");
|
|
@@ -279,12 +279,12 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
279
279
|
}
|
|
280
280
|
const perpMarketAccount = perpMarket.data;
|
|
281
281
|
const perpMarketIndex = perpMarketAccount.marketIndex;
|
|
282
|
-
const oracle = perpMarketAccount.
|
|
283
|
-
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.
|
|
282
|
+
const oracle = perpMarketAccount.oracle;
|
|
283
|
+
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
|
|
284
284
|
if (!this.oracleSubscribers.has(oracleId)) {
|
|
285
285
|
addOraclePromises.push(this.addOracle({
|
|
286
286
|
publicKey: oracle,
|
|
287
|
-
source: perpMarket.data.
|
|
287
|
+
source: perpMarket.data.oracleSource,
|
|
288
288
|
}));
|
|
289
289
|
}
|
|
290
290
|
this.perpOracleMap.set(perpMarketIndex, oracle);
|
|
@@ -375,7 +375,7 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
375
375
|
if (!perpMarketAccount || !oracleId) {
|
|
376
376
|
return undefined;
|
|
377
377
|
}
|
|
378
|
-
if (!perpMarketAccount.data.
|
|
378
|
+
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
379
379
|
// If the oracle has changed, we need to update the oracle map in background
|
|
380
380
|
this.setPerpOracleMap();
|
|
381
381
|
}
|
|
@@ -396,5 +396,3 @@ class WebSocketVelocityClientAccountSubscriber {
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
exports.WebSocketVelocityClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
|
|
399
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriber` instead. `WebSocketDriftClientAccountSubscriber` will be removed in a future major. */
|
|
400
|
-
exports.WebSocketDriftClientAccountSubscriber = WebSocketVelocityClientAccountSubscriber;
|
|
@@ -85,7 +85,3 @@ export declare class WebSocketVelocityClientAccountSubscriberV2 implements Veloc
|
|
|
85
85
|
getOraclePriceDataAndSlotForPerpMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
86
86
|
getOraclePriceDataAndSlotForSpotMarket(marketIndex: number): DataAndSlot<OraclePriceData> | undefined;
|
|
87
87
|
}
|
|
88
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
89
|
-
export declare const WebSocketDriftClientAccountSubscriberV2: typeof WebSocketVelocityClientAccountSubscriberV2;
|
|
90
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
91
|
-
export type WebSocketDriftClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.WebSocketVelocityClientAccountSubscriberV2 = void 0;
|
|
4
4
|
const types_1 = require("./types");
|
|
5
5
|
const types_2 = require("../types");
|
|
6
6
|
const events_1 = require("events");
|
|
@@ -330,12 +330,12 @@ class WebSocketVelocityClientAccountSubscriberV2 {
|
|
|
330
330
|
}
|
|
331
331
|
const perpMarketAccount = perpMarket.data;
|
|
332
332
|
const perpMarketIndex = perpMarketAccount.marketIndex;
|
|
333
|
-
const oracle = perpMarketAccount.
|
|
334
|
-
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.
|
|
333
|
+
const oracle = perpMarketAccount.oracle;
|
|
334
|
+
const oracleId = (0, oracleId_1.getOracleId)(oracle, perpMarket.data.oracleSource);
|
|
335
335
|
if (!this.oracleSubscribers.has(oracleId)) {
|
|
336
336
|
addOraclePromises.push(this.addOracle({
|
|
337
337
|
publicKey: oracle,
|
|
338
|
-
source: perpMarket.data.
|
|
338
|
+
source: perpMarket.data.oracleSource,
|
|
339
339
|
}));
|
|
340
340
|
}
|
|
341
341
|
this.perpOracleMap.set(perpMarketIndex, oracle);
|
|
@@ -421,7 +421,7 @@ class WebSocketVelocityClientAccountSubscriberV2 {
|
|
|
421
421
|
if (!perpMarketAccount || !oracleId) {
|
|
422
422
|
return undefined;
|
|
423
423
|
}
|
|
424
|
-
if (!perpMarketAccount.data.
|
|
424
|
+
if (!perpMarketAccount.data.oracle.equals(oracle)) {
|
|
425
425
|
// If the oracle has changed, we need to update the oracle map in background
|
|
426
426
|
this.setPerpOracleMap();
|
|
427
427
|
}
|
|
@@ -442,5 +442,3 @@ class WebSocketVelocityClientAccountSubscriberV2 {
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
exports.WebSocketVelocityClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
|
|
445
|
-
/** @deprecated Use `WebSocketVelocityClientAccountSubscriberV2` instead. `WebSocketDriftClientAccountSubscriberV2` will be removed in a future major. */
|
|
446
|
-
exports.WebSocketDriftClientAccountSubscriberV2 = WebSocketVelocityClientAccountSubscriberV2;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PDA derivation helpers for all
|
|
2
|
+
* PDA derivation helpers for all Velocity protocol accounts.
|
|
3
3
|
* Covers: User, UserStats, PerpMarket, SpotMarket, InsuranceFundStake,
|
|
4
4
|
* HighLeverageModeConfig, State, and vault PDAs.
|
|
5
5
|
* All functions are pure (no RPC calls).
|
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
import { PublicKey } from '@solana/web3.js';
|
|
8
8
|
import { SpotMarketAccount } from '../types';
|
|
9
9
|
export declare function getVelocityStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
|
|
10
|
-
/** @deprecated Use `getVelocityStateAccountPublicKeyAndNonce` instead. `getDriftStateAccountPublicKeyAndNonce` will be removed in a future major. */
|
|
11
|
-
export declare const getDriftStateAccountPublicKeyAndNonce: typeof getVelocityStateAccountPublicKeyAndNonce;
|
|
12
10
|
export declare function getVelocityStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
|
|
13
|
-
/** @deprecated Use `getVelocityStateAccountPublicKey` instead. `getDriftStateAccountPublicKey` will be removed in a future major. */
|
|
14
|
-
export declare const getDriftStateAccountPublicKey: typeof getVelocityStateAccountPublicKey;
|
|
15
11
|
export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<[PublicKey, number]>;
|
|
16
12
|
export declare function getUserAccountPublicKey(programId: PublicKey, authority: PublicKey, subAccountId?: number): Promise<PublicKey>;
|
|
17
13
|
export declare function getUserAccountPublicKeySync(programId: PublicKey, authority: PublicKey, subAccountId?: number): PublicKey;
|
|
@@ -26,8 +22,6 @@ export declare function getSpotMarketVaultPublicKey(programId: PublicKey, market
|
|
|
26
22
|
export declare function getInsuranceFundVaultPublicKey(programId: PublicKey, marketIndex: number): Promise<PublicKey>;
|
|
27
23
|
export declare function getInsuranceFundStakeAccountPublicKey(programId: PublicKey, authority: PublicKey, marketIndex: number): PublicKey;
|
|
28
24
|
export declare function getVelocitySignerPublicKey(programId: PublicKey): PublicKey;
|
|
29
|
-
/** @deprecated Use `getVelocitySignerPublicKey` instead. `getDriftSignerPublicKey` will be removed in a future major. */
|
|
30
|
-
export declare const getDriftSignerPublicKey: typeof getVelocitySignerPublicKey;
|
|
31
25
|
export declare function getReferrerNamePublicKeySync(programId: PublicKey, nameBuffer: number[]): PublicKey;
|
|
32
26
|
export declare function getProtocolIfSharesTransferConfigPublicKey(programId: PublicKey): PublicKey;
|
|
33
27
|
export declare function getPrelaunchOraclePublicKey(programId: PublicKey, marketIndex: number): PublicKey;
|
|
@@ -23,9 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getLpPoolTokenTokenAccountPublicKey = exports.getConstituentCorrelationsPublicKey = exports.getAmmCachePublicKey = exports.getConstituentVaultPublicKey = exports.getConstituentPublicKey = exports.getConstituentTargetBasePublicKey = exports.getAmmConstituentMappingPublicKey = exports.getLpPoolTokenVaultPublicKey = exports.getLpPoolPublicKey = exports.getRevenueShareEscrowAccountPublicKey = exports.getRevenueShareAccountPublicKey = exports.getIfRebalanceConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.
|
|
26
|
+
exports.getLpPoolTokenTokenAccountPublicKey = exports.getConstituentCorrelationsPublicKey = exports.getAmmCachePublicKey = exports.getConstituentVaultPublicKey = exports.getConstituentPublicKey = exports.getConstituentTargetBasePublicKey = exports.getAmmConstituentMappingPublicKey = exports.getLpPoolTokenVaultPublicKey = exports.getLpPoolPublicKey = exports.getRevenueShareEscrowAccountPublicKey = exports.getRevenueShareAccountPublicKey = exports.getIfRebalanceConfigPublicKey = exports.getTokenProgramForSpotMarket = exports.getPythLazerOraclePublicKey = exports.getPrelaunchOraclePublicKey = exports.getProtocolIfSharesTransferConfigPublicKey = exports.getReferrerNamePublicKeySync = exports.getVelocitySignerPublicKey = exports.getInsuranceFundStakeAccountPublicKey = exports.getInsuranceFundVaultPublicKey = exports.getSpotMarketVaultPublicKey = exports.getSpotMarketPublicKeySync = exports.getSpotMarketPublicKey = exports.getPerpMarketPublicKeySync = exports.getPerpMarketPublicKey = exports.getSignedMsgWsDelegatesAccountPublicKey = exports.getSignedMsgUserAccountPublicKey = exports.getUserStatsAccountPublicKey = exports.getUserAccountPublicKeySync = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getVelocityStateAccountPublicKey = exports.getVelocityStateAccountPublicKeyAndNonce = void 0;
|
|
27
27
|
/**
|
|
28
|
-
* PDA derivation helpers for all
|
|
28
|
+
* PDA derivation helpers for all Velocity protocol accounts.
|
|
29
29
|
* Covers: User, UserStats, PerpMarket, SpotMarket, InsuranceFundStake,
|
|
30
30
|
* HighLeverageModeConfig, State, and vault PDAs.
|
|
31
31
|
* All functions are pure (no RPC calls).
|
|
@@ -36,17 +36,13 @@ const anchor_1 = require("../isomorphic/anchor");
|
|
|
36
36
|
const spl_token_1 = require("@solana/spl-token");
|
|
37
37
|
const types_1 = require("../types");
|
|
38
38
|
async function getVelocityStateAccountPublicKeyAndNonce(programId) {
|
|
39
|
-
return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('
|
|
39
|
+
return web3_js_1.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('velocity_state'))], programId);
|
|
40
40
|
}
|
|
41
41
|
exports.getVelocityStateAccountPublicKeyAndNonce = getVelocityStateAccountPublicKeyAndNonce;
|
|
42
|
-
/** @deprecated Use `getVelocityStateAccountPublicKeyAndNonce` instead. `getDriftStateAccountPublicKeyAndNonce` will be removed in a future major. */
|
|
43
|
-
exports.getDriftStateAccountPublicKeyAndNonce = getVelocityStateAccountPublicKeyAndNonce;
|
|
44
42
|
async function getVelocityStateAccountPublicKey(programId) {
|
|
45
43
|
return (await getVelocityStateAccountPublicKeyAndNonce(programId))[0];
|
|
46
44
|
}
|
|
47
45
|
exports.getVelocityStateAccountPublicKey = getVelocityStateAccountPublicKey;
|
|
48
|
-
/** @deprecated Use `getVelocityStateAccountPublicKey` instead. `getDriftStateAccountPublicKey` will be removed in a future major. */
|
|
49
|
-
exports.getDriftStateAccountPublicKey = getVelocityStateAccountPublicKey;
|
|
50
46
|
async function getUserAccountPublicKeyAndNonce(programId, authority, subAccountId = 0) {
|
|
51
47
|
return web3_js_1.PublicKey.findProgramAddress([
|
|
52
48
|
Buffer.from(anchor.utils.bytes.utf8.encode('user')),
|
|
@@ -139,11 +135,9 @@ function getInsuranceFundStakeAccountPublicKey(programId, authority, marketIndex
|
|
|
139
135
|
}
|
|
140
136
|
exports.getInsuranceFundStakeAccountPublicKey = getInsuranceFundStakeAccountPublicKey;
|
|
141
137
|
function getVelocitySignerPublicKey(programId) {
|
|
142
|
-
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('
|
|
138
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from(anchor.utils.bytes.utf8.encode('velocity_signer'))], programId)[0];
|
|
143
139
|
}
|
|
144
140
|
exports.getVelocitySignerPublicKey = getVelocitySignerPublicKey;
|
|
145
|
-
/** @deprecated Use `getVelocitySignerPublicKey` instead. `getDriftSignerPublicKey` will be removed in a future major. */
|
|
146
|
-
exports.getDriftSignerPublicKey = getVelocitySignerPublicKey;
|
|
147
141
|
function getReferrerNamePublicKeySync(programId, nameBuffer) {
|
|
148
142
|
return web3_js_1.PublicKey.findProgramAddressSync([
|
|
149
143
|
Buffer.from(anchor.utils.bytes.utf8.encode('referrer_name')),
|
|
@@ -313,7 +313,7 @@ export declare class AdminClient extends VelocityClient {
|
|
|
313
313
|
updateConstituentCorrelationData(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionSignature>;
|
|
314
314
|
getUpdateConstituentCorrelationDataIx(lpPoolId: number, index1: number, index2: number, correlation: BN): Promise<TransactionInstruction[]>;
|
|
315
315
|
/**
|
|
316
|
-
* Get the
|
|
316
|
+
* Get the velocity begin_swap and end_swap instructions
|
|
317
317
|
*
|
|
318
318
|
* @param outMarketIndex the market index of the token you're buying
|
|
319
319
|
* @param inMarketIndex the market index of the token you're selling
|