@generationsoftware/pt-v5-autotasks-library
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -1,2 +0,3 @@ | ||
export * from './flash.js'; | ||
export * from './flashLiquidatorConst.js'; | ||
export * from './uniswapV2WethPairFlashLiquidator.js'; | ||
export * from './multipliers.js'; | ||
@@ -3,0 +4,0 @@ export * from './network.js'; |
@@ -1,2 +0,3 @@ | ||
export * from './flash.js'; | ||
export * from './flashLiquidatorConst.js'; | ||
export * from './uniswapV2WethPairFlashLiquidator.js'; | ||
export * from './multipliers.js'; | ||
@@ -3,0 +4,0 @@ export * from './network.js'; |
@@ -6,20 +6,10 @@ import { ethers } from 'ethers'; | ||
import { LiquidationPairAbi } from './abis/LiquidationPairAbi.js'; | ||
import { FLASH_LIQUIDATION_PAIRS, UNISWAP_V2_FLASH_LIQUIDATOR_CONTRACT_ADDRESS, NETWORK_NATIVE_TOKEN_INFO, } from './constants/index.js'; | ||
import { FLASH_LIQUIDATION_PAIRS, FLASH_LIQUIDATOR_CONTRACT_ADDRESS, NETWORK_NATIVE_TOKEN_INFO, } from './constants/index.js'; | ||
import { sendPopulatedTx } from './helpers/sendPopulatedTx.js'; | ||
export async function runFlashLiquidator(config) { | ||
const { chainId, wallet, signer, provider, relayerAddress, minProfitThresholdUsd, covalentApiKey, } = config; | ||
const { chainId, wallet, signer, provider, swapRecipient, minProfitThresholdUsd, covalentApiKey, } = config; | ||
console.log('Config - MIN_PROFIT_THRESHOLD_USD:', config.minProfitThresholdUsd); | ||
printSpacer(); | ||
let swapRecipient = config.swapRecipient; | ||
if (!swapRecipient) { | ||
const message = `Config - SWAP_RECIPIENT not provided, setting swap recipient to relayer address:`; | ||
console.log(chalk.dim(message), chalk.yellow(relayerAddress)); | ||
swapRecipient = relayerAddress; | ||
} | ||
else { | ||
console.log(chalk.dim(`Config - SWAP_RECIPIENT:`), chalk.yellow(swapRecipient)); | ||
} | ||
console.log(chalk.dim('Config - MIN_PROFIT_THRESHOLD_USD:'), chalk.yellow(config.minProfitThresholdUsd)); | ||
printSpacer(); | ||
console.log('Starting ...'); | ||
const flashLiquidationContract = new ethers.Contract(UNISWAP_V2_FLASH_LIQUIDATOR_CONTRACT_ADDRESS[chainId], FlashLiquidatorAbi, signer); | ||
const flashLiquidationContract = new ethers.Contract(FLASH_LIQUIDATOR_CONTRACT_ADDRESS, FlashLiquidatorAbi, signer); | ||
printSpacer(); | ||
@@ -36,3 +26,3 @@ printSpacer(); | ||
const liquidationPairContract = new ethers.Contract(flashLiquidationPair.address, LiquidationPairAbi, provider); | ||
const context = await getFlashLiquidatorContextMulticall(chainId, liquidationPairContract, provider, covalentApiKey); | ||
const context = await getFlashLiquidatorContextMulticall(liquidationPairContract, provider, covalentApiKey); | ||
const pair = `${context.tokenIn.symbol}/${context.tokenOut.symbol}`; | ||
@@ -86,3 +76,3 @@ printContext(context); | ||
try { | ||
avgFeeUsd = await getGasCost(chainId, config, flashLiquidationContract, flashLiquidateParams, provider); | ||
avgFeeUsd = await getGasCost(chainId, flashLiquidationContract, flashLiquidateParams, provider, covalentApiKey); | ||
} | ||
@@ -116,3 +106,4 @@ catch (e) { | ||
const gasLimit = 1050000; | ||
const tx = await sendPopulatedTx(provider, wallet, populatedTx, gasLimit); | ||
const gasPrice = await provider.getGasPrice(); | ||
const tx = await sendPopulatedTx(provider, wallet, populatedTx, gasLimit, gasPrice); | ||
console.log(chalk.greenBright.bold('Transaction sent! ✔')); | ||
@@ -178,4 +169,4 @@ console.log(chalk.blueBright.bold('Transaction hash:', tx.hash)); | ||
}; | ||
const getGasCost = async (chainId, config, flashLiquidationContract, flashLiquidateParams, provider) => { | ||
const nativeTokenMarketRateUsd = await getNativeTokenMarketRateUsd(chainId, config.covalentApiKey); | ||
const getGasCost = async (chainId, flashLiquidationContract, flashLiquidateParams, provider, covalentApiKey) => { | ||
const nativeTokenMarketRateUsd = await getNativeTokenMarketRateUsd(chainId, covalentApiKey); | ||
printAsterisks(); | ||
@@ -182,0 +173,0 @@ console.log(chalk.blue('4. Current gas costs for transaction:')); |
@@ -0,1 +1,2 @@ | ||
export { runFlashLiquidator } from './flashLiquidator.js'; | ||
export { runPrizeClaimer } from './prizeClaimer.js'; | ||
@@ -2,0 +3,0 @@ export { runLiquidator } from './liquidator.js'; |
@@ -0,1 +1,2 @@ | ||
export { runFlashLiquidator } from './flashLiquidator.js'; | ||
export { runPrizeClaimer } from './prizeClaimer.js'; | ||
@@ -2,0 +3,0 @@ export { runLiquidator } from './liquidator.js'; |
@@ -56,2 +56,4 @@ import { Contract, BigNumber, Wallet, Signer } from 'ethers'; | ||
} | ||
export interface FlashLiquidatorConfig extends SharedLiquidatorConfig { | ||
} | ||
export interface DrawAuctionConfig extends AutotaskConfig { | ||
@@ -66,2 +68,4 @@ errorStateMaxGasCostThresholdUsd: number; | ||
} | ||
export interface FlashLiquidatorContext extends BaseLiquidatorContext { | ||
} | ||
export interface LiquidatorContext extends BaseLiquidatorContext { | ||
@@ -90,2 +94,4 @@ relayer: LiquidatorRelayerContext; | ||
} | ||
export interface FlashLiquidatorEnvVars extends SharedLiquidatorEnvVars { | ||
} | ||
export interface PrizeClaimerEnvVars extends AutotaskEnvVars { | ||
@@ -92,0 +98,0 @@ SUBGRAPH_URL: string; |
import { Contract } from 'ethers'; | ||
import { Provider } from '@ethersproject/providers'; | ||
import { FlashLiquidatorContext } from '../types.js'; | ||
export declare const getFlashLiquidatorContextMulticall: (chainId: number, liquidationPairContract: Contract, provider: Provider, covalentApiKey: string) => Promise<FlashLiquidatorContext>; | ||
export declare const getFlashLiquidatorContextMulticall: (liquidationPairContract: Contract, provider: Provider, covalentApiKey?: string) => Promise<FlashLiquidatorContext>; |
import chalk from 'chalk'; | ||
import { ethers } from 'ethers'; | ||
import { getEthersMulticallProviderResults } from '@generationsoftware/pt-v5-utils-js'; | ||
import { printSpacer, getEthMainnetTokenMarketRateUsd } from '../utils/index.js'; | ||
import { printSpacer, getEthMainnetTokenMarketRateUsd } from './index.js'; | ||
import { ERC20Abi } from '../abis/ERC20Abi.js'; | ||
@@ -9,3 +9,4 @@ import { ERC4626Abi } from '../abis/ERC4626Abi.js'; | ||
const { MulticallWrapper } = ethersMulticallProviderPkg; | ||
export const getFlashLiquidatorContextMulticall = async (chainId, liquidationPairContract, provider, covalentApiKey) => { | ||
export const getFlashLiquidatorContextMulticall = async (liquidationPairContract, provider, covalentApiKey) => { | ||
const chainId = provider._network.chainId; | ||
const multicallProvider = MulticallWrapper.wrap(provider); | ||
@@ -12,0 +13,0 @@ let queries = {}; |
@@ -7,2 +7,3 @@ export * from './checkOrX.js'; | ||
export * from './getComputeTotalClaimFeesMulticall.js'; | ||
export * from './getFlashLiquidatorContextMulticall.js'; | ||
export * from './getLiquidatorContextMulticall.js'; | ||
@@ -12,2 +13,3 @@ export * from './getLiquidationPairsMulticall.js'; | ||
export * from './getWinnersUri.js'; | ||
export * from './loadFlashLiquidatorEnvVars.js'; | ||
export * from './loadLiquidatorEnvVars.js'; | ||
@@ -14,0 +16,0 @@ export * from './loadPrizeClaimerEnvVars.js'; |
@@ -7,2 +7,3 @@ export * from './checkOrX.js'; | ||
export * from './getComputeTotalClaimFeesMulticall.js'; | ||
export * from './getFlashLiquidatorContextMulticall.js'; | ||
export * from './getLiquidatorContextMulticall.js'; | ||
@@ -12,2 +13,3 @@ export * from './getLiquidationPairsMulticall.js'; | ||
export * from './getWinnersUri.js'; | ||
export * from './loadFlashLiquidatorEnvVars.js'; | ||
export * from './loadLiquidatorEnvVars.js'; | ||
@@ -14,0 +16,0 @@ export * from './loadPrizeClaimerEnvVars.js'; |
@@ -0,1 +1,2 @@ | ||
import { FlashLiquidatorEnvVars } from './../types.js'; | ||
export declare const loadFlashLiquidatorEnvVars: () => FlashLiquidatorEnvVars; |
{ | ||
"name": "@generationsoftware/pt-v5-autotasks-library", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Library of shared utils to run PoolTogether v5 hyperstructure autotasks.", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
408853
141
6690