Skip to content

OriginProtocol/origin-app-plugin

 
 

Repository files navigation

Ensure compliance with Ledger guidelines Compilation & tests

Origin DeFi Ledger Plugin

This is a plugin for the Ethereum application which helps parsing and displaying relevant information when signing an OUSD or OETH transaction on their respective dapps.

Plugins are lightweight applications that go hand-in-hand with the Ethereum Application on a Nano (S, S plus, X) and Stax devices.

They allow users to safely interact with smart contracts by parsing the transaction data and displaying its content in a human-readable way. This is done on a "per contract" basis, meaning a plugin is required for every DApp.

The code has been commented, and special "EDIT THIS" comments indicate where developers are expected to adapt the code to their own needs.

It is STRONGLY recommended to follow the plugin guide in order to better understand the flow and the context for plugins.

Prerequisite

Clone the plugin to a new folder.

git clone https://github.com/OriginProtocol/origin-app-plugin.git

Then in the same folder clone two more repositories, which is the plugin-tools and app-ethereum.

git clone --recurse-submodules https://github.com/LedgerHQ/app-ethereum
docker run --rm -ti -v "$(realpath .):/app" --user $(id -u $USER):$(id -g $USER) ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

Build

The script will build a docker image and attach a console. When the docker image is running go to the "origin-app-plugin" folder and build the ".elf" files.

cd origin-app-plugin/tests       # go to the tests folder in origin-app-plugin
./build_local_test_elfs.sh      # run the script build_local_test_elfs.sh

Tests

To test the plugin go to the tests folder in a new console window from the "origin-app-plugin" and run the script "test"

cd origin-app-plugin/tests       # go to the tests folder in origin-app-plugin
yarn install
yarn test                       # run the script test

Documentation

Need more information about the interface, the architecture, or general stuff about ethereum plugins? You can find more about them in the ethereum-app documentation.

Smart Contracts

Smart contracts covered by this plugin are:

Contract Address
OETH Zapper 0x9858e47bcbbe6fbac040519b02d7cd4b2c470c66
OETH Vault 0x39254033945aa2e4809cc2977e7087bee48bd7ab
ETH/OETH Curve Pool 0x94b17476a93b3262d87b9a326965d1e91f9c13e7
Curve Router 0x99a58482bd75cbab83b27ec03ca68ff489b5788f
OUSD Vault 0xe75d77b1865ae93c7eaa3040b038d7aa7bc02f70
OUSD Flipper 0xcecad69d7d4ed6d52efcfa028af8732f27e08f70
UniswapV3 Router 0xe592427a0aece92de3edee1f18e0157c05861564
OUSD/3CRV Curve Pool 0x87650d7bbfc3a9f10587d7778206671719d9910d
ETH/OETH Curve Pool 0x94b17476a93b3262d87b9a326965d1e91f9c13e7
Curve Router 0x99a58482bd75cbab83b27ec03ca68ff489b5788f
OUSD Vault 0xe75d77b1865ae93c7eaa3040b038d7aa7bc02f70
OUSD Flipper 0xcecad69d7d4ed6d52efcfa028af8732f27e08f70
WOETH 0xdcee70654261af21c44c093c300ed3bb97b78192
WOUSD 0xd2af830e8cbdfed6cc11bab697bb25496ed6fa62

Functions implemented:

Function Selector Displayed Parameters
deposit 0xd0e30db0
depositSFRXETH 0xd443e97d
uint256 amount
uint256 minOETH
mint 0x156e29f6
address _asset
,uint256 _amount
uint256 _minimumOusdAmount
redeem 0x7cbc2373
uint256 _amount
uint256 _minimumUnitAmount
exchange 0x3df02124
int128 i
int128 j
uint256 _dx
uint256 _min_dy
exchange_underlying 0xa6417ed6
int128 i
int128 j
uint256 _dx
uint256 _min_dy
exchange_multiple 0x353ca424
address[9] _route
uint256 _amount
uint256 _expected
exactInput 0xc04b8d59
bytes path
address recipient
uint256 amountIn
uint256 amountOutMinimum
exactInputSingle 0x414bf389
address tokenIn
address tokenOut
address recipient
uint256 amountIn
uint256 amountOutMinimum
buyOusdWithUsdt 0x35aa0b96
uint256 amount
sellOusdForUsdt 0xcb939053
uint256 amount
buyOusdWithDai 0x5981c746
uint256 amount
sellOusdForDai 0x8a095a0f
uint256 amount
buyOusdWithUsdc 0xbfc11ffd
uint256 amount
sellOusdForUsdc 0xc6b68169
uint256 amount
redeem 0xba087652
uint256 assets
address receiver
redeem 0xba087652
uint256 shares
address receiver

Ethereum SDK

Ethereum plugins need the Ethereum SDK. You can use the ETHEREUM_PLUGIN_SDK variable to point to the directory where you cloned this repository. By default, the Makefile expects it to be at the root directory of this plugin repository by the ethereum-plugin-sdk name.

You can see that this CI workflow verifies that the SDK used is either on the latest master or develop references. This ensures the code is compiled and tested on the latest version of the SDK.

Documentation

The documentation about the plugin shall be added in PLUGIN_SPECIFICATON.md. It shall includes at least the smart contracts and functions supported by the plugin.

Formatting

The C source code is expected to be formatted with clang-format 11.0.0 or higher.

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 47.7%
  • C 42.3%
  • Python 3.5%
  • Makefile 2.9%
  • CMake 2.0%
  • Shell 1.3%
  • Dockerfile 0.3%