0.1.5 • Published 2 years ago

@amra-finance/ding-plugin-dcs v0.1.5

Weekly downloads
Last release
2 years ago


A Ding.js plugin for interacting with the ding credit system contracts.

Example usage

import DcsPlugin, { ETH, DING, WBNB } from '@amra-finance/ding-plugin-dcs';
import Amra from '@amra-finance/ding';
import { createCurrency } from '@amra-finance/currency';
import { tokenAddress, tokenAbi } from 'someOtherTokenData';

const TOK = createCurrency('TOK');

const amra = await Amra.create('http', {
  // ...other configuration...
  plugins: [
        // omit this option to get the default set:
        // ETH-A, WBNB-A
        cdpTypes: [
          { currency: ETH, ilk: 'ETH-A' },
          { currency: WBNB, ilk: 'WBNB-A', decimals: 8 },
          { currency: TOK, ilk: 'TOK-Z', address: tokenAddress, abi: tokenAbi },

await amra.service('proxy').ensureProxy();
const cdpManager = amra.service('dcs:cdpManager');
const cdp1 = await cdpManager.openLockAndDraw('WBNB-A', WBNB(50), DING(1000));
const cdp2 = await cdpManager.openLockAndDraw('ETH-A', ETH(50), DING(1000));
const cdp3 = await cdpManager.openLockAndDraw('TOK-Z', TOK(50), DING(1000));


  • Creating and manipulating CDPs (via the CDP Manager via a user's DSProxy)
  • Reading data about the DCS system.


The contracts store the stability fee per second in a variable called tax as a number in the form 1.X 10^27 (e.g. 1000000000472114805215157978), and the base rate in a variable called repo as a number in the form 0.X 10^27.

In this plugin, the getAnnualStabilityFee() and get getAnnualBaseRate functions convert those values to return a decimal representation of the yearly rates (e.g. 0.015 and 0.01).

Run the tests from the top-level ding.js directory.

Local Development

Due to the way that Babel7 handles transpilation it is not possible to use yarn link when locally developing this plugin, and importing it. We recommend using yalc instead. We've also found that a watcher tool called sane is helpful.

Steps to Run: 1. In this directory run sane "yalc publish && cd [INSERT THE DIRECTORY OF THE PROJECT THAT IS IMPORTING THIS PLUGIN] && yalc link @amra-finance/ding-plugin-dcs" src --wait=3


2 years ago


2 years ago


2 years ago


2 years ago


2 years ago