Skip to content
uxd-evm-client / 0.6.1-beta

uxd-evm-client 0.6.1-beta

Install from the command line:
Learn more about npm packages
$ npm install @uxdprotocol/uxd-evm-client@0.6.1-beta
Install via package.json:
"@uxdprotocol/uxd-evm-client": "0.6.1-beta"

About this version

UXD EVM client (v1)

Typescript library for interacting with the UXD contracts on EVM.

To Build

  1. Build the package
npm run build
  1. Run the linter to properly format typescript files.
npm run format

To use

Install the library

Import library code

You need to import the UXDController from the library as well as the ethers library

import { ethers } from "ethers";
import { UXDClient } from "uxd-evm-client";

Initialize the client

The client must be initialized with following parameters:

  1. JSON RPC provider pointing to the kovan optimism RPC endpoint.
  2. UXD Controller contract address on kovan optimism.
  3. The address of the depository
  4. UXD token on kovan optimism.

The provider can be injected when using Metamask or other browser wallet

const controller = "..."; // controller address
const depository = "..."; // depository address
const redeemable = "..."; // redeemable address

const provider = new ethers.providers.JsonRpcProvider("https://goerli.optimism.io");
const client = new UXDClient({
  provider,
  controller,
  depository
  redeemable
});

Interact with controller contract

You can then start calling functions on the controller

Get UXD total supply

const controller = client.controller();
const totalSupply = await controller.getRedeemableMintCirculatingSupply();
console.log("totalsupply = ", totalSupply);

Mint UXD with WETH

To mint with WETH can call the mint() function:

await controller.mint(ethAmount, targetePrice, signer, collateralAddress);

Note: The controller must be approved to access the users WETH otherwise the call with revert with an error.

To approve the controller to spend WETH:

await controller.approveToken(contractAddress, spender, amount, signer);

Mint UXD with ETH

await controller.mintWithEth(ethAmount, targetPrice, signer);

No prior approval is required to mint with native ETH.

Redeem UXD for ETH

await controller.redeem(wethAddress, uxdAmount, targetPrice, signer);

Redeem UXD for ETH

await controller.redeemEth(uxdAmount, targetPrice, signer);

Check here to see the list of public functions availale on the controller.

Version

Version 1.0.0 has been unpublished. Current version are tagged as beta 0.0.1-beta.X

Details


Assets

  • uxd-evm-client-0.6.1-beta.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0