0.1.2 • Published 6 years ago

oleg-baturov v0.1.2

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

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)