UNPKG

@tempus-labs/utils

Version:

Tempus utility helpers

83 lines 4.1 kB
import { Contract, Transaction } from "ethers"; import { Decimal } from "../utils/Decimal"; import { Numberish } from "../utils/DecimalUtils"; import { ContractBase, Signer, Addressable } from "../utils/ContractBase"; import { IERC20 } from "./IERC20"; /** * Typed wrapper for ERC20 contracts */ export declare class ERC20 extends ContractBase implements IERC20 { constructor(contractName: string, decimals: number, contract?: Contract); /** * Deploy a contract of type T which extends ERC20 * Example: const token = await MyERC20Token.deployClass(MyERC20Token); * @param type Type of the ERC20 instance */ static deployClass<T extends ERC20>(type: new () => T, ...args: any[]): Promise<T>; /** * Deploys any ERC20 contract without a concrete backing TypeScript class */ static deploy(contractName: string, decimals: number, ...args: any[]): Promise<ERC20>; /** * Attaches to any contract address and attempts to convert it to ERC20 * Uses default provider * @param contractName Name of the solidity contract * @param contractAddress Address of the contract * @param decimals Contract decimals */ static attach(contractName: string, contractAddress: string, decimals: number): Promise<ERC20>; /** * Attaches to any contract address from a provided Signer and attempts to convert it to ERC20 * @param contractName Name of the solidity contract * @param contractAddress Address of the contract * @param signer Signer to attach with, can be ethers.VoidSigner or SignerWithAddress */ static attachWithSigner(contractName: string, contractAddress: string, signer: Signer): Promise<ERC20>; private getContractDecimals; /** @return ERC20 name of this contract */ name(): Promise<string>; /** @return ERC20 symbol of this contract */ symbol(): Promise<string>; /** * @returns Total supply of this ERC20 token as a decimal, such as 10.0 */ totalSupply(): Promise<Decimal>; /** * @param account ERC20 account's address * @returns Balance of ERC20 address in decimals, eg 2.0 */ balanceOf(account: Addressable): Promise<Decimal>; /** * @dev Moves `amount` tokens from the sender's account to `recipient`. * @param sender The sender/caller of this transfer * @param recipient ERC20 transfer recipient's address * @param amount Amount of tokens to send in contract decimals, eg 2.0 or "0.00001" */ transfer(sender: Signer, recipient: Addressable, amount: Numberish): Promise<any>; /** * @param owner ERC20 owner's address * @param spender ERC20 spender's address * @returns The remaining number of tokens that `spender` will be allowed to * spend on behalf of `owner` through {transferFrom}. This is zero by default. */ allowance(owner: Addressable, spender: Addressable): Promise<Decimal>; /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * @param caller The caller who is sending this approve * @param spender ERC20 approve's, spender's address * @param amount Amount of tokens to approve in contract decimals, eg 2.0 or "0.00001" */ approve(caller: Signer, spender: Addressable, amount: Numberish): Promise<any>; /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's allowance. * @param sender ERC20 transferFrom sender's address * @param recipient ERC20 transferFrom recipient's address * @param amount Amount of tokens to send in contract decimals, eg 2.0 or "0.00001" */ transferFrom(sender: Addressable, recipient: Addressable, amount: Numberish): Promise<any>; /** Sends some ether directly to the contract, * which is handled in the contract receive() function */ sendToContract(signer: Signer, amount: Numberish): Promise<Transaction>; } //# sourceMappingURL=ERC20.d.ts.map