@@ -0,0 +1,53 @@
// Settings edited by user
const YOUR_KEEP3R_ADDRESSS = "" ;
const YOUR_KEEP3R_PRIVATE_KEY = "" ;
// Code starts here
const { ethers } = require ( "ethers" ) ;
const privateKey = Buffer . from ( YOUR_KEEP3R_PRIVATE_KEY , 'hex' ) ;
const UniswapOracleV2 = "UniswapOracleV2" ;
const HegicPoolKeep3r = "HegicPoolKeep3r" ;
const YearnV1EarnKeep3r = "YearnV1EarnKeep3r" ;
const abis = {
UniswapOracleV2 : [ { "inputs" :[ { "internalType" :"address" , "name" :"_keep3r" , "type" :"address" } ] , "stateMutability" :"nonpayable" , "type" :"constructor" } , { "inputs" :[ ] , "name" :"KP3R" , "outputs" :[ { "internalType" :"contract IKeep3rV1" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"acceptGovernance" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"tokenA" , "type" :"address" } , { "internalType" :"address" , "name" :"tokenB" , "type" :"address" } ] , "name" :"add" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"tokenIn" , "type" :"address" } , { "internalType" :"uint256" , "name" :"amountIn" , "type" :"uint256" } , { "internalType" :"address" , "name" :"tokenOut" , "type" :"address" } ] , "name" :"consult" , "outputs" :[ { "internalType" :"uint256" , "name" :"amountOut" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"factory" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"governance" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"granularity" , "outputs" :[ { "internalType" :"uint8" , "name" :"" , "type" :"uint8" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "name" :"lastUpdated" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"uint256" , "name" :"timestamp" , "type" :"uint256" } ] , "name" :"observationIndexOf" , "outputs" :[ { "internalType" :"uint8" , "name" :"index" , "type" :"uint8" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } , { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "name" :"pairObservations" , "outputs" :[ { "internalType" :"uint256" , "name" :"timestamp" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"price0Cumulative" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"price1Cumulative" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"pairs" , "outputs" :[ { "internalType" :"address[]" , "name" :"" , "type" :"address[]" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"pendingGovernance" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"periodSize" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_governance" , "type" :"address" } ] , "name" :"setGovernance" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_keep3r" , "type" :"address" } ] , "name" :"setKeep3r" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"tokenA" , "type" :"address" } , { "internalType" :"address" , "name" :"tokenB" , "type" :"address" } ] , "name" :"update" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"uint256" , "name" :"i" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"length" , "type" :"uint256" } ] , "name" :"updateFor" , "outputs" :[ { "internalType" :"bool" , "name" :"updated" , "type" :"bool" } ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"pair" , "type" :"address" } ] , "name" :"updatePair" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"updateable" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"uint256" , "name" :"i" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"length" , "type" :"uint256" } ] , "name" :"updateableFor" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"updateableList" , "outputs" :[ { "internalType" :"address[]" , "name" :"list" , "type" :"address[]" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"windowSize" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"work" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } ] ,
HegicPoolKeep3r : [ { "inputs" :[ { "internalType" :"address" , "name" :"_keep3r" , "type" :"address" } , { "internalType" :"address" , "name" :"_hegicPool" , "type" :"address" } , { "internalType" :"uint256" , "name" :"_minETHRewards" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"_minWBTCRewards" , "type" :"uint256" } ] , "stateMutability" :"nonpayable" , "type" :"constructor" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"address" , "name" :"_to" , "type" :"address" } , { "indexed" :false , "internalType" :"address" , "name" :"token" , "type" :"address" } , { "indexed" :false , "internalType" :"uint256" , "name" :"amount" , "type" :"uint256" } ] , "name" :"DustSent" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"uint256" , "name" :"rewards" , "type" :"uint256" } ] , "name" :"ForcedClaimedRewards" , "type" :"event" } , { "anonymous" :false , "inputs" :[ ] , "name" :"GovernorAccepted" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"address" , "name" :"hegicPool" , "type" :"address" } ] , "name" :"HegicPoolSet" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"address" , "name" :"keep3r" , "type" :"address" } ] , "name" :"Keep3rSet" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"uint256" , "name" :"eth" , "type" :"uint256" } , { "indexed" :false , "internalType" :"uint256" , "name" :"wbtc" , "type" :"uint256" } ] , "name" :"LotsBought" , "type" :"event" } , { "anonymous" :false , "inputs" :[ ] , "name" :"ManagerAccepted" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"uint256" , "name" :"_minETHRewards" , "type" :"uint256" } , { "indexed" :false , "internalType" :"uint256" , "name" :"_minWBTCRewards" , "type" :"uint256" } ] , "name" :"MinRewardsSet" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"address" , "name" :"pendingGovernor" , "type" :"address" } ] , "name" :"PendingGovernorSet" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"address" , "name" :"pendingManager" , "type" :"address" } ] , "name" :"PendingManagerSet" , "type" :"event" } , { "anonymous" :false , "inputs" :[ { "indexed" :false , "internalType" :"uint256" , "name" :"rewards" , "type" :"uint256" } ] , "name" :"RewardsClaimedByKeeper" , "type" :"event" } , { "inputs" :[ ] , "name" :"ETH_ADDRESS" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"HegicPool" , "outputs" :[ { "internalType" :"contract IHegicPoolV2" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"acceptGovernor" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"acceptManager" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"uint256" , "name" :"_eth" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"_wbtc" , "type" :"uint256" } ] , "name" :"buyLots" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"claimRewards" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"forceClaimRewards" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"governor" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"keep3r" , "outputs" :[ { "internalType" :"contract IKeep3rV1" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"minETHRewards" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"minWBTCRewards" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"pendingGovernor" , "outputs" :[ { "internalType" :"address" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_to" , "type" :"address" } , { "internalType" :"address" , "name" :"_token" , "type" :"address" } , { "internalType" :"uint256" , "name" :"_amount" , "type" :"uint256" } ] , "name" :"sendDust" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_hegicPool" , "type" :"address" } ] , "name" :"setHegicPool" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_keep3r" , "type" :"address" } ] , "name" :"setKeep3r" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"uint256" , "name" :"_minETHRewards" , "type" :"uint256" } , { "internalType" :"uint256" , "name" :"_minWBTCRewards" , "type" :"uint256" } ] , "name" :"setMinRewards" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_pendingGovernor" , "type" :"address" } ] , "name" :"setPendingGovernor" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ { "internalType" :"address" , "name" :"_pendingManager" , "type" :"address" } ] , "name" :"setPendingManager" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"workable" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"view" , "type" :"function" } ] ,
YearnV1EarnKeep3r : [ { "inputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"constructor" } , { "inputs" :[ ] , "name" :"BASE" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"KP3R" , "outputs" :[ { "internalType" :"contract IKeep3rV1" , "name" :"" , "type" :"address" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"THRESHOLD" , "outputs" :[ { "internalType" :"uint256" , "name" :"" , "type" :"uint256" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ { "internalType" :"contract IYERC20" , "name" :"_token" , "type" :"address" } ] , "name" :"shouldRebalance" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"tokens" , "outputs" :[ { "internalType" :"contract IYERC20[]" , "name" :"" , "type" :"address[]" } ] , "stateMutability" :"view" , "type" :"function" } , { "inputs" :[ ] , "name" :"work" , "outputs" :[ ] , "stateMutability" :"nonpayable" , "type" :"function" } , { "inputs" :[ ] , "name" :"workable" , "outputs" :[ { "internalType" :"bool" , "name" :"" , "type" :"bool" } ] , "stateMutability" :"view" , "type" :"function" } ] ,
}
class KeeperJob {
constructor ( name , addr , workableFunctionName , workFunctionName ) {
this . name = name ;
this . abi = abis [ name ] ;
this . addr = addr ;
this . workableFunctionName = workableFunctionName ;
this . workFunctionName = workFunctionName ;
}
}
const jobs = [
new KeeperJob ( UniswapOracleV2 , "0x127a2975c4E1c75f1ed4757a861bbd42523DB035" , "updateable" , "work" ) ,
new KeeperJob ( HegicPoolKeep3r , "0x5DDe926b0A31346f2485900C5e64c2577F43F774" , "workable" , "claimRewards" ) ,
new KeeperJob ( YearnV1EarnKeep3r , "0xe7F4ab593aeC81EcA754Da1B3B7cE0C42a13Ec0C" , "workable" , "work" ) ,
]
// Entrypoint for the Autotask
exports . handler = async function ( credentials ) {
const provider = ethers . getDefaultProvider ( 'mainnet' ) ;
const signer = new ethers . Wallet ( privateKey , provider , { speed : 'fastest' , YOUR_KEEP3R_ADDRESSS } ) ;
for ( var i = 0 ; i < jobs . length ; i ++ )
{
const job = jobs [ i ] ;
const contract = new ethers . Contract ( job . addr , job . abi , signer ) ;
// Run work if needed
if ( await contract [ job . workableFunctionName ] ( ) ) {
console . log ( job . name + " workable" ) ;
const tx = await contract [ job . workFunctionName ] ( ) ;
console . log ( tx . hash ) ;
} else {
console . log ( job . name + " not workable" ) ;
}
}
}