@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
|
@@ -64,9 +64,6 @@ export type VelocityClientConfig = {
|
|
|
64
64
|
coder?: Coder;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
/** @deprecated Use `VelocityClientConfig` instead. `DriftClientConfig` will be removed in a future major. */
|
|
68
|
-
export type DriftClientConfig = VelocityClientConfig;
|
|
69
|
-
|
|
70
67
|
type GrpcVelocityClientAccountSubscriberCtor = new (
|
|
71
68
|
grpcConfigs: GrpcConfigs,
|
|
72
69
|
program: Program,
|
|
@@ -97,8 +94,6 @@ export type VelocityClientSubscriptionConfig =
|
|
|
97
94
|
resubTimeoutMs?: number;
|
|
98
95
|
logResubMessages?: boolean;
|
|
99
96
|
velocityClientAccountSubscriber?: GrpcVelocityClientAccountSubscriberCtor;
|
|
100
|
-
/** @deprecated Use `velocityClientAccountSubscriber` instead. `driftClientAccountSubscriber` will be removed in a future major. */
|
|
101
|
-
driftClientAccountSubscriber?: GrpcVelocityClientAccountSubscriberCtor;
|
|
102
97
|
grpcMultiUserAccountSubscriber?: grpcMultiUserAccountSubscriber;
|
|
103
98
|
}
|
|
104
99
|
| {
|
|
@@ -117,13 +112,8 @@ export type VelocityClientSubscriptionConfig =
|
|
|
117
112
|
) => WebSocketAccountSubscriberV2<any> | WebSocketAccountSubscriber<any>;
|
|
118
113
|
/** If you use V2 here, whatever you pass for perpMarketAccountSubscriber will be ignored and it will use v2 under the hood regardless */
|
|
119
114
|
velocityClientAccountSubscriber?: WsVelocityClientAccountSubscriberCtor;
|
|
120
|
-
/** @deprecated Use `velocityClientAccountSubscriber` instead. `driftClientAccountSubscriber` will be removed in a future major. */
|
|
121
|
-
driftClientAccountSubscriber?: WsVelocityClientAccountSubscriberCtor;
|
|
122
115
|
}
|
|
123
116
|
| {
|
|
124
117
|
type: 'polling';
|
|
125
118
|
accountLoader: BulkAccountLoader;
|
|
126
119
|
};
|
|
127
|
-
|
|
128
|
-
/** @deprecated Use `VelocityClientSubscriptionConfig` instead. `DriftClientSubscriptionConfig` will be removed in a future major. */
|
|
129
|
-
export type DriftClientSubscriptionConfig = VelocityClientSubscriptionConfig;
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { VelocityCore } from '../../src/core/VelocityCore';
|
|
3
3
|
import { userAccountBufferStrings } from '../decode/userAccountBufferStrings';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
5
|
+
describe('VelocityCore decoding', () => {
|
|
6
6
|
test('can decode User account from fixture buffer', () => {
|
|
7
7
|
const s = userAccountBufferStrings[0];
|
|
8
8
|
const buf = Buffer.from(s, 'base64');
|
|
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { Keypair } from '@solana/web3.js';
|
|
3
3
|
import { VelocityCore } from '../../src/core/VelocityCore';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
5
|
+
describe('VelocityCore fill/trigger builders', () => {
|
|
6
6
|
test('buildFillPerpOrderInstruction wires accounts + args', async () => {
|
|
7
7
|
const called: any[] = [];
|
|
8
8
|
const fakeIx = {
|
|
@@ -3,7 +3,7 @@ import { VelocityCore } from '../../src/core/VelocityCore';
|
|
|
3
3
|
import { Keypair } from '@solana/web3.js';
|
|
4
4
|
import { BN } from '../../src/isomorphic/anchor';
|
|
5
5
|
|
|
6
|
-
describe('
|
|
6
|
+
describe('VelocityCore instruction builders', () => {
|
|
7
7
|
test('buildDepositInstruction calls underlying program.deposit', async () => {
|
|
8
8
|
const called: any[] = [];
|
|
9
9
|
const fakeIx = {
|
|
@@ -2,13 +2,15 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { Keypair, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { VelocityCore } from '../../src/core/VelocityCore';
|
|
4
4
|
|
|
5
|
-
describe('
|
|
5
|
+
describe('VelocityCore.pdas', () => {
|
|
6
6
|
test('derives deterministic user/state PDAs', async () => {
|
|
7
7
|
const programId = Keypair.generate().publicKey;
|
|
8
8
|
const authority = Keypair.generate().publicKey;
|
|
9
9
|
|
|
10
10
|
const [state] =
|
|
11
|
-
await VelocityCore.pdas.
|
|
11
|
+
await VelocityCore.pdas.getVelocityStateAccountPublicKeyAndNonce(
|
|
12
|
+
programId
|
|
13
|
+
);
|
|
12
14
|
const user0 = await VelocityCore.pdas.getUserAccountPublicKey(
|
|
13
15
|
programId,
|
|
14
16
|
authority,
|
|
@@ -49,7 +49,7 @@ describe('Verify Constants', function () {
|
|
|
49
49
|
1
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const devnetVelocityClient = new VelocityClient({
|
|
53
53
|
connection: devnetConnection,
|
|
54
54
|
wallet,
|
|
55
55
|
env: 'devnet',
|
|
@@ -59,7 +59,7 @@ describe('Verify Constants', function () {
|
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const mainnetVelocityClient = new VelocityClient({
|
|
63
63
|
connection: mainnetConnection,
|
|
64
64
|
wallet,
|
|
65
65
|
env: 'mainnet-beta',
|
|
@@ -72,18 +72,19 @@ describe('Verify Constants', function () {
|
|
|
72
72
|
let lutAccounts: string[];
|
|
73
73
|
|
|
74
74
|
before(async () => {
|
|
75
|
-
await
|
|
76
|
-
await
|
|
75
|
+
await devnetVelocityClient.subscribe();
|
|
76
|
+
await mainnetVelocityClient.subscribe();
|
|
77
77
|
|
|
78
|
-
const lookupTables =
|
|
78
|
+
const lookupTables =
|
|
79
|
+
await mainnetVelocityClient.fetchAllLookupTableAccounts();
|
|
79
80
|
lutAccounts = lookupTables
|
|
80
81
|
.map((lut) => lut.state.addresses.map((x) => x.toBase58()))
|
|
81
82
|
.flat();
|
|
82
83
|
});
|
|
83
84
|
|
|
84
85
|
after(async () => {
|
|
85
|
-
await
|
|
86
|
-
await
|
|
86
|
+
await devnetVelocityClient.unsubscribe();
|
|
87
|
+
await mainnetVelocityClient.unsubscribe();
|
|
87
88
|
});
|
|
88
89
|
|
|
89
90
|
it('has all mainnet markets', async () => {
|
|
@@ -95,7 +96,7 @@ describe('Verify Constants', function () {
|
|
|
95
96
|
description: string;
|
|
96
97
|
}[] = [];
|
|
97
98
|
|
|
98
|
-
const spotMarkets =
|
|
99
|
+
const spotMarkets = mainnetVelocityClient.getSpotMarketAccounts();
|
|
99
100
|
spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
100
101
|
|
|
101
102
|
for (const market of spotMarkets) {
|
|
@@ -170,11 +171,11 @@ describe('Verify Constants', function () {
|
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
const perpMarkets =
|
|
174
|
+
const perpMarkets = mainnetVelocityClient.getPerpMarketAccounts();
|
|
174
175
|
perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
175
176
|
|
|
176
177
|
for (const market of perpMarkets) {
|
|
177
|
-
if (isPullOracleSource(market.
|
|
178
|
+
if (isPullOracleSource(market.oracleSource)) {
|
|
178
179
|
continue;
|
|
179
180
|
}
|
|
180
181
|
|
|
@@ -192,26 +193,25 @@ describe('Verify Constants', function () {
|
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
if (
|
|
195
|
-
correspondingConfigMarket.oracle.toBase58() !==
|
|
196
|
-
market.amm.oracle.toBase58()
|
|
196
|
+
correspondingConfigMarket.oracle.toBase58() !== market.oracle.toBase58()
|
|
197
197
|
) {
|
|
198
198
|
errors.push(
|
|
199
199
|
`Oracle mismatch for mainnet perp market ${
|
|
200
200
|
market.marketIndex
|
|
201
|
-
}, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.
|
|
201
|
+
}, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.oracle.toBase58()}`
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
if (
|
|
206
206
|
getVariant(correspondingConfigMarket.oracleSource) !==
|
|
207
|
-
getVariant(market.
|
|
207
|
+
getVariant(market.oracleSource)
|
|
208
208
|
) {
|
|
209
209
|
errors.push(
|
|
210
210
|
`Oracle source mismatch for mainnet perp market ${
|
|
211
211
|
market.marketIndex
|
|
212
212
|
}, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
|
|
213
213
|
correspondingConfigMarket.oracleSource
|
|
214
|
-
)}, chain: ${getVariant(market.
|
|
214
|
+
)}, chain: ${getVariant(market.oracleSource)}`
|
|
215
215
|
);
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -225,14 +225,12 @@ describe('Verify Constants', function () {
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
const lutHasMarketOracle = lutAccounts.includes(
|
|
229
|
-
market.amm.oracle.toBase58()
|
|
230
|
-
);
|
|
228
|
+
const lutHasMarketOracle = lutAccounts.includes(market.oracle.toBase58());
|
|
231
229
|
if (!lutHasMarketOracle) {
|
|
232
230
|
missingLutAddresses.push({
|
|
233
231
|
type: 'perp',
|
|
234
232
|
marketIndex: market.marketIndex,
|
|
235
|
-
address: market.
|
|
233
|
+
address: market.oracle.toBase58(),
|
|
236
234
|
description: 'oracle',
|
|
237
235
|
});
|
|
238
236
|
}
|
|
@@ -275,7 +273,7 @@ describe('Verify Constants', function () {
|
|
|
275
273
|
it('has all devnet markets', async () => {
|
|
276
274
|
const errors: string[] = [];
|
|
277
275
|
|
|
278
|
-
const spotMarkets =
|
|
276
|
+
const spotMarkets = devnetVelocityClient.getSpotMarketAccounts();
|
|
279
277
|
spotMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
280
278
|
|
|
281
279
|
for (const market of spotMarkets) {
|
|
@@ -330,11 +328,11 @@ describe('Verify Constants', function () {
|
|
|
330
328
|
}
|
|
331
329
|
}
|
|
332
330
|
|
|
333
|
-
const perpMarkets =
|
|
331
|
+
const perpMarkets = devnetVelocityClient.getPerpMarketAccounts();
|
|
334
332
|
perpMarkets.sort((a, b) => a.marketIndex - b.marketIndex);
|
|
335
333
|
|
|
336
334
|
for (const market of perpMarkets) {
|
|
337
|
-
if (isPullOracleSource(market.
|
|
335
|
+
if (isPullOracleSource(market.oracleSource)) {
|
|
338
336
|
continue;
|
|
339
337
|
}
|
|
340
338
|
|
|
@@ -352,26 +350,25 @@ describe('Verify Constants', function () {
|
|
|
352
350
|
}
|
|
353
351
|
|
|
354
352
|
if (
|
|
355
|
-
correspondingConfigMarket.oracle.toBase58() !==
|
|
356
|
-
market.amm.oracle.toBase58()
|
|
353
|
+
correspondingConfigMarket.oracle.toBase58() !== market.oracle.toBase58()
|
|
357
354
|
) {
|
|
358
355
|
errors.push(
|
|
359
356
|
`Oracle mismatch for devnet perp market ${
|
|
360
357
|
market.marketIndex
|
|
361
|
-
}, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.
|
|
358
|
+
}, market: ${market.pubkey.toBase58()}, constants: ${correspondingConfigMarket.oracle.toBase58()}, chain: ${market.oracle.toBase58()}`
|
|
362
359
|
);
|
|
363
360
|
}
|
|
364
361
|
|
|
365
362
|
if (
|
|
366
363
|
getVariant(correspondingConfigMarket.oracleSource) !==
|
|
367
|
-
getVariant(market.
|
|
364
|
+
getVariant(market.oracleSource)
|
|
368
365
|
) {
|
|
369
366
|
errors.push(
|
|
370
367
|
`Oracle source mismatch for devnet perp market ${
|
|
371
368
|
market.marketIndex
|
|
372
369
|
}, market: ${market.pubkey.toBase58()}, constants: ${getVariant(
|
|
373
370
|
correspondingConfigMarket.oracleSource
|
|
374
|
-
)}, chain: ${getVariant(market.
|
|
371
|
+
)}, chain: ${getVariant(market.oracleSource)}`
|
|
375
372
|
);
|
|
376
373
|
}
|
|
377
374
|
}
|
package/tests/decode/test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorProvider, Idl, Program } from '@coral-xyz/anchor';
|
|
2
|
-
import
|
|
2
|
+
import velocityIDL from '../../src/idl/velocity.json';
|
|
3
3
|
import { Connection, Keypair } from '@solana/web3.js';
|
|
4
4
|
import {
|
|
5
5
|
decodeUser,
|
|
@@ -21,7 +21,7 @@ describe('Custom user decode', () => {
|
|
|
21
21
|
const wallet = new Wallet(new Keypair());
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
const provider = new AnchorProvider(connection, wallet);
|
|
24
|
-
const program = new Program(
|
|
24
|
+
const program = new Program(velocityIDL as Idl, provider);
|
|
25
25
|
|
|
26
26
|
let totalAnchorSize = 0;
|
|
27
27
|
let totalCustomSize = 0;
|
package/tests/dlob/helpers.ts
CHANGED
|
@@ -172,7 +172,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
172
172
|
liquidatorFee: 0,
|
|
173
173
|
imfFactor: 0,
|
|
174
174
|
nextFundingRateRecordId: new BN(0),
|
|
175
|
-
nextCurveRecordId: new BN(0),
|
|
176
175
|
unrealizedPnlImfFactor: 0,
|
|
177
176
|
unrealizedPnlMaxImbalance: ZERO,
|
|
178
177
|
unrealizedPnlInitialAssetWeight: 0,
|
|
@@ -199,7 +198,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
199
198
|
lastFillPrice: new BN(0),
|
|
200
199
|
contractTier: ContractTier.A,
|
|
201
200
|
nextFundingRateRecordId: new BN(0),
|
|
202
|
-
nextCurveRecordId: new BN(0),
|
|
203
201
|
name: [],
|
|
204
202
|
contractType: ContractType.PERPETUAL,
|
|
205
203
|
expiryTs: new BN(0),
|
|
@@ -245,7 +243,6 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
245
243
|
lastFillPrice: new BN(0),
|
|
246
244
|
contractTier: ContractTier.A,
|
|
247
245
|
nextFundingRateRecordId: new BN(0),
|
|
248
|
-
nextCurveRecordId: new BN(0),
|
|
249
246
|
name: [],
|
|
250
247
|
contractType: ContractType.PERPETUAL,
|
|
251
248
|
expiryTs: new BN(0),
|
|
@@ -553,7 +550,6 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
553
550
|
];
|
|
554
551
|
|
|
555
552
|
export const mockStateAccount: StateAccount = {
|
|
556
|
-
admin: PublicKey.default,
|
|
557
553
|
featureBitFlags: 0,
|
|
558
554
|
defaultMarketOrderTimeInForce: 0,
|
|
559
555
|
defaultSpotAuctionDuration: 0,
|
|
@@ -634,12 +630,12 @@ export class MockUserMap implements UserMapInterface {
|
|
|
634
630
|
eventEmitter: EventEmitter = new EventEmitter();
|
|
635
631
|
private userMap = new Map<string, User>();
|
|
636
632
|
private userAccountToAuthority = new Map<string, string>();
|
|
637
|
-
private
|
|
633
|
+
private velocityClient: VelocityClient;
|
|
638
634
|
|
|
639
635
|
constructor() {
|
|
640
636
|
this.userMap = new Map();
|
|
641
637
|
this.userAccountToAuthority = new Map();
|
|
642
|
-
this.
|
|
638
|
+
this.velocityClient = new VelocityClient({
|
|
643
639
|
connection: new Connection('http://localhost:8899'),
|
|
644
640
|
wallet: new Wallet(new Keypair()),
|
|
645
641
|
programID: PublicKey.default,
|
|
@@ -652,7 +648,7 @@ export class MockUserMap implements UserMapInterface {
|
|
|
652
648
|
|
|
653
649
|
public async addPubkey(userAccountPublicKey: PublicKey): Promise<void> {
|
|
654
650
|
const user = new User({
|
|
655
|
-
|
|
651
|
+
velocityClient: this.velocityClient,
|
|
656
652
|
userAccountPublicKey: userAccountPublicKey,
|
|
657
653
|
});
|
|
658
654
|
this.userMap.set(userAccountPublicKey.toBase58(), user);
|
|
@@ -686,7 +682,7 @@ export class MockUserMap implements UserMapInterface {
|
|
|
686
682
|
|
|
687
683
|
public async mustGet(_key: string): Promise<User> {
|
|
688
684
|
return new User({
|
|
689
|
-
|
|
685
|
+
velocityClient: this.velocityClient,
|
|
690
686
|
userAccountPublicKey: PublicKey.default,
|
|
691
687
|
});
|
|
692
688
|
}
|
|
@@ -694,7 +690,7 @@ export class MockUserMap implements UserMapInterface {
|
|
|
694
690
|
public async mustGetWithSlot(_key: string): Promise<DataAndSlot<User>> {
|
|
695
691
|
return {
|
|
696
692
|
data: new User({
|
|
697
|
-
|
|
693
|
+
velocityClient: this.velocityClient,
|
|
698
694
|
userAccountPublicKey: PublicKey.default,
|
|
699
695
|
}),
|
|
700
696
|
slot: 0,
|
|
@@ -11,13 +11,13 @@ describe('parseLogsForCuUsage Tests', () => {
|
|
|
11
11
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
12
12
|
'Program ComputeBudget111111111111111111111111111111 invoke [1]',
|
|
13
13
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
14
|
-
'Program
|
|
14
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P invoke [1]',
|
|
15
15
|
'Program log: Instruction: UpdateFundingRate',
|
|
16
16
|
'Program log: correcting mark twap update (oracle previously invalid for 1625 seconds)',
|
|
17
17
|
'Program data: Ze4o5EYuPXWjSrNoAAAAADkUAAAAAAAAZTIKAAAAAAAAAAAAAAAAAGwIAGYvdqgAAAAAAAAAAAAxpQahVMKdAAAAAAAAAAAAK0cfnMcFowAAAAAAAAAAAGUyCgAAAAAAAAAAAAAAAAAbXpy4n6WoAAAAAAAAAAAAGAAXbsHunQAAAAAAAAAAAObum9evM6MAAAAAAAAAAAAA9PA5+UYKAAAAAAAAAAAAAKhuDZ0RCgAAAAAAAAAAAABMgixcNQAAAAAAAAAAAAA9NqYKSgAAAAAAAAAAAAAA4nylcy0AAAAAAAAAAAAAAMvCAAAAAAAAAAAAAAAAAACOjAkAAAAAAET3AgAAAAAAAAAAAAAAAAAMAQAAHgA=',
|
|
18
18
|
'Program data: RAP/GoVbk/6jSrNoAAAAAA0rAAAAAAAAHgBxcgEAAAAAAHFyAQAAAAAAAAAAAAAAAABxcgEAAAAAAAAAAAAAAAAAZRuYAQAAAAAAAAAAAAAAAJMNmAEAAAAAAAAAAAAAAAC0eAkAAAAAAByBCQAAAAAAWUbv4v////8ATIIsXDUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==',
|
|
19
|
-
'Program
|
|
20
|
-
'Program
|
|
19
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P consumed 102636 of 143817 compute units',
|
|
20
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P success',
|
|
21
21
|
];
|
|
22
22
|
const cuUsage = parseLogsForCuUsage(logs);
|
|
23
23
|
expect(cuUsage).to.deep.equal([
|
|
@@ -37,21 +37,21 @@ describe('parseLogsForCuUsage Tests', () => {
|
|
|
37
37
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
38
38
|
'Program ComputeBudget111111111111111111111111111111 invoke [1]',
|
|
39
39
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
40
|
-
'Program
|
|
40
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P invoke [1]',
|
|
41
41
|
'Program log: Instruction: PostPythLazerOracleUpdate',
|
|
42
42
|
'Program log: Skipping new lazer update. current ts 1756622092550000 >= next ts 1756622092000000',
|
|
43
43
|
'Program log: Skipping new lazer update. current ts 1756622092550000 >= next ts 1756622092000000',
|
|
44
44
|
'Program log: Skipping new lazer update. current ts 1756622092550000 >= next ts 1756622092000000',
|
|
45
45
|
'Program log: Price updated to 433158894',
|
|
46
46
|
'Program log: Posting new lazer update. current ts 1756622079000000 < next ts 1756622092000000',
|
|
47
|
-
'Program
|
|
48
|
-
'Program
|
|
49
|
-
'Program
|
|
47
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P consumed 29242 of 199700 compute units',
|
|
48
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P success',
|
|
49
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P invoke [1]',
|
|
50
50
|
'Program log: Instruction: UpdatePerpBidAskTwap',
|
|
51
51
|
'Program log: estimated_bid = None estimated_ask = None',
|
|
52
52
|
'Program log: after amm bid twap = 204332308 -> 204328128 \n ask twap = 204350474 -> 204347149 \n ts = 1756622080 -> 1756622092',
|
|
53
|
-
'Program
|
|
54
|
-
'Program
|
|
53
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P consumed 71006 of 170458 compute units',
|
|
54
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P success',
|
|
55
55
|
];
|
|
56
56
|
const cuUsage = parseLogsForCuUsage(logs);
|
|
57
57
|
expect(cuUsage).to.deep.equal([
|
|
@@ -78,7 +78,7 @@ describe('parseLogsForCuUsage Tests', () => {
|
|
|
78
78
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
79
79
|
'Program ComputeBudget111111111111111111111111111111 invoke [1]',
|
|
80
80
|
'Program ComputeBudget111111111111111111111111111111 success',
|
|
81
|
-
'Program
|
|
81
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P invoke [1]',
|
|
82
82
|
'Program log: Instruction: BeginSwap',
|
|
83
83
|
'Program data: t7rLuuG7X4K7X+loAAAAAAAAoDz72UK0JwQAAAAAAAAAAMS7r8ACAAAAAAAAAAAAAAB36Aiv26cZAwAAAAAAAAAArDDOLAMAAAAAAAAAAAAAAAA1DAAUzQAAoLsNAA==',
|
|
84
84
|
'Program data: t7rLuuG7X4K7X+loAAAAAAEASQcRhBUVAQAAAAAAAAAAAG3WGn8CAAAAAAAAAAAAAADBBakRTIoAAAAAAAAAAAAAFfFDwgIAAAAAAAAAAAAAAAA1DACghgEAYOMWAA==',
|
|
@@ -86,8 +86,8 @@ describe('parseLogsForCuUsage Tests', () => {
|
|
|
86
86
|
'Program log: Instruction: Transfer',
|
|
87
87
|
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 1336324 compute units',
|
|
88
88
|
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
|
|
89
|
-
'Program
|
|
90
|
-
'Program
|
|
89
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P consumed 79071 of 1399700 compute units',
|
|
90
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P success',
|
|
91
91
|
'Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 invoke [1]',
|
|
92
92
|
'Program log: Instruction: Route',
|
|
93
93
|
'Program SV2EYYJyRz2YhfXwXnhNAevDEui5Q6yrfyo13WtupPF invoke [2]',
|
|
@@ -108,15 +108,15 @@ describe('parseLogsForCuUsage Tests', () => {
|
|
|
108
108
|
'Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 consumed 81059 of 1320629 compute units',
|
|
109
109
|
'Program return: JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 Z/tXxXEAAAA=',
|
|
110
110
|
'Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 success',
|
|
111
|
-
'Program
|
|
111
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P invoke [1]',
|
|
112
112
|
'Program log: Instruction: EndSwap',
|
|
113
113
|
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
|
|
114
114
|
'Program log: Instruction: Transfer',
|
|
115
115
|
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4736 of 1187840 compute units',
|
|
116
116
|
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
|
|
117
117
|
'Program data: ort7woo4+vG7X+loAAAAAJ1Bg8Gp9WhWrw9VRm1UiC0KW6LRC2am2mjhfd3lzm6WZ/tXxXEAAAAA6HZIFwAAAAEAAAAJdDEMAAAAANFBDwAAAAAAAAAAAAAAAAA=',
|
|
118
|
-
'Program
|
|
119
|
-
'Program
|
|
118
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P consumed 156076 of 1239570 compute units',
|
|
119
|
+
'Program vELoC1audYbSYVRXn1vPaV8Axoa9oU6BYmNGZZBDZ1P success',
|
|
120
120
|
];
|
|
121
121
|
const cuUsage = parseLogsForCuUsage(logs);
|
|
122
122
|
expect(cuUsage).to.deep.equal([
|
package/tests/user/helpers.ts
CHANGED
|
@@ -107,8 +107,8 @@ export async function makeMockUser(
|
|
|
107
107
|
const umap = new MockUserMap();
|
|
108
108
|
const mockUser: User = await umap.mustGet('1');
|
|
109
109
|
mockUser._isSubscribed = true;
|
|
110
|
-
mockUser.
|
|
111
|
-
mockUser.
|
|
110
|
+
mockUser.velocityClient._isSubscribed = true;
|
|
111
|
+
mockUser.velocityClient.accountSubscriber.isSubscribed = true;
|
|
112
112
|
const getStateAccount = () =>
|
|
113
113
|
({
|
|
114
114
|
data: {
|
|
@@ -116,7 +116,7 @@ export async function makeMockUser(
|
|
|
116
116
|
},
|
|
117
117
|
slot: 0,
|
|
118
118
|
}) as any;
|
|
119
|
-
mockUser.
|
|
119
|
+
mockUser.velocityClient.getStateAccount = getStateAccount;
|
|
120
120
|
|
|
121
121
|
const oraclePriceMap: Record<string, number> = {};
|
|
122
122
|
for (let i = 0; i < myMockPerpMarkets.length; i++) {
|
|
@@ -172,14 +172,14 @@ export async function makeMockUser(
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
mockUser.getUserAccount = getMockUserAccount;
|
|
175
|
-
mockUser.
|
|
176
|
-
mockUser.
|
|
177
|
-
mockUser.
|
|
178
|
-
mockUser.
|
|
175
|
+
mockUser.velocityClient.getPerpMarketAccount = getMockPerpMarket as any;
|
|
176
|
+
mockUser.velocityClient.getSpotMarketAccount = getMockSpotMarket as any;
|
|
177
|
+
mockUser.velocityClient.getOraclePriceDataAndSlot = getMockOracle as any;
|
|
178
|
+
mockUser.velocityClient.getOracleDataForPerpMarket =
|
|
179
179
|
getOracleDataForPerpMarket as any;
|
|
180
|
-
mockUser.
|
|
180
|
+
mockUser.velocityClient.getOracleDataForSpotMarket =
|
|
181
181
|
getOracleDataForSpotMarket as any;
|
|
182
|
-
mockUser.
|
|
182
|
+
mockUser.velocityClient.getMMOracleDataForPerpMarket =
|
|
183
183
|
getMMOracleDataForPerpMarket as any;
|
|
184
184
|
return mockUser;
|
|
185
185
|
}
|
package/tests/user/test.ts
CHANGED
|
@@ -39,8 +39,8 @@ async function makeMockUser(
|
|
|
39
39
|
const umap = new MockUserMap();
|
|
40
40
|
const mockUser: User = await umap.mustGet('1');
|
|
41
41
|
mockUser._isSubscribed = true;
|
|
42
|
-
mockUser.
|
|
43
|
-
mockUser.
|
|
42
|
+
mockUser.velocityClient._isSubscribed = true;
|
|
43
|
+
mockUser.velocityClient.accountSubscriber.isSubscribed = true;
|
|
44
44
|
|
|
45
45
|
const oraclePriceMap = {};
|
|
46
46
|
// console.log(perpOraclePriceList, myMockPerpMarkets.length);
|
|
@@ -105,12 +105,14 @@ async function makeMockUser(
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
mockUser.getUserAccount = getMockUserAccount;
|
|
108
|
-
mockUser.
|
|
109
|
-
mockUser.
|
|
110
|
-
mockUser.
|
|
111
|
-
mockUser.
|
|
112
|
-
|
|
113
|
-
mockUser.
|
|
108
|
+
mockUser.velocityClient.getPerpMarketAccount = getMockPerpMarket;
|
|
109
|
+
mockUser.velocityClient.getSpotMarketAccount = getMockSpotMarket;
|
|
110
|
+
mockUser.velocityClient.getOraclePriceDataAndSlot = getMockOracle;
|
|
111
|
+
mockUser.velocityClient.getOracleDataForPerpMarket =
|
|
112
|
+
getOracleDataForPerpMarket;
|
|
113
|
+
mockUser.velocityClient.getOracleDataForSpotMarket =
|
|
114
|
+
getOracleDataForSpotMarket;
|
|
115
|
+
mockUser.velocityClient.getMMOracleDataForPerpMarket =
|
|
114
116
|
getMMOracleDataForPerpMarket;
|
|
115
117
|
return mockUser;
|
|
116
118
|
}
|
|
@@ -177,14 +179,15 @@ describe('User Tests', () => {
|
|
|
177
179
|
assert(uA.perpPositions[0].quoteAssetAmount.eq(new BN('10000000'))); // $10
|
|
178
180
|
assert(mockUser.getFreeCollateral().eq(ZERO));
|
|
179
181
|
|
|
180
|
-
const quotePrice =
|
|
182
|
+
const quotePrice =
|
|
183
|
+
mockUser.velocityClient.getOracleDataForSpotMarket(0).price;
|
|
181
184
|
console.log('quotePrice:', quotePrice.toString());
|
|
182
185
|
assert(quotePrice.eq(new BN('1000000')));
|
|
183
186
|
const pnl1 = calculatePositionPNL(
|
|
184
187
|
myMockPerpMarkets[0],
|
|
185
188
|
activePerps[0],
|
|
186
189
|
false,
|
|
187
|
-
mockUser.
|
|
190
|
+
mockUser.velocityClient.getOracleDataForPerpMarket(0)
|
|
188
191
|
);
|
|
189
192
|
console.log('pnl1:', pnl1.toString());
|
|
190
193
|
assert(pnl1.eq(new BN('10000000')));
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type helpers for expressing the Drift → Velocity rename surface.
|
|
3
|
-
*
|
|
4
|
-
* The SDK exposes paired keys (`velocityX` canonical, `driftX` deprecated) on
|
|
5
|
-
* several config objects. {@link AtLeastOne} captures the "callers must supply
|
|
6
|
-
* one of the two" contract at the type level so the runtime fallback in the
|
|
7
|
-
* consuming class can rely on the value being present.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* `AtLeastOne<A, B, T>` requires the caller to set at least one of two keys
|
|
11
|
-
* (`A` canonical, `B` deprecated) to a value of type `T`. Whichever the caller
|
|
12
|
-
* omits remains optional.
|
|
13
|
-
*
|
|
14
|
-
* Use this to express "rename `B` to `A`, but keep `B` accepted until the next
|
|
15
|
-
* major" on a config object without dropping back to "both optional + runtime
|
|
16
|
-
* throw".
|
|
17
|
-
*/
|
|
18
|
-
export type AtLeastOne<A extends string, B extends string, T> = ({
|
|
19
|
-
[K in A]: T;
|
|
20
|
-
} & {
|
|
21
|
-
[K in B]?: T;
|
|
22
|
-
}) | ({
|
|
23
|
-
[K in A]?: T;
|
|
24
|
-
} & {
|
|
25
|
-
[K in B]: T;
|
|
26
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Type helpers for expressing the Drift → Velocity rename surface.
|
|
4
|
-
*
|
|
5
|
-
* The SDK exposes paired keys (`velocityX` canonical, `driftX` deprecated) on
|
|
6
|
-
* several config objects. {@link AtLeastOne} captures the "callers must supply
|
|
7
|
-
* one of the two" contract at the type level so the runtime fallback in the
|
|
8
|
-
* consuming class can rely on the value being present.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|