{"size": 529, "ext": "js", "max_stars_repo_path": "packages/dai-plugin-migrations/src/migrations/RedeemSai.js", "max_stars_repo_name": "lzxm160/dai.js", "max_stars_repo_stars_event_min_datetime": "2018-08-10T18:28:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-09T19:49:53.000Z", "max_issues_repo_path": "packages/dai-plugin-migrations/src/migrations/RedeemSai.js", "max_issues_repo_name": "strykerin/dai.js", "max_issues_repo_issues_event_min_datetime": "2018-08-10T17:57:18.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-24T10:33:08.000Z", "max_forks_repo_path": "packages/dai-plugin-migrations/src/migrations/RedeemSai.js", "max_forks_repo_name": "strykerin/dai.js", "max_forks_repo_forks_event_min_datetime": "2018-09-07T07:42:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T10:14:45.000Z"}
{"max_stars_count": 226, "max_issues_count": 241, "max_forks_count": 115, "avg_line_length": 20.3461538462, "max_line_length": 74, "alphanum_fraction": 0.6238185255}
import { DAI } from '..';

export default class RedeemSai {
  constructor(manager) {
    this._manager = manager;
    this._tap = this._manager.get('smartContract').getContract('SAI_TAP');
    return this;
  }

  off() {
    return this._tap.off();
  }

  async getRate() {
    const fix = await this._tap.fix();
    return fix / Math.pow(10, 27);
  }

  redeemSai(wad) {
    const cageFree = this._manager
      .get('smartContract')
      .getContract('SAI_CAGEFREE');
    return cageFree.freeCash(DAI(wad).toFixed(18));
  }
}
