Fix & extend JSDoc notes
This commit is contained in:
parent
65af25e76b
commit
9def6cd536
@ -35,7 +35,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
/**
|
/**
|
||||||
* Because Optimism transaction published on Mainnet, for each OP transaction we need to calculate L1 security fee:
|
* Because Optimism transaction published on Mainnet, for each OP transaction we need to calculate L1 security fee:
|
||||||
* https://community.optimism.io/docs/developers/build/transaction-fees/#priority-fee
|
* https://community.optimism.io/docs/developers/build/transaction-fees/#priority-fee
|
||||||
* @param {TransactionData} tx Transaction data to estimate L1 additional fee
|
* @param {TransactionData} [tx] Transaction data to estimate L1 additional fee
|
||||||
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (MATIC), '0' if chain is not Optimism
|
* @returns {Promise<HexadecimalStringifiedNumber>} Fee in WEI (MATIC), '0' if chain is not Optimism
|
||||||
*/
|
*/
|
||||||
async fetchL1OptimismFee(tx?: TransactionData): Promise<HexadecimalStringifiedNumber> {
|
async fetchL1OptimismFee(tx?: TransactionData): Promise<HexadecimalStringifiedNumber> {
|
||||||
@ -49,7 +49,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate gas price, gas limit and l1Fee for sidechain (if exists)
|
* Estimate gas price, gas limit and l1Fee for sidechain (if exists)
|
||||||
* @param {GetGasParamsInput} params Function input arguments object
|
* @param {GetGasParamsInput} [params] Function input arguments object
|
||||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||||
* @param {TxType} [params.txType=other] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
* @param {TxType} [params.txType=other] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||||
@ -100,7 +100,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimates next block gas for signed, unsigned or incomplete Tornado transaction
|
* Estimates next block gas for signed, unsigned or incomplete Tornado transaction
|
||||||
* @param {GetGasInput} params Function input arguments object
|
* @param {GetGasInput} [params] Function input arguments object
|
||||||
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
* @param {TransactionData} [params.tx] Transaction data in web3 / ethers format
|
||||||
* @param {TxType} [params.txType] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
* @param {TxType} [params.txType] Tornado transaction type: withdrawal by user, withdrawal by relayer or 'other'
|
||||||
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
* @param {number} [params.predefinedGasLimit] Predefined gas limit, if already calculated (no refetching)
|
||||||
@ -135,8 +135,8 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate next block gas price
|
* Estimate next block gas price
|
||||||
* @param {LegacyGasPriceKey} speed Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
* @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559)
|
||||||
* @param {number} bumpPercent Gas bump percent to prioritize transaction
|
* @param {number} [bumpPercent] Gas bump percent to prioritize transaction
|
||||||
* @returns {Promise<HexadecimalStringifiedNumber>} Gas price in WEI (hex string)
|
* @returns {Promise<HexadecimalStringifiedNumber>} Gas price in WEI (hex string)
|
||||||
*/
|
*/
|
||||||
async getGasPrice(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<HexadecimalStringifiedNumber> {
|
async getGasPrice(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise<HexadecimalStringifiedNumber> {
|
||||||
@ -146,9 +146,9 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimates gas limit for transaction (or basic gas limit, if no tx data provided)
|
* Estimates gas limit for transaction (or basic gas limit, if no tx data provided)
|
||||||
* @param {TransactionData} tx Transaction data (object in web3 / ethers format)
|
* @param {TransactionData} [tx] Transaction data (object in web3 / ethers format)
|
||||||
* @param {TxType} type Tornado transaction type: withdrawal by user, withdrawal by relayer, relayer fee check or 'other'
|
* @param {TxType} [type] Tornado transaction type: withdrawal by user, withdrawal by relayer, relayer fee check or 'other'
|
||||||
* @param {number} bumpPercent Gas bump percent to prioritize transaction
|
* @param {number} [bumpPercent] Gas bump percent to prioritize transaction
|
||||||
* @returns {Promise<number>} Gas limit
|
* @returns {Promise<number>} Gas limit
|
||||||
*/
|
*/
|
||||||
abstract getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
abstract getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise<number>;
|
||||||
@ -232,7 +232,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle {
|
|||||||
* so that the real commission from the relayer side is a little less,
|
* so that the real commission from the relayer side is a little less,
|
||||||
* in order to the relayer can send a transaction without fear that he will go into the red
|
* in order to the relayer can send a transaction without fear that he will go into the red
|
||||||
* @param {GetWithdrawalFeeViaRelayerInput} params Function input arguments object
|
* @param {GetWithdrawalFeeViaRelayerInput} params Function input arguments object
|
||||||
* @param {TxType} params.type Tornado transaction type: withdrawal costs calculation from user side or from relayer side
|
* @param {TxType} params.txType Tornado transaction type: withdrawal costs calculation from user side or from relayer side
|
||||||
* @param {TransactionData} [params.tx] Transaction data (object in web3 / ethers format)
|
* @param {TransactionData} [params.tx] Transaction data (object in web3 / ethers format)
|
||||||
* @param {number} params.relayerFeePercent Relayer fee percent from the transaction amount (for example, 0.15 for BNB or 0.4 for ETH Mainnet)
|
* @param {number} params.relayerFeePercent Relayer fee percent from the transaction amount (for example, 0.15 for BNB or 0.4 for ETH Mainnet)
|
||||||
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
* @param {AvailableTokenSymbols | Uppercase<AvailableTokenSymbols>} params.currency Currency symbol
|
||||||
|
@ -4,6 +4,9 @@ import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPrices } from './t
|
|||||||
import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
||||||
import { bump } from './utils';
|
import { bump } from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle for V4 (old-version) transactions - estimates fee with predefined gas limit and without smart bumping
|
||||||
|
*/
|
||||||
export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
export class TornadoFeeOracleV4 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||||
public constructor(chainId: number, rpcUrl: string, defaultGasPrices?: LegacyGasPrices) {
|
public constructor(chainId: number, rpcUrl: string, defaultGasPrices?: LegacyGasPrices) {
|
||||||
const oracleConfig = {
|
const oracleConfig = {
|
||||||
|
@ -12,6 +12,9 @@ import { GasPriceOracle } from '@tornado/gas-price-oracle';
|
|||||||
import { bump } from './utils';
|
import { bump } from './utils';
|
||||||
import { TornadoFeeOracleV4 } from './feeOracleV4';
|
import { TornadoFeeOracleV4 } from './feeOracleV4';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Oracle for new V5 version - estimates transaction fees with smart gas limit & bumping
|
||||||
|
*/
|
||||||
export class TornadoFeeOracleV5 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
export class TornadoFeeOracleV5 extends TornadoFeeOracle implements ITornadoFeeOracle {
|
||||||
private fallbackFeeOracle: TornadoFeeOracleV4;
|
private fallbackFeeOracle: TornadoFeeOracleV4;
|
||||||
|
|
||||||
|
@ -40,9 +40,10 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
|||||||
private provider: Provider;
|
private provider: Provider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Constructs TokenPriceOracle class instance
|
||||||
* @param rpcUrl
|
* @param {string} rpcUrl http RPC (Ethereum Mainnet) url to fetch token prices from contract
|
||||||
* @param tokens
|
* @param {Token[]} [tokens] Array of tokens
|
||||||
|
* @param {TokenPrices} [defaultTokenPrices] Default token prices, fallback if nothing loaded from contract
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
rpcUrl: string,
|
rpcUrl: string,
|
||||||
@ -61,7 +62,7 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare data for MultiCall contract
|
* Prepare data for MultiCall contract
|
||||||
* @param {Token[]} tokens Tokens array
|
* @param {Token[]} [tokens] Tokens array
|
||||||
* @returns Valid structure to provide to MultiCall contract
|
* @returns Valid structure to provide to MultiCall contract
|
||||||
*/
|
*/
|
||||||
private prepareCallData(tokens: Token[] = this.tokens): MultiCall.CallStruct[] {
|
private prepareCallData(tokens: Token[] = this.tokens): MultiCall.CallStruct[] {
|
||||||
@ -73,7 +74,7 @@ export class TokenPriceOracle implements ITornadoPriceOracle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch actual tokens price rate to ETH from offchain oracles
|
* Fetch actual tokens price rate to ETH from offchain oracles
|
||||||
* @param {Token[]} tokens Token array
|
* @param {Token[]} [tokens] Token array
|
||||||
* @returns {TokenPrices} Object with token price rate to ETH in WEI
|
* @returns {TokenPrices} Object with token price rate to ETH in WEI
|
||||||
*/
|
*/
|
||||||
async fetchPrices(tokens: Token[] = this.tokens): Promise<TokenPrices> {
|
async fetchPrices(tokens: Token[] = this.tokens): Promise<TokenPrices> {
|
||||||
|
Loading…
Reference in New Issue
Block a user