@aurigami/sdk 1.7.2 → 1.7.3
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/consts/constants.d.ts +1 -0
- package/dist/entities/auriEnv.d.ts +2 -1
- package/dist/entities/tokenAmount.d.ts +1 -0
- package/dist/helpers/helpers.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +77 -22
- 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 +76 -24
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +2 -2
- package/src/consts/constants.ts +8 -0
- package/src/consts/symbols.ts +3 -1
- package/src/entities/auriEnv.ts +13 -1
- package/src/entities/tokenAmount.ts +5 -1
- package/src/helpers/helpers.ts +10 -0
- package/src/index.ts +1 -0
- package/src/types/index.ts +5 -0
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuToken } from '@aurigami/contracts/typechain';
|
|
1
2
|
import BigNumber from 'bignumber.js';
|
|
2
3
|
import type { providers, Signer } from 'ethers';
|
|
3
4
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
@@ -101,3 +102,6 @@ export declare type AccountAuTokensInfo = {
|
|
|
101
102
|
address: string;
|
|
102
103
|
tokens: AccountAuTokenInfo[];
|
|
103
104
|
};
|
|
105
|
+
export declare type AuTokenWithUnderlying = AuToken & {
|
|
106
|
+
underlying?: string;
|
|
107
|
+
};
|
package/package.json
CHANGED
package/src/consts/constants.ts
CHANGED
|
@@ -102,6 +102,14 @@ export const networkAddresses: NetworkAddresses = {
|
|
|
102
102
|
},
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
+
export const DEPOSIT_ONLY_TOKENS = [
|
|
106
|
+
MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(),
|
|
107
|
+
MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(),
|
|
108
|
+
MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(),
|
|
109
|
+
MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(),
|
|
110
|
+
MAINNET_ADDRESSES.auTokens.USN.toLowerCase(),
|
|
111
|
+
];
|
|
112
|
+
|
|
105
113
|
// All token that we can calculate the price via oracle + coingecko
|
|
106
114
|
export const PRICE_WHITELISTED = new Set([
|
|
107
115
|
...networkAddresses.auTokens.map((t) => t.underlying),
|
package/src/consts/symbols.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { networkAddresses } from './constants';
|
|
2
2
|
|
|
3
3
|
export const symbolRecords: Record<string, string> = Object.fromEntries(
|
|
4
|
-
networkAddresses.auTokens
|
|
4
|
+
networkAddresses.auTokens
|
|
5
|
+
.map((e) => [e.address.toLowerCase(), e.name])
|
|
6
|
+
.concat(networkAddresses.auTokens.map((e) => [e.underlying.toLowerCase(), e.name.slice(2)]))
|
|
5
7
|
);
|
package/src/entities/auriEnv.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
AuriFairLaunch,
|
|
3
3
|
AuriInternalLens,
|
|
4
4
|
AuriLens,
|
|
5
|
+
AuToken,
|
|
5
6
|
Comptroller,
|
|
6
7
|
IERC20,
|
|
7
8
|
PULP,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
import { Contract } from 'ethers';
|
|
10
11
|
import * as abis from '../abis';
|
|
11
12
|
import { networkAddresses } from '../consts/constants';
|
|
12
|
-
import { NetworkConnection } from '../types';
|
|
13
|
+
import { AuTokenWithUnderlying, NetworkConnection } from '../types';
|
|
13
14
|
import { BlockchainEntityRead } from './BlockchainEntity';
|
|
14
15
|
|
|
15
16
|
export class AuriEnv extends BlockchainEntityRead {
|
|
@@ -25,6 +26,17 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
25
26
|
return new Contract(address, abi, this._networkConnection.provider) as CType;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
public getAuTokenContracts(): AuTokenWithUnderlying[] {
|
|
30
|
+
return networkAddresses.auTokens.map((auToken) => {
|
|
31
|
+
const contract: AuTokenWithUnderlying = this.getContract<AuToken>(
|
|
32
|
+
auToken.address,
|
|
33
|
+
abis.AuTokenABI.abi
|
|
34
|
+
);
|
|
35
|
+
contract.underlying = auToken.underlying;
|
|
36
|
+
return contract;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
public constructor(networkConnection: NetworkConnection) {
|
|
29
41
|
super(networkConnection);
|
|
30
42
|
this.comptroller = this.getContract<Comptroller>(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { decimalFactor, getDecimal } from '../helpers/helpers';
|
|
2
|
+
import { decimalFactor, getDecimal, getSymbol } from '../helpers/helpers';
|
|
3
3
|
import { Address } from '../types';
|
|
4
4
|
import { Token } from './token';
|
|
5
5
|
|
|
@@ -20,6 +20,10 @@ export class TokenAmount {
|
|
|
20
20
|
return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
public formattedAmountWithSymbol(): string {
|
|
24
|
+
return `${this.formattedAmount()} ${getSymbol(this.token.address)}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
public rawAmount(): string {
|
|
24
28
|
return this.rawAmnt;
|
|
25
29
|
}
|
package/src/helpers/helpers.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
3
|
import { BigNumber as BN, utils } from 'ethers';
|
|
4
|
+
import { networkAddresses } from '../consts/constants';
|
|
4
5
|
import { decimalRecords } from '../consts/decimals';
|
|
5
6
|
import { symbolRecords } from '../consts/symbols';
|
|
6
7
|
import { Address } from '../types';
|
|
@@ -50,6 +51,15 @@ export function getSymbol(address: Address): string {
|
|
|
50
51
|
return symbolRecords[addressLowercase];
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
export function getUnderlying(address: Address): Address {
|
|
55
|
+
let addressLowercase = address.toLowerCase();
|
|
56
|
+
let matching = networkAddresses.auTokens.filter((e) => e.address == addressLowercase);
|
|
57
|
+
if (matching.length == 0) {
|
|
58
|
+
throw new Error('Underlying not found for ' + address);
|
|
59
|
+
}
|
|
60
|
+
return matching[0].underlying;
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
export function calcLMRewardApr(
|
|
54
64
|
rewardsValue: BigNumber,
|
|
55
65
|
totalStakeValue: BigNumber,
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Logger } from 'ethers/lib/utils';
|
|
|
5
5
|
ethers.utils.Logger.setLogLevel(Logger.levels.ERROR);
|
|
6
6
|
BigNumber.config({ DECIMAL_PLACES: 50 });
|
|
7
7
|
|
|
8
|
+
export * as abis from './abis';
|
|
8
9
|
export * from './consts';
|
|
9
10
|
export * from './contracts';
|
|
10
11
|
export * from './entities';
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuToken } from '@aurigami/contracts/typechain';
|
|
1
2
|
import BigNumber from 'bignumber.js';
|
|
2
3
|
import type { providers, Signer } from 'ethers';
|
|
3
4
|
import { TokenAmount } from '../entities/tokenAmount';
|
|
@@ -116,3 +117,7 @@ export type AccountAuTokensInfo = {
|
|
|
116
117
|
address: string;
|
|
117
118
|
tokens: AccountAuTokenInfo[];
|
|
118
119
|
};
|
|
120
|
+
|
|
121
|
+
export type AuTokenWithUnderlying = AuToken & {
|
|
122
|
+
underlying?: string;
|
|
123
|
+
};
|