mylenproj
v0.1.4
Published
Web3.js wrapper that interacts with Lendroid Smart Contracts
Downloads
6
Readme
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:
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
- On Lendroid UI, Lender deposits 1000 OMG.
- Contract Code Wallet.deposit
lendroidJS.Wallet.deposit(‘OMG’, 1000).sender(lender)
- On Lendroid UI, Lender commits 1000 OMG:
- Contract Code Wallet.commit
lendroidJS.Wallet.commit(‘OMG’, 1000).sender(lender)
- 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" } }
- 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
- 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
- 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)