@aurigami/sdk 1.6.7 → 1.6.9
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 +1 -0
- package/dist/abis/index.d.ts +3 -2
- package/dist/consts/index.d.ts +2 -1
- package/dist/consts/symbols.d.ts +1 -0
- package/dist/contracts/misc.d.ts +3 -0
- package/dist/entities/auriEnv.d.ts +2 -1
- package/dist/helpers/helpers.d.ts +1 -0
- package/dist/sdk.cjs.development.js +207 -49
- 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 +214 -58
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/package.json +3 -3
- package/src/SDK.ts +8 -12
- package/src/abis/index.ts +4 -2
- package/src/consts/constants.ts +2 -1
- package/src/consts/index.ts +2 -1
- package/src/consts/symbols.ts +5 -0
- package/src/contracts/misc.ts +51 -1
- package/src/entities/auriEnv.ts +14 -1
- package/src/helpers/helpers.ts +7 -0
- package/src/types/index.ts +6 -0
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.6.
|
|
2
|
+
"version": "1.6.9",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"typescript": "^4.5.4"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aurigami/contracts": "3.
|
|
65
|
+
"@aurigami/contracts": "3.9.1",
|
|
66
66
|
"axios": "^0.26.1",
|
|
67
67
|
"bignumber.js": "^9.0.2",
|
|
68
68
|
"ethers": "^5.6.4"
|
|
69
69
|
}
|
|
70
|
-
}
|
|
70
|
+
}
|
package/src/SDK.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { UltilizationHelper } from '@aurigami/contracts/typechain';
|
|
2
1
|
import { TransactionResponse } from '@ethersproject/abstract-provider';
|
|
3
2
|
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { Contract } from 'ethers';
|
|
5
|
-
import * as abis from './abis';
|
|
6
3
|
import * as consts from './consts';
|
|
7
4
|
import { MiscRead, StakingRead, StakingReadWrite } from './contracts';
|
|
8
5
|
import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from './entities';
|
|
@@ -84,15 +81,14 @@ export class SdkRead extends BlockchainEntityRead {
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
public async getUltilizations(userAddr: types.Address): Promise<BigNumber> {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return sumBorrow.dividedBy(sumCol);
|
|
84
|
+
return this._misc.getUltilizations(userAddr);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public async sneakAccounts(
|
|
88
|
+
accounts: string[],
|
|
89
|
+
tokenAddresses: string[]
|
|
90
|
+
): Promise<types.AccountAuTokenInfo[][]> {
|
|
91
|
+
return this._misc.sneakAccounts(accounts, tokenAddresses);
|
|
96
92
|
}
|
|
97
93
|
}
|
|
98
94
|
|
package/src/abis/index.ts
CHANGED
|
@@ -4,17 +4,19 @@ import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.
|
|
|
4
4
|
import AuriFairLaunchABI from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
|
|
5
5
|
import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
6
6
|
import AuriOracleABI from '@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json';
|
|
7
|
+
import AuTokenABI from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
|
|
7
8
|
import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
8
9
|
import EthRepayHelperABI from '@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json';
|
|
9
10
|
import EIP20InterfaceABI from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
10
11
|
// import FaucetABI from '@aurigami/contracts/artifacts/contracts/mock/Faucet.sol/Faucet.json';
|
|
12
|
+
import AuriInternalLensABI from '@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json';
|
|
11
13
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
12
14
|
import Multicall2ABI from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
13
|
-
import UltilizationHelperABI from '@aurigami/contracts/artifacts/contracts/mock/UltilizationHelper.sol/UltilizationHelper.json';
|
|
14
15
|
import PulpABI from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
15
16
|
import ReferralDirectoryABI from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
|
|
16
17
|
export {
|
|
17
18
|
AuriOracleABI,
|
|
19
|
+
AuTokenABI,
|
|
18
20
|
IUniswapV2PairABI,
|
|
19
21
|
AuriAirdropABI,
|
|
20
22
|
AuriFairLaunchABI,
|
|
@@ -28,5 +30,5 @@ export {
|
|
|
28
30
|
EthRepayHelperABI,
|
|
29
31
|
Multicall2ABI,
|
|
30
32
|
PulpABI,
|
|
31
|
-
|
|
33
|
+
AuriInternalLensABI,
|
|
32
34
|
};
|
package/src/consts/constants.ts
CHANGED
|
@@ -85,7 +85,8 @@ export const networkAddresses: NetworkAddresses = {
|
|
|
85
85
|
MULTICALL: MAINNET_ADDRESSES.multicall.toLowerCase(),
|
|
86
86
|
TEAM_MULTISIG: '0x2D05FfFE70CE64c5954710D4C308dB31C8dBd8dE'.toLowerCase(),
|
|
87
87
|
PLY_TOKEN_LOCK: MAINNET_ADDRESSES.plyTokenLock.toLowerCase(),
|
|
88
|
-
REFERRAL: MAINNET_ADDRESSES.referralDirectory.
|
|
88
|
+
REFERRAL: MAINNET_ADDRESSES.referralDirectory.toLowerCase(),
|
|
89
|
+
AURI_INTERNAL_LENS: MAINNET_ADDRESSES.auriInternalLens.toLowerCase(),
|
|
89
90
|
},
|
|
90
91
|
tokens: {
|
|
91
92
|
AURORA: '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79'.toLowerCase(),
|
package/src/consts/index.ts
CHANGED
package/src/contracts/misc.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { AuToken, PriceOracle } from '@aurigami/contracts/typechain';
|
|
1
2
|
import BigNumber from 'bignumber.js';
|
|
2
3
|
import { BigNumber as BN } from 'ethers';
|
|
4
|
+
import * as abis from '../abis';
|
|
3
5
|
import * as consts from '../consts';
|
|
4
6
|
import { AuriEnv, BlockchainEntityRead, PLYToken, Token, TokenAmount } from '../entities';
|
|
5
|
-
import { decimalFactor, isSameAddress } from '../helpers/helpers';
|
|
7
|
+
import { decimalFactor, getSymbol, isSameAddress } from '../helpers/helpers';
|
|
6
8
|
import { calcValuation, fetchPrice } from '../helpers/priceFetcher';
|
|
7
9
|
import * as types from '../types';
|
|
8
10
|
import { MoneyMarketRead } from './MoneyMarket';
|
|
@@ -280,4 +282,52 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
280
282
|
|
|
281
283
|
return new TokenAmount(PLYToken, circulatingSupply.toString());
|
|
282
284
|
}
|
|
285
|
+
|
|
286
|
+
public async getUltilizations(userAddr: types.Address): Promise<BigNumber> {
|
|
287
|
+
let accountDetail = await this.env.auriInternalLens.getAccountLiquidity(userAddr);
|
|
288
|
+
let sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
|
|
289
|
+
let sumCol = new BigNumber(accountDetail.sumCollateral.toString());
|
|
290
|
+
return sumBorrow.dividedBy(sumCol);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
public async sneakAccounts(
|
|
294
|
+
accounts: string[],
|
|
295
|
+
tokenAddresses: string[]
|
|
296
|
+
): Promise<types.AccountAuTokenInfo[][]> {
|
|
297
|
+
const _1E18 = BN.from(10).pow(18);
|
|
298
|
+
const _1E9 = BN.from(10).pow(9);
|
|
299
|
+
const oracle = this.env.getContract<PriceOracle>(
|
|
300
|
+
consts.networkAddresses.misc.oracle,
|
|
301
|
+
abis.AuriOracleABI.abi
|
|
302
|
+
);
|
|
303
|
+
const tokens = tokenAddresses.map((addr) =>
|
|
304
|
+
this.env.getContract<AuToken>(addr, abis.AuTokenABI.abi)
|
|
305
|
+
);
|
|
306
|
+
const prices = await oracle.getUnderlyingPrices(tokenAddresses);
|
|
307
|
+
const exrate = await this.env.auriInternalLens.callStatic.getExchangeRates(tokenAddresses);
|
|
308
|
+
|
|
309
|
+
const res: types.AccountAuTokenInfo[][] = [];
|
|
310
|
+
|
|
311
|
+
for (let addr of accounts) {
|
|
312
|
+
const infos: types.AccountAuTokenInfo[] = [];
|
|
313
|
+
for (let i = 0; i < tokens.length; ++i) {
|
|
314
|
+
const snapshot = await tokens[i].getAccountSnapshot(addr);
|
|
315
|
+
const bal = snapshot[0].mul(exrate[i]).div(_1E18).mul(prices[i]).div(_1E18);
|
|
316
|
+
const bor = snapshot[1].mul(prices[i]).div(_1E18);
|
|
317
|
+
|
|
318
|
+
let balR = bal.div(_1E9).toNumber() / 10 ** 9;
|
|
319
|
+
let borR = bor.div(_1E9).toNumber() / 10 ** 9;
|
|
320
|
+
|
|
321
|
+
if (balR < 0.1 || borR < 0.1) continue;
|
|
322
|
+
|
|
323
|
+
infos.push({
|
|
324
|
+
token: getSymbol(tokenAddresses[i]),
|
|
325
|
+
deposit: balR,
|
|
326
|
+
borrow: borR,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
res.push(infos);
|
|
330
|
+
}
|
|
331
|
+
return res;
|
|
332
|
+
}
|
|
283
333
|
}
|
package/src/entities/auriEnv.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AuriFairLaunch,
|
|
3
|
+
AuriInternalLens,
|
|
4
|
+
AuriLens,
|
|
5
|
+
Comptroller,
|
|
6
|
+
IERC20,
|
|
7
|
+
PULP,
|
|
8
|
+
} from '@aurigami/contracts/typechain';
|
|
2
9
|
import { Contract } from 'ethers';
|
|
3
10
|
import * as abis from '../abis';
|
|
4
11
|
import { networkAddresses } from '../consts/constants';
|
|
@@ -11,6 +18,7 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
11
18
|
public auriLens: AuriLens;
|
|
12
19
|
public ply: IERC20;
|
|
13
20
|
public pulp: PULP;
|
|
21
|
+
public auriInternalLens: AuriInternalLens;
|
|
14
22
|
// public faucet: Faucet;
|
|
15
23
|
|
|
16
24
|
public getContract<CType extends Contract>(address: string, abi: any) {
|
|
@@ -35,5 +43,10 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
35
43
|
this.ply = this.getContract<IERC20>(networkAddresses.tokens.PLY, abis.EIP20InterfaceABI.abi);
|
|
36
44
|
this.pulp = this.getContract<PULP>(networkAddresses.tokens.PULP, abis.PulpABI.abi);
|
|
37
45
|
// this.faucet = this.getContract<Faucet>(networkAddresses.misc.FAUCET, abis.FaucetABI.abi);
|
|
46
|
+
|
|
47
|
+
this.auriInternalLens = this.getContract<AuriInternalLens>(
|
|
48
|
+
networkAddresses.misc.AURI_INTERNAL_LENS,
|
|
49
|
+
abis.AuriInternalLensABI.abi
|
|
50
|
+
);
|
|
38
51
|
}
|
|
39
52
|
}
|
package/src/helpers/helpers.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Provider } from '@ethersproject/abstract-provider';
|
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { BigNumber as BN, utils } from 'ethers';
|
|
4
4
|
import { decimalRecords } from '../consts/decimals';
|
|
5
|
+
import { symbolRecords } from '../consts/symbols';
|
|
5
6
|
import { Address } from '../types';
|
|
6
7
|
import { getQuery as getAuroraAPIQuery } from './aurora-api-helpers';
|
|
7
8
|
|
|
@@ -42,6 +43,12 @@ export function getDecimal(address: Address): number {
|
|
|
42
43
|
return decimalRecords[addressLowercase];
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
export function getSymbol(address: Address): string {
|
|
47
|
+
let addressLowercase = address.toLowerCase();
|
|
48
|
+
assert(symbolRecords[addressLowercase] != undefined, 'Symbol not found for ' + address);
|
|
49
|
+
return symbolRecords[addressLowercase];
|
|
50
|
+
}
|
|
51
|
+
|
|
45
52
|
export function calcLMRewardApr(
|
|
46
53
|
rewardsValue: BigNumber,
|
|
47
54
|
totalStakeValue: BigNumber,
|