@aurigami/sdk 1.9.6 → 1.10.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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.9.6",
2
+ "version": "1.10.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "typescript": "^4.5.4"
63
63
  },
64
64
  "dependencies": {
65
- "@aurigami/contracts": "3.9.1",
65
+ "@aurigami/contracts": "3.10.3",
66
66
  "axios": "^0.26.1",
67
67
  "bignumber.js": "^9.0.2",
68
68
  "ethers": "^5.6.4"
@@ -70,4 +70,4 @@
70
70
  "jest": {
71
71
  "testURL": "https://app.aurigami.finance"
72
72
  }
73
- }
73
+ }
package/src/a.ts.log ADDED
@@ -0,0 +1,29 @@
1
+ import { AuToken } from '@aurigami/contracts/typechain';
2
+ import { ethers } from 'ethers';
3
+ import { AuriEnv, formatObject, getDecimal, MAINNET_ADDRESSES, networkAddresses, SDK, Token } from '../src';
4
+ import { ask } from 'stdio';
5
+ const AURORA_DEFAULT_PROVIDER_URL = `https://mainnet.aurora.dev/`;
6
+
7
+ const AURORA_DEFAULT_PROVIDER = new ethers.providers.JsonRpcProvider(
8
+ AURORA_DEFAULT_PROVIDER_URL
9
+ );
10
+
11
+ async function foo(contract: AuToken, block: number) {
12
+ let data = await contract.callStatic.borrowBalanceCurrent('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
13
+ console.log("c", data.toString());
14
+ data = await contract.callStatic.borrowBalanceStored('0x25a087dc3512e3be548f0ca13233ae29d3781bdc', {blockTag: block});
15
+ console.log("s", data.toString());
16
+ }
17
+
18
+ async function main() {
19
+ let env = new AuriEnv({ provider: AURORA_DEFAULT_PROVIDER });
20
+ let contract = env.getAuErc20Contract({address: MAINNET_ADDRESSES.auTokens.USDC});
21
+ // let block = 60596417;
22
+ // while (true) {
23
+ // block = parseInt(eval(await ask('block')));
24
+ // if (block == 0) break;
25
+ // await foo(contract, block);
26
+ // }
27
+ }
28
+
29
+ main();
@@ -1,15 +1,17 @@
1
1
  import {
2
+ AuErc20,
2
3
  AuriAirdrop,
3
4
  AuriFairLaunch,
4
5
  AuriInternalLens,
5
6
  AuriLens,
7
+ AuriOracle,
6
8
  Comptroller,
7
9
  IERC20,
8
- AuriOracle,
9
10
  PULP,
10
11
  ReferralDirectory,
11
12
  } from '@aurigami/contracts/typechain';
12
13
  import { Contract } from 'ethers';
14
+ import { assert } from '../helpers/helpers';
13
15
  import * as abis from '../abis';
14
16
  import { networkAddresses } from '../consts/constants';
15
17
  import { AuTokenWithUnderlying } from '../types';
@@ -41,6 +43,35 @@ export class AuriEnv extends BlockchainEntityRead {
41
43
  });
42
44
  }
43
45
 
46
+ /**
47
+ * Get AuErc20 contract by its address or underlying name.
48
+ *
49
+ * Either address or underlyingName must be provided
50
+ *
51
+ */
52
+ public getAuErc20Contract({
53
+ address,
54
+ underlyingName,
55
+ }: {
56
+ address?: string;
57
+ underlyingName?: string;
58
+ }): AuErc20 {
59
+ assert(
60
+ address !== undefined || underlyingName !== undefined,
61
+ 'Either address or underlyingName must be provided'
62
+ );
63
+
64
+ if (underlyingName) {
65
+ address = networkAddresses.auTokens.find(
66
+ (auToken) => auToken.name == 'au' + underlyingName
67
+ )?.address;
68
+ console.log(address);
69
+ assert(address !== undefined, `AuToken with underlying ${underlyingName} not found`);
70
+ }
71
+
72
+ return this.getContract<AuErc20>(address!, abis.AuErc20ABI.abi);
73
+ }
74
+
44
75
  get comptroller(): Comptroller {
45
76
  if (!this._comptroller) {
46
77
  this._comptroller = this.getContract<Comptroller>(
@@ -118,7 +149,7 @@ export class AuriEnv extends BlockchainEntityRead {
118
149
  get oracle(): AuriOracle {
119
150
  if (!this._oracle) {
120
151
  this._oracle = this.getContract<AuriOracle>(
121
- networkAddresses.misc.PRICE_ORACLE,
152
+ networkAddresses.misc.oracle,
122
153
  abis.AuriOracleABI.abi
123
154
  );
124
155
  }
@@ -47,7 +47,7 @@ export class PapermillRead extends BlockchainEntityRead {
47
47
  return new TokenAmount(this.plyToken, rewardBalancesMetadata.plyAccrured.toString());
48
48
  }
49
49
 
50
- private getWeek(timestamp: number): number {
50
+ public getWeek(timestamp: number): number {
51
51
  return BN.from(timestamp - consts.REWARD_CLAIM_START)
52
52
  .div(consts.ONE_WEEK)
53
53
  .toNumber();