@aurigami/sdk 0.6.6 → 0.6.7

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.6.6",
2
+ "version": "0.6.7",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "typescript": "^4.5.4"
58
58
  },
59
59
  "dependencies": {
60
- "@aurigami/contracts": "2.3.0-beta",
60
+ "@aurigami/contracts": "2.3.0",
61
61
  "axios": "^0.24.0",
62
62
  "bignumber.js": "^9.0.2",
63
63
  "dotenv": "^16.0.0",
@@ -5,7 +5,8 @@ import AuErc20ABI from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuEr
5
5
  import AuETHABI from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
6
6
  import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
7
7
  import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
8
- import { AuErc20, AuETH, AuriLens, Comptroller } from "@aurigami/contracts/typechain";
8
+ import EthRepayHelperABI from "@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json"
9
+ import { AuErc20, AuETH, AuriLens, Comptroller, EthRepayHelper } from "@aurigami/contracts/typechain";
9
10
  import { TransactionResponse } from '@ethersproject/abstract-provider';
10
11
  import { networkAddresses, ETHAddress, ONE_YEAR, INF } from "./constants";
11
12
  import BigNumber from "bignumber.js";
@@ -138,7 +139,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
138
139
  await Promise.all(promises);
139
140
 
140
141
  var borrowPlyApy = calcLMRewardApr(
141
- await calcValuation(
142
+ calcValuation(
142
143
  new TokenAmount(
143
144
  PLYToken,
144
145
  rewardSpeeds!.plyRewardBorrowSpeed.toString()
@@ -149,7 +150,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
149
150
  ONE_YEAR
150
151
  );
151
152
  var depositPlyApy = calcLMRewardApr(
152
- await calcValuation(
153
+ calcValuation(
153
154
  new TokenAmount(
154
155
  PLYToken,
155
156
  rewardSpeeds!.plyRewardSupplySpeed.toString()
@@ -191,6 +192,13 @@ export class MoneyMarketRead extends BlockchainEntityRead {
191
192
  }
192
193
 
193
194
  export class MoneyMarketReadWrite extends MoneyMarketRead {
195
+
196
+ protected _EthRepayHelper: EthRepayHelper;
197
+ constructor(networkConnection: NetworkConnection, auToken: Address, underlyingAsset: Address) {
198
+ super(networkConnection, auToken, underlyingAsset);
199
+ this._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, EthRepayHelperABI.abi, networkConnection.provider) as EthRepayHelper;
200
+ }
201
+
194
202
  public async deposit(amount: TokenAmount): Promise<TransactionResponse> {
195
203
  if (isSameAddress(amount.token.address, ETHAddress)) {
196
204
  return (this.auToken as AuETH).connect(this._networkConnection.signer!).mint({value: amount.rawAmount()});
@@ -208,20 +216,14 @@ export class MoneyMarketReadWrite extends MoneyMarketRead {
208
216
  return this.auToken.connect(this._networkConnection.signer!).redeemUnderlying(amount.rawAmount());
209
217
  }
210
218
  public async repay(amount: TokenAmount): Promise<TransactionResponse> {
211
- var repayAmount: BN;
212
- if (new BigNumber(amount.rawAmount()).lt(0)) {
213
- if (isSameAddress(amount.token.address, ETHAddress)) {
214
- repayAmount = BN.from((await this.getUserBorrowBalance(await this._networkConnection.signer!.getAddress())).rawAmount());
215
- } else {
216
- repayAmount = INF;
217
- }
218
- } else {
219
- repayAmount = BN.from(amount.rawAmount());
220
- }
221
219
  if (isSameAddress(amount.token.address, ETHAddress)) {
222
- return (this.auToken as AuETH).connect(this._networkConnection.signer!).repayBorrow({value: repayAmount});
220
+ return this._EthRepayHelper.connect(this._networkConnection.signer!).repayBorrow({value: amount.rawAmount()});
223
221
  } else {
224
- return (this.auToken as AuErc20).connect(this._networkConnection.signer!).repayBorrow(repayAmount);
222
+ if (new BigNumber(amount.rawAmount()).lt(0)) {
223
+ return this.auToken.connect(this._networkConnection.signer!).repayBorrow(INF);
224
+ } else {
225
+ return this.auToken.connect(this._networkConnection.signer!).repayBorrow(amount.rawAmount());
226
+ }
225
227
  }
226
228
  }
227
229
  public async enableCollateral(): Promise<TransactionResponse> {
@@ -244,4 +246,8 @@ export class MoneyMarket extends BlockchainEntity {
244
246
  public read(networkConnection: NetworkConnection): MoneyMarketRead {
245
247
  return new MoneyMarketRead(networkConnection, this.address, this.underlying);
246
248
  }
249
+
250
+ public readWrite(networkConnection: NetworkConnection): MoneyMarketReadWrite {
251
+ return new MoneyMarketReadWrite(networkConnection, this.address, this.underlying);
252
+ }
247
253
  }
package/src/constants.ts CHANGED
@@ -60,7 +60,8 @@ export const networkAddresses: NetworkAddresses = {
60
60
  AURIFAIRLAUNCH: "0xD204fD43bFe4aAEB9aB993c116c1dECdDF1b9F1A".toLowerCase(),
61
61
  AURILENS: '0x0Aa7Ce0f5D6259412602A230C3Ed83eDc857bDa1'.toLowerCase(),
62
62
  TOKENLOCK: '0x1b5c4c6A77f784104662B293a0166B27aF71d2c0'.toLowerCase(),
63
- FAUCET: "0xe8b53eE0443620fB8DcEaEB6DE98ED117971c329".toLowerCase() // doesn't exist on mainnet
63
+ FAUCET: "0xe8b53eE0443620fB8DcEaEB6DE98ED117971c329".toLowerCase(), // doesn't exist on mainnet
64
+ ETHREPAYHELPER: "0x0b28E2F1767623f2D5Cd59165e79f83E3D63b71F".toLowerCase()
64
65
  },
65
66
  tokens: {
66
67
  AURORA: dummyAddress.toLowerCase(),