项目作者: gyrostable

项目描述 :
TypeScript/JavaScript to interact with the Gyroscope protocol
高级语言: TypeScript
项目地址: git://github.com/gyrostable/sdk.git
创建时间: 2021-01-17T21:22:36Z
项目社区:https://github.com/gyrostable/sdk

开源协议:

下载


Gyro SDK

TypeScript/JavaScript SDK to interact with Gyro.

Development

Follow the installation instructions of https://github.com/stablecoin-labs/core
including starting the node and linking the package.
Then run the following

  1. yarn install
  2. yarn link @gyrostable/core
  3. yarn link
  4. yarn build

To make sure everything is working, try running the tests using yarn test.

To compile automatically when changing something, run yarn build --watch instead of yarn build.

Usage

The SDK is based around the Gyro class, which can be instantiated as follows:

  1. import { Gyro } from "@gyrostable/sdk";
  2. import { ethers } from "ethers";
  3. const provider = new ethers.providers.Web3Provider(window.ethereum);
  4. const gyro = await Gyro.create(provider);
  5. const tokens = await gyro.getSupportedTokens();
  6. const usdt = tokens.find((t) => t.symbol === "USDT");
  7. const weth = tokens.find((t) => t.symbol === "WETH");
  8. const inputs = [
  9. { token: usdt.address, amount: MonetaryAmount.fromNormalized(2500, usdc.decimals) }
  10. { token: weth.address, amount: MonetaryAmount.fromNormalized(2, weth.decimals) }
  11. ];
  12. const mintResult = await gyro.mint(inputs);
  13. console.log(`Minted ${mintResult} tokens`);
  14. const currentBalance = await gyro.balance();
  15. console.log(`Gyro balance: ${currentBalance.toNormalizedString()}`);