@aurigami/sdk 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.4",
2
+ "version": "0.4.5",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -7,7 +7,7 @@ import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.
7
7
  import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
8
8
  import { AuErc20, AuETH, AuriLens, Comptroller } from "@aurigami/contracts/typechain";
9
9
  import { TransactionResponse } from '@ethersproject/abstract-provider';
10
- import { networkAddresses, ETHAddress, ONE_YEAR } from "./constants";
10
+ import { networkAddresses, ETHAddress, ONE_YEAR, INF } from "./constants";
11
11
  import BigNumber from "bignumber.js";
12
12
  import { decimalFactor, isSameAddress, calcLMRewardApr } from './helpers';
13
13
  import { Token, PLYToken } from './token';
@@ -203,6 +203,9 @@ export class MoneyMarketReadWrite extends MoneyMarketRead {
203
203
  return this.auToken.connect(this._networkConnection.signer!).borrow(amount.rawAmount());
204
204
  }
205
205
  public async withdraw(amount: TokenAmount): Promise<TransactionResponse> {
206
+ if (new BigNumber(amount.rawAmount()).lt(0)) {
207
+ return this.auToken.connect(this._networkConnection.signer!).redeemUnderlying(INF);
208
+ }
206
209
  return this.auToken.connect(this._networkConnection.signer!).redeemUnderlying(amount.rawAmount());
207
210
  }
208
211
  public async repay(amount: TokenAmount): Promise<TransactionResponse> {
package/src/constants.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { ethers, Signer} from 'ethers';
2
+ import { ethers, Signer, BigNumber as BN} from 'ethers';
3
3
  export const dummyAddress: string = "0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE";
4
4
  export const ETHAddress: string = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
5
5
 
@@ -73,4 +73,6 @@ export const ONE_DAY = 86400;
73
73
  export const ONE_YEAR = ONE_DAY * 365;
74
74
 
75
75
  export const AurPlyPid = 0;
76
+ export const INF = BN.from(2).pow(256).sub(1)
77
+
76
78