@aurigami/sdk 1.0.2 → 1.0.3-fix

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": "1.0.2",
2
+ "version": "1.0.3-fix",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
package/src/SDK.ts CHANGED
@@ -1,30 +1,25 @@
1
+ import AuriFairLaunchABI from "@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json";
2
+ import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
3
+ import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
4
+ import FaucetABI from "@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json";
5
+ import TokenLockABI from "@aurigami/contracts/artifacts/contracts/TokenLock.sol/TokenLock.json";
6
+ import { AuriFairLaunch, AuriLens, Comptroller, TokenLock } from '@aurigami/contracts/typechain';
7
+ import { TransactionResponse } from '@ethersproject/abstract-provider';
8
+ import BigNumber from 'bignumber.js';
9
+ import { BigNumber as BN, Contract } from 'ethers';
1
10
  import { BlockchainEntity, BlockchainEntityRead } from './BlockchainEntity';
11
+ import { AurPlyPid, BORROW_LIMIT_BUFFER, DECIMAL_PRECISION, networkAddresses, ONE_DAY, REWARDCLAIMSTART } from './constants';
12
+ import { calcLMRewardApr, decimalFactor, getCurrentTimestamp, isSameAddress } from './helpers';
13
+ import { MoneyMarketRead } from './MoneyMarket';
14
+ import { calcValuation, fetchPrice, fetchValuation } from './priceFetcher';
15
+ import { AURPLYToken, PLYToken, Token } from './token';
16
+ import { TokenAmount } from './tokenAmount';
2
17
  import {
3
- LockingDetails,
4
- PlyAuroraPoolDetails,
5
- NetworkConnection,
6
- UserDetails,
7
- UserMarketDetails,
8
18
  Address,
9
19
  CurrencyAmount,
10
- HypotheticalStats,
11
- MarketAction
20
+ HypotheticalStats, LockingDetails, MarketAction, NetworkConnection, PlyAuroraPoolDetails, UserDetails,
21
+ UserMarketDetails
12
22
  } from './types';
13
- import { networkAddresses, BORROW_LIMIT_BUFFER, DECIMAL_PRECISION, REWARDCLAIMSTART, ONE_DAY, AurPlyPid } from './constants';
14
- import { TransactionResponse } from '@ethersproject/abstract-provider';
15
- import { Contract, BigNumber as BN, ethers, providers } from 'ethers';
16
- import { isSameAddress, decimalFactor, getCurrentTimestamp, calcLMRewardApr } from './helpers';
17
- import { MoneyMarketRead } from './MoneyMarket';
18
- import { fetchValuation, fetchPrice, calcValuation } from './priceFetcher';
19
- import { AuriFairLaunch, Comptroller, TokenLock, AuriLens } from '@aurigami/contracts/typechain';
20
- import { TokenAmount } from './tokenAmount';
21
- import { AURPLYToken, PLYToken, Token } from './token';
22
- import BigNumber from 'bignumber.js';
23
- import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
24
- import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
25
- import TokenLockABI from "@aurigami/contracts/artifacts/contracts/TokenLock.sol/TokenLock.json";
26
- import AuriFairLaunchABI from "@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json";
27
- import FaucetABI from "@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json";
28
23
 
29
24
  export class SdkRead extends BlockchainEntityRead {
30
25
 
@@ -97,18 +92,9 @@ export class SdkRead extends BlockchainEntityRead {
97
92
  return p;
98
93
  }, new BigNumber(0))
99
94
 
100
- promises = new Array(3);
101
- var accountLiquidity: [BN, BN], rewardBalancesMetadata, lockedAmount: BN;
102
- promises[0] = this._comptroller.getAccountLiquidity(userAddress);
103
- promises[1] = this._auriLens.callStatic.claimAndGetRewardBalancesMetadata(this._comptroller.address, this._auriFairLaunch.address, [AurPlyPid], {from: userAddress}).catch((err: any) => {
104
- return {
105
- plyAccrued: BN.from(0)
106
- }
107
- });
108
- promises[2] = this._tokenLock.lockedAmounts(userAddress);
109
- var values = await Promise.all(promises);
95
+ var accountLiquidity: [BN, BN];
110
96
 
111
- accountLiquidity = values[0]; rewardBalancesMetadata = values[1]; lockedAmount = values[2];
97
+ accountLiquidity = await this._comptroller.getAccountLiquidity(userAddress);
112
98
  var borrowedvaluation: BigNumber = totalBorrowLimit.minus(new BigNumber(accountLiquidity[0].toString()).div(decimalFactor(18)));
113
99
 
114
100
  if (borrowedvaluation.lt("0.00001")) { // Igore dust, dust could be the result of network delay causing collateral valuation calc to be different on vs off chain
@@ -143,13 +129,13 @@ export class SdkRead extends BlockchainEntityRead {
143
129
  }
144
130
 
145
131
  return {
146
- markets: userMarketDetails,
132
+ markets: [],
147
133
  borrowLimit: {
148
134
  currency: "USD",
149
135
  amount: bufferedBorrowLimit.toFixed(DECIMAL_PRECISION)
150
136
  },
151
- accruedPly: new TokenAmount(PLYToken, rewardBalancesMetadata.plyAccrued.toString()),
152
- lockedPly: new TokenAmount(PLYToken, lockedAmount.toString()),
137
+ accruedPly: new TokenAmount(PLYToken, "0"),
138
+ lockedPly: new TokenAmount(PLYToken, "0"),
153
139
  borrowableAmount: {
154
140
  currency: "USD",
155
141
  amount: borrowableAmount.toFixed(DECIMAL_PRECISION)