Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: export retryables fees utils #220

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { parseEther } from 'viem';

/**
* Approximate value necessary to pay for retryables fees for `createRollup`.
*/
export const createRollupDefaultRetryablesFees = parseEther('0.125');

/**
* Approximate value necessary to pay for retryables fees for `createTokenBridge`.
*/
export const createTokenBridgeDefaultRetryablesFees = parseEther('0.02');
20 changes: 20 additions & 0 deletions src/createRollupGetRetryablesFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ export type CreateRollupGetRetryablesFeesParams = {
maxFeePerGasForRetryables?: bigint;
};

/**
* Fetch estimated retryables fees for `createRollup`.
*
* @param publicClient `PublicClient` for the parent chain.
* @param params.account Account used for deploying the rollup.
* @param params.nativeToken (Optional) The native token used for the rollup. Defaults to ETH.
* @param params.maxFeePerGasForRetryables (Optional) `maxFeePerGas` to use for retryables. Defaults to 0.1 Gwei.
*
* @returns Estimated fees.
*/
export async function createRollupGetRetryablesFees<TChain extends Chain | undefined>(
publicClient: PublicClient<Transport, TChain>,
{ account, nativeToken, maxFeePerGasForRetryables }: CreateRollupGetRetryablesFeesParams,
Expand Down Expand Up @@ -152,6 +162,16 @@ export async function createRollupGetRetryablesFees<TChain extends Chain | undef
applyPercentIncrease({ base: decodedResult, percentIncrease: 3n });
}

/**
* Fetch estimated retryables fees for `createRollup`. If the call fails, falls back to approximate values.
*
* @param publicClient `PublicClient` for the parent chain.
* @param params.account Account used for deploying the rollup.
* @param params.nativeToken (Optional) The native token used for the rollup. Defaults to ETH.
* @param params.maxFeePerGasForRetryables (Optional) `maxFeePerGas` to use for retryables. Defaults to 0.1 Gwei.
*
* @returns Estimated fees.
*/
export async function createRollupGetRetryablesFeesWithDefaults<TChain extends Chain | undefined>(
publicClient: PublicClient<Transport, TChain>,
{ account, nativeToken, maxFeePerGasForRetryables }: CreateRollupGetRetryablesFeesParams,
Expand Down
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ import {
scaleFrom18DecimalsToNativeTokenDecimals,
scaleFromNativeTokenDecimalsTo18Decimals,
} from './utils/decimals';
import {
createRollupDefaultRetryablesFees,
createTokenBridgeDefaultRetryablesFees,
} from './constants';
import {
CreateRollupGetRetryablesFeesParams,
createRollupGetRetryablesFees,
createRollupGetRetryablesFeesWithDefaults,
} from './createRollupGetRetryablesFees';

export {
arbOwnerPublicActions,
Expand Down Expand Up @@ -274,4 +283,11 @@ export {
//
scaleFrom18DecimalsToNativeTokenDecimals,
scaleFromNativeTokenDecimalsTo18Decimals,
//
createRollupDefaultRetryablesFees,
createRollupGetRetryablesFees,
createRollupGetRetryablesFeesWithDefaults,
CreateRollupGetRetryablesFeesParams,
//
createTokenBridgeDefaultRetryablesFees,
};
Loading