@aurigami/sdk 1.6.10 → 1.7.0
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/contracts/Referral.d.ts +7 -0
- package/dist/helpers/aurigami-api.d.ts +13 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +150 -18
- 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 +149 -19
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/package.json +4 -1
- package/src/contracts/Referral.ts +14 -0
- package/src/contracts/misc.ts +4 -4
- package/src/helpers/aurigami-api.ts +42 -0
- package/src/helpers/index.ts +1 -0
- package/src/types/index.ts +3 -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,8 +94,8 @@ 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;
|
|
98
99
|
};
|
|
99
100
|
export declare type AccountAuTokensInfo = {
|
|
100
101
|
address: string;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -66,5 +66,8 @@
|
|
|
66
66
|
"axios": "^0.26.1",
|
|
67
67
|
"bignumber.js": "^9.0.2",
|
|
68
68
|
"ethers": "^5.6.4"
|
|
69
|
+
},
|
|
70
|
+
"jest": {
|
|
71
|
+
"testURL": "https://app.aurigami.finance"
|
|
69
72
|
}
|
|
70
73
|
}
|
|
@@ -4,6 +4,7 @@ import { Contract, ethers } from 'ethers';
|
|
|
4
4
|
import * as abis from '../abis';
|
|
5
5
|
import * as consts from '../consts';
|
|
6
6
|
import { BlockchainEntity, BlockchainEntityRead } from '../entities';
|
|
7
|
+
import * as AuriAPI from '../helpers/aurigami-api';
|
|
7
8
|
import { Address, NetworkConnection } from '../types';
|
|
8
9
|
|
|
9
10
|
export class ReferralRead extends BlockchainEntityRead {
|
|
@@ -55,6 +56,19 @@ export class ReferralRead extends BlockchainEntityRead {
|
|
|
55
56
|
const referralCode = ethers.utils.formatBytes32String(code);
|
|
56
57
|
return this.referral.referralCodeOwner(referralCode);
|
|
57
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
62
|
+
*/
|
|
63
|
+
public async getReferralsList(userAddr: Address): Promise<{ user: string; timestamp: number }[]> {
|
|
64
|
+
const result = await AuriAPI.getPaginatedApi('/referral/list', { address: userAddr });
|
|
65
|
+
|
|
66
|
+
const items = result.items.map((item) => ({
|
|
67
|
+
user: item.user!,
|
|
68
|
+
timestamp: item.blockNumber!, // @TODO: change this to timestamp
|
|
69
|
+
}));
|
|
70
|
+
return items;
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
export class ReferralReadWrite extends ReferralRead {
|
package/src/contracts/misc.ts
CHANGED
|
@@ -295,7 +295,7 @@ export class MiscRead extends BlockchainEntityRead {
|
|
|
295
295
|
tokenAddresses: string[]
|
|
296
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
|
|
@@ -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]),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
const AURIGAMI_API_END_POINT = 'https://api.aurigami.finance/app/';
|
|
4
|
+
|
|
5
|
+
export async function getApi(url: string, params: Record<string, any> = {}): Promise<any> {
|
|
6
|
+
const resp = await axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
7
|
+
headers: { 'Content-Type': 'application/json' },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return resp.data;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type MetaApiResponse = {
|
|
14
|
+
totalItems: number;
|
|
15
|
+
itemCount: number;
|
|
16
|
+
itemsPerPage: number;
|
|
17
|
+
totalPages: number;
|
|
18
|
+
currentPage: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type PaginagedApiResponse<T> = {
|
|
22
|
+
items: T[];
|
|
23
|
+
meta: MetaApiResponse;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export async function getPaginatedApi(
|
|
27
|
+
url: string,
|
|
28
|
+
params: Record<string, any> = {},
|
|
29
|
+
page: number = 1,
|
|
30
|
+
pageSize: number = 50
|
|
31
|
+
): Promise<PaginagedApiResponse<any>> {
|
|
32
|
+
params = {
|
|
33
|
+
...params,
|
|
34
|
+
page,
|
|
35
|
+
limit: pageSize,
|
|
36
|
+
};
|
|
37
|
+
const resp = await axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return resp.data;
|
|
42
|
+
}
|
package/src/helpers/index.ts
CHANGED
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,8 +108,8 @@ export type HypotheticalStats = {
|
|
|
107
108
|
|
|
108
109
|
export type AccountAuTokenInfo = {
|
|
109
110
|
token: string;
|
|
110
|
-
deposit:
|
|
111
|
-
borrow:
|
|
111
|
+
deposit: BigNumber;
|
|
112
|
+
borrow: BigNumber;
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
export type AccountAuTokensInfo = {
|