/** * @file Comet * @desc These methods facilitate interactions with Compound III. */ import { BigNumber } from '@ethersproject/bignumber/lib/bignumber'; import { AssetInfo, CallOptions, Signature, TrxResponse } from './types'; /** * Supplies the user's Ethereum asset to Compound Comet. * * @param {string} from A string of the address that the supplied asset is * supplied from. This allows approved account managers to supply on behalf * of an account that has already approved their ERC-20 asset to be * transferred to the Comet contract. To supply on behalf of the sender, * this should be set to the sender's address. * @param {string} dst A string of the address that the supplied asset is * credited to within Comet. To supply to the sender's account, this should * be set to the sender's address. * @param {string} asset A string of the name of the asset to supply. * @param {number | string | BigNumber} amount A string, number, or BigNumber * object of the amount of an asset to supply. Use the `mantissa` boolean in * the `options` parameter to indicate if this value is scaled up (so there * are no decimals) or in its natural scale. * @param {boolean} noApprove Explicitly prevent this method from attempting an * ERC-20 `approve` transaction prior to sending the `supply` transaction. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. A passed `gasLimit` will be used in both the `approve` (if * not supressed) and `supply` transactions. * * @returns {object} Returns an Ethers.js transaction object of the supply * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * // Ethers.js overrides are an optional last parameter * // const trxOptions = { gasLimit: 250000, mantissa: false }; * * (async function() { * * const me = '0xSenderAddress'; // can be compound._provider.address * * console.log('Supplying ETH to Compound Comet...'); * const trx = await comet.supply( * me, // supplied asset comes from this account * me, // supplied asset is credited to this account's balance * Compound.WBTC, * 3 * ); * console.log('Ethers.js transaction object', trx); * * })().catch(console.error); * ``` */ export declare function supply(from: string, dst: string, asset: string, amount: string | number | BigNumber, noApprove?: boolean, options?: CallOptions): Promise; /** * Allows or disallows an address to withdraw or transfer on behalf of the * Sender's address. * * @param {string} manager The address of the manager. * @param {boolean} isAllowed True to add the manager and false to remove the * manager. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the allow * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const address = '0xManagerAddressHere'; * const trx = await comet.allow(address, true); * console.log('Ethers.js transaction object', trx); * })().catch(console.error); * ``` */ export declare function allow(manager: string, isAllowed: boolean, options?: CallOptions): Promise; /** * Enable or disable a Comet account manager using an EIP-712 signature. * * @param {string} owner The address of the account that is changing a manager. * @param {string} manager The address of the manager of the account. * @param {boolean} isAllowed Pass true to enable a manager, false to disable. * @param {number} nonce The contract state required to match the signature. * This can be retrieved from the contract's public nonces mapping. * @param {number} expiry The time at which to expire the signature. A block * timestamp as seconds since the unix epoch. * @param {object} signature An object that contains the v, r, and, s values of * an EIP-712 signature. * @param {CallOptions} [options] Options to set for `eth_call`, optional ABI * (as JSON object), and Ethers.js method overrides. The ABI can be a string * of the single intended method, an array of many methods, or a JSON object * of the ABI generated by a Solidity compiler. * * @returns {object} Returns an Ethers.js transaction object of the allow * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function() { * const allowTx = await comet.allowBySig( * '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', * '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', * true, * 42, * 9999999999, * { * v: '0x1b', * r: '0x130dbca2fafa07424c033b4479687cc1deeb65f08809e3ab397988cc4c6f2e78', * s: '0x1debeb8250262f23906b1177161f0c7c9aa3641e8bff5b6f5c88a6bb78d5d8cd' * } * ); * console.log('Ethers.js transaction object', allowTx); * })().catch(console.error); * ``` */ export declare function allowBySig(owner: string, manager: string, isAllowed: boolean, nonce: number, expiry: number, signature?: Signature, options?: CallOptions): Promise; /** * Create an EIP-712 signature for enabling or disabling a Comet account * manager. Anyone can post it to the blockchain using the `allowBySig` * method, which does have gas costs. * * @param {string} manager The address of the manager of the account. * @param {boolean} isAllowed Pass true to enable a manager, false to disable. * @param {number} [expiry] The time at which to expire the signature. A block * timestamp as seconds since the unix epoch. Defaults to `10e9`. * * @returns {object} Returns an object that contains the `v`, `r`, and `s` * components of an Ethereum signature as hexadecimal strings. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async () => { * * const allowSignature = await comet.createAllowSignature( * '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', * true * ); * console.log('allowSignature', allowSignature); * * })().catch(console.error); * ``` */ export declare function createAllowSignature(manager: string, isAllowed: boolean, expiry?: number): Promise; /** * Transfers an asset to another account within Compound Comet. * * @param {string | boolean} src The source account address in the transfer. If * the transfer is on behalf of the sender instead of a manager, `true` can * be passed instead of an address as a string. * @param {string} dst The desination account address in the transfer. * @param {string} asset A string of the name of the asset to transfer. * @param {number | string | BigNumber} amount A string, number, or BigNumber * object of the amount of an asset to transfer. Use the `mantissa` boolean * in the `options` parameter to indicate if this value is scaled up (so * there are no decimals) or in its natural scale. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the transfer * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * // Ethers.js overrides are an optional last parameter * // const trxOptions = { gasLimit: 250000 }; * * (async function() { * * console.log('Transferring WETH in Compound Comet...'); * const trx = await comet.transfer( * true, // on behalf of the sender * destinationAddress, * Compound.WETH, * '10000000', * trxOptions * ); * console.log('Ethers.js transaction object', trx); * * })().catch(console.error); * ``` */ export declare function transfer(src: string | boolean, dst: string, asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise; /** * Withdraws an asset from Compound Comet from the sender's account to itself. * * @param {string} asset A string of the name of the asset to withdraw. * @param {number | string | BigNumber} amount A string, number, or BigNumber * object of the amount of an asset to withdraw. Use the `mantissa` boolean * in the `options` parameter to indicate if this value is scaled up (so * there are no decimals) or in its natural scale. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the withdraw * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * // Ethers.js overrides are an optional last parameter * // const trxOptions = { gasLimit: 250000 }; * * (async function() { * * console.log('Withdrawing DAI from my account...'); * const trx = await comet.withdraw( * Compound.DAI, * 10, * trxOptions * ); * console.log('Ethers.js transaction object', trx); * * })().catch(console.error); * ``` */ export declare function withdraw(asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise; /** * Withdraws an asset from Compound Comet from the sender's account to another. * * @param {string} dst The desination account address in the withdrawal. * @param {string} asset A string of the name of the asset to withdraw. * @param {number | string | BigNumber} amount A string, number, or BigNumber * object of the amount of an asset to withdraw. Use the `mantissa` boolean * in the `options` parameter to indicate if this value is scaled up (so * there are no decimals) or in its natural scale. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the withdraw * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * // Ethers.js overrides are an optional last parameter * // const trxOptions = { gasLimit: 250000 }; * * (async function() { * * console.log('Withdrawing DAI from my account to dst account...'); * const trx = await comet.withdrawTo( * dst, // destination, the address that the withdrawn asset is sent to * Compound.DAI, * 10, * trxOptions * ); * console.log('Ethers.js transaction object', trx); * * })().catch(console.error); * ``` */ export declare function withdrawTo(dst: string, asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise; /** * Withdraws an asset from Compound Comet from one account to another. The * caller must be an allowed manager for the source account. * * @param {string} src The source account address in the withdrawal. The sender * must be an allowed manager for the source account. * @param {string} dst The desination account address in the withdrawal. * @param {string} asset A string of the name of the asset to withdraw. * @param {number | string | BigNumber} amount A string, number, or BigNumber * object of the amount of an asset to withdraw. Use the `mantissa` boolean * in the `options` parameter to indicate if this value is scaled up (so * there are no decimals) or in its natural scale. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the withdraw * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * // Ethers.js overrides are an optional last parameter * // const trxOptions = { gasLimit: 250000 }; * * (async function() { * * console.log('Withdrawing DAI from src account to dst account...'); * const trx = await comet.withdrawFrom( * src, // source address, sender must be an allowed manager for the address * dst, // destination, the address that the withdrawn asset is sent to * Compound.DAI, * 10, * trxOptions * ); * console.log('Ethers.js transaction object', trx); * * })().catch(console.error); * ``` */ export declare function withdrawFrom(src: string, dst: string, asset: string, amount: string | number | BigNumber, options?: CallOptions): Promise; /** * Gets the supply rate. This method returns the current supply rate as the * decimal representation of a percentage scaled up by 10 ^ 18. * * @param {string | number | BigNumber} [utilization] A number representing the * utilization rate in which to get the corresponding supply rate. The * current utilization rate can be fetched by using `Compound.comet.getUtilization()`. * * @returns {string} Returns a string of the numeric value of the supply rate. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const supplyRate = await comet.getSupplyRate(); * console.log('Supply Rate', supplyRate); * })().catch(console.error); * ``` */ export declare function getSupplyRate(utilization: string | number | BigNumber): Promise; /** * Gets the borrow rate. This method returns the current borrow rate as the * decimal representation of a percentage scaled up by 10 ^ 18. * * @param {string | number | BigNumber} [utilization] A number representing the * utilization rate in which to get the corresponding supply rate. The * current utilization rate can be fetched by using `Compound.comet.getUtilization()`. * * @returns {string} Returns a string of the numeric value of the borrow rate. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const borrowRate = await comet.getBorrowRate(); * console.log('Borrow Rate', borrowRate); * })().catch(console.error); * ``` */ export declare function getBorrowRate(utilization: string | number | BigNumber): Promise; /** * Gets the utilization rate. * * @returns {string} Returns the current protocol utilization as a percentage as * a decimal, represented by an unsigned integer, scaled up by 10 ^ 18. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const utilization = await comet.getUtilization(); * console.log('Utilization', utilization); * })().catch(console.error); * ``` */ export declare function getUtilization(): Promise; /** * This method triggers the liquidation of one or many underwater accounts. * * @param {string} absorber The account that is issued liquidator points during * successful execution. * @param {string | string[]} accounts A string of one or an array of many * addresses of underwater accounts. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the absorb * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const addresses = [ * '0xUnderwaterAccountAddress1', * ]; * const trx = await comet.absorb(addresses); * console.log('Ethers.js transaction object', trx); * })().catch(console.error); * ``` */ export declare function absorb(absorber: string, accounts: string[], options?: CallOptions): Promise; /** * Gets the Comet protocol reserves for the base asset as an integer. * * @returns {string} Returns the current protocol reserves in in the base asset * as an unsigned integer, scaled up by 10 to the "decimals" integer in the * base asset's contract. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const reserves = await comet.getReserves(); * console.log('Reserves', reserves); * })().catch(console.error); * ``` */ export declare function getReserves(): Promise; /** * Gets the Comet protocol target reserves. * * @returns {string} Returns the protocol target reserves in the base asset as * an unsigned integer, scaled up by 10 to the "decimals" integer in the * base asset's contract. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const target = await comet.targetReserves(); * console.log('Target Reserves', target); * })().catch(console.error); * ``` */ export declare function targetReserves(): Promise; /** * Gets the collateralization of an account as a boolean. * * @param {string} account The account address as a string. * * @returns {boolean} Returns the collateralization of the account as a boolean. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const address = '0xAccountThatBorrows'; * const isCollateralized = await comet.isBorrowCollateralized(address); * console.log('Is Collateralized', isCollateralized); * })().catch(console.error); * ``` */ export declare function isBorrowCollateralized(account: string): Promise; /** * Checks if the passed account is presently liquidatable. * * @param {string} account The account address as a string. * * @returns {boolean} Returns the ability to liquidate the account as a boolean. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const address = '0xAccountThatBorrows'; * const isLiquidatable = await comet.isLiquidatable(address); * console.log('Is Liquidatable', isLiquidatable); * })().catch(console.error); * ``` */ export declare function isLiquidatable(account: string): Promise; /** * Gets the price of the asset that is passed to it in USD as an unsigned * integer, scaled up by 10 ^ 8. * * @param {string} asset A string of the name of the asset. * @param {number | string | BigNumber} baseAmount A string, number, or BigNumber * object of the amount of the base asset to get a quote. Use the `mantissa` * boolean in the `options` parameter to indicate if this value is scaled up * (so there are no decimals) or in its natural scale. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {string} Returns the price of the asset that is passed to it in USD * as an unsigned integer, scaled up by 10 ^ 6. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const price = await comet.quoteCollateral(Compound.UNI, '1000000000'); * console.log('Price quote of 1000 base asset of UNI', price); * })().catch(console.error); * ``` */ export declare function quoteCollateral(asset: string, baseAmount: string | number | BigNumber, options?: CallOptions): Promise; /** * Buys discounted collateral from the protocol. This collateral is available * after an insolvent borrower account has been absorbed by the protocol. * Collateral is only sold when the target reserves amount is not yet * reached. The `mantissa` call option is applied to both the `minAmount` * and `baseAmount` parameters. * * @param {string} asset A string of the name of the asset to buy. * @param {number | string | BigNumber} minAmount A string, number, or BigNumber * object of the minimum amount of an asset to buy from the protocol. Use * the `mantissa` boolean in the `options` parameter to indicate if this * value is scaled up (so there are no decimals) or in its natural scale. * @param {number | string | BigNumber} baseAmount A string, number, or * BigNumber object of the amount of base asset used to buy the collateral. * @param {string} recipient The desination account address of the collateral * that is purchased. * @param {boolean} noApprove Explicitly prevent this method from attempting an * ERC-20 `approve` transaction prior to buying collateral using the base * asset. * @param {CallOptions} [options] Call options and Ethers.js overrides for the * transaction. * * @returns {object} Returns an Ethers.js transaction object of the buy * transaction. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function() { * * const me = '0xRecipient'; * * console.log('Buying collateral...'); * const trx = await comet.buyCollateral( * Compound.WBTC, * 1, * 10000 * ); * console.log('Ethers.js transaction object', trx); * await trx.wait(1); * * })().catch(console.error); * ``` */ export declare function buyCollateral(asset: string, minAmount: string | number | BigNumber, baseAmount: string | number | BigNumber, recipient: string, noApprove?: boolean, options?: CallOptions): Promise; /** * Gets the price of the asset that is passed to it in USD as an unsigned * integer, scaled up by 10 ^ 8. * * @param {string} asset A string of the symbol of the asset. * * @returns {string} Returns the price of the asset that is passed to it in USD * as an unsigned integer, scaled up by 10 ^ 8. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const price = await comet.getPrice(Compound.WBTC); * console.log('Price of WBTC', price); * })().catch(console.error); * ``` */ export declare function getPrice(asset: string): Promise; /** * Gets the current borrow balance of an account as an unsigned integer. If the * account has a non-negative base asset balance, it will return 0. * * @param {string} account The account address as a string. * * @returns {string} Returns the collateralization of the account as an integer. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const address = '0xAccountThatBorrows'; * const bal = await comet.borrowBalanceOf(address); * console.log('Borrow Balance', bal.toString()); * })().catch(console.error); * ``` */ export declare function borrowBalanceOf(account: string): Promise; /** * Gets the current balance of the collateral asset for the specified account. * * @param {string} account The account address as a string. * @param {string} asset The name of the collateral asset. * * @returns {string} Returns the collateral balance as an integer. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const address = '0xAccountThatSupplied'; * const balance = await comet.collateralBalanceOf(address, Compound.WBTC); * console.log('Collateral balance', balance); * })().catch(console.error); * ``` */ export declare function collateralBalanceOf(account: string, asset: string): Promise; /** * Gets the stored information for a supported asset. * * @param {number | string | BigNumber} assetIndex The index of the asset in the * array in the Comet contract. * * @returns {AssetInfo} Returns a tuple of the asset's information. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const assetInfo = await comet.getAssetInfo(2); * console.log('Asset Info', assetInfo); * })().catch(console.error); * ``` */ export declare function getAssetInfo(assetIndex: string | number | BigNumber): Promise; /** * Gets the stored information for a supported asset. * * @param {string} _address The contract address of the supported asset. * * @returns {AssetInfo} Returns a tuple of the asset's information. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const assetInfo = await comet.getAssetInfoByAddress('0xContract'); * console.log('Asset Info', assetInfo); * })().catch(console.error); * ``` */ export declare function getAssetInfoByAddress(_address: string): Promise; /** * Gets the stored information for a supported asset. * * @param {string} symbol The symbol of the supported asset. * * @returns {AssetInfo} Returns a tuple of the asset's information. * * @example * * ``` * const compound = new Compound(window.ethereum); * const comet = compound.comet.MAINNET_USDC(); * * (async function () { * const assetInfo = await comet.getAssetInfoBySymbol(Compound.WETH); * console.log('Asset Info', assetInfo); * })().catch(console.error); * ``` */ export declare function getAssetInfoBySymbol(asset: string): Promise; /** * Gets an array of the supported Compound III deployment names. * * @returns {string[]} Returns an array of strings that are used to refer to each Compound III deployment. * * @example * * ``` * const networkNames = Compound.comet.getSupportedDeployments(); * ``` */ export declare function getSupportedDeployments(): string[]; /** * Gets an array of the supported collateral assets in the specified Comet * instance. * * @param {string?} deployment The specific deployment in which to get supported * collaterals. The key is usually `${network}_${baseAssetSymbol}`. Use * `getSupportedDeployments` to get proper values for this parameter. * Defaults to cUSDCv3 on Ethereum Mainnet (`mainnet_usdc`) if nothing is * passed. * * @returns {string[]} Returns an array of strings of the asset names. * * @example * * ``` * const collaterals = Compound.comet.getSupportedCollaterals(); * ``` */ export declare function getSupportedCollaterals(deployment?: string): string[]; /** * Gets the name of the base asset in the specified instance. * * @param {string?} deployment The specific deployment in which to get supported * collaterals. The key is usually `${network}_${baseAssetSymbol}`. Use * `getSupportedDeployments` to get proper values for this parameter. * Defaults to cUSDCv3 on Ethereum Mainnet (`mainnet_usdc`) if nothing is * passed. * * @returns {string} Returns a string of the base asset name. * * @example * * ``` * const baseAssetName = Compound.comet.getBaseAssetName(); * ``` */ export declare function getBaseAssetName(deployment?: string): string;