@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/lib/node/user.js
CHANGED
|
@@ -27,10 +27,6 @@ const strictOraclePrice_1 = require("./oracles/strictOraclePrice");
|
|
|
27
27
|
const grpcUserAccountSubscriber_1 = require("./accounts/grpcUserAccountSubscriber");
|
|
28
28
|
const marginCalculation_1 = require("./marginCalculation");
|
|
29
29
|
class User {
|
|
30
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
31
|
-
get driftClient() {
|
|
32
|
-
return this.velocityClient;
|
|
33
|
-
}
|
|
34
30
|
get isSubscribed() {
|
|
35
31
|
return this._isSubscribed && this.accountSubscriber.isSubscribed;
|
|
36
32
|
}
|
|
@@ -38,40 +34,40 @@ class User {
|
|
|
38
34
|
this._isSubscribed = val;
|
|
39
35
|
}
|
|
40
36
|
constructor(config) {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k
|
|
37
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
42
38
|
this._isSubscribed = false;
|
|
43
39
|
// Type-system guarantees at least one of the two is supplied.
|
|
44
|
-
const velocityClient =
|
|
40
|
+
const velocityClient = config.velocityClient;
|
|
45
41
|
this.velocityClient = velocityClient;
|
|
46
42
|
this.userAccountPublicKey = config.userAccountPublicKey;
|
|
47
|
-
if (((
|
|
43
|
+
if (((_a = config.accountSubscription) === null || _a === void 0 ? void 0 : _a.type) === 'polling') {
|
|
48
44
|
this.accountSubscriber = new pollingUserAccountSubscriber_1.PollingUserAccountSubscriber(velocityClient.connection, config.userAccountPublicKey, config.accountSubscription.accountLoader, this.velocityClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.user.coder.accounts));
|
|
49
45
|
}
|
|
50
|
-
else if (((
|
|
46
|
+
else if (((_b = config.accountSubscription) === null || _b === void 0 ? void 0 : _b.type) === 'custom') {
|
|
51
47
|
this.accountSubscriber = config.accountSubscription.userAccountSubscriber;
|
|
52
48
|
}
|
|
53
|
-
else if (((
|
|
49
|
+
else if (((_c = config.accountSubscription) === null || _c === void 0 ? void 0 : _c.type) === 'grpc') {
|
|
54
50
|
if (config.accountSubscription.grpcMultiUserAccountSubscriber) {
|
|
55
51
|
this.accountSubscriber =
|
|
56
52
|
config.accountSubscription.grpcMultiUserAccountSubscriber.forUser(config.userAccountPublicKey);
|
|
57
53
|
}
|
|
58
54
|
else {
|
|
59
55
|
this.accountSubscriber = new grpcUserAccountSubscriber_1.grpcUserAccountSubscriber(config.accountSubscription.grpcConfigs, velocityClient.program, config.userAccountPublicKey, {
|
|
60
|
-
resubTimeoutMs: (
|
|
61
|
-
logResubMessages: (
|
|
56
|
+
resubTimeoutMs: (_d = config.accountSubscription) === null || _d === void 0 ? void 0 : _d.resubTimeoutMs,
|
|
57
|
+
logResubMessages: (_e = config.accountSubscription) === null || _e === void 0 ? void 0 : _e.logResubMessages,
|
|
62
58
|
});
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
else {
|
|
66
|
-
if (((
|
|
67
|
-
((
|
|
62
|
+
if (((_f = config.accountSubscription) === null || _f === void 0 ? void 0 : _f.type) === 'websocket' &&
|
|
63
|
+
((_g = config.accountSubscription) === null || _g === void 0 ? void 0 : _g.programUserAccountSubscriber)) {
|
|
68
64
|
this.accountSubscriber = new websocketProgramUserAccountSubscriber_1.WebSocketProgramUserAccountSubscriber(velocityClient.program, config.userAccountPublicKey, config.accountSubscription.programUserAccountSubscriber);
|
|
69
65
|
}
|
|
70
66
|
else {
|
|
71
67
|
this.accountSubscriber = new webSocketUserAccountSubscriber_1.WebSocketUserAccountSubscriber(velocityClient.program, config.userAccountPublicKey, {
|
|
72
|
-
resubTimeoutMs: (
|
|
73
|
-
logResubMessages: (
|
|
74
|
-
}, (
|
|
68
|
+
resubTimeoutMs: (_h = config.accountSubscription) === null || _h === void 0 ? void 0 : _h.resubTimeoutMs,
|
|
69
|
+
logResubMessages: (_j = config.accountSubscription) === null || _j === void 0 ? void 0 : _j.logResubMessages,
|
|
70
|
+
}, (_k = config.accountSubscription) === null || _k === void 0 ? void 0 : _k.commitment);
|
|
75
71
|
}
|
|
76
72
|
}
|
|
77
73
|
this.eventEmitter = this.accountSubscriber.eventEmitter;
|
|
@@ -1102,8 +1098,8 @@ class User {
|
|
|
1102
1098
|
continue;
|
|
1103
1099
|
}
|
|
1104
1100
|
const market = this.velocityClient.getPerpMarketAccount(userPosition.marketIndex);
|
|
1105
|
-
if (market.
|
|
1106
|
-
market.
|
|
1101
|
+
if (market.cumulativeFundingRateLong.eq(userPosition.lastCumulativeFundingRate) ||
|
|
1102
|
+
market.cumulativeFundingRateShort.eq(userPosition.lastCumulativeFundingRate)) {
|
|
1107
1103
|
continue;
|
|
1108
1104
|
}
|
|
1109
1105
|
return true;
|
|
@@ -1133,14 +1129,14 @@ class User {
|
|
|
1133
1129
|
const oracle = market.oracle;
|
|
1134
1130
|
const perpMarketWithSameOracle = this.velocityClient
|
|
1135
1131
|
.getPerpMarketAccounts()
|
|
1136
|
-
.find((market) => market.
|
|
1132
|
+
.find((market) => market.oracle.equals(oracle));
|
|
1137
1133
|
const oraclePrice = this.velocityClient.getOracleDataForSpotMarket(marketIndex).price;
|
|
1138
1134
|
if (perpMarketWithSameOracle) {
|
|
1139
1135
|
const perpPosition = this.getPerpPositionOrEmpty(perpMarketWithSameOracle.marketIndex);
|
|
1140
1136
|
if (perpPosition) {
|
|
1141
1137
|
let freeCollateralDeltaForPerp = this.calculateFreeCollateralDeltaForPerp(perpMarketWithSameOracle, perpPosition, numericConstants_1.ZERO, oraclePrice);
|
|
1142
1138
|
if (freeCollateralDeltaForPerp) {
|
|
1143
|
-
const { numerator, denominator } = (0, oracles_1.getMultipleBetweenOracleSources)(market.oracleSource, perpMarketWithSameOracle.
|
|
1139
|
+
const { numerator, denominator } = (0, oracles_1.getMultipleBetweenOracleSources)(market.oracleSource, perpMarketWithSameOracle.oracleSource);
|
|
1144
1140
|
freeCollateralDeltaForPerp = freeCollateralDeltaForPerp
|
|
1145
1141
|
.mul(numerator)
|
|
1146
1142
|
.div(denominator);
|
|
@@ -1172,7 +1168,7 @@ class User {
|
|
|
1172
1168
|
*/
|
|
1173
1169
|
liquidationPrice(marketIndex, positionBaseSizeChange = numericConstants_1.ZERO, estimatedEntryPrice = numericConstants_1.ZERO, marginCategory = 'Maintenance', includeOpenOrders = false, offsetCollateral = numericConstants_1.ZERO, marginType) {
|
|
1174
1170
|
const market = this.velocityClient.getPerpMarketAccount(marketIndex);
|
|
1175
|
-
const oracle = this.velocityClient.getPerpMarketAccount(marketIndex).
|
|
1171
|
+
const oracle = this.velocityClient.getPerpMarketAccount(marketIndex).oracle;
|
|
1176
1172
|
const oraclePrice = this.velocityClient.getOracleDataForPerpMarket(marketIndex).price;
|
|
1177
1173
|
const currentPerpPosition = this.getPerpPositionOrEmpty(marketIndex);
|
|
1178
1174
|
if (marginType === 'Isolated') {
|
|
@@ -1201,7 +1197,7 @@ class User {
|
|
|
1201
1197
|
const totalCollateral = this.getTotalCollateral(marginCategory, false, includeOpenOrders);
|
|
1202
1198
|
const marginRequirement = this.getMarginRequirement(marginCategory, undefined, false, includeOpenOrders);
|
|
1203
1199
|
let freeCollateral = anchor_1.BN.max(numericConstants_1.ZERO, totalCollateral.sub(marginRequirement)).add(offsetCollateral);
|
|
1204
|
-
positionBaseSizeChange = (0, orders_1.standardizeBaseAssetAmount)(positionBaseSizeChange, market.
|
|
1200
|
+
positionBaseSizeChange = (0, orders_1.standardizeBaseAssetAmount)(positionBaseSizeChange, market.orderStepSize);
|
|
1205
1201
|
const freeCollateralChangeFromNewPosition = this.calculateEntriesEffectOnFreeCollateral(market, oraclePrice, currentPerpPosition, positionBaseSizeChange, estimatedEntryPrice, includeOpenOrders);
|
|
1206
1202
|
freeCollateral = freeCollateral.add(freeCollateralChangeFromNewPosition);
|
|
1207
1203
|
let freeCollateralDelta = this.calculateFreeCollateralDeltaForPerp(market, currentPerpPosition, positionBaseSizeChange, oraclePrice, marginCategory, includeOpenOrders);
|
|
@@ -1217,7 +1213,7 @@ class User {
|
|
|
1217
1213
|
const signedTokenAmount = (0, spotBalance_1.getSignedTokenAmount)((0, spotBalance_2.getTokenAmount)(spotPosition.scaledBalance, spotMarketWithSameOracle, spotPosition.balanceType), spotPosition.balanceType);
|
|
1218
1214
|
let spotFreeCollateralDelta = this.calculateFreeCollateralDeltaForSpot(spotMarketWithSameOracle, signedTokenAmount, marginCategory);
|
|
1219
1215
|
if (spotFreeCollateralDelta) {
|
|
1220
|
-
const { numerator, denominator } = (0, oracles_1.getMultipleBetweenOracleSources)(market.
|
|
1216
|
+
const { numerator, denominator } = (0, oracles_1.getMultipleBetweenOracleSources)(market.oracleSource, spotMarketWithSameOracle.oracleSource);
|
|
1221
1217
|
spotFreeCollateralDelta = spotFreeCollateralDelta
|
|
1222
1218
|
.mul(numerator)
|
|
1223
1219
|
.div(denominator);
|
package/lib/node/userConfig.d.ts
CHANGED
|
@@ -5,12 +5,13 @@ import { GrpcConfigs, UserAccountSubscriber } from './accounts/types';
|
|
|
5
5
|
import { WebSocketProgramAccountSubscriber } from './accounts/webSocketProgramAccountSubscriber';
|
|
6
6
|
import { UserAccount } from './types';
|
|
7
7
|
import { grpcMultiUserAccountSubscriber } from './accounts/grpcMultiUserAccountSubscriber';
|
|
8
|
-
import { AtLeastOne } from './util/deprecatedAlias';
|
|
9
8
|
type UserConfigBase = {
|
|
10
9
|
accountSubscription?: UserSubscriptionConfig;
|
|
11
10
|
userAccountPublicKey: PublicKey;
|
|
12
11
|
};
|
|
13
|
-
export type UserConfig = UserConfigBase &
|
|
12
|
+
export type UserConfig = UserConfigBase & {
|
|
13
|
+
velocityClient: VelocityClient;
|
|
14
|
+
};
|
|
14
15
|
export type UserSubscriptionConfig = {
|
|
15
16
|
type: 'grpc';
|
|
16
17
|
resubTimeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userConfig.d.ts","sourceRoot":"","sources":["../../src/userConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"userConfig.d.ts","sourceRoot":"","sources":["../../src/userConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,KAAK,cAAc,GAAG;IACrB,mBAAmB,CAAC,EAAE,sBAAsB,CAAC;IAC7C,oBAAoB,EAAE,SAAS,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IAAE,cAAc,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,sBAAsB,GAC/B;IACA,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,8BAA8B,CAAC,EAAE,8BAA8B,CAAC;CAC/D,GACD;IACA,IAAI,EAAE,WAAW,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,4BAA4B,CAAC,EAAE,iCAAiC,CAAC,WAAW,CAAC,CAAC;CAC7E,GACD;IACA,IAAI,EAAE,SAAS,CAAC;IAChB,aAAa,EAAE,iBAAiB,CAAC;CAChC,GACD;IACA,IAAI,EAAE,QAAQ,CAAC;IACf,qBAAqB,EAAE,qBAAqB,CAAC;CAC5C,CAAC"}
|
|
@@ -22,7 +22,7 @@ class WebsocketSubscription {
|
|
|
22
22
|
if (this.additionalFilters) {
|
|
23
23
|
filters.push(...this.additionalFilters);
|
|
24
24
|
}
|
|
25
|
-
this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('UserMap', 'user', this.userMap.
|
|
25
|
+
this.subscriber = new webSocketProgramAccountSubscriber_1.WebSocketProgramAccountSubscriber('UserMap', 'user', this.userMap.velocityClient.program, this.decodeFn, {
|
|
26
26
|
filters,
|
|
27
27
|
commitment: this.commitment,
|
|
28
28
|
}, this.resubOpts);
|
|
@@ -22,7 +22,7 @@ class grpcSubscription {
|
|
|
22
22
|
if (this.additionalFilters) {
|
|
23
23
|
filters.push(...this.additionalFilters);
|
|
24
24
|
}
|
|
25
|
-
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'UserMap', 'user', this.userMap.
|
|
25
|
+
this.subscriber = await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'UserMap', 'user', this.userMap.velocityClient.program, this.decodeFn, {
|
|
26
26
|
filters,
|
|
27
27
|
}, this.resubOpts);
|
|
28
28
|
}
|
|
@@ -12,8 +12,6 @@ export declare class ReferrerMap {
|
|
|
12
12
|
*/
|
|
13
13
|
private referrerReferrerInfoMap;
|
|
14
14
|
private velocityClient;
|
|
15
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
16
|
-
private get driftClient();
|
|
17
15
|
private parallelSync;
|
|
18
16
|
private fetchPromise?;
|
|
19
17
|
private fetchPromiseResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"referrerMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/referrerMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAcxC,qBAAa,WAAW;IACvB;;OAEG;IACH,OAAO,CAAC,oBAAoB,CAA6B;IACzD;;;OAGG;IACH,OAAO,CAAC,uBAAuB,CAAmC;IAClE,OAAO,CAAC,cAAc,CAAiB;IACvC,
|
|
1
|
+
{"version":3,"file":"referrerMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/referrerMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAGZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAcxC,qBAAa,WAAW;IACvB;;OAEG;IACH,OAAO,CAAC,oBAAoB,CAA6B;IACzD;;;OAGG;IACH,OAAO,CAAC,uBAAuB,CAAmC;IAClE,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,oBAAoB,CAAa;IAEzC;;;;OAIG;gBACS,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,OAAO;IAKlE;;OAEG;IACU,SAAS;IASf,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO;IAIxC,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAInD,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAqB7D;;;;;OAKG;IACU,OAAO,CACnB,kBAAkB,EAAE,MAAM,GACxB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAO7B,WAAW,CAAC,kBAAkB,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAgCjE,IAAI,IAAI,MAAM;IAId,gBAAgB,IAAI,MAAM;IAMpB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA2BrB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAwC/B,YAAY,CAAC,cAAc,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDlD,WAAW;CAIxB"}
|
|
@@ -10,10 +10,6 @@ const memcmp_1 = require("../memcmp");
|
|
|
10
10
|
const bs58_1 = __importDefault(require("bs58"));
|
|
11
11
|
const DEFAULT_PUBLIC_KEY = web3_js_1.PublicKey.default.toBase58();
|
|
12
12
|
class ReferrerMap {
|
|
13
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
-
get driftClient() {
|
|
15
|
-
return this.velocityClient;
|
|
16
|
-
}
|
|
17
13
|
/**
|
|
18
14
|
* Creates a new UserStatsMap instance.
|
|
19
15
|
*
|
|
@@ -6,8 +6,6 @@ export declare class RevenueShareEscrowMap {
|
|
|
6
6
|
*/
|
|
7
7
|
private authorityEscrowMap;
|
|
8
8
|
private velocityClient;
|
|
9
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
10
|
-
private get driftClient();
|
|
11
9
|
private parallelSync;
|
|
12
10
|
private fetchPromise?;
|
|
13
11
|
private fetchPromiseResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revenueShareEscrowMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/revenueShareEscrowMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,qBAAa,qBAAqB;IACjC;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAgD;IAC1E,OAAO,CAAC,cAAc,CAAiB;IACvC,
|
|
1
|
+
{"version":3,"file":"revenueShareEscrowMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/revenueShareEscrowMap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,qBAAa,qBAAqB;IACjC;;OAEG;IACH,OAAO,CAAC,kBAAkB,CAAgD;IAC1E,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,oBAAoB,CAAa;IAEzC;;;;;OAKG;gBACS,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,EAAE,OAAO;IAKlE;;OAEG;IACU,SAAS;IASf,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO;IAIxC,GAAG,CACT,kBAAkB,EAAE,MAAM,GACxB,yBAAyB,GAAG,SAAS;IAIxC;;;;;OAKG;IACU,OAAO,CACnB,kBAAkB,EAAE,MAAM,GACxB,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC;IAOpC,qBAAqB,CAAC,SAAS,EAAE,MAAM;IA8B7C,IAAI,IAAI,MAAM;IAIR,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBlC;;;OAGG;IACU,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA4FrC;;OAEG;IACI,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC;IAIvD;;OAEG;IACI,cAAc,IAAI,MAAM,EAAE;IAIjC;;OAEG;IACI,+BAA+B,IAAI,GAAG,CAC5C,MAAM,EACN,yBAAyB,CACzB;IAUD;;OAEG;IACI,oBAAoB,IAAI,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC;IAUrE;;OAEG;IACI,aAAa,CACnB,iBAAiB,EAAE,MAAM,GACvB,yBAAyB,GAAG,SAAS;IASxC;;OAEG;IACI,gBAAgB,CACtB,iBAAiB,EAAE,MAAM,GACvB,yBAAyB,EAAE;IAUjB,WAAW;CAGxB"}
|
|
@@ -5,10 +5,6 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
5
5
|
const pda_1 = require("../addresses/pda");
|
|
6
6
|
const memcmp_1 = require("../memcmp");
|
|
7
7
|
class RevenueShareEscrowMap {
|
|
8
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
9
|
-
get driftClient() {
|
|
10
|
-
return this.velocityClient;
|
|
11
|
-
}
|
|
12
8
|
/**
|
|
13
9
|
* Creates a new RevenueShareEscrowMap instance.
|
|
14
10
|
*
|
|
@@ -30,8 +30,6 @@ export interface UserMapInterface {
|
|
|
30
30
|
export declare class UserMap implements UserMapInterface {
|
|
31
31
|
private userMap;
|
|
32
32
|
velocityClient: VelocityClient;
|
|
33
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
34
|
-
get driftClient(): VelocityClient;
|
|
35
33
|
eventEmitter: StrictEventEmitter<EventEmitter, UserEvents>;
|
|
36
34
|
private connection;
|
|
37
35
|
private commitment;
|
|
@@ -99,13 +97,13 @@ export declare class UserMap implements UserMapInterface {
|
|
|
99
97
|
private getFilters;
|
|
100
98
|
/**
|
|
101
99
|
* Syncs the UserMap using the default sync method (single getProgramAccounts call with filters).
|
|
102
|
-
* This method may fail when
|
|
100
|
+
* This method may fail when velocity has too many users. (nodejs response size limits)
|
|
103
101
|
* @returns
|
|
104
102
|
*/
|
|
105
103
|
private defaultSync;
|
|
106
104
|
/**
|
|
107
105
|
* Syncs the UserMap using the paginated sync method (multiple getMultipleAccounts calls with filters).
|
|
108
|
-
* This method is more reliable when
|
|
106
|
+
* This method is more reliable when velocity has many users.
|
|
109
107
|
* @returns
|
|
110
108
|
*/
|
|
111
109
|
private paginatedSync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/userMap.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACN,WAAW,EACX,WAAW,EAQX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG5D,OAAO,EAIN,SAAS,EAET,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EAEN,yBAAyB,IAAI,kBAAkB,EAC/C,aAAa,EACb,MAAM,iBAAiB,CAAC;AAKzB,OAAO,kBAAk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CAAC;IAiCpD,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC;IAKjC,cAAc,IAAI,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAIpD,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAK5C,eAAe,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAIhE,IAAI,IAAI,MAAM;IAIrB;;;;OAIG;IACI,oBAAoB,CAC1B,cAAc,CAAC,EAAE,kBAAkB,GACjC,SAAS,EAAE;IAmBD,IAAI;IAQjB,OAAO,CAAC,UAAU;IAclB;;;;OAIG;YACW,WAAW;IA4FzB;;;;OAIG;YACW,aAAa;IAqHd,WAAW;IAoBX,iBAAiB,CAC7B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM;IAkBb,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI7B,OAAO,IAAI,MAAM;CAGxB"}
|
|
@@ -15,15 +15,11 @@ const grpcSubscription_1 = require("./grpcSubscription");
|
|
|
15
15
|
const events_1 = require("events");
|
|
16
16
|
const MAX_USER_ACCOUNT_SIZE_BYTES = 4376;
|
|
17
17
|
class UserMap {
|
|
18
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
19
|
-
get driftClient() {
|
|
20
|
-
return this.velocityClient;
|
|
21
|
-
}
|
|
22
18
|
/**
|
|
23
19
|
* Constructs a new UserMap instance.
|
|
24
20
|
*/
|
|
25
21
|
constructor(config) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
23
|
this.userMap = new Map();
|
|
28
24
|
this.stateAccountUpdateCallback = async (state) => {
|
|
29
25
|
if (!state.numberOfSubAccounts.eq(this.lastNumberOfSubAccounts)) {
|
|
@@ -33,7 +29,7 @@ class UserMap {
|
|
|
33
29
|
};
|
|
34
30
|
this.mostRecentSlot = 0;
|
|
35
31
|
// Type-system guarantees at least one of the two is supplied.
|
|
36
|
-
this.velocityClient =
|
|
32
|
+
this.velocityClient = config.velocityClient;
|
|
37
33
|
if (config.connection) {
|
|
38
34
|
this.connection = config.connection;
|
|
39
35
|
}
|
|
@@ -43,15 +39,15 @@ class UserMap {
|
|
|
43
39
|
this.commitment =
|
|
44
40
|
config.subscriptionConfig.type === 'websocket' ||
|
|
45
41
|
config.subscriptionConfig.type === 'polling'
|
|
46
|
-
? (
|
|
42
|
+
? (_a = config.subscriptionConfig.commitment) !== null && _a !== void 0 ? _a : this.velocityClient.opts.commitment
|
|
47
43
|
: this.velocityClient.opts.commitment;
|
|
48
|
-
this.includeIdle = (
|
|
44
|
+
this.includeIdle = (_b = config.includeIdle) !== null && _b !== void 0 ? _b : false;
|
|
49
45
|
this.filterByPoolId = config.filterByPoolId;
|
|
50
46
|
this.additionalFilters = config.additionalFilters;
|
|
51
47
|
this.disableSyncOnTotalAccountsChange =
|
|
52
|
-
(
|
|
48
|
+
(_c = config.disableSyncOnTotalAccountsChange) !== null && _c !== void 0 ? _c : false;
|
|
53
49
|
let decodeFn;
|
|
54
|
-
if ((
|
|
50
|
+
if ((_d = config.fastDecode) !== null && _d !== void 0 ? _d : true) {
|
|
55
51
|
decodeFn = (name, buffer) => (0, user_2.decodeUser)(buffer);
|
|
56
52
|
}
|
|
57
53
|
else {
|
|
@@ -89,11 +85,11 @@ class UserMap {
|
|
|
89
85
|
decodeFn,
|
|
90
86
|
});
|
|
91
87
|
}
|
|
92
|
-
this.syncConfig = (
|
|
88
|
+
this.syncConfig = (_e = config.syncConfig) !== null && _e !== void 0 ? _e : {
|
|
93
89
|
type: 'default',
|
|
94
90
|
};
|
|
95
91
|
// Whether to throw an error if the userMap fails to sync. Defaults to false.
|
|
96
|
-
this.throwOnFailedSync = (
|
|
92
|
+
this.throwOnFailedSync = (_f = config.throwOnFailedSync) !== null && _f !== void 0 ? _f : false;
|
|
97
93
|
this.eventEmitter = new events_1.EventEmitter();
|
|
98
94
|
}
|
|
99
95
|
async subscribe() {
|
|
@@ -284,7 +280,7 @@ class UserMap {
|
|
|
284
280
|
}
|
|
285
281
|
/**
|
|
286
282
|
* Syncs the UserMap using the default sync method (single getProgramAccounts call with filters).
|
|
287
|
-
* This method may fail when
|
|
283
|
+
* This method may fail when velocity has too many users. (nodejs response size limits)
|
|
288
284
|
* @returns
|
|
289
285
|
*/
|
|
290
286
|
async defaultSync() {
|
|
@@ -357,7 +353,7 @@ class UserMap {
|
|
|
357
353
|
}
|
|
358
354
|
/**
|
|
359
355
|
* Syncs the UserMap using the paginated sync method (multiple getMultipleAccounts calls with filters).
|
|
360
|
-
* This method is more reliable when
|
|
356
|
+
* This method is more reliable when velocity has many users.
|
|
361
357
|
* @returns
|
|
362
358
|
*/
|
|
363
359
|
async paginatedSync() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Commitment, Connection, MemcmpFilter } from '@solana/web3.js';
|
|
2
2
|
import { VelocityClient } from '../velocityClient';
|
|
3
3
|
import { GrpcConfigs } from '../accounts/types';
|
|
4
|
-
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
5
4
|
export type UserAccountFilterCriteria = {
|
|
6
5
|
hasOpenOrders: boolean;
|
|
7
6
|
};
|
|
@@ -38,6 +37,8 @@ type UserMapConfigBase = {
|
|
|
38
37
|
filterByPoolId?: number;
|
|
39
38
|
additionalFilters?: MemcmpFilter[];
|
|
40
39
|
};
|
|
41
|
-
export type UserMapConfig = UserMapConfigBase &
|
|
40
|
+
export type UserMapConfig = UserMapConfigBase & {
|
|
41
|
+
velocityClient: VelocityClient;
|
|
42
|
+
};
|
|
42
43
|
export {};
|
|
43
44
|
//# sourceMappingURL=userMapConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userMapConfig.d.ts","sourceRoot":"","sources":["../../../src/userMap/userMapConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"userMapConfig.d.ts","sourceRoot":"","sources":["../../../src/userMap/userMapConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,MAAM,yBAAyB,GAAG;IAEvC,aAAa,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,UAAU,GACnB;IACA,IAAI,EAAE,SAAS,CAAC;CACf,GACD;IACA,IAAI,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEL,KAAK,iBAAiB,GAAG;IAExB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,kBAAkB,EACf;QACA,IAAI,EAAE,SAAS,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,UAAU,CAAC;KACvB,GACD;QACA,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,WAAW,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC1B,GACD;QACA,IAAI,EAAE,WAAW,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,UAAU,CAAC,EAAE,UAAU,CAAC;KACvB,CAAC;IAGL,eAAe,CAAC,EAAE,OAAO,CAAC;IAG1B,WAAW,CAAC,EAAE,OAAO,CAAC;IAGtB,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAE3C,UAAU,CAAC,EAAE,UAAU,CAAC;IAGxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAG5B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,iBAAiB,CAAC,EAAE,YAAY,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG;IAC/C,cAAc,EAAE,cAAc,CAAC;CAC/B,CAAC"}
|
|
@@ -12,8 +12,6 @@ export declare class UserStatsMap {
|
|
|
12
12
|
*/
|
|
13
13
|
private userStatsMap;
|
|
14
14
|
private velocityClient;
|
|
15
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
16
|
-
private get driftClient();
|
|
17
15
|
private bulkAccountLoader;
|
|
18
16
|
private decode;
|
|
19
17
|
private syncConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStatsMap.d.ts","sourceRoot":"","sources":["../../../src/userMap/userStatsMap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EACN,WAAW,EACX,gBAAgB,EAQhB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,YAAY;IACxB;;OAEG;IACH,OAAO,CAAC,YAAY,CAAgC;IACpD,OAAO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AAC,kBAAkB,EAAE,MAAM,GAAG,OAAO;IAIxC,GAAG,CAAC,kBAAkB,EAAE,MAAM,GAAG,SAAS;IAIjD;;;;;OAKG;IACU,OAAO,CAAC,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAW7D,MAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC;IAIrC,IAAI,IAAI,MAAM;IAIrB;;;;OAIG;IACU,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE;IAQ1C;;;;OAIG;YACW,WAAW;IASzB;;;OAGG;YACW,aAAa;IA8Gd,WAAW;CAMxB"}
|
|
@@ -7,10 +7,6 @@ const bulkAccountLoader_1 = require("../accounts/bulkAccountLoader");
|
|
|
7
7
|
const memcmp_1 = require("../memcmp");
|
|
8
8
|
const web3_js_1 = require("@solana/web3.js");
|
|
9
9
|
class UserStatsMap {
|
|
10
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
11
|
-
get driftClient() {
|
|
12
|
-
return this.velocityClient;
|
|
13
|
-
}
|
|
14
10
|
/**
|
|
15
11
|
* Creates a new UserStatsMap instance.
|
|
16
12
|
*
|
package/lib/node/userStats.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ import { UserStatsConfig } from './userStatsConfig';
|
|
|
10
10
|
import { ReferrerInfo, UserStatsAccount } from './types';
|
|
11
11
|
export declare class UserStats {
|
|
12
12
|
velocityClient: VelocityClient;
|
|
13
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
14
|
-
get driftClient(): VelocityClient;
|
|
15
13
|
userStatsAccountPublicKey: PublicKey;
|
|
16
14
|
accountSubscriber: UserStatsAccountSubscriber;
|
|
17
15
|
isSubscribed: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStats.d.ts","sourceRoot":"","sources":["../../src/userStats.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,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,32 +7,28 @@ const webSocketUserStatsAccountSubsriber_1 = require("./accounts/webSocketUserSt
|
|
|
7
7
|
const pda_1 = require("./addresses/pda");
|
|
8
8
|
const grpcUserStatsAccountSubscriber_1 = require("./accounts/grpcUserStatsAccountSubscriber");
|
|
9
9
|
class UserStats {
|
|
10
|
-
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
11
|
-
get driftClient() {
|
|
12
|
-
return this.velocityClient;
|
|
13
|
-
}
|
|
14
10
|
constructor(config) {
|
|
15
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
12
|
// Type-system guarantees at least one of the two is supplied.
|
|
17
|
-
const velocityClient =
|
|
13
|
+
const velocityClient = config.velocityClient;
|
|
18
14
|
this.velocityClient = velocityClient;
|
|
19
15
|
this.userStatsAccountPublicKey = config.userStatsAccountPublicKey;
|
|
20
|
-
if (((
|
|
16
|
+
if (((_a = config.accountSubscription) === null || _a === void 0 ? void 0 : _a.type) === 'polling') {
|
|
21
17
|
this.accountSubscriber = new pollingUserStatsAccountSubscriber_1.PollingUserStatsAccountSubscriber(velocityClient.program, config.userStatsAccountPublicKey, config.accountSubscription.accountLoader);
|
|
22
18
|
}
|
|
23
|
-
else if (((
|
|
19
|
+
else if (((_b = config.accountSubscription) === null || _b === void 0 ? void 0 : _b.type) === 'grpc') {
|
|
24
20
|
this.accountSubscriber = new grpcUserStatsAccountSubscriber_1.grpcUserStatsAccountSubscriber(config.accountSubscription.grpcConfigs, velocityClient.program, config.userStatsAccountPublicKey, {
|
|
25
|
-
resubTimeoutMs: (
|
|
26
|
-
logResubMessages: (
|
|
21
|
+
resubTimeoutMs: (_c = config.accountSubscription) === null || _c === void 0 ? void 0 : _c.resubTimeoutMs,
|
|
22
|
+
logResubMessages: (_d = config.accountSubscription) === null || _d === void 0 ? void 0 : _d.logResubMessages,
|
|
27
23
|
});
|
|
28
24
|
}
|
|
29
|
-
else if (((
|
|
25
|
+
else if (((_e = config.accountSubscription) === null || _e === void 0 ? void 0 : _e.type) === 'websocket') {
|
|
30
26
|
this.accountSubscriber = new webSocketUserStatsAccountSubsriber_1.WebSocketUserStatsAccountSubscriber(velocityClient.program, config.userStatsAccountPublicKey, {
|
|
31
|
-
resubTimeoutMs: (
|
|
32
|
-
logResubMessages: (
|
|
27
|
+
resubTimeoutMs: (_f = config.accountSubscription) === null || _f === void 0 ? void 0 : _f.resubTimeoutMs,
|
|
28
|
+
logResubMessages: (_g = config.accountSubscription) === null || _g === void 0 ? void 0 : _g.logResubMessages,
|
|
33
29
|
}, config.accountSubscription.commitment);
|
|
34
30
|
}
|
|
35
|
-
else if (((
|
|
31
|
+
else if (((_h = config.accountSubscription) === null || _h === void 0 ? void 0 : _h.type) === 'custom') {
|
|
36
32
|
this.accountSubscriber =
|
|
37
33
|
config.accountSubscription.userStatsAccountSubscriber;
|
|
38
34
|
}
|
|
@@ -2,12 +2,13 @@ import { VelocityClient } from './velocityClient';
|
|
|
2
2
|
import { Commitment, PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
4
4
|
import { GrpcConfigs, UserStatsAccountSubscriber } from './accounts/types';
|
|
5
|
-
import { AtLeastOne } from './util/deprecatedAlias';
|
|
6
5
|
type UserStatsConfigBase = {
|
|
7
6
|
accountSubscription?: UserStatsSubscriptionConfig;
|
|
8
7
|
userStatsAccountPublicKey: PublicKey;
|
|
9
8
|
};
|
|
10
|
-
export type UserStatsConfig = UserStatsConfigBase &
|
|
9
|
+
export type UserStatsConfig = UserStatsConfigBase & {
|
|
10
|
+
velocityClient: VelocityClient;
|
|
11
|
+
};
|
|
11
12
|
export type UserStatsSubscriptionConfig = {
|
|
12
13
|
type: 'websocket';
|
|
13
14
|
resubTimeoutMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userStatsConfig.d.ts","sourceRoot":"","sources":["../../src/userStatsCon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,CAAC;CACxB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionInstruction } from '@solana/web3.js';
|
|
2
2
|
/**
|
|
3
3
|
* Constructs a minimal Ed25519 verification instruction that references the data
|
|
4
|
-
* inside the
|
|
4
|
+
* inside the velocity custom instruction (e.g. postPythLazerOracleUpdate, placeSignedMsgTakerOrder).
|
|
5
5
|
*
|
|
6
6
|
* @param customInstructionIndex The index of the custom instruction in the transaction (e.g. if tx contains compute budget limit, compute budget price, ed25519 verify, custom ix, this would be 3).
|
|
7
7
|
* @param messageOffset The offset within the custom instruction data where the signed message begins.
|
|
@@ -47,7 +47,7 @@ const ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct([
|
|
|
47
47
|
]);
|
|
48
48
|
/**
|
|
49
49
|
* Constructs a minimal Ed25519 verification instruction that references the data
|
|
50
|
-
* inside the
|
|
50
|
+
* inside the velocity custom instruction (e.g. postPythLazerOracleUpdate, placeSignedMsgTakerOrder).
|
|
51
51
|
*
|
|
52
52
|
* @param customInstructionIndex The index of the custom instruction in the transaction (e.g. if tx contains compute budget limit, compute budget price, ed25519 verify, custom ix, this would be 3).
|
|
53
53
|
* @param messageOffset The offset within the custom instruction data where the signed message begins.
|