@aurigami/sdk 1.7.2 → 1.7.4

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.
@@ -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
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.2",
2
+ "version": "1.7.4",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -70,4 +70,4 @@
70
70
  "jest": {
71
71
  "testURL": "https://app.aurigami.finance"
72
72
  }
73
- }
73
+ }
@@ -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),
@@ -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.map((e) => [e.address.toLowerCase(), e.name])
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
  );
@@ -9,7 +9,7 @@ import {
9
9
  import { Contract } from 'ethers';
10
10
  import * as abis from '../abis';
11
11
  import { networkAddresses } from '../consts/constants';
12
- import { NetworkConnection } from '../types';
12
+ import { AuTokenWithUnderlying, NetworkConnection } from '../types';
13
13
  import { BlockchainEntityRead } from './BlockchainEntity';
14
14
 
15
15
  export class AuriEnv extends BlockchainEntityRead {
@@ -25,6 +25,17 @@ export class AuriEnv extends BlockchainEntityRead {
25
25
  return new Contract(address, abi, this._networkConnection.provider) as CType;
26
26
  }
27
27
 
28
+ public getAuTokenContracts(): AuTokenWithUnderlying[] {
29
+ return networkAddresses.auTokens.map((auToken) => {
30
+ const contract = this.getContract<AuTokenWithUnderlying>(
31
+ auToken.address,
32
+ abis.AuTokenABI.abi
33
+ );
34
+ contract.underlying = auToken.underlying;
35
+ return contract;
36
+ });
37
+ }
38
+
28
39
  public constructor(networkConnection: NetworkConnection) {
29
40
  super(networkConnection);
30
41
  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
  }
@@ -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';
@@ -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
+ };