UNPKG

@d3or/slotseek

Version:

A library for finding the storage slots on an ERC20 token for balances and approvals, which can be used to mock the balances and approvals of an address when estimating gas costs of transactions that would fail if the address did not have the required bal

26 lines 1.35 kB
import { ethers } from "ethers"; /** * Compute the storage slot for permit2 allowance. * NOTE: unlike arbitrary erc20 contracts, we know the slot for where this is stored (1) :) * * @param erc20Address - The address of the ERC20 token * @param ownerAddress - The address of the ERC20 token owner * @param spenderAddress - The address of the spender * @returns The slot where the allowance amount is stored, mock this * * - This uses a brute force approach similar to the balance slot search. See the balance slot search comment for more details. */ export declare const computePermit2AllowanceStorageSlot: (ownerAddress: string, erc20Address: string, spenderAddress: string) => { slot: string; }; /** * Get the permit2 erc20 allowance for a given ERC20 token and spender * @param provider - The JsonRpcProvider instance * @param permit2Address - The permit2 contract address * @param erc20Address - The address of the ERC20 token * @param ownerAddress - The address of the ERC20 token owner * @param spenderAddress - The address of the spender * @returns The approval amount */ export declare const getPermit2ERC20Allowance: (provider: ethers.providers.JsonRpcProvider, permit2Address: string, ownerAddress: string, erc20Address: string, spenderAddress: string) => Promise<ethers.BigNumber>; //# sourceMappingURL=permit2.d.ts.map