forked from tornado-packages/tornado-oracles
Compare commits
2 Commits
build
...
08635da692
| Author | SHA1 | Date | |
|---|---|---|---|
|
08635da692
|
|||
|
bef587cc1a
|
2
lib/feeOracle.d.ts
vendored
2
lib/feeOracle.d.ts
vendored
@@ -118,5 +118,5 @@ export declare abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
*
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
|
||||
*/
|
||||
calculateWithdrawalFeeViaRelayer({ tx, txType, relayerFeePercent, currency, amount, decimals, refundInEth, tokenPriceInEth, predefinedGasLimit, predefinedGasPrice, bumpGasLimitPercent, bumpGasPricePercent, }: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber>;
|
||||
calculateWithdrawalFeeViaRelayer({ tx, txType, relayerFeePercent, currency, amount, decimals, refundInEth, tokenPriceInEth, predefinedGasLimit, predefinedGasPrice, }: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber>;
|
||||
}
|
||||
|
||||
@@ -341,21 +341,14 @@ var TornadoFeeOracle = /** @class */ (function () {
|
||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (hexed string)
|
||||
*/
|
||||
TornadoFeeOracle.prototype.calculateWithdrawalFeeViaRelayer = function (_a) {
|
||||
var tx = _a.tx, txType = _a.txType, relayerFeePercent = _a.relayerFeePercent, currency = _a.currency, amount = _a.amount, decimals = _a.decimals, refundInEth = _a.refundInEth, tokenPriceInEth = _a.tokenPriceInEth, predefinedGasLimit = _a.predefinedGasLimit, predefinedGasPrice = _a.predefinedGasPrice, bumpGasLimitPercent = _a.bumpGasLimitPercent, bumpGasPricePercent = _a.bumpGasPricePercent;
|
||||
var tx = _a.tx, txType = _a.txType, relayerFeePercent = _a.relayerFeePercent, currency = _a.currency, amount = _a.amount, decimals = _a.decimals, refundInEth = _a.refundInEth, tokenPriceInEth = _a.tokenPriceInEth, predefinedGasLimit = _a.predefinedGasLimit, predefinedGasPrice = _a.predefinedGasPrice;
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var relayerFee, _b, gasPrice, gasLimit, gasCosts, hasTokenPrice, feeInEth;
|
||||
return __generator(this, function (_c) {
|
||||
switch (_c.label) {
|
||||
case 0:
|
||||
relayerFee = this.calculateRelayerFeeInWei(relayerFeePercent, amount, decimals);
|
||||
return [4 /*yield*/, this.getGasParams({
|
||||
tx: tx,
|
||||
txType: txType,
|
||||
predefinedGasLimit: predefinedGasLimit,
|
||||
predefinedGasPrice: predefinedGasPrice,
|
||||
bumpGasLimitPercent: bumpGasLimitPercent,
|
||||
bumpGasPricePercent: bumpGasPricePercent,
|
||||
})];
|
||||
return [4 /*yield*/, this.getGasParams({ tx: tx, txType: txType, predefinedGasLimit: predefinedGasLimit, predefinedGasPrice: predefinedGasPrice })];
|
||||
case 1:
|
||||
_b = _c.sent(), gasPrice = _b.gasPrice, gasLimit = _b.gasLimit;
|
||||
gasCosts = ethers_1.BigNumber.from(gasPrice).mul(gasLimit);
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
lib/feeOracleV6.d.ts
vendored
4
lib/feeOracleV6.d.ts
vendored
@@ -14,12 +14,12 @@ export declare class TornadoFeeOracleV6 extends TornadoFeeOracle implements ITor
|
||||
*/
|
||||
getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||
/**
|
||||
* Apply static 50% gasPrice premium for EIP-1559 enabled networks
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 50% premium to combat basefee spike (ethers.js uses 100% premium by default)
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams>;
|
||||
|
||||
@@ -91,12 +91,12 @@ var TornadoFeeOracleV6 = /** @class */ (function (_super) {
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Apply static 50% gasPrice premium for EIP-1559 enabled networks
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 50% premium to combat basefee spike (ethers.js uses 100% premium by default)
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
TornadoFeeOracleV6.prototype.getGasPriceParams = function (speed, bumpPercent) {
|
||||
@@ -106,7 +106,7 @@ var TornadoFeeOracleV6 = /** @class */ (function (_super) {
|
||||
return [2 /*return*/, this.overrideGasPrice];
|
||||
}
|
||||
if (typeof bumpPercent === 'undefined') {
|
||||
bumpPercent = this.chainId === config_1.ChainId.BSC ? undefined : 50;
|
||||
bumpPercent = this.chainId === config_1.ChainId.BSC ? undefined : 30;
|
||||
}
|
||||
return [2 /*return*/, _super.prototype.getGasPriceParams.call(this, speed, bumpPercent)];
|
||||
});
|
||||
|
||||
2
lib/types.d.ts
vendored
2
lib/types.d.ts
vendored
@@ -89,6 +89,4 @@ export type GetWithdrawalFeeViaRelayerInput = {
|
||||
tokenPriceInEth?: HexadecimalStringifiedNumber | string;
|
||||
predefinedGasPrice?: HexadecimalStringifiedNumber;
|
||||
predefinedGasLimit?: number;
|
||||
bumpGasLimitPercent?: number;
|
||||
bumpGasPricePercent?: number;
|
||||
};
|
||||
|
||||
@@ -283,18 +283,9 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
||||
tokenPriceInEth,
|
||||
predefinedGasLimit,
|
||||
predefinedGasPrice,
|
||||
bumpGasLimitPercent,
|
||||
bumpGasPricePercent,
|
||||
}: GetWithdrawalFeeViaRelayerInput): Promise<HexadecimalStringifiedNumber> {
|
||||
const relayerFee = this.calculateRelayerFeeInWei(relayerFeePercent, amount, decimals);
|
||||
const { gasPrice, gasLimit } = await this.getGasParams({
|
||||
tx,
|
||||
txType,
|
||||
predefinedGasLimit,
|
||||
predefinedGasPrice,
|
||||
bumpGasLimitPercent,
|
||||
bumpGasPricePercent,
|
||||
});
|
||||
const { gasPrice, gasLimit } = await this.getGasParams({ tx, txType, predefinedGasLimit, predefinedGasPrice });
|
||||
const gasCosts = BigNumber.from(gasPrice).mul(gasLimit);
|
||||
|
||||
const hasTokenPrice =
|
||||
|
||||
@@ -40,12 +40,12 @@ export class TornadoFeeOracleV6 extends TornadoFeeOracle implements ITornadoFeeO
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply static 50% gasPrice premium for EIP-1559 enabled networks
|
||||
* Apply static 30% gasPrice premium for EIP-1559 enabled networks
|
||||
*
|
||||
* Because Tornado Transactions are censored from block builders
|
||||
* it would take some time to be confirmed after when the transaction is broadcasted.
|
||||
*
|
||||
* We apply 50% premium to combat basefee spike (ethers.js uses 100% premium by default)
|
||||
* We apply 30% premium and 56% overall premium to combat basefee spike
|
||||
* (Can spike 12.5% per block accoring to the EIP-1559 metrics https://metamask.io/1559/)
|
||||
*/
|
||||
async getGasPriceParams(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<GasPriceParams> {
|
||||
@@ -53,7 +53,7 @@ export class TornadoFeeOracleV6 extends TornadoFeeOracle implements ITornadoFeeO
|
||||
return this.overrideGasPrice;
|
||||
}
|
||||
if (typeof bumpPercent === 'undefined') {
|
||||
bumpPercent = this.chainId === ChainId.BSC ? undefined : 50;
|
||||
bumpPercent = this.chainId === ChainId.BSC ? undefined : 30;
|
||||
}
|
||||
return super.getGasPriceParams(speed, bumpPercent);
|
||||
}
|
||||
|
||||
@@ -117,6 +117,4 @@ export type GetWithdrawalFeeViaRelayerInput = {
|
||||
tokenPriceInEth?: HexadecimalStringifiedNumber | string; // Token (currency) price in ETH wei, if withdrawing non-native currency
|
||||
predefinedGasPrice?: HexadecimalStringifiedNumber; // Predefined gas price for withdrawal tx (wont be calculated again in function)
|
||||
predefinedGasLimit?: number; // Predefined gas limit for withdrawal tx (wont be calculated again in function)
|
||||
bumpGasLimitPercent?: number; // Gas limit bump percent to prioritize transaction (recenlty used)
|
||||
bumpGasPricePercent?: number; // Gas price bump percent to prioritize transaction (rarely used)
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user