Coder Social home page Coder Social logo

niklr / defi-adapter-kit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opty-fi/defi-adapters

0.0 1.0 0.0 2.44 MB

Starter kit for defi adapter development compatible with Opty-Fi's earn-protocol

Home Page: https://docs.opty.fi

License: GNU Affero General Public License v3.0

JavaScript 0.75% Shell 0.57% Solidity 66.54% TypeScript 32.15%

defi-adapter-kit's Introduction

Header

DeFi Adapters

Collection of defi adapters compatible with opty.fi's yield protocol - earn-protocol

Prerequisites

And passion for financial freedom...

Getting started

Development Setup

  • Create a .env file and set a BIP-39 compatible mnemonic as an environment variable. Follow the example in .env.example. If you don't already have a mnemonic, use this website to generate one.
  • You are only required to get the archive node URL of the network which is being used for developing/testing of defi Adapters.

Proceed with installing dependencies:

yarn install

What is a DeFiAdapter

  • DeFi adapter is a vital building block for executing opty.fi's network of strategies.
  • Specifications for DeFi adapter help perform :
    • transactions like deposit, withdraw, staking, un-staking, adding liquidity, claim reward and harvesting of the reward.
    • read calls for liquidity pool token contract address, liquidity pool token balance, staked token balance, balance in underlying token of both staked and non-staked liquidity pool token, unclaimed reward tokens and reward token contract address
  • A DeFi Adapter smart contract requires implementation of following interfaces :

Pro Tip : Inherit IAdapterFull interface from IAdapterFull.sol to Adapter Contract if the protocol you choose required implementation of all the above interfaces.

Implementing IAdapter interface

Unit Tests

  • Write unit tests for all the functions across all the pool contracts gathered in Step 1.
  • You might want to use a test utility contract like TestDeFiAdapter for creating a sandbox environment to execute the transaction based on function signature and target address returned from getCodes()-style functions from DeFiAdapter.
  • All other functions can be directly tested from the DeFiAdapter contract.
  • The unit test for HarvestFinanceAdapter.sol can be found in HarvestFinanceAdapter.ts

Useful commands

Usage Command
Compile the smart contracts with Hardhat $ yarn compile
Compile the smart contracts and generate TypeChain artifacts $ yarn typechain
Lint the Solidity Code $ yarn lint:sol
Lint the TypeScript Code $ yarn lint:ts
Run the Mocha tests $ yarn test:{network}:fork
Generate the code coverage report $ yarn coverage:{network}
Delete the smart contract artifacts, the coverage reports and the Hardhat cache $ yarn clean

Syntax Highlighting

If you use VSCode, you can enjoy syntax highlighting for your Solidity code via the vscode-solidity extension. The recommended approach to set the compiler version is to add the following fields to your VSCode user settings:

{
  "solidity.compileUsingRemoteVersion": "v0.6.12+commit.27d51765",
  "solidity.defaultCompiler": "remote"
}

Where of course v0.6.12+commit.27d51765 can be replaced with any other version.

References

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.