Giter VIP home page Giter VIP logo

aaveloop's Introduction

AaveLoop

What is this

DeFi strategy to invest USDC in Aave in a loop in order to earn stkAAVE rewards for approx x7 of the initial investment.

E2E Tests

Run test on a mainnet fork with Hardhat:

npm install
npm run build
npm run test

To see all event logs pass --logs to the test command.

Contract deployment

  1. Clone and initialize the repo:
    • git clone
    • npm install
    • npm run build
  2. Enter your infura/alchemy endpoint in hardhat.config.ts under networks.eth.url
  3. Create a new temporary address with a mnemonic generator and import the private key to metamask.
  4. Send 0.3ETH (enough for deployment) to the temp address (preferably from a cefi origin like Binance, so that it will be a "clean" account with no history)
  5. npm run deploy eth and follow the prompts.
  6. The deploy script will take care of everything, after deployment send any leftover funds back and BURN THE MNEMONIC!
  7. A backup is created under ./deployments just in case.
  8. The contract is ready to be used by the owner.
  9. To add custom abi to etherscan, use the ABI in deployments/*/artifacts/contracts/AaveLoop.sol/AaveLoop.json

Management roles

  • Owner owns the contract and the funds inside. Can enter, exit and withdraw.

Sending management transactions

It's recommended to take the ABI created during deployment and upload it as private custom ABI to Etherscan and this way we can easily use Etherscan's read/write interface (with Trezor) without publishing the contract source. (pass false at contract deployment to skip source upload).

Monitoring against liquidations

  • Call getPositionData to see that the liquidity is not dropping to 1 (approaching liquidation).

Emergencies

If exitPosition fails, exit can be done manually:

  1. Using a lower number in maxIterations. Partial exits are supported, will deleverage but stay in position.
  2. Using multiple manual rollback transactions
  3. The owner of the contract can also execute an arbitrary transaction using emergencyFunctionCall or emergencyFunctionDelegateCall. Check the tests.
  4. By sending more USDC to the contract before running exitPosition again, this will reduce the numebr of exit iterations

aaveloop's People

Contributors

danielzlotin avatar rotemy avatar talkol avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.