lendroid-js
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

lendroid-js

A library to wrapper the lendroid Server and Lendroid Contract API's

Pre-reqs:

npm install

npm install -g tslint

To serve app on localhost:8080:

Create an index.ts under src. This will be executed on Webpack server initialization

npm start (serves files via Webpack, compiles on file changes)

To watch and compile TypeScript to Javascript:

npm run watch

To build:

npm run build

To test:

npm run test

On the Lendroid UI

  1. On Lendroid UI, Lender deposits 1000 OMG.
    • Contract Code Wallet.deposit
    • lendroidJS.Wallet.deposit(‘OMG’, 1000).sender(lender)
  2. On Lendroid UI, Lender commits 1000 OMG:
    • Contract Code Wallet.commit
    • lendroidJS.Wallet.commit(‘OMG’, 1000).sender(lender)
  3. On Lendroid UI, Lender creates a loan offer for the loan terms
       {  
          "lenderAddress": "0x012345",
          "market": "OMG/ETH",
          "loanQuantity": 100,
          "loanToken": "OMG",
          "costAmount": 100,
          "costToken": "ETH",
          "wrangler": "0xWrangler",
          "ecSignature": {
            "v": 27,
            "r": "0x61a3ed31",
            "s": "0x40349190"
          }
        }
  4. Sends a HTTP POST request with a Loan Offer object to /offers endpoint of Lendroid API server API service whenever Lender creates the loan offer.
    • Server code: POST /offers
    • On the API server, this Loan Offer object is saved.
    • Method Signature: lendroidJS.createOffer(loanTerms)
    • HTTP Signature:
      curl -v -XPOST  http://localhost:8080/offers \
      -H 'application/json' \
      -d @- << EOF
       {  
          "lenderAddress": "0x012345",
          "market": "OMG/ETH",
          "loanQuantity": 100,
          "loanToken": "OMG",
          "costAmount": 100,
          "costToken": "ETH",
          "wrangler": "0xWrangler",
          "ecSignature": {
            "v": 27,
            "r": "0x61a3ed31",
            "s": "0x40349190"
          }
        }
       EOF
      

On the Relayer UI

  1. Retrieves loan offers via HTTP GET from the API service
    • Server code: GET /offers
    • Method Signature: lendroidJS.getOffers()
    • HTTP Signature:
      curl -v -XGET  http://localhost:8080/offers
      
  2. Sends the picked pair of (0x order, loan offer) to Lendroid’s Smart Contracts via Web3.js to open a position.
    • Contract Code: PositionManager.openPosition)
    •  lendroidJS.PositionManager
                 .openPosition(orderValues[],
                               orderAddresses[],
                               orderV,
                               orderRS[],
                               offerValues[],     
                               offerAddresses[])
                 .sender(marginTrader)
      

Readme

Keywords

none

Package Sidebar

Install

npm i lendroid-js

Weekly Downloads

0

Version

0.1.3

License

ISC

Unpacked Size

378 kB

Total Files

73

Last publish

Collaborators

  • oleg-baturov