@drift-labs/sdk 2.59.0-beta.2 → 2.59.0-beta.4
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/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.59.0-beta.
|
|
1
|
+
2.59.0-beta.4
|
|
@@ -12,6 +12,7 @@ export declare class PriorityFeeSubscriber {
|
|
|
12
12
|
maxStrategy: MaxOverSlotsStrategy;
|
|
13
13
|
priorityFeeMethod: PriorityFeeMethod;
|
|
14
14
|
lookbackDistance: number;
|
|
15
|
+
maxFeeMicroLamports?: number;
|
|
15
16
|
heliusRpcUrl?: string;
|
|
16
17
|
lastHeliusSample?: HeliusPriorityFeeLevels;
|
|
17
18
|
intervalId?: ReturnType<typeof setTimeout>;
|
|
@@ -24,6 +25,7 @@ export declare class PriorityFeeSubscriber {
|
|
|
24
25
|
subscribe(): Promise<void>;
|
|
25
26
|
private loadForSolana;
|
|
26
27
|
private loadForHelius;
|
|
28
|
+
getMaxPriorityFee(): number | undefined;
|
|
27
29
|
getHeliusPriorityFeeLevel(level?: HeliusPriorityLevel): number;
|
|
28
30
|
getCustomStrategyResult(): number;
|
|
29
31
|
getAvgStrategyResult(): number;
|
|
@@ -48,6 +48,7 @@ class PriorityFeeSubscriber {
|
|
|
48
48
|
throw new Error('connection must be provided to use SOLANA priority fee API');
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
51
52
|
}
|
|
52
53
|
async subscribe() {
|
|
53
54
|
if (this.intervalId) {
|
|
@@ -70,20 +71,44 @@ class PriorityFeeSubscriber {
|
|
|
70
71
|
var _a, _b;
|
|
71
72
|
const sample = await (0, heliusPriorityFeeMethod_1.fetchHeliusPriorityFee)(this.heliusRpcUrl, this.lookbackDistance, this.addresses);
|
|
72
73
|
this.lastHeliusSample = (_b = (_a = sample === null || sample === void 0 ? void 0 : sample.result) === null || _a === void 0 ? void 0 : _a.priorityFeeLevels) !== null && _b !== void 0 ? _b : undefined;
|
|
74
|
+
if (this.lastHeliusSample) {
|
|
75
|
+
this.lastAvgStrategyResult =
|
|
76
|
+
this.heliusRpcUrl[heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM];
|
|
77
|
+
this.lastMaxStrategyResult =
|
|
78
|
+
this.heliusRpcUrl[heliusPriorityFeeMethod_1.HeliusPriorityLevel.UNSAFE_MAX];
|
|
79
|
+
if (this.customStrategy) {
|
|
80
|
+
this.lastCustomStrategyResult = this.customStrategy.calculate(sample);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
getMaxPriorityFee() {
|
|
85
|
+
return this.maxFeeMicroLamports;
|
|
73
86
|
}
|
|
74
87
|
getHeliusPriorityFeeLevel(level = heliusPriorityFeeMethod_1.HeliusPriorityLevel.MEDIUM) {
|
|
75
88
|
if (this.lastHeliusSample === undefined) {
|
|
76
89
|
return 0;
|
|
77
90
|
}
|
|
91
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
92
|
+
return Math.min(this.maxFeeMicroLamports, this.lastHeliusSample[level]);
|
|
93
|
+
}
|
|
78
94
|
return this.lastHeliusSample[level];
|
|
79
95
|
}
|
|
80
96
|
getCustomStrategyResult() {
|
|
97
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
98
|
+
return Math.min(this.maxFeeMicroLamports, this.lastCustomStrategyResult);
|
|
99
|
+
}
|
|
81
100
|
return this.lastCustomStrategyResult;
|
|
82
101
|
}
|
|
83
102
|
getAvgStrategyResult() {
|
|
103
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
104
|
+
return Math.min(this.maxFeeMicroLamports, this.lastAvgStrategyResult);
|
|
105
|
+
}
|
|
84
106
|
return this.lastAvgStrategyResult;
|
|
85
107
|
}
|
|
86
108
|
getMaxStrategyResult() {
|
|
109
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
110
|
+
return Math.min(this.maxFeeMicroLamports, this.lastMaxStrategyResult);
|
|
111
|
+
}
|
|
87
112
|
return this.lastMaxStrategyResult;
|
|
88
113
|
}
|
|
89
114
|
async load() {
|
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ export class PriorityFeeSubscriber {
|
|
|
22
22
|
maxStrategy = new MaxOverSlotsStrategy();
|
|
23
23
|
priorityFeeMethod = PriorityFeeMethod.SOLANA;
|
|
24
24
|
lookbackDistance: number;
|
|
25
|
+
maxFeeMicroLamports?: number;
|
|
25
26
|
|
|
26
27
|
heliusRpcUrl?: string;
|
|
27
28
|
lastHeliusSample?: HeliusPriorityFeeLevels;
|
|
@@ -69,6 +70,8 @@ export class PriorityFeeSubscriber {
|
|
|
69
70
|
);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
|
|
74
|
+
this.maxFeeMicroLamports = config.maxFeeMicroLamports;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
public async subscribe(): Promise<void> {
|
|
@@ -103,6 +106,20 @@ export class PriorityFeeSubscriber {
|
|
|
103
106
|
this.addresses
|
|
104
107
|
);
|
|
105
108
|
this.lastHeliusSample = sample?.result?.priorityFeeLevels ?? undefined;
|
|
109
|
+
|
|
110
|
+
if (this.lastHeliusSample) {
|
|
111
|
+
this.lastAvgStrategyResult =
|
|
112
|
+
this.heliusRpcUrl[HeliusPriorityLevel.MEDIUM];
|
|
113
|
+
this.lastMaxStrategyResult =
|
|
114
|
+
this.heliusRpcUrl[HeliusPriorityLevel.UNSAFE_MAX];
|
|
115
|
+
if (this.customStrategy) {
|
|
116
|
+
this.lastCustomStrategyResult = this.customStrategy.calculate(sample!);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public getMaxPriorityFee(): number | undefined {
|
|
122
|
+
return this.maxFeeMicroLamports;
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
public getHeliusPriorityFeeLevel(
|
|
@@ -111,18 +128,30 @@ export class PriorityFeeSubscriber {
|
|
|
111
128
|
if (this.lastHeliusSample === undefined) {
|
|
112
129
|
return 0;
|
|
113
130
|
}
|
|
131
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
132
|
+
return Math.min(this.maxFeeMicroLamports, this.lastHeliusSample[level]);
|
|
133
|
+
}
|
|
114
134
|
return this.lastHeliusSample[level];
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
public getCustomStrategyResult(): number {
|
|
138
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
139
|
+
return Math.min(this.maxFeeMicroLamports, this.lastCustomStrategyResult);
|
|
140
|
+
}
|
|
118
141
|
return this.lastCustomStrategyResult;
|
|
119
142
|
}
|
|
120
143
|
|
|
121
144
|
public getAvgStrategyResult(): number {
|
|
145
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
146
|
+
return Math.min(this.maxFeeMicroLamports, this.lastAvgStrategyResult);
|
|
147
|
+
}
|
|
122
148
|
return this.lastAvgStrategyResult;
|
|
123
149
|
}
|
|
124
150
|
|
|
125
151
|
public getMaxStrategyResult(): number {
|
|
152
|
+
if (this.maxFeeMicroLamports !== undefined) {
|
|
153
|
+
return Math.min(this.maxFeeMicroLamports, this.lastMaxStrategyResult);
|
|
154
|
+
}
|
|
126
155
|
return this.lastMaxStrategyResult;
|
|
127
156
|
}
|
|
128
157
|
|
package/src/priorityFee/types.ts
CHANGED