Implement CrvStrategyKeep3r

Hey there.

I have tried to implement the script for “CrvStrategyKeep3r”. Script below returns me this error

2020-11-08T11:25:29.390Z AUTOTASK START
2020-11-08T11:25:34.289Z INFO workable
2020-11-08T11:25:34.291Z INFO TypeError: contract.harvest(…) is not a function
** at Runtime.exports.handler (/var/task/index.js:25:92)**
** at processTicksAndRejections (internal/process/task_queues.js:97:5)**
2020-11-08T11:25:34.327Z AUTOTASK COMPLETE

    const { ethers } = require("ethers");
    const { DefenderRelaySigner } = require('defender-relay-client/lib/ethers');
    // Settings edited by user
    const ABI = [
      {"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"calculateHarvest","outputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},
      {"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"harvest","outputs":[],"stateMutability":"nonpayable","type":"function"}
      {"inputs":[{"internalType":"address","name":"_strategy","type":"address"}],"name":"workable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}];

    exports.handler = async function(credentials) {
      const provider = ethers.getDefaultProvider("mainnet", { 
        etherscan: "XXXXX",
        alchemy: "BXXXXxH",
        infura: {
          projectId: "XXXXX",
          projectSecret: "XXXX",
        },
      });
      const signer = new DefenderRelaySigner(credentials, provider, { speed: 'fastest' });
      const contract = new ethers.Contract('0xd0aC37E3524F295D141d3839d5ed5F26A40b589D', ABI , signer);
      
      if (await contract.workable('0xC59601F0CC49baa266891b7fc63d2D5FE097A79D')) {
            console.log(" workable");
            var overrideOptions = {}
            try {
                const tx = await contract.harvest('0xC59601F0CC49baa266891b7fc63d2D5FE097A79D')(overrideOptions)
                console.log(tx.hash);
            } catch(error) {
              console.log(error)
            }

        } else {
           console.log(" not workable");
        }
    }

Any will be really appriciate.

Ty

1 Like

Hey @bolo, harvest() function call takes the strategy being harvested as its input parameter.

For example harvest(yBUSD) which is harvest(0x112570655b32A8c747845E0215ad139661e66E7F)

Will still write a default demo script on how to harvest these, will confirm which ones have been approved by yearn.

1 Like

sounds perfect. I will wait for the demo.

1 Like

I was able to find few strategies and run my script with success . ty for your help

1 Like

4 jobs done with profit. I am very happy :smiling_face_with_three_hearts:

I will suggest everyone to have in minimum 0.7 in your wallet to avoid the out of gas error.

2 Likes

AUTOTASK START
2020-12-02T19:40:47.566Z INFO not workable StrategyCurve3CrvVoterProxy
2020-12-02T19:40:47.837Z INFO not workable StrategyCurveBTCVoterProxy
2020-12-02T19:40:48.109Z INFO not workable StrategyCurveYVoterProxy
2020-12-02T19:40:48.388Z INFO not workable StrategyCurveBUSDVoterProxy
2020-12-02T19:40:48.753Z INFO not workable StrategyCurveGUSDProxy
2020-12-02T19:40:49.022Z INFO not workable StrategyCurveCompoundVoterProxy
END RequestId: e78b74ef-0110-4bd2-a303-1c1e654cf517
AUTOTASK COMPLETE

What’s wrong?