# definer-js

> SDK for DeFiner's protocol in Javascript

Latest version **0.2.0** (published 2020-12-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install definer-js
pnpm add definer-js
yarn add definer-js
bun add definer-js
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2020-12-15 |
| First published | 2020-12-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 433 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yichun Yan |
| Maintainers | yichunyan |
| Keywords | DeFiner, definer, definer protocol, DeFi, lending, defi, ethereum |

## Links

- npm: https://www.npmjs.com/package/definer-js
- Repository: https://github.com/JoeBlack220/definer-js
- Homepage: https://github.com/JoeBlack220/definer-js#readme
- Issues: https://github.com/JoeBlack220/definer-js/issues
- npm.io page: https://npm.io/package/definer-js

## Dependencies (11)

- [chai](https://npm.io/package/chai.md) ^4.2.0
- [web3](https://npm.io/package/web3.md) ^1.3.0
- [axios](https://npm.io/package/axios.md) ^0.21.0
- [@types/chai](https://npm.io/package/@types/chai.md) ^4.2.14
- [@types/web3](https://npm.io/package/@types/web3.md) ^1.2.2
- [@types/axios](https://npm.io/package/@types/axios.md) ^0.14.0
- [@types/mocha](https://npm.io/package/@types/mocha.md) ^8.2.0
- [truffle-hdwallet-provider](https://npm.io/package/truffle-hdwallet-provider.md) ^1.0.17
- [@openzeppelin/test-helpers](https://npm.io/package/@openzeppelin/test-helpers.md) ^0.5.9
- [truffle-privatekey-provider](https://npm.io/package/truffle-privatekey-provider.md) ^1.5.0
- [@types/truffle-privatekey-provider](https://npm.io/package/@types/truffle-privatekey-provider.md) ^1.1.0

## Recent versions

- 0.2.0 (latest) — 2020-12-15
- 0.0.11 — 2020-12-14
- 0.0.10 — 2020-12-14
- 0.0.9 — 2020-12-14
- 0.0.8 — 2020-12-14
- 0.0.7 — 2020-12-14
- 0.0.6 — 2020-12-14
- 0.0.5 — 2020-12-14
- 0.0.4 — 2020-12-14
- 0.0.3 — 2020-12-14
- 0.0.2 — 2020-12-14
- 0.0.1 — 2020-12-14

## README

# definer-js
Javascript SDK for definer protocols

## Overview
This is the SDK that can be used in javascript or typescript project. Developers can use it to as a wrapper to interact with DeFiner's protocl on the mainnet and also can be used to interact with the backend API to get the statistical data from DeFiner.

## Installation
Just use npm to install this DeFiner SDK:
```bash
npm i definer-js
```

## Usage
- First we need to import DeFiner class from the package: `import { DeFiner } from 'definer-js'`
- Create a new DeFiner class: `const definer = new DeFiner(web3);`
  - Here `web3` is created through Web3 library(https://web3js.readthedocs.io/en/v1.3.0/).
- Initialize the definer object, it will create all the contract instances for you: `await definer.initialize();`
- Interact with the contract: `await definer.getBorrowBalanceCurrent(Token.DAI, TheAccountYouWantToQuery);`
- Interact with the backend API: `await definer.API.statusAssests(TheAccountYouWantToQuery);`
- When interacting with the contract on mainnet, it uses the average gas price that get from:https://docs.ethgasstation.info/
- Currently, it only supports interacting with the contracts on mainnet, but in the future we will provide more options.


## APIs
- deposit(token: Token, amount: any): Deposit an amount of token to DeFiner.
- borrow(token: Token, amount: any): Borrow an amount of token from DeFiner.
- repay(token: Token, amount: any): Repay an amount of token to DeFiner.
- withdraw(token: Token, amount: any): Withdraw an amount of token from DeFiner.
- withdrawAll(token: Token): Withdraw all tokens from DeFiner.
- userHasAnyDeposit(target: string): Check whether the target user has deposits in DeFiner or not.
- getDepositPrincipal(token: Token, target: string): Get the deposit principal of a specific token of the target user since last deposit.
- getBorrowPrincipal(token: Token, target: string): Get the borrow principal of a specific token of the target user since last borrow.
- getLastDepositBlock(token: Token, target: string): Get the last deposit block of the target user.
- getLastBorrowBlock(token: Token, target: string): Get the last borrow block of the target user.
- getDepositInterest(token: Token, target: string): Get the deposit interest since last deposit block to now.
- getBorrowInterest(token: Token, target: string): Get the borrow interest since last deposit block to now.
- getDepositBalanceCurrent(token: Token, target: string): Get the total deposit balance(interests + principal) of a target user.
- getBorrowBalanceCurrent(token: Token, target: string): Get the total borrow balance(interests + principal) of a target user.
- getBorrowPower(target: string): Get the borrow power of a target user. This means how much value of asset that one account can borrow given its deposits value. The returned value's unit is ETH wei.
- getBorrowETH(target: string): Get the total borrowed asset value of the target account in ETH wei.
- getDepositETH(target: string): Get the total deposited asset value of the target account in ETH wei.
- isAccountLiquidatable(target: string): Check the liquidatable status of an account.
- getTotalDepositStore(token: Token): Get the total deposit amount of a specific token in DeFiner.
- getBorrowRatePerBlock(token: Token): Get the current borrow rate per block.
- getDepositRatePerBlock(token: Token): Get the current deposit rate per block.
- getCapitalUtilizationRatio(token: Token): Get the current utilization ratio of DeFiner.
- getCapitalCompoundRatio(token: Token): Get the current Compound ratio of DeFiner.
- getPoolAmount(token: Token): Get the total amount of a specific token that is still in DeFiner.

---
_Source: https://npm.io/package/definer-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
