@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
52 lines • 2.41 kB
TypeScript
import { ethers } from "ethers";
/**
* Generate mock approval data for a given ERC20 token
* @param provider - The JsonRpcProvider instance
* @param tokenAddress - The address of the ERC20 token
* @param ownerAddress - The address of the owner
* @param spenderAddress - The address of the spender
* @param mockAddress - The address to mock the approval for
* @param mockApprovalAmount - The amount to mock the approval for
* @param maxSlots - The maximum number of slots to search
* @returns An object containing the slot and approval data
*
*/
export declare const generateMockApprovalData: (provider: ethers.providers.JsonRpcProvider, { tokenAddress, ownerAddress, spenderAddress, mockAddress, mockApprovalAmount, maxSlots, useFallbackSlot }: {
tokenAddress: string;
ownerAddress: string;
spenderAddress: string;
mockAddress: string;
mockApprovalAmount: string;
maxSlots?: number | undefined;
useFallbackSlot?: boolean | undefined;
}) => Promise<{
slot: string;
approval: string;
isVyper: boolean;
}>;
/**
* Get the storage slot for a given ERC20 token approval
* @param provider - The JsonRpcProvider instance
* @param erc20Address - The address of the ERC20 token
* @param ownerAddress - The address of the owner, used to find the approval slot
* @param spenderAddress - The address of the spender, used to find the approval slot
* @param maxSlots - The maximum number of slots to search
* @returns The slot for the approval
*
* - This uses a brute force approach similar to the balance slot search. See the balance slot search comment for more details.
*/
export declare const getErc20ApprovalStorageSlot: (provider: ethers.providers.JsonRpcProvider, erc20Address: string, ownerAddress: string, spenderAddress: string, maxSlots: number, useFallbackSlot?: boolean) => Promise<{
slot: string;
slotHash: string;
isVyper: boolean;
}>;
/**
* Get the approval for a given ERC20 token
* @param provider - The JsonRpcProvider instance
* @param address - The address of the ERC20 token
* @param ownerAddress - The address of the owner
* @param spenderAddress - The address of the spender
* @returns The approval amount
*/
export declare const getErc20Approval: (provider: ethers.providers.JsonRpcProvider, address: string, ownerAddress: string, spenderAddress: string) => Promise<ethers.BigNumber>;
//# sourceMappingURL=approval.d.ts.map