diff --git a/src/feeOracle.ts b/src/feeOracle.ts index e8c9019..9fb44ac 100644 --- a/src/feeOracle.ts +++ b/src/feeOracle.ts @@ -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: * 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} Fee in WEI (MATIC), '0' if chain is not Optimism */ async fetchL1OptimismFee(tx?: TransactionData): Promise { @@ -49,7 +49,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { /** * 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 {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) @@ -100,7 +100,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { /** * 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 {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) @@ -135,8 +135,8 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { /** * Estimate next block gas price - * @param {LegacyGasPriceKey} speed Preferred transaction speed, if uses legacy gas (before EIP-1559) - * @param {number} bumpPercent Gas bump percent to prioritize transaction + * @param {LegacyGasPriceKey} [speed] Preferred transaction speed, if uses legacy gas (before EIP-1559) + * @param {number} [bumpPercent] Gas bump percent to prioritize transaction * @returns {Promise} Gas price in WEI (hex string) */ async getGasPrice(speed?: LegacyGasPriceKey, bumpPercent?: number): Promise { @@ -146,9 +146,9 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { /** * 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 {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 {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 {number} [bumpPercent] Gas bump percent to prioritize transaction * @returns {Promise} Gas limit */ abstract getGasLimit(tx?: TransactionData, type?: TxType, bumpPercent?: number): Promise; @@ -232,7 +232,7 @@ export abstract class TornadoFeeOracle implements ITornadoFeeOracle { * 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 * @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 {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} params.currency Currency symbol diff --git a/src/feeOracleV4.ts b/src/feeOracleV4.ts index 9231bb2..d073362 100644 --- a/src/feeOracleV4.ts +++ b/src/feeOracleV4.ts @@ -4,6 +4,9 @@ import { ITornadoFeeOracle, TransactionData, TxType, LegacyGasPrices } from './t import { GasPriceOracle } from '@tornado/gas-price-oracle'; 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 { public constructor(chainId: number, rpcUrl: string, defaultGasPrices?: LegacyGasPrices) { const oracleConfig = { diff --git a/src/feeOracleV5.ts b/src/feeOracleV5.ts index ab2121f..7babced 100644 --- a/src/feeOracleV5.ts +++ b/src/feeOracleV5.ts @@ -12,6 +12,9 @@ import { GasPriceOracle } from '@tornado/gas-price-oracle'; import { bump } from './utils'; import { TornadoFeeOracleV4 } from './feeOracleV4'; +/** + * Oracle for new V5 version - estimates transaction fees with smart gas limit & bumping + */ export class TornadoFeeOracleV5 extends TornadoFeeOracle implements ITornadoFeeOracle { private fallbackFeeOracle: TornadoFeeOracleV4; diff --git a/src/tokenPriceOracle.ts b/src/tokenPriceOracle.ts index ec32d1c..a2c0ae8 100644 --- a/src/tokenPriceOracle.ts +++ b/src/tokenPriceOracle.ts @@ -40,9 +40,10 @@ export class TokenPriceOracle implements ITornadoPriceOracle { private provider: Provider; /** - * - * @param rpcUrl - * @param tokens + * Constructs TokenPriceOracle class instance + * @param {string} rpcUrl http RPC (Ethereum Mainnet) url to fetch token prices from contract + * @param {Token[]} [tokens] Array of tokens + * @param {TokenPrices} [defaultTokenPrices] Default token prices, fallback if nothing loaded from contract */ constructor( rpcUrl: string, @@ -61,7 +62,7 @@ export class TokenPriceOracle implements ITornadoPriceOracle { /** * Prepare data for MultiCall contract - * @param {Token[]} tokens Tokens array + * @param {Token[]} [tokens] Tokens array * @returns Valid structure to provide to MultiCall contract */ 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 - * @param {Token[]} tokens Token array + * @param {Token[]} [tokens] Token array * @returns {TokenPrices} Object with token price rate to ETH in WEI */ async fetchPrices(tokens: Token[] = this.tokens): Promise {