@aurigami/sdk 0.1.6 → 0.1.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/dist/MoneyMarket.d.ts +7 -7
- package/dist/SDK.d.ts +6 -5
- package/dist/constants.d.ts +1 -1
- package/dist/dummy.d.ts +6 -5
- package/dist/helpers.d.ts +2 -0
- package/dist/sdk.cjs.development.js +2939 -84
- 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 +2938 -85
- package/dist/sdk.esm.js.map +1 -1
- package/dist/token.d.ts +6 -0
- package/dist/tokenAmount.d.ts +8 -0
- package/dist/types.d.ts +12 -12
- package/package.json +2 -4
- package/src/MoneyMarket.ts +17 -20
- package/src/SDK.ts +44 -43
- package/src/abis/IERC20.json +1259 -0
- package/src/abis/auToken.json +1536 -0
- package/src/constants.ts +4 -7
- package/src/dummy.ts +30 -44
- package/src/helpers.ts +15 -0
- package/src/token.ts +11 -0
- package/src/tokenAmount.ts +29 -0
- package/src/types.ts +12 -12
package/src/constants.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { Token } from '
|
|
1
|
+
import { Token } from './token';
|
|
2
2
|
// import ethers from 'ethers';
|
|
3
3
|
const ethers = require('ethers');
|
|
4
4
|
import { Signer } from 'ethers';
|
|
5
|
-
export const DOLLAR = new Token(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
symbol: 'USDC',
|
|
9
|
-
address: '0x0000000000000000000000000000000000000001',
|
|
10
|
-
});
|
|
5
|
+
export const DOLLAR = new Token(
|
|
6
|
+
'0x0000000000000000000000000000000000000001', 2
|
|
7
|
+
);
|
|
11
8
|
|
|
12
9
|
export const AVAX_DEFAULT_PROVIDER_URL =
|
|
13
10
|
'https://api.avax.network/ext/bc/C/rpc';
|
package/src/dummy.ts
CHANGED
|
@@ -1,49 +1,35 @@
|
|
|
1
|
-
import { Token
|
|
1
|
+
import { Token } from './token';
|
|
2
|
+
import { TokenAmount } from './tokenAmount';
|
|
2
3
|
import { UserMarketDetails } from './types';
|
|
3
4
|
|
|
4
|
-
export const dummyToken = new Token(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
currency: dummyToken,
|
|
33
|
-
amount: '0',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export const dummyTokenAmount2 = new CurrencyAmount({
|
|
37
|
-
currency: dummyToken,
|
|
38
|
-
amount: '456.123',
|
|
39
|
-
isRaw: false,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
export const dummyTokenAmount3 = new CurrencyAmount({
|
|
43
|
-
currency: dummyToken,
|
|
44
|
-
amount: '1000.123',
|
|
45
|
-
isRaw: false,
|
|
46
|
-
});
|
|
5
|
+
export const dummyToken = new Token('0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e', 6);
|
|
6
|
+
|
|
7
|
+
export const dummyPly = new Token('0x8729438eb15e2c8b576fcc6aecda6a148776c0f5', 18);
|
|
8
|
+
|
|
9
|
+
export const dummyPlyAurora = new Token('0xE530dC2095Ef5653205CF5ea79F8979a7028065c', 18);
|
|
10
|
+
|
|
11
|
+
export const dummyTokenAmount = new TokenAmount(
|
|
12
|
+
dummyToken,
|
|
13
|
+
'123.456',
|
|
14
|
+
false,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const dummyZeroTokenAmount = new TokenAmount(
|
|
18
|
+
dummyToken,
|
|
19
|
+
'0',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const dummyTokenAmount2 = new TokenAmount(
|
|
23
|
+
dummyToken,
|
|
24
|
+
'456.123',
|
|
25
|
+
false,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const dummyTokenAmount3 = new TokenAmount(
|
|
29
|
+
dummyToken,
|
|
30
|
+
'1000.123',
|
|
31
|
+
false,
|
|
32
|
+
);
|
|
47
33
|
|
|
48
34
|
export const dummyMarketAddress = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f'; // qiUSDC
|
|
49
35
|
|
package/src/helpers.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { BigNumber as BN, utils } from "ethers";
|
|
1
2
|
export function formatObject(object: Object) {
|
|
2
3
|
return JSON.stringify(object, null, ' ');
|
|
3
4
|
}
|
|
5
|
+
|
|
6
|
+
export const decimalFactor = (decimal: number): string => {
|
|
7
|
+
return BN.from(10)
|
|
8
|
+
.pow(decimal)
|
|
9
|
+
.toString();
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export function validateAndParseAddress(address: string): string {
|
|
13
|
+
try {
|
|
14
|
+
return utils.getAddress(address);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
throw new Error("Invalid address " + address);
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/token.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class Token {
|
|
2
|
+
public readonly address: string;
|
|
3
|
+
public readonly decimals: number;
|
|
4
|
+
public readonly expiry?: number;
|
|
5
|
+
|
|
6
|
+
public constructor(address: string, decimals: number, expiry?: number) {
|
|
7
|
+
this.address = address.toLowerCase();
|
|
8
|
+
this.decimals = decimals;
|
|
9
|
+
this.expiry = expiry;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Token } from "./token";
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { decimalFactor } from "./helpers";
|
|
4
|
+
|
|
5
|
+
export class TokenAmount {
|
|
6
|
+
public readonly token: Token;
|
|
7
|
+
private rawAmnt: string;
|
|
8
|
+
|
|
9
|
+
public constructor(token: Token, amount: string, isRaw: boolean = true) {
|
|
10
|
+
if (isRaw) {
|
|
11
|
+
this.rawAmnt = amount;
|
|
12
|
+
} else {
|
|
13
|
+
this.rawAmnt = new BigNumber(amount)
|
|
14
|
+
.times(decimalFactor(token.decimals))
|
|
15
|
+
.toFixed(0);
|
|
16
|
+
}
|
|
17
|
+
this.token = token;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public formattedAmount(): string {
|
|
21
|
+
return new BigNumber(this.rawAmnt)
|
|
22
|
+
.div(decimalFactor(this.token.decimals))
|
|
23
|
+
.toString();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public rawAmount(): string {
|
|
27
|
+
return this.rawAmnt;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { providers, Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { TokenAmount } from './tokenAmount';
|
|
3
3
|
|
|
4
4
|
export type ProviderOrSigner = providers.Provider | Signer;
|
|
5
5
|
|
|
6
6
|
export type MoneyMarketDetails = {
|
|
7
7
|
auTokenAddress: string;
|
|
8
|
-
totalTokenDeposited:
|
|
9
|
-
totalTokenBorrowed:
|
|
8
|
+
totalTokenDeposited: TokenAmount;
|
|
9
|
+
totalTokenBorrowed: TokenAmount;
|
|
10
10
|
depositApy: number;
|
|
11
11
|
depositPlyApy: number;
|
|
12
12
|
borrowApy: number;
|
|
@@ -16,10 +16,10 @@ export type MoneyMarketDetails = {
|
|
|
16
16
|
|
|
17
17
|
export type UserDetails = {
|
|
18
18
|
markets: UserMarketDetails[];
|
|
19
|
-
borrowLimit:
|
|
20
|
-
accruedPly:
|
|
21
|
-
lockedPly:
|
|
22
|
-
borrowableAmount:
|
|
19
|
+
borrowLimit: TokenAmount;
|
|
20
|
+
accruedPly: TokenAmount;
|
|
21
|
+
lockedPly: TokenAmount;
|
|
22
|
+
borrowableAmount: TokenAmount;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type LockingDetails = {
|
|
@@ -29,19 +29,19 @@ export type LockingDetails = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type PlyAuroraPool = {
|
|
32
|
-
totalStakedLiquidity:
|
|
32
|
+
totalStakedLiquidity: TokenAmount;
|
|
33
33
|
apy: number;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export type UserMarketDetails = {
|
|
37
37
|
market: string;
|
|
38
|
-
depositBalance:
|
|
39
|
-
borrowBalance:
|
|
38
|
+
depositBalance: TokenAmount;
|
|
39
|
+
borrowBalance: TokenAmount;
|
|
40
40
|
isCollateral: boolean;
|
|
41
|
-
maxWithdrawableAmount:
|
|
41
|
+
maxWithdrawableAmount: TokenAmount;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export type PlyAuroraPoolDetails = {
|
|
45
|
-
totalStakedLiquidity:
|
|
45
|
+
totalStakedLiquidity: TokenAmount;
|
|
46
46
|
apy: number;
|
|
47
47
|
};
|