Skip to content

Commit

Permalink
feat: initial Liquity SDK release
Browse files Browse the repository at this point in the history
  • Loading branch information
danielattilasimon committed Feb 12, 2021
1 parent ce1e788 commit 92e6ce5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/examples/src/liqbot.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const { red, blue, green, yellow, dim, bold } = require("chalk");

const { JsonRpcProvider } = require("@ethersproject/providers");
const { Wallet } = require("@ethersproject/wallet");

const { Wallet, providers } = require("ethers");
const { Decimal, Trove, LUSD_LIQUIDATION_RESERVE } = require("@liquity/lib-base");
const { EthersLiquity, EthersLiquityWithStore } = require("@liquity/lib-ethers");

Expand All @@ -17,7 +14,7 @@ const success = message => log(`${green("✔")} ${message}`);

async function main() {
// Replace URL if not using a local node
const provider = new JsonRpcProvider("http://localhost:8545");
const provider = new providers.JsonRpcProvider("http://localhost:8545");
const wallet = new Wallet(process.env.PRIVATE_KEY).connect(provider);
const liquity = await EthersLiquity.connect(wallet, { useStore: "blockPolled" });

Expand Down
9 changes: 9 additions & 0 deletions packages/lib-base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @liquity/lib-base

Shared interfaces and classes of the Liquity SDK.

Needs to be installed in order to use other Liquity SDK packages, for example [@liquity/lib-ethers](https://www.npmjs.com/package/@liquity/lib-ethers).

## API Reference

For now, it can be found in the public Liquity [repo](https://github.com/liquity/liquity/blob/master/docs/sdk/lib-base.md).
41 changes: 41 additions & 0 deletions packages/lib-ethers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# @liquity/lib-ethers

[Ethers](https://www.npmjs.com/package/ethers)-based library for reading Liquity protocol state and sending transactions.

## Quickstart

Install in your project:

```
npm install --save @liquity/lib-base @liquity/lib-ethers ethers@^5.0.0
```

Connecting to an Ethereum node and sending a transaction:

```javascript
const { Wallet, providers } = require("ethers");
const { EthersLiquity } = require("@liquity/lib-ethers");

async function example() {
const provider = new providers.JsonRpcProvider("http://localhost:8545");
const wallet = new Wallet(process.env.PRIVATE_KEY).connect(provider);
const liquity = await EthersLiquity.connect(wallet);

const { newTrove } = await liquity.openTrove({
depositCollateral: 1, // ETH
borrowLUSD: 200
});

console.log(`Successfully opened a Liquity Trove (${newTrove})!`);
}
```

## More examples

See [packages/examples](https://github.com/liquity/liquity/tree/master/packages/examples) in the repo.

Liquity's [Dev UI](https://github.com/liquity/liquity/tree/master/packages/dev-frontend) itself contains many examples of `@liquity/lib-ethers` use.

## API Reference

For now, it can be found in the public Liquity [repo](https://github.com/liquity/liquity/blob/master/docs/sdk/lib-ethers.md).

0 comments on commit 92e6ce5

Please sign in to comment.