@aurigami/sdk 1.6.9 → 1.6.11
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/dist/SDK.d.ts +2 -2
- package/dist/contracts/misc.d.ts +2 -2
- package/dist/sdk.cjs.development.js +20 -17
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +20 -17
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +7 -2
- package/package.json +1 -1
- package/src/SDK.ts +3 -3
- package/src/contracts/misc.ts +11 -8
- package/src/types/index.ts +8 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
import type { providers, Signer } from 'ethers';
|
|
2
3
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
3
4
|
export declare enum ComptrollerRewardType {
|
|
@@ -93,6 +94,10 @@ export declare type HypotheticalStats = {
|
|
|
93
94
|
};
|
|
94
95
|
export declare type AccountAuTokenInfo = {
|
|
95
96
|
token: string;
|
|
96
|
-
deposit:
|
|
97
|
-
borrow:
|
|
97
|
+
deposit: BigNumber;
|
|
98
|
+
borrow: BigNumber;
|
|
99
|
+
};
|
|
100
|
+
export declare type AccountAuTokensInfo = {
|
|
101
|
+
address: string;
|
|
102
|
+
tokens: AccountAuTokenInfo[];
|
|
98
103
|
};
|
package/package.json
CHANGED
package/src/SDK.ts
CHANGED
|
@@ -80,14 +80,14 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
80
80
|
return this._misc.getPlyCirculatingSupply();
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
public async
|
|
84
|
-
return this._misc.
|
|
83
|
+
public async getUtilisation(userAddr: types.Address): Promise<BigNumber> {
|
|
84
|
+
return this._misc.getUtilisation(userAddr);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
public async sneakAccounts(
|
|
88
88
|
accounts: string[],
|
|
89
89
|
tokenAddresses: string[]
|
|
90
|
-
): Promise<types.
|
|
90
|
+
): Promise<types.AccountAuTokensInfo[]> {
|
|
91
91
|
return this._misc.sneakAccounts(accounts, tokenAddresses);
|
|
92
92
|
}
|
|
93
93
|
}
|
package/src/contracts/misc.ts
CHANGED
|
@@ -283,7 +283,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
283
283
|
return new TokenAmount(PLYToken, circulatingSupply.toString());
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
public async
|
|
286
|
+
public async getUtilisation(userAddr: types.Address): Promise<BigNumber> {
|
|
287
287
|
let accountDetail = await this.env.auriInternalLens.getAccountLiquidity(userAddr);
|
|
288
288
|
let sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
|
|
289
289
|
let sumCol = new BigNumber(accountDetail.sumCollateral.toString());
|
|
@@ -293,9 +293,9 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
293
293
|
public async sneakAccounts(
|
|
294
294
|
accounts: string[],
|
|
295
295
|
tokenAddresses: string[]
|
|
296
|
-
): Promise<types.
|
|
296
|
+
): Promise<types.AccountAuTokensInfo[]> {
|
|
297
297
|
const _1E18 = BN.from(10).pow(18);
|
|
298
|
-
const
|
|
298
|
+
const dust = new BigNumber(0.1);
|
|
299
299
|
const oracle = this.env.getContract<PriceOracle>(
|
|
300
300
|
consts.networkAddresses.misc.oracle,
|
|
301
301
|
abis.AuriOracleABI.abi
|
|
@@ -306,7 +306,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
306
306
|
const prices = await oracle.getUnderlyingPrices(tokenAddresses);
|
|
307
307
|
const exrate = await this.env.auriInternalLens.callStatic.getExchangeRates(tokenAddresses);
|
|
308
308
|
|
|
309
|
-
const res: types.
|
|
309
|
+
const res: types.AccountAuTokensInfo[] = [];
|
|
310
310
|
|
|
311
311
|
for (let addr of accounts) {
|
|
312
312
|
const infos: types.AccountAuTokenInfo[] = [];
|
|
@@ -315,10 +315,10 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
315
315
|
const bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
|
|
316
316
|
const bor = snapshot[1].mul(prices[i]).div(_1E18);
|
|
317
317
|
|
|
318
|
-
let balR = bal.
|
|
319
|
-
let borR = bor.
|
|
318
|
+
let balR = new BigNumber(bal.toString()).dividedBy(_1E18.toString());
|
|
319
|
+
let borR = new BigNumber(bor.toString()).dividedBy(_1E18.toString());
|
|
320
320
|
|
|
321
|
-
if (balR
|
|
321
|
+
if (balR.lt(dust) || borR.lt(dust)) continue;
|
|
322
322
|
|
|
323
323
|
infos.push({
|
|
324
324
|
token: getSymbol(tokenAddresses[i]),
|
|
@@ -326,7 +326,10 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
326
326
|
borrow: borR,
|
|
327
327
|
});
|
|
328
328
|
}
|
|
329
|
-
res.push(
|
|
329
|
+
res.push({
|
|
330
|
+
address: addr,
|
|
331
|
+
tokens: infos,
|
|
332
|
+
});
|
|
330
333
|
}
|
|
331
334
|
return res;
|
|
332
335
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
1
2
|
import type { providers, Signer } from 'ethers';
|
|
2
3
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
3
4
|
|
|
@@ -107,6 +108,11 @@ export type HypotheticalStats = {
|
|
|
107
108
|
|
|
108
109
|
export type AccountAuTokenInfo = {
|
|
109
110
|
token: string;
|
|
110
|
-
deposit:
|
|
111
|
-
borrow:
|
|
111
|
+
deposit: BigNumber;
|
|
112
|
+
borrow: BigNumber;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type AccountAuTokensInfo = {
|
|
116
|
+
address: string;
|
|
117
|
+
tokens: AccountAuTokenInfo[];
|
|
112
118
|
};
|