@clonegod/ttd-core 3.1.73 → 3.1.75
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.
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface EvmGasStrategy {
|
|
2
|
+
evm_tx_type?: 0 | 2;
|
|
3
|
+
evm_gas_limit?: number;
|
|
4
|
+
evm_gas_price_gwei?: number;
|
|
5
|
+
evm_max_fee_per_gas_gwei?: number;
|
|
6
|
+
evm_max_priority_fee_per_gas_gwei?: number;
|
|
7
|
+
evm_tip_amount_gwei?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface EvmGasDefaults {
|
|
10
|
+
gasLimit: number;
|
|
11
|
+
gasPriceGwei: number;
|
|
12
|
+
tipAmountGwei: number;
|
|
13
|
+
}
|
|
14
|
+
export interface EvmGasCaps {
|
|
15
|
+
gasLimit: number;
|
|
16
|
+
gasPriceGwei: number;
|
|
17
|
+
maxFeePerGasGwei: number;
|
|
18
|
+
maxPriorityFeePerGasGwei: number;
|
|
19
|
+
tipAmountGwei: number;
|
|
20
|
+
}
|
|
21
|
+
export interface EvmGasArgs {
|
|
22
|
+
gasLimit: number;
|
|
23
|
+
txType: 0 | 2;
|
|
24
|
+
gasPriceGwei?: number;
|
|
25
|
+
maxFeePerGasGwei?: number;
|
|
26
|
+
maxPriorityFeePerGasGwei?: number;
|
|
27
|
+
tipGasPriceGwei: number;
|
|
28
|
+
tipAmountGwei: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function buildEvmGasArgs(strategy: EvmGasStrategy, defaults: EvmGasDefaults, caps: EvmGasCaps): EvmGasArgs;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildEvmGasArgs = buildEvmGasArgs;
|
|
4
|
+
function buildEvmGasArgs(strategy, defaults, caps) {
|
|
5
|
+
var _a;
|
|
6
|
+
const rawGasLimit = strategy.evm_gas_limit && strategy.evm_gas_limit > 0
|
|
7
|
+
? strategy.evm_gas_limit
|
|
8
|
+
: defaults.gasLimit;
|
|
9
|
+
const gasLimit = Math.min(rawGasLimit, caps.gasLimit);
|
|
10
|
+
const rawLegacyGasPrice = strategy.evm_gas_price_gwei && strategy.evm_gas_price_gwei > 0
|
|
11
|
+
? strategy.evm_gas_price_gwei
|
|
12
|
+
: defaults.gasPriceGwei;
|
|
13
|
+
const legacyGasPrice = Math.min(rawLegacyGasPrice, caps.gasPriceGwei);
|
|
14
|
+
const rawTipAmount = strategy.evm_tip_amount_gwei && strategy.evm_tip_amount_gwei > 0
|
|
15
|
+
? strategy.evm_tip_amount_gwei
|
|
16
|
+
: defaults.tipAmountGwei;
|
|
17
|
+
const tipAmountGwei = Math.min(rawTipAmount, caps.tipAmountGwei);
|
|
18
|
+
const tipGasPriceGwei = legacyGasPrice;
|
|
19
|
+
if (strategy.evm_tx_type === 2) {
|
|
20
|
+
const rawMaxFee = strategy.evm_max_fee_per_gas_gwei && strategy.evm_max_fee_per_gas_gwei > 0
|
|
21
|
+
? strategy.evm_max_fee_per_gas_gwei
|
|
22
|
+
: caps.maxFeePerGasGwei;
|
|
23
|
+
const maxFeePerGasGwei = Math.min(rawMaxFee, caps.maxFeePerGasGwei);
|
|
24
|
+
const rawMaxPriority = (_a = strategy.evm_max_priority_fee_per_gas_gwei) !== null && _a !== void 0 ? _a : 0;
|
|
25
|
+
const maxPriorityFeePerGasGwei = Math.min(rawMaxPriority, caps.maxPriorityFeePerGasGwei);
|
|
26
|
+
return {
|
|
27
|
+
gasLimit,
|
|
28
|
+
txType: 2,
|
|
29
|
+
maxFeePerGasGwei,
|
|
30
|
+
maxPriorityFeePerGasGwei,
|
|
31
|
+
tipGasPriceGwei,
|
|
32
|
+
tipAmountGwei,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
gasLimit,
|
|
37
|
+
txType: 0,
|
|
38
|
+
gasPriceGwei: legacyGasPrice,
|
|
39
|
+
tipGasPriceGwei,
|
|
40
|
+
tipAmountGwei,
|
|
41
|
+
};
|
|
42
|
+
}
|
package/dist/trade/index.d.ts
CHANGED
package/dist/trade/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./abstract_trade"), exports);
|
|
|
18
18
|
__exportStar(require("./abstract_tx_check"), exports);
|
|
19
19
|
__exportStar(require("./trade_context"), exports);
|
|
20
20
|
__exportStar(require("./handle_order_message"), exports);
|
|
21
|
+
__exportStar(require("./evm_gas_args"), exports);
|