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
Typescript library for interacting with the UXD contracts on EVM.
- Build the package
npm run build
- Run the linter to properly format typescript files.
npm run format
npm i "[email protected]"
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";
The client must be initialized with following parameters:
- JSON RPC provider pointing to the kovan optimism RPC endpoint.
- UXD Controller contract address on kovan optimism.
- The address of the depository
- 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
});
You can then start calling functions on the controller
const controller = client.controller();
const totalSupply = await controller.getRedeemableMintCirculatingSupply();
console.log("totalsupply = ", totalSupply);
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);
await controller.mintWithEth(ethAmount, targetPrice, signer);
No prior approval is required to mint with native ETH.
await controller.redeem(wethAddress, uxdAmount, targetPrice, signer);
await controller.redeemEth(uxdAmount, targetPrice, signer);
Check here to see the list of public functions availale on the controller.
Version 1.0.0 has been unpublished. Current version are tagged as beta 0.0.1-beta.X
Details
- uxd-evm-client
- UXDProtocol
- almost 2 years ago
- MIT
- 17 dependencies
Assets
- uxd-evm-client-0.6.1-beta.tgz
Download activity
- Total downloads 0
- Last 30 days 0
- Last week 0
- Today 0