@velocity-exchange/sdk 0.0.2 → 0.0.5
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/CHANGELOG.md +15 -0
- package/README.md +5 -6
- package/bunfig.toml +3 -0
- package/lib/browser/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/browser/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/browser/auctionSubscriber/types.d.ts +4 -2
- package/lib/browser/config.d.ts +3 -8
- package/lib/browser/config.js +14 -22
- package/lib/browser/constituentMap/constituentMap.d.ts +4 -2
- package/lib/browser/constituentMap/constituentMap.js +14 -10
- package/lib/browser/core/VelocityCore.d.ts +4 -0
- package/lib/browser/core/VelocityCore.js +3 -1
- package/lib/browser/decode/user.js +5 -5
- package/lib/browser/dlob/DLOB.js +1 -1
- package/lib/browser/dlob/DLOBNode.js +1 -2
- package/lib/browser/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/browser/dlob/DLOBSubscriber.js +19 -10
- package/lib/browser/dlob/types.d.ts +3 -1
- package/lib/browser/idl/drift.d.ts +59 -6
- package/lib/browser/idl/drift.json +6049 -806
- package/lib/browser/math/auction.d.ts +1 -1
- package/lib/browser/math/auction.js +2 -9
- package/lib/browser/math/orders.js +3 -3
- package/lib/browser/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/browser/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/browser/orderSubscriber/types.d.ts +3 -1
- package/lib/browser/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/browser/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/browser/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/browser/priorityFee/types.d.ts +9 -5
- package/lib/browser/priorityFee/types.js +1 -1
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/browser/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/browser/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/browser/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/browser/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/browser/swift/swiftOrderSubscriber.js +19 -11
- package/lib/browser/types.d.ts +2 -2
- package/lib/browser/user.d.ts +3 -1
- package/lib/browser/user.js +93 -86
- package/lib/browser/userConfig.d.ts +4 -2
- package/lib/browser/userMap/referrerMap.d.ts +5 -3
- package/lib/browser/userMap/referrerMap.js +18 -14
- package/lib/browser/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/browser/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/browser/userMap/userMap.d.ts +3 -1
- package/lib/browser/userMap/userMap.js +24 -19
- package/lib/browser/userMap/userMapConfig.d.ts +4 -2
- package/lib/browser/userMap/userStatsMap.d.ts +5 -3
- package/lib/browser/userMap/userStatsMap.js +15 -11
- package/lib/browser/userStats.d.ts +3 -1
- package/lib/browser/userStats.js +21 -15
- package/lib/browser/userStatsConfig.d.ts +4 -2
- package/lib/browser/util/deprecatedAlias.d.ts +26 -0
- package/lib/browser/util/deprecatedAlias.js +10 -0
- package/lib/browser/velocityClient.d.ts +6 -6
- package/lib/browser/velocityClient.js +6 -6
- package/lib/browser/velocityClientConfig.d.ts +7 -4
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriber.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriber.js +9 -4
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts +4 -2
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.d.ts.map +1 -1
- package/lib/node/auctionSubscriber/auctionSubscriberGrpc.js +9 -4
- package/lib/node/auctionSubscriber/types.d.ts +4 -2
- package/lib/node/auctionSubscriber/types.d.ts.map +1 -1
- package/lib/node/config.d.ts +3 -8
- package/lib/node/config.d.ts.map +1 -1
- package/lib/node/config.js +14 -22
- package/lib/node/constituentMap/constituentMap.d.ts +4 -2
- package/lib/node/constituentMap/constituentMap.d.ts.map +1 -1
- package/lib/node/constituentMap/constituentMap.js +14 -10
- package/lib/node/core/VelocityCore.d.ts +4 -0
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.js +3 -1
- package/lib/node/decode/user.js +5 -5
- package/lib/node/dlob/DLOB.js +1 -1
- package/lib/node/dlob/DLOBNode.js +1 -2
- package/lib/node/dlob/DLOBSubscriber.d.ts +3 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.js +19 -10
- package/lib/node/dlob/types.d.ts +3 -1
- package/lib/node/dlob/types.d.ts.map +1 -1
- package/lib/node/idl/drift.d.ts +59 -6
- package/lib/node/idl/drift.d.ts.map +1 -1
- package/lib/node/idl/drift.json +6049 -806
- package/lib/node/math/auction.d.ts +1 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/auction.js +2 -9
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/orders.js +3 -3
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts +3 -1
- package/lib/node/orderSubscriber/OrderSubscriber.d.ts.map +1 -1
- package/lib/node/orderSubscriber/OrderSubscriber.js +19 -11
- package/lib/node/orderSubscriber/types.d.ts +3 -1
- package/lib/node/orderSubscriber/types.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts +4 -2
- package/lib/node/priorityFee/priorityFeeSubscriber.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriber.js +15 -11
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts +11 -9
- package/lib/node/priorityFee/priorityFeeSubscriberMap.d.ts.map +1 -1
- package/lib/node/priorityFee/priorityFeeSubscriberMap.js +18 -18
- package/lib/node/priorityFee/types.d.ts +9 -5
- package/lib/node/priorityFee/types.d.ts.map +1 -1
- package/lib/node/priorityFee/types.js +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts +3 -12
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/grpcSignedMsgUserAccountSubscriber.js +3 -9
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts +11 -8
- package/lib/node/swift/signedMsgUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/swift/signedMsgUserAccountSubscriber.js +10 -5
- package/lib/node/swift/swiftOrderSubscriber.d.ts +7 -4
- package/lib/node/swift/swiftOrderSubscriber.d.ts.map +1 -1
- package/lib/node/swift/swiftOrderSubscriber.js +19 -11
- package/lib/node/types.d.ts +2 -2
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +3 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +93 -86
- package/lib/node/userConfig.d.ts +4 -2
- package/lib/node/userConfig.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.d.ts +5 -3
- package/lib/node/userMap/referrerMap.d.ts.map +1 -1
- package/lib/node/userMap/referrerMap.js +18 -14
- package/lib/node/userMap/revenueShareEscrowMap.d.ts +5 -3
- package/lib/node/userMap/revenueShareEscrowMap.d.ts.map +1 -1
- package/lib/node/userMap/revenueShareEscrowMap.js +18 -14
- package/lib/node/userMap/userMap.d.ts +3 -1
- package/lib/node/userMap/userMap.d.ts.map +1 -1
- package/lib/node/userMap/userMap.js +24 -19
- package/lib/node/userMap/userMapConfig.d.ts +4 -2
- package/lib/node/userMap/userMapConfig.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.d.ts +5 -3
- package/lib/node/userMap/userStatsMap.d.ts.map +1 -1
- package/lib/node/userMap/userStatsMap.js +15 -11
- package/lib/node/userStats.d.ts +3 -1
- package/lib/node/userStats.d.ts.map +1 -1
- package/lib/node/userStats.js +21 -15
- package/lib/node/userStatsConfig.d.ts +4 -2
- package/lib/node/userStatsConfig.d.ts.map +1 -1
- package/lib/node/util/deprecatedAlias.d.ts +27 -0
- package/lib/node/util/deprecatedAlias.d.ts.map +1 -0
- package/lib/node/util/deprecatedAlias.js +10 -0
- package/lib/node/velocityClient.d.ts +6 -6
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +6 -6
- package/lib/node/velocityClientConfig.d.ts +7 -4
- package/lib/node/velocityClientConfig.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/auctionSubscriber/auctionSubscriber.ts +12 -6
- package/src/auctionSubscriber/auctionSubscriberGrpc.ts +12 -6
- package/src/auctionSubscriber/types.ts +5 -2
- package/src/config.ts +38 -27
- package/src/constituentMap/constituentMap.ts +17 -9
- package/src/core/VelocityCore.ts +6 -0
- package/src/decode/user.ts +5 -5
- package/src/dlob/DLOB.ts +1 -1
- package/src/dlob/DLOBNode.ts +1 -1
- package/src/dlob/DLOBSubscriber.ts +21 -11
- package/src/dlob/types.ts +3 -1
- package/src/idl/drift.json +23940 -18697
- package/src/idl/drift.ts +59 -6
- package/src/math/auction.ts +3 -10
- package/src/math/orders.ts +3 -6
- package/src/orderSubscriber/OrderSubscriber.ts +17 -7
- package/src/orderSubscriber/types.ts +3 -1
- package/src/priorityFee/priorityFeeSubscriber.ts +13 -9
- package/src/priorityFee/priorityFeeSubscriberMap.ts +23 -25
- package/src/priorityFee/types.ts +19 -9
- package/src/swift/grpcSignedMsgUserAccountSubscriber.ts +10 -23
- package/src/swift/signedMsgUserAccountSubscriber.ts +22 -14
- package/src/swift/swiftOrderSubscriber.ts +24 -16
- package/src/types.ts +2 -2
- package/src/user.ts +93 -82
- package/src/userConfig.ts +5 -2
- package/src/userMap/referrerMap.ts +19 -15
- package/src/userMap/revenueShareEscrowMap.ts +20 -16
- package/src/userMap/userMap.ts +20 -15
- package/src/userMap/userMapConfig.ts +6 -3
- package/src/userMap/userStatsMap.ts +19 -15
- package/src/userStats.ts +13 -7
- package/src/userStatsConfig.ts +5 -2
- package/src/util/deprecatedAlias.ts +21 -0
- package/src/velocityClient.ts +12 -12
- package/src/velocityClientConfig.ts +27 -42
- package/tests/auctions/test.ts +4 -4
- package/tests/decode/test.ts +1 -1
- package/tests/dlob/test.ts +5 -5
- package/tests/user/helpers.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auction.d.ts","sourceRoot":"","sources":["../../../src/math/auction.ts"],"names":[],"mappings":";AAAA,OAAO,EAIN,KAAK,EAEL,iBAAiB,EACjB,YAAY,EACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAO1C,OAAO,EAA4B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMrE;AAED,wBAAgB,kCAAkC,CACjD,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,iBAAiB,EACzB,aAAa,CAAC,EAAE,OAAO,GACrB,OAAO,CAsCT;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,EAAE,GACb,EAAE,CAwBJ;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE,CA+B7E;AAED;;;;;;GAMG;AACH,wBAAgB,qCAAqC,CACpD,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,EAAE,GACb,EAAE,CA+BJ;AAED,w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(order, slot, oraclePrice) {
|
|
|
56
56
|
return getAuctionPriceForFixedAuction(order, slot);
|
|
57
57
|
}
|
|
58
58
|
else if ((0, types_1.isVariant)(order.orderType, 'limit')) {
|
|
59
|
-
if (order.oraclePriceOffset != null && order.oraclePriceOffset
|
|
59
|
+
if (order.oraclePriceOffset != null && !order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
|
|
60
60
|
return getAuctionPriceForOracleOffsetAuction(order, slot, oraclePrice);
|
|
61
61
|
}
|
|
62
62
|
else {
|
|
@@ -153,13 +153,6 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
|
|
|
153
153
|
? auctionEndPrice.sub(oraclePrice).add(numericConstants_1.ONE)
|
|
154
154
|
: auctionEndPrice.sub(oraclePrice).sub(numericConstants_1.ONE);
|
|
155
155
|
}
|
|
156
|
-
let oraclePriceOffsetNum;
|
|
157
|
-
try {
|
|
158
|
-
oraclePriceOffsetNum = oraclePriceOffset.toNumber();
|
|
159
|
-
}
|
|
160
|
-
catch (e) {
|
|
161
|
-
oraclePriceOffsetNum = 0;
|
|
162
|
-
}
|
|
163
156
|
if (auctionPriceCaps) {
|
|
164
157
|
auctionStartPrice = anchor_1.BN.min(anchor_1.BN.max(auctionStartPrice, auctionPriceCaps.min), auctionPriceCaps.max);
|
|
165
158
|
auctionEndPrice = anchor_1.BN.min(anchor_1.BN.max(auctionEndPrice, auctionPriceCaps.min), auctionPriceCaps.max);
|
|
@@ -167,7 +160,7 @@ function deriveOracleAuctionParams({ direction, oraclePrice, auctionStartPrice,
|
|
|
167
160
|
return {
|
|
168
161
|
auctionStartPrice: auctionStartPrice.sub(oraclePrice),
|
|
169
162
|
auctionEndPrice: auctionEndPrice.sub(oraclePrice),
|
|
170
|
-
oraclePriceOffset:
|
|
163
|
+
oraclePriceOffset: oraclePriceOffset,
|
|
171
164
|
};
|
|
172
165
|
}
|
|
173
166
|
exports.deriveOracleAuctionParams = deriveOracleAuctionParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../src/math/orders.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAGN,iBAAiB,EACjB,GAAG,EACH,KAAK,EACL,iBAAiB,EACjB,aAAa,EAEb,YAAY,EACZ,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAatE,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAoCvE;AAED,wBAAgB,oCAAoC,CACnD,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACV,OAAO,CA4BT;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CA0BnE;AAED,wBAAgB,0BAA0B,CACzC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,EAAE,GACV,EAAE,CAGJ;AAED,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,EAAE,EACT,QAAQ,EAAE,EAAE,EACZ,SAAS,EAAE,iBAAiB,GAC1B,EAAE,CAgBJ;AAED,wBAAgB,aAAa,CAAC,CAAC,SAAS,aAAa,EACpD,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,CAAC,SAAS,MAAM,GAAG,eAAe,GAAG,iBAAiB,EACvE,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,EAAE,GAChB,EAAE,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../src/math/orders.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAGN,iBAAiB,EACjB,GAAG,EACH,KAAK,EACL,i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AAE,EAAE,EACV,SAAS,EAAE,EAAE,EACb,eAAe,EAAE,EAAE,EACnB,MAAM,EAAE,iBAAiB,GACvB,EAAE,GAAG,IAAI,CAqDX"}
|
package/lib/node/math/orders.js
CHANGED
|
@@ -101,8 +101,8 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice) {
|
|
|
101
101
|
if (hasAuctionPrice(order, slot)) {
|
|
102
102
|
return (0, auction_1.getAuctionPrice)(order, slot, oraclePriceData.price);
|
|
103
103
|
}
|
|
104
|
-
else if (order.oraclePriceOffset
|
|
105
|
-
return anchor_1.BN.max(oraclePriceData.price.add(
|
|
104
|
+
else if (!order.oraclePriceOffset.eq(numericConstants_1.ZERO)) {
|
|
105
|
+
return anchor_1.BN.max(oraclePriceData.price.add(order.oraclePriceOffset), numericConstants_1.ONE);
|
|
106
106
|
}
|
|
107
107
|
else if (order.price.eq(numericConstants_1.ZERO)) {
|
|
108
108
|
return fallbackPrice;
|
|
@@ -114,7 +114,7 @@ function getLimitPrice(order, oraclePriceData, slot, fallbackPrice) {
|
|
|
114
114
|
exports.getLimitPrice = getLimitPrice;
|
|
115
115
|
function hasLimitPrice(order, slot) {
|
|
116
116
|
return (order.price.gt(numericConstants_1.ZERO) ||
|
|
117
|
-
order.oraclePriceOffset
|
|
117
|
+
!order.oraclePriceOffset.eq(numericConstants_1.ZERO) ||
|
|
118
118
|
!(0, auction_1.isAuctionComplete)(order, slot));
|
|
119
119
|
}
|
|
120
120
|
exports.hasLimitPrice = hasLimitPrice;
|
|
@@ -13,7 +13,9 @@ import StrictEventEmitter from 'strict-event-emitter-types';
|
|
|
13
13
|
import { EventEmitter } from 'events';
|
|
14
14
|
import { grpcSubscription } from './grpcSubscription';
|
|
15
15
|
export declare class OrderSubscriber {
|
|
16
|
-
|
|
16
|
+
velocityClient: VelocityClient;
|
|
17
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
+
get driftClient(): VelocityClient;
|
|
17
19
|
usersAccounts: Map<string, {
|
|
18
20
|
slot: number;
|
|
19
21
|
userAccount: UserAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderSubscriber.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/OrderSubscriber.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAMvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAyB,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,qBAAa,eAAe;IAC3B,
|
|
1
|
+
{"version":3,"file":"OrderSubscriber.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/OrderSubscriber.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAMvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAyB,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACvE,OAA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AAC,IAAI,CAAC;IAsB1C,OAAO,IAAI,MAAM;IAIX,SAAS,CAAC,oBAAoB,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOrD,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAIzC"}
|
|
@@ -14,10 +14,18 @@ const grpcSubscription_1 = require("./grpcSubscription");
|
|
|
14
14
|
const orders_1 = require("../math/orders");
|
|
15
15
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
16
16
|
class OrderSubscriber {
|
|
17
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
18
|
+
get driftClient() {
|
|
19
|
+
return this.velocityClient;
|
|
20
|
+
}
|
|
17
21
|
constructor(config) {
|
|
18
|
-
var _a, _b, _c, _d, _e;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
23
|
this.usersAccounts = new Map();
|
|
20
|
-
|
|
24
|
+
const velocityClient = (_a = config.velocityClient) !== null && _a !== void 0 ? _a : config.driftClient;
|
|
25
|
+
if (!velocityClient) {
|
|
26
|
+
throw new Error('OrderSubscriber: velocityClient (or deprecated driftClient) must be provided');
|
|
27
|
+
}
|
|
28
|
+
this.velocityClient = velocityClient;
|
|
21
29
|
this.commitment = config.subscriptionConfig.commitment || 'processed';
|
|
22
30
|
if (config.subscriptionConfig.type === 'polling') {
|
|
23
31
|
this.subscription = new PollingSubscription_1.PollingSubscription({
|
|
@@ -31,8 +39,8 @@ class OrderSubscriber {
|
|
|
31
39
|
grpcConfigs: config.subscriptionConfig.grpcConfigs,
|
|
32
40
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
33
41
|
resubOpts: {
|
|
34
|
-
resubTimeoutMs: (
|
|
35
|
-
logResubMessages: (
|
|
42
|
+
resubTimeoutMs: (_b = config.subscriptionConfig) === null || _b === void 0 ? void 0 : _b.resubTimeoutMs,
|
|
43
|
+
logResubMessages: (_c = config.subscriptionConfig) === null || _c === void 0 ? void 0 : _c.logResubMessages,
|
|
36
44
|
},
|
|
37
45
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
38
46
|
decoded: config.decodeData,
|
|
@@ -44,18 +52,18 @@ class OrderSubscriber {
|
|
|
44
52
|
commitment: this.commitment,
|
|
45
53
|
skipInitialLoad: config.subscriptionConfig.skipInitialLoad,
|
|
46
54
|
resubOpts: {
|
|
47
|
-
resubTimeoutMs: (
|
|
48
|
-
logResubMessages: (
|
|
55
|
+
resubTimeoutMs: (_d = config.subscriptionConfig) === null || _d === void 0 ? void 0 : _d.resubTimeoutMs,
|
|
56
|
+
logResubMessages: (_e = config.subscriptionConfig) === null || _e === void 0 ? void 0 : _e.logResubMessages,
|
|
49
57
|
},
|
|
50
58
|
resyncIntervalMs: config.subscriptionConfig.resyncIntervalMs,
|
|
51
59
|
decoded: config.decodeData,
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
|
-
if ((
|
|
62
|
+
if ((_f = config.fastDecode) !== null && _f !== void 0 ? _f : true) {
|
|
55
63
|
this.decodeFn = (name, data) => (0, user_1.decodeUser)(data);
|
|
56
64
|
}
|
|
57
65
|
else {
|
|
58
|
-
this.decodeFn = this.
|
|
66
|
+
this.decodeFn = this.velocityClient.program.account.user.coder.accounts.decodeUnchecked.bind(this.velocityClient.program.account.user.coder.accounts);
|
|
59
67
|
}
|
|
60
68
|
this.eventEmitter = new events_1.EventEmitter();
|
|
61
69
|
this.fetchAllNonIdleUsers = config.fetchAllNonIdleUsers;
|
|
@@ -75,7 +83,7 @@ class OrderSubscriber {
|
|
|
75
83
|
: [(0, memcmp_1.getUserFilter)(), (0, memcmp_1.getUserWithOrderFilter)()];
|
|
76
84
|
try {
|
|
77
85
|
const rpcRequestArgs = [
|
|
78
|
-
this.
|
|
86
|
+
this.velocityClient.program.programId.toBase58(),
|
|
79
87
|
{
|
|
80
88
|
commitment: this.commitment,
|
|
81
89
|
filters,
|
|
@@ -85,7 +93,7 @@ class OrderSubscriber {
|
|
|
85
93
|
];
|
|
86
94
|
const rpcJSONResponse =
|
|
87
95
|
// @ts-ignore
|
|
88
|
-
await this.
|
|
96
|
+
await this.velocityClient.connection._rpcRequest('getProgramAccounts', rpcRequestArgs);
|
|
89
97
|
const rpcResponseAndContext = rpcJSONResponse.result;
|
|
90
98
|
const slot = rpcResponseAndContext.context.slot;
|
|
91
99
|
for (const programAccount of rpcResponseAndContext.value) {
|
|
@@ -174,7 +182,7 @@ class OrderSubscriber {
|
|
|
174
182
|
return (_a = this.mostRecentSlot) !== null && _a !== void 0 ? _a : 0;
|
|
175
183
|
}
|
|
176
184
|
async addPubkey(userAccountPublicKey) {
|
|
177
|
-
const accountInfo = await this.
|
|
185
|
+
const accountInfo = await this.velocityClient.connection.getAccountInfoAndContext(userAccountPublicKey, this.commitment);
|
|
178
186
|
if (accountInfo) {
|
|
179
187
|
this.tryUpdateUserAccount(userAccountPublicKey.toString(), 'buffer', accountInfo.value.data, accountInfo.context.slot);
|
|
180
188
|
}
|
|
@@ -3,7 +3,9 @@ import { Order, UserAccount } from '../types';
|
|
|
3
3
|
import { VelocityClient } from '../velocityClient';
|
|
4
4
|
import { GrpcConfigs } from '../accounts/types';
|
|
5
5
|
export type OrderSubscriberConfig = {
|
|
6
|
-
|
|
6
|
+
velocityClient?: VelocityClient;
|
|
7
|
+
/** @deprecated Use `velocityClient` instead. `driftClient` will be removed in a future major. */
|
|
8
|
+
driftClient?: VelocityClient;
|
|
7
9
|
subscriptionConfig: {
|
|
8
10
|
type: 'polling';
|
|
9
11
|
frequency: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/orderSubscriber/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MA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AAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACrC,YAAY,EAAE,CACb,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,KAAK,EAAE,EACtB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;IACV,WAAW,EAAE,CACZ,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;IACV,cAAc,EAAE,CACf,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,KAClC,IAAI,CAAC;CACV"}
|
|
@@ -8,7 +8,9 @@ export declare class PriorityFeeSubscriber {
|
|
|
8
8
|
connection: Connection;
|
|
9
9
|
frequencyMs: number;
|
|
10
10
|
addresses: string[];
|
|
11
|
-
|
|
11
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
12
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
13
|
+
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
12
14
|
customStrategy?: PriorityFeeStrategy;
|
|
13
15
|
averageStrategy: AverageOverSlotsStrategy;
|
|
14
16
|
maxStrategy: MaxOverSlotsStrategy;
|
|
@@ -44,6 +46,6 @@ export declare class PriorityFeeSubscriber {
|
|
|
44
46
|
load(): Promise<void>;
|
|
45
47
|
unsubscribe(): Promise<void>;
|
|
46
48
|
updateAddresses(addresses: PublicKey[]): void;
|
|
47
|
-
updateMarketTypeAndIndex(
|
|
49
|
+
updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
|
|
48
50
|
}
|
|
49
51
|
//# sourceMappingURL=priorityFeeSubscriber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priorityFeeSubscriber.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAEN,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,kBAAkB,EAClB,MAAM,6BAA6B,CAAC;AAErC,qBAAa,qBAAqB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,
|
|
1
|
+
{"version":3,"file":"priorityFeeSubscriber.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAEN,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EACN,uBAAuB,EACvB,mBAAmB,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEN,kBAAkB,EAClB,MAAM,6BAA6B,CAAC;AAErC,qBAAa,qBAAqB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,W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IAsBrB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE;IAItC,wBAAwB,CAAC,eAAe,EAAE,kBAAkB,EAAE;CAGrE"}
|
|
@@ -8,12 +8,16 @@ const solanaPriorityFeeMethod_1 = require("./solanaPriorityFeeMethod");
|
|
|
8
8
|
const heliusPriorityFeeMethod_1 = require("./heliusPriorityFeeMethod");
|
|
9
9
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
10
10
|
class PriorityFeeSubscriber {
|
|
11
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
12
|
+
get driftMarkets() {
|
|
13
|
+
return this.velocityMarkets;
|
|
14
|
+
}
|
|
11
15
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
12
16
|
get driftPriorityFeeEndpoint() {
|
|
13
17
|
return this.velocityPriorityFeeEndpoint;
|
|
14
18
|
}
|
|
15
19
|
constructor(config) {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
17
21
|
this.averageStrategy = new averageOverSlotsStrategy_1.AverageOverSlotsStrategy();
|
|
18
22
|
this.maxStrategy = new maxOverSlotsStrategy_1.MaxOverSlotsStrategy();
|
|
19
23
|
this.priorityFeeMethod = types_1.PriorityFeeMethod.SOLANA;
|
|
@@ -28,14 +32,14 @@ class PriorityFeeSubscriber {
|
|
|
28
32
|
this.addresses = config.addresses
|
|
29
33
|
? config.addresses.map((address) => address.toBase58())
|
|
30
34
|
: [];
|
|
31
|
-
this.
|
|
35
|
+
this.velocityMarkets = (_b = config.velocityMarkets) !== null && _b !== void 0 ? _b : config.driftMarkets;
|
|
32
36
|
if (config.customStrategy) {
|
|
33
37
|
this.customStrategy = config.customStrategy;
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
40
|
this.customStrategy = this.averageStrategy;
|
|
37
41
|
}
|
|
38
|
-
this.lookbackDistance = (
|
|
42
|
+
this.lookbackDistance = (_c = config.slotsToCheck) !== null && _c !== void 0 ? _c : 50;
|
|
39
43
|
if (config.priorityFeeMethod) {
|
|
40
44
|
this.priorityFeeMethod = config.priorityFeeMethod;
|
|
41
45
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
@@ -51,9 +55,9 @@ class PriorityFeeSubscriber {
|
|
|
51
55
|
this.heliusRpcUrl = config.heliusRpcUrl;
|
|
52
56
|
}
|
|
53
57
|
}
|
|
54
|
-
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.
|
|
58
|
+
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
55
59
|
this.velocityPriorityFeeEndpoint =
|
|
56
|
-
(
|
|
60
|
+
(_d = config.velocityPriorityFeeEndpoint) !== null && _d !== void 0 ? _d : config.driftPriorityFeeEndpoint;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
if (this.priorityFeeMethod === types_1.PriorityFeeMethod.SOLANA) {
|
|
@@ -62,7 +66,7 @@ class PriorityFeeSubscriber {
|
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
68
|
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
65
|
-
this.priorityFeeMultiplier = (
|
|
69
|
+
this.priorityFeeMultiplier = (_e = config.priorityFeeMultiplier) !== null && _e !== void 0 ? _e : 1.0;
|
|
66
70
|
}
|
|
67
71
|
async subscribe() {
|
|
68
72
|
if (this.intervalId) {
|
|
@@ -98,10 +102,10 @@ class PriorityFeeSubscriber {
|
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
async loadForDrift() {
|
|
101
|
-
if (!this.
|
|
105
|
+
if (!this.velocityMarkets) {
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
|
-
const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.
|
|
108
|
+
const sample = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
|
|
105
109
|
if (sample.length > 0) {
|
|
106
110
|
this.lastAvgStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM];
|
|
107
111
|
this.lastMaxStrategyResult = sample[heliusPriorityFeeMethod_1.HeliusPriorityLevel.UNSAFE_MAX];
|
|
@@ -164,7 +168,7 @@ class PriorityFeeSubscriber {
|
|
|
164
168
|
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.HELIUS) {
|
|
165
169
|
await this.loadForHelius();
|
|
166
170
|
}
|
|
167
|
-
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.
|
|
171
|
+
else if (this.priorityFeeMethod === types_1.PriorityFeeMethod.VELOCITY) {
|
|
168
172
|
await this.loadForDrift();
|
|
169
173
|
}
|
|
170
174
|
else {
|
|
@@ -186,8 +190,8 @@ class PriorityFeeSubscriber {
|
|
|
186
190
|
updateAddresses(addresses) {
|
|
187
191
|
this.addresses = addresses.map((k) => k.toBase58());
|
|
188
192
|
}
|
|
189
|
-
updateMarketTypeAndIndex(
|
|
190
|
-
this.
|
|
193
|
+
updateMarketTypeAndIndex(velocityMarkets) {
|
|
194
|
+
this.velocityMarkets = velocityMarkets;
|
|
191
195
|
}
|
|
192
196
|
}
|
|
193
197
|
exports.PriorityFeeSubscriber = PriorityFeeSubscriber;
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
import { VelocityMarketInfo, VelocityPriorityFeeLevels } from './velocityPriorityFeeMethod';
|
|
2
2
|
import { PriorityFeeSubscriberMapConfig } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* takes advantage of /batchPriorityFees endpoint from
|
|
4
|
+
* takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
|
|
5
5
|
*/
|
|
6
6
|
export declare class PriorityFeeSubscriberMap {
|
|
7
7
|
frequencyMs: number;
|
|
8
8
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
10
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
+
get driftMarkets(): VelocityMarketInfo[] | undefined;
|
|
12
|
+
velocityPriorityFeeEndpoint: string;
|
|
11
13
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
12
|
-
get driftPriorityFeeEndpoint(): string
|
|
14
|
+
get driftPriorityFeeEndpoint(): string;
|
|
13
15
|
feesMap: Map<string, Map<number, VelocityPriorityFeeLevels>>;
|
|
14
16
|
constructor(config: PriorityFeeSubscriberMapConfig);
|
|
15
17
|
private updateFeesMap;
|
|
16
18
|
subscribe(): Promise<void>;
|
|
17
19
|
unsubscribe(): Promise<void>;
|
|
18
20
|
load(): Promise<void>;
|
|
19
|
-
updateMarketTypeAndIndex(
|
|
21
|
+
updateMarketTypeAndIndex(velocityMarkets: VelocityMarketInfo[]): void;
|
|
20
22
|
getPriorityFees(marketType: string, marketIndex: number): VelocityPriorityFeeLevels | undefined;
|
|
21
23
|
}
|
|
22
24
|
/** Example usage:
|
|
23
25
|
async function main() {
|
|
24
|
-
const
|
|
26
|
+
const velocityMarkets: VelocityMarketInfo[] = [
|
|
25
27
|
{ marketType: 'perp', marketIndex: 0 },
|
|
26
28
|
{ marketType: 'perp', marketIndex: 1 },
|
|
27
29
|
{ marketType: 'spot', marketIndex: 2 }
|
|
28
30
|
];
|
|
29
31
|
|
|
30
32
|
const subscriber = new PriorityFeeSubscriberMap({
|
|
31
|
-
velocityPriorityFeeEndpoint: 'https://dlob.
|
|
33
|
+
velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
|
|
32
34
|
frequencyMs: 5000,
|
|
33
|
-
|
|
35
|
+
velocityMarkets
|
|
34
36
|
});
|
|
35
37
|
await subscriber.subscribe();
|
|
36
38
|
|
|
37
39
|
for (let i = 0; i < 20; i++) {
|
|
38
40
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
39
|
-
|
|
41
|
+
velocityMarkets.forEach(market => {
|
|
40
42
|
const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
|
|
41
43
|
console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
|
|
42
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"priorityFeeSubscriberMap.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriberMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EAGzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,8BAA8B,EAC9B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,wBAAwB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAE3C,
|
|
1
|
+
{"version":3,"file":"priorityFeeSubscriberMap.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/priorityFeeSubscriberMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EAGzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEN,8BAA8B,EAC9B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,qBAAa,wBAAwB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;IAE3C,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,mGAAmG;IACnG,IAAW,YAAY,IAAI,kBAAkB,EAAE,GAAG,SAAS,CAE1D;IACD,2BAA2B,EAAE,MAAM,CAAC;IACpC,2HAA2H;IAC3H,IAAW,wBAAwB,IAAI,MAAM,CAE5C;IACD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAC;gBAE1C,MAAM,EAAE,8BAA8B;IAYzD,OAAO,CAAC,aAAa;IAQR,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAS1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,wBAAwB,CAAC,eAAe,EAAE,kBAAkB,EAAE;IAI9D,eAAe,CACrB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GACjB,yBAAyB,GAAG,SAAS;CAGxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4BE"}
|
|
@@ -4,24 +4,24 @@ exports.PriorityFeeSubscriberMap = void 0;
|
|
|
4
4
|
const velocityPriorityFeeMethod_1 = require("./velocityPriorityFeeMethod");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
/**
|
|
7
|
-
* takes advantage of /batchPriorityFees endpoint from
|
|
7
|
+
* takes advantage of /batchPriorityFees endpoint from Velocity hosted priority fee service
|
|
8
8
|
*/
|
|
9
9
|
class PriorityFeeSubscriberMap {
|
|
10
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
11
|
+
get driftMarkets() {
|
|
12
|
+
return this.velocityMarkets;
|
|
13
|
+
}
|
|
10
14
|
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
11
15
|
get driftPriorityFeeEndpoint() {
|
|
12
16
|
return this.velocityPriorityFeeEndpoint;
|
|
13
17
|
}
|
|
14
18
|
constructor(config) {
|
|
15
|
-
var _a, _b;
|
|
16
|
-
this.frequencyMs = config.frequencyMs;
|
|
19
|
+
var _a, _b, _c;
|
|
17
20
|
this.frequencyMs =
|
|
18
21
|
(_a = config.frequencyMs) !== null && _a !== void 0 ? _a : types_1.DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
this.velocityPriorityFeeEndpoint = endpoint;
|
|
24
|
-
this.driftMarkets = config.driftMarkets;
|
|
22
|
+
// Type-system guarantees at least one of the two is supplied.
|
|
23
|
+
this.velocityPriorityFeeEndpoint = ((_b = config.velocityPriorityFeeEndpoint) !== null && _b !== void 0 ? _b : config.driftPriorityFeeEndpoint);
|
|
24
|
+
this.velocityMarkets = (_c = config.velocityMarkets) !== null && _c !== void 0 ? _c : config.driftMarkets;
|
|
25
25
|
this.feesMap = new Map();
|
|
26
26
|
this.feesMap.set('perp', new Map());
|
|
27
27
|
this.feesMap.set('spot', new Map());
|
|
@@ -46,18 +46,18 @@ class PriorityFeeSubscriberMap {
|
|
|
46
46
|
}
|
|
47
47
|
async load() {
|
|
48
48
|
try {
|
|
49
|
-
if (!this.
|
|
49
|
+
if (!this.velocityMarkets) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
-
const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.
|
|
52
|
+
const fees = await (0, velocityPriorityFeeMethod_1.fetchVelocityPriorityFee)(this.velocityPriorityFeeEndpoint, this.velocityMarkets.map((m) => m.marketType), this.velocityMarkets.map((m) => m.marketIndex));
|
|
53
53
|
this.updateFeesMap(fees);
|
|
54
54
|
}
|
|
55
55
|
catch (e) {
|
|
56
|
-
console.error('Error fetching
|
|
56
|
+
console.error('Error fetching priority fees', e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
updateMarketTypeAndIndex(
|
|
60
|
-
this.
|
|
59
|
+
updateMarketTypeAndIndex(velocityMarkets) {
|
|
60
|
+
this.velocityMarkets = velocityMarkets;
|
|
61
61
|
}
|
|
62
62
|
getPriorityFees(marketType, marketIndex) {
|
|
63
63
|
var _a;
|
|
@@ -67,22 +67,22 @@ class PriorityFeeSubscriberMap {
|
|
|
67
67
|
exports.PriorityFeeSubscriberMap = PriorityFeeSubscriberMap;
|
|
68
68
|
/** Example usage:
|
|
69
69
|
async function main() {
|
|
70
|
-
const
|
|
70
|
+
const velocityMarkets: VelocityMarketInfo[] = [
|
|
71
71
|
{ marketType: 'perp', marketIndex: 0 },
|
|
72
72
|
{ marketType: 'perp', marketIndex: 1 },
|
|
73
73
|
{ marketType: 'spot', marketIndex: 2 }
|
|
74
74
|
];
|
|
75
75
|
|
|
76
76
|
const subscriber = new PriorityFeeSubscriberMap({
|
|
77
|
-
velocityPriorityFeeEndpoint: 'https://dlob.
|
|
77
|
+
velocityPriorityFeeEndpoint: 'https://dlob.velocity.trade',
|
|
78
78
|
frequencyMs: 5000,
|
|
79
|
-
|
|
79
|
+
velocityMarkets
|
|
80
80
|
});
|
|
81
81
|
await subscriber.subscribe();
|
|
82
82
|
|
|
83
83
|
for (let i = 0; i < 20; i++) {
|
|
84
84
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
85
|
-
|
|
85
|
+
velocityMarkets.forEach(market => {
|
|
86
86
|
const fees = subscriber.getPriorityFees(market.marketType, market.marketIndex);
|
|
87
87
|
console.log(`Priority fees for ${market.marketType} market ${market.marketIndex}:`, fees);
|
|
88
88
|
});
|
|
@@ -2,6 +2,7 @@ import { Connection, PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import { SolanaPriorityFeeResponse } from './solanaPriorityFeeMethod';
|
|
3
3
|
import { HeliusPriorityFeeResponse } from './heliusPriorityFeeMethod';
|
|
4
4
|
import { VelocityMarketInfo, VelocityPriorityFeeResponse } from './velocityPriorityFeeMethod';
|
|
5
|
+
import { AtLeastOne } from '../util/deprecatedAlias';
|
|
5
6
|
export declare const DEFAULT_PRIORITY_FEE_MAP_FREQUENCY_MS = 10000;
|
|
6
7
|
export interface PriorityFeeStrategy {
|
|
7
8
|
calculate(samples: SolanaPriorityFeeResponse[] | HeliusPriorityFeeResponse | VelocityPriorityFeeResponse): number;
|
|
@@ -9,12 +10,14 @@ export interface PriorityFeeStrategy {
|
|
|
9
10
|
export declare enum PriorityFeeMethod {
|
|
10
11
|
SOLANA = "solana",
|
|
11
12
|
HELIUS = "helius",
|
|
12
|
-
|
|
13
|
+
VELOCITY = "velocity"
|
|
13
14
|
}
|
|
14
15
|
export type PriorityFeeSubscriberConfig = {
|
|
15
16
|
connection?: Connection;
|
|
16
17
|
frequencyMs?: number;
|
|
17
18
|
addresses?: PublicKey[];
|
|
19
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
20
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
18
21
|
driftMarkets?: VelocityMarketInfo[];
|
|
19
22
|
customStrategy?: PriorityFeeStrategy;
|
|
20
23
|
priorityFeeMethod?: PriorityFeeMethod;
|
|
@@ -26,11 +29,12 @@ export type PriorityFeeSubscriberConfig = {
|
|
|
26
29
|
maxFeeMicroLamports?: number;
|
|
27
30
|
priorityFeeMultiplier?: number;
|
|
28
31
|
};
|
|
29
|
-
|
|
32
|
+
type PriorityFeeSubscriberMapConfigBase = {
|
|
30
33
|
frequencyMs?: number;
|
|
34
|
+
velocityMarkets?: VelocityMarketInfo[];
|
|
35
|
+
/** @deprecated Use `velocityMarkets` instead. `driftMarkets` will be removed in a future major. */
|
|
31
36
|
driftMarkets?: VelocityMarketInfo[];
|
|
32
|
-
velocityPriorityFeeEndpoint?: string;
|
|
33
|
-
/** @deprecated Use `velocityPriorityFeeEndpoint` instead. `driftPriorityFeeEndpoint` will be removed in a future major. */
|
|
34
|
-
driftPriorityFeeEndpoint?: string;
|
|
35
37
|
};
|
|
38
|
+
export type PriorityFeeSubscriberMapConfig = PriorityFeeSubscriberMapConfigBase & AtLeastOne<'velocityPriorityFeeEndpoint', 'driftPriorityFeeEndpoint', string>;
|
|
39
|
+
export {};
|
|
36
40
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/priorityFee/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACN,kBAAkB,EAClB,2BAA2B,EAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,eAAO,MAAM,qCAAqC,QAAS,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAGnC,SAAS,CACR,OAAO,EACJ,yBAAyB,EAAE,GAC3B,yBAAyB,GACzB,2BAA2B,GAC5B,MAAM,CAAC;CACV;AAED,oBAAY,iBAAiB;IAC5B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,QAAQ,aAAa;CACrB;AAED,MAAM,MAAM,2BAA2B,GAAG;IAEzC,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IAExB,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,mGAAmG;IACnG,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAEpC,cAAc,CAAC,EAAE,mBAAmB,CAAC;IAErC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IAEtC,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,2HAA2H;IAC3H,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAElC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,KAAK,kCAAkC,GAAG;IAEzC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACvC,mGAAmG;IACnG,YAAY,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACpC,CAAC;AAGF,MAAM,MAAM,8BAA8B,GACzC,kCAAkC,GACjC,UAAU,CACT,6BAA6B,EAC7B,0BAA0B,EAC1B,MAAM,CACN,CAAC"}
|
|
@@ -6,5 +6,5 @@ var PriorityFeeMethod;
|
|
|
6
6
|
(function (PriorityFeeMethod) {
|
|
7
7
|
PriorityFeeMethod["SOLANA"] = "solana";
|
|
8
8
|
PriorityFeeMethod["HELIUS"] = "helius";
|
|
9
|
-
PriorityFeeMethod["
|
|
9
|
+
PriorityFeeMethod["VELOCITY"] = "velocity";
|
|
10
10
|
})(PriorityFeeMethod || (exports.PriorityFeeMethod = PriorityFeeMethod = {}));
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
import { Commitment } from '@solana/web3.js';
|
|
4
1
|
import { grpcProgramAccountSubscriber } from '../accounts/grpcProgramAccountSubscriber';
|
|
5
|
-
import { GrpcConfigs
|
|
2
|
+
import { GrpcConfigs } from '../accounts/types';
|
|
6
3
|
import { SignedMsgUserOrdersAccount } from '../types';
|
|
7
|
-
import { SignedMsgUserOrdersAccountSubscriber } from './signedMsgUserAccountSubscriber';
|
|
8
|
-
import { VelocityClient } from '../velocityClient';
|
|
4
|
+
import { SignedMsgUserOrdersAccountSubscriber, SignedMsgUserOrdersAccountSubscriberConfig } from './signedMsgUserAccountSubscriber';
|
|
9
5
|
export declare class grpcSignedMsgUserOrdersAccountSubscriber extends SignedMsgUserOrdersAccountSubscriber {
|
|
10
6
|
private grpcConfigs;
|
|
11
7
|
subscriber: grpcProgramAccountSubscriber<SignedMsgUserOrdersAccount>;
|
|
12
|
-
constructor({ grpcConfigs,
|
|
8
|
+
constructor({ grpcConfigs, ...rest }: SignedMsgUserOrdersAccountSubscriberConfig & {
|
|
13
9
|
grpcConfigs: GrpcConfigs;
|
|
14
|
-
driftClient: VelocityClient;
|
|
15
|
-
commitment?: Commitment;
|
|
16
|
-
resubOpts?: ResubOpts;
|
|
17
|
-
decodeFn?: (name: string, data: Buffer) => SignedMsgUserOrdersAccount;
|
|
18
|
-
resyncIntervalMs?: number;
|
|
19
10
|
});
|
|
20
11
|
subscribe(): Promise<void>;
|
|
21
12
|
unsubscribe(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpcSignedMsgUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/swift/grpcSignedMsgUserAccountSubscriber.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grpcSignedMsgUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../../src/swift/grpcSignedMsgUserAccountSubscriber.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EACN,oCAAoC,EACpC,0CAA0C,EAC1C,MAAM,kCAAkC,CAAC;AAE1C,qBAAa,wCAAyC,SAAQ,oCAAoC;IACjG,OAAO,CAAC,WAAW,CAAc;IACxB,UAAU,EAAE,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;gBAElE,EACX,WAAW,EACX,GAAG,IAAI,EACP,EAAE,0CAA0C,GAAG;QAC/C,WAAW,EAAE,WAAW,CAAC;KACzB;IAKY,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAgD1B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CASzC"}
|
|
@@ -5,20 +5,14 @@ const grpcProgramAccountSubscriber_1 = require("../accounts/grpcProgramAccountSu
|
|
|
5
5
|
const memcmp_1 = require("../memcmp");
|
|
6
6
|
const signedMsgUserAccountSubscriber_1 = require("./signedMsgUserAccountSubscriber");
|
|
7
7
|
class grpcSignedMsgUserOrdersAccountSubscriber extends signedMsgUserAccountSubscriber_1.SignedMsgUserOrdersAccountSubscriber {
|
|
8
|
-
constructor({ grpcConfigs,
|
|
9
|
-
super(
|
|
10
|
-
driftClient,
|
|
11
|
-
commitment,
|
|
12
|
-
resubOpts,
|
|
13
|
-
decodeFn,
|
|
14
|
-
resyncIntervalMs,
|
|
15
|
-
});
|
|
8
|
+
constructor({ grpcConfigs, ...rest }) {
|
|
9
|
+
super(rest);
|
|
16
10
|
this.grpcConfigs = grpcConfigs;
|
|
17
11
|
}
|
|
18
12
|
async subscribe() {
|
|
19
13
|
if (!this.subscriber) {
|
|
20
14
|
this.subscriber =
|
|
21
|
-
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.
|
|
15
|
+
await grpcProgramAccountSubscriber_1.grpcProgramAccountSubscriber.create(this.grpcConfigs, 'SingedMsgUserOrdersAccountMap', 'signedMsgUserOrders', this.velocityClient.program, this.decodeFn, {
|
|
22
16
|
filters: [(0, memcmp_1.getSignedMsgUserOrdersFilter)()],
|
|
23
17
|
}, this.resubOpts);
|
|
24
18
|
}
|