Coder Social home page Coder Social logo

poa010101 / structured-products Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ribbon-finance/ribbon-v1

0.0 0.0 0.0 1.87 MB

Crypto structured products on Ethereum

Home Page: https://ribbon.finance

License: MIT License

Solidity 39.30% JavaScript 57.57% TypeScript 3.12% Shell 0.01%

structured-products's Introduction

Ribbon Finance

Ribbon Finance is a new protocol that helps users access crypto structured products for DeFi. It combine options, futures, and fixed income to improve a portfolio's risk-return profile. Please review our documentation for details about the structured products.

Getting Started

We use Hardhat for compiling and testing, and currently use Truffle for running migrations & deployments. We are planning to move to doing deployments using Hardhat scripts in the future.

  1. Install Node 12.3.0 with nvm
nvm install 12.3.0

nvm use 12.3.0
  1. Install all the NodeJS dependencies with yarn.
yarn install
  1. You can start compiling the Solidity code with Hardhat.
npx hardhat compile
  1. You will need access to an archive node to run tests, since the tests use forked mainnet state. Create a .env file with a TEST_URI. Ask @kenchangh for access to archive node.
TEST_URI=<add node url here>
  1. Run the unit tests with the command:
npx hardhat test

To run the unit tests for a specific unit test, you can run the tests directly with mocha

npx mocha --timeout 20000 --exit test/adapters/HegicAdapter.js -g 'purchase'

Deployments

Ribbon uses truffle for migrations and deployments.

  1. First, run the truffle migrations.
# This runs all the migration scripts from the beginning.
npx truffle migrate --network kovan

# To run individual migration files, do:
npx truffle migrate --network kovan -f 1 --to 3

This will update the constants/deployments.json file for the kovan network. If this is an upgrade, commit it into Git. This helps other scripts that rely on it to use the latest version of the contracts.

  1. To programmatically verify the deployed contracts, run the command:
yarn verify

The command automates the contract verification process on Etherscan.

Running scripts

Scripts are written in Typescript. To run them, we use the ts-node installed:

yarn run ts-node ./scripts/encodeSwapData.ts

Linting & Formatting

We use a combination of Prettier, ESLint and Solhint for linting and formatting.

# Formatting solidity files
yarn lint:sol:prettier

# Linting solidity
yarn lint:sol:fix

# Formatting test files
yarn lint:test:prettier

# Linting test files
yarn lint:test:fix

Security tooling

We are using Slither to detect common vulnerabilities and exploits. To get started, compile and merge the contract files.

npx truffle compile
yarn merge-contracts

The merged contract files are in the build/merged/ directory.

Because it's a pain to fix the merge results, we have already pre-merged the major contracts. Run slither on individual contract files:

slither merged-contracts/RibbonCoveredCall.sol
slither merged-contracts/RibbonFactory.sol
slither merged-contracts/GammaAdapter.sol
slither merged-contracts/ProtocolAdapter.sol

Test coverage

We use solidity-coverage for testing contract coverage. Run:

yarn coverage

And then you can browse the coverage/index.html.

structured-products's People

Contributors

chudnov avatar cjinghong avatar jgcogsystematictrading avatar jmonteer avatar kenchangh 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.