@aurigami/sdk 0.7.3 → 0.8.1

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": "0.7.3",
2
+ "version": "0.8.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -57,7 +57,7 @@
57
57
  "typescript": "^4.5.4"
58
58
  },
59
59
  "dependencies": {
60
- "@aurigami/contracts": "^2.2.2",
60
+ "@aurigami/contracts": "2.3.0",
61
61
  "axios": "^0.24.0",
62
62
  "bignumber.js": "^9.0.2",
63
63
  "dotenv": "^16.0.0",
@@ -5,7 +5,8 @@ import AuErc20ABI from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuEr
5
5
  import AuETHABI from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
6
6
  import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
7
7
  import AuriLensABI from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
8
- import { AuErc20, AuETH, AuriLens, Comptroller } from "@aurigami/contracts/typechain";
8
+ import EthRepayHelperABI from "@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json"
9
+ import { AuErc20, AuETH, AuriLens, Comptroller, EthRepayHelper } from "@aurigami/contracts/typechain";
9
10
  import { TransactionResponse } from '@ethersproject/abstract-provider';
10
11
  import { networkAddresses, ETHAddress, ONE_YEAR, INF } from "./constants";
11
12
  import BigNumber from "bignumber.js";
@@ -138,7 +139,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
138
139
  await Promise.all(promises);
139
140
 
140
141
  var borrowPlyApy = calcLMRewardApr(
141
- await calcValuation(
142
+ calcValuation(
142
143
  new TokenAmount(
143
144
  PLYToken,
144
145
  rewardSpeeds!.plyRewardBorrowSpeed.toString()
@@ -149,7 +150,7 @@ export class MoneyMarketRead extends BlockchainEntityRead {
149
150
  ONE_YEAR
150
151
  );
151
152
  var depositPlyApy = calcLMRewardApr(
152
- await calcValuation(
153
+ calcValuation(
153
154
  new TokenAmount(
154
155
  PLYToken,
155
156
  rewardSpeeds!.plyRewardSupplySpeed.toString()
@@ -191,6 +192,13 @@ export class MoneyMarketRead extends BlockchainEntityRead {
191
192
  }
192
193
 
193
194
  export class MoneyMarketReadWrite extends MoneyMarketRead {
195
+
196
+ protected _EthRepayHelper: EthRepayHelper;
197
+ constructor(networkConnection: NetworkConnection, auToken: Address, underlyingAsset: Address) {
198
+ super(networkConnection, auToken, underlyingAsset);
199
+ this._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, EthRepayHelperABI.abi, networkConnection.provider) as EthRepayHelper;
200
+ }
201
+
194
202
  public async deposit(amount: TokenAmount): Promise<TransactionResponse> {
195
203
  if (isSameAddress(amount.token.address, ETHAddress)) {
196
204
  return (this.auToken as AuETH).connect(this._networkConnection.signer!).mint({value: amount.rawAmount()});
@@ -208,20 +216,14 @@ export class MoneyMarketReadWrite extends MoneyMarketRead {
208
216
  return this.auToken.connect(this._networkConnection.signer!).redeemUnderlying(amount.rawAmount());
209
217
  }
210
218
  public async repay(amount: TokenAmount): Promise<TransactionResponse> {
211
- var repayAmount: BN;
212
- if (new BigNumber(amount.rawAmount()).lt(0)) {
213
- if (isSameAddress(amount.token.address, ETHAddress)) {
214
- repayAmount = BN.from((await this.getUserBorrowBalance(await this._networkConnection.signer!.getAddress())).rawAmount());
215
- } else {
216
- repayAmount = INF;
217
- }
218
- } else {
219
- repayAmount = BN.from(amount.rawAmount());
220
- }
221
219
  if (isSameAddress(amount.token.address, ETHAddress)) {
222
- return (this.auToken as AuETH).connect(this._networkConnection.signer!).repayBorrow({value: repayAmount});
220
+ return this._EthRepayHelper.connect(this._networkConnection.signer!).repayBorrow({value: amount.rawAmount()});
223
221
  } else {
224
- return (this.auToken as AuErc20).connect(this._networkConnection.signer!).repayBorrow(repayAmount);
222
+ if (new BigNumber(amount.rawAmount()).lt(0)) {
223
+ return this.auToken.connect(this._networkConnection.signer!).repayBorrow(INF);
224
+ } else {
225
+ return this.auToken.connect(this._networkConnection.signer!).repayBorrow(amount.rawAmount());
226
+ }
225
227
  }
226
228
  }
227
229
  public async enableCollateral(): Promise<TransactionResponse> {
@@ -244,4 +246,8 @@ export class MoneyMarket extends BlockchainEntity {
244
246
  public read(networkConnection: NetworkConnection): MoneyMarketRead {
245
247
  return new MoneyMarketRead(networkConnection, this.address, this.underlying);
246
248
  }
249
+
250
+ public readWrite(networkConnection: NetworkConnection): MoneyMarketReadWrite {
251
+ return new MoneyMarketReadWrite(networkConnection, this.address, this.underlying);
252
+ }
247
253
  }
package/src/SDK.ts CHANGED
@@ -255,7 +255,7 @@ export class SdkReadWrite extends SdkRead {
255
255
  );
256
256
  }
257
257
  public async stake(amount: TokenAmount): Promise<TransactionResponse> {
258
- return this._auriFairLaunch.connect(this._networkConnection.signer!).deposit(AurPlyPid, amount.rawAmount(), false);
258
+ return this._auriFairLaunch.connect(this._networkConnection.signer!).deposit(AurPlyPid, amount.rawAmount());
259
259
  }
260
260
  public async unstake(amount: TokenAmount): Promise<TransactionResponse> {
261
261
  return this._auriFairLaunch.connect(this._networkConnection.signer!).withdraw(AurPlyPid, amount.rawAmount());
package/src/constants.ts CHANGED
@@ -9,6 +9,7 @@ export const DECIMAL_PRECISION = 10;
9
9
 
10
10
  export type NetworkAddresses = {
11
11
  auTokens: {
12
+ name: string,
12
13
  address: string,
13
14
  underlying: string
14
15
  }[],
@@ -18,45 +19,53 @@ export type NetworkAddresses = {
18
19
  export const networkAddresses: NetworkAddresses = {
19
20
  auTokens: [
20
21
  {
21
- address: '0x7D9F7B4734E274Ff10531bBD5aE8fE6069164d28'.toLowerCase(),
22
+ name: "auUSDC",
23
+ address: '0x9728d8920707a5C12958E4cB2979Ae5588F85EcA'.toLowerCase(),
22
24
  underlying: '0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase()
23
25
  },
24
26
  {
25
- address: '0x580Ac375176A4e9B26977490656c3B2F00Abf624'.toLowerCase(),
27
+ name: "auETH",
28
+ address: '0xc263e92038139879918C0DE0e97eA2F3f3984F72'.toLowerCase(),
26
29
  underlying: ETHAddress.toLowerCase()
27
30
  },
28
31
  {
29
- address: '0x705b9d83222c4EeDeaD1A0E399cDeB917173E1F6'.toLowerCase(),
32
+ name: "auWBTC",
33
+ address: '0xC08FF86edF64c2d3816Eb43c5Ec95475a2d47BD0'.toLowerCase(),
30
34
  underlying: '0xf4eb217ba2454613b15dbdea6e5f22276410e89e'.toLowerCase()
31
35
  },
32
36
  {
33
- address: '0xF9739783b767b358b21A1373140296c09271d6F5'.toLowerCase(),
37
+ name: "auUSDT",
38
+ address: '0x22AE568df8D8AeE3Ed9Ab0f135Ca8cFeF5d2Cf18'.toLowerCase(),
34
39
  underlying: '0x4988a896b1227218e4a686fde5eabdcabd91571f'.toLowerCase()
35
40
  },
36
41
  {
37
- address: '0x4d2c286D74597B13642dd311D1050dFf9E7eF666'.toLowerCase(),
42
+ name: "auDAI",
43
+ address: '0x6664d272c820d70c923DE9b1992De02A12C8a7d8'.toLowerCase(),
38
44
  underlying: '0xe3520349f477a5f6eb06107066048508498a291b'.toLowerCase()
39
45
  },
40
46
  {
41
- address: '0x367E3fD10006bC64D279e5F1F499DcfA92518A35'.toLowerCase(),
42
- underlying: '0x07a4f270836F2B2B5CACb00b09552e690276aC33'.toLowerCase()
47
+ name: "auPLY",
48
+ address: '0xD204fD43bFe4aAEB9aB993c116c1dECdDF1b9F1A'.toLowerCase(),
49
+ underlying: '0x9ae13dd1FFd2008F68bC71d93C5a2381dC3F1D27'.toLowerCase()
43
50
  },
44
51
  {
45
- address: '0x7FDe6C1C53DD4E94a8CD4c60BF1418613c90c42F'.toLowerCase(),
52
+ name: "auWNEAR",
53
+ address: '0xa64F1875080B91Db293dE1f547DC1D6Bc5d3Ef55'.toLowerCase(),
46
54
  underlying: '0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase()
47
55
  }
48
56
  ],
49
57
  misc: {
50
- COMPTROLLER: "0xc77877b0bd08fE3B060EbD8AEE06fb560C91A125".toLowerCase(),
51
- oracle: "0x9c8180255ED1bA5fA812FABc933E3ecbd3B585D5".toLowerCase(),
52
- AURIFAIRLAUNCH: "0x660159696c9E0B2c17E3e0ac2019F436aE34fc7A".toLowerCase(),
53
- AURILENS: '0x503bD4B6a056F7E66671D2B4620f0aDC4ff2A4e9'.toLowerCase(),
54
- TOKENLOCK: '0xa4623FC7C96B59f9a0a46144324d68C8E8710966'.toLowerCase(),
55
- FAUCET: '0x8F791d611D71699B76C03857A51D7B7E5E66f01E'.toLowerCase() // doesn't exist on mainnet
58
+ COMPTROLLER: "0xe3618BaDA3728a339A2214423C0426AD47d30626".toLowerCase(),
59
+ oracle: "0xC6e5185438e1730959c1eF3551059A3feC744E90".toLowerCase(),
60
+ AURIFAIRLAUNCH: "0x451d4e8964d79081EFFDAEde236354b20b678640".toLowerCase(),
61
+ AURILENS: '0xe8b53eE0443620fB8DcEaEB6DE98ED117971c329'.toLowerCase(),
62
+ TOKENLOCK: '0xE28339435478245CB1c57f84D246b67EECb3E204'.toLowerCase(),
63
+ FAUCET: dummyAddress.toLowerCase(), // doesn't exist on mainnet
64
+ ETHREPAYHELPER: "0xFb7c45A326DB421da1CE532420232D655107b110".toLowerCase()
56
65
  },
57
66
  tokens: {
58
67
  AURORA: "0x8bec47865ade3b172a928df8f990bc7f2a3b9f79".toLowerCase(),
59
- PLY: "0x07a4f270836F2B2B5CACb00b09552e690276aC33".toLowerCase(),
68
+ PLY: "0x9ae13dd1FFd2008F68bC71d93C5a2381dC3F1D27".toLowerCase(),
60
69
  AURPLY: dummyAddress.toLowerCase() // This is dummy
61
70
  }
62
71
  }
package/src/decimals.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  export const decimalRecords: Record<string, number> = {
2
2
  '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
3
- '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
4
- '0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
5
3
  '0xb12bfca5a55806aaf64e99521918a4bf0fc40802': 6,
6
- '0x7fde6c1c53dd4e94a8cd4c60bf1418613c90c42f': 8,
7
- '0xe3520349f477a5f6eb06107066048508498a291b': 18,
8
- '0xf9739783b767b358b21a1373140296c09271d6f5': 8,
9
- '0x07a4f270836f2b2b5cacb00b09552e690276ac33': 18,
4
+ '0xd204fd43bfe4aaeb9ab993c116c1decddf1b9f1a': 8,
10
5
  '0xf4eb217ba2454613b15dbdea6e5f22276410e89e': 8,
11
- '0x705b9d83222c4eedead1a0e399cdeb917173e1f6': 8,
12
- '0x367e3fd10006bc64d279e5f1f499dcfa92518a35': 8,
13
- '0x580ac375176a4e9b26977490656c3b2f00abf624': 8,
14
- '0x4d2c286d74597b13642dd311d1050dff9e7ef666': 8,
15
- '0x7d9f7b4734e274ff10531bbd5ae8fe6069164d28': 8,
16
- '0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24
6
+ '0xc08ff86edf64c2d3816eb43c5ec95475a2d47bd0': 8,
7
+ '0xc263e92038139879918c0de0e97ea2f3f3984f72': 8,
8
+ '0x22ae568df8d8aee3ed9ab0f135ca8cfef5d2cf18': 8,
9
+ '0x9ae13dd1ffd2008f68bc71d93c5a2381dc3f1d27': 18,
10
+ '0x9728d8920707a5c12958e4cb2979ae5588f85eca': 8,
11
+ '0xa64f1875080b91db293de1f547dc1d6bc5d3ef55': 8,
12
+ '0xe3520349f477a5f6eb06107066048508498a291b': 18,
13
+ '0x4988a896b1227218e4a686fde5eabdcabd91571f': 6,
14
+ '0xc42c30ac6cc15fac9bd938618bcaa1a1fae8501d': 24,
15
+ '0x8bec47865ade3b172a928df8f990bc7f2a3b9f79': 18,
16
+ '0x6664d272c820d70c923de9b1992de02a12c8a7d8': 8
17
17
  }
@@ -1,31 +1,21 @@
1
1
  {
2
- "networkId": 1313161554,
3
- "deployer": "0xf5FDd938B6BE0a0E6800262b3F623FE26c098410",
4
- "unitroller": "0xc77877b0bd08fE3B060EbD8AEE06fb560C91A125",
5
- "comptroller": "0x2082a661FCe093F1DEDd1842e79b9f95e68bb39B",
6
- "ply": "0x07a4f270836F2B2B5CACb00b09552e690276aC33",
7
- "tokenLock": "0xa4623FC7C96B59f9a0a46144324d68C8E8710966",
8
- "lens": "0x503bD4B6a056F7E66671D2B4620f0aDC4ff2A4e9",
9
- "fairLaunch": "0x660159696c9E0B2c17E3e0ac2019F436aE34fc7A",
10
- "oracle": "0x9c8180255ED1bA5fA812FABc933E3ecbd3B585D5",
11
- "interestRateModel": "0x70787df7735d736E20E06DBdc41B8455B98cc1e5",
2
+ "deployer": "0xb969526EBc8dd4b1d816Da846eE08180515fFBbC",
3
+ "unitroller": "0xe3618BaDA3728a339A2214423C0426AD47d30626",
4
+ "comptrollerImpl": "0xEAdafBD9D7c09CE42512bf38d12abCD2D9ECBe0E",
5
+ "comptroller": "0xe3618BaDA3728a339A2214423C0426AD47d30626",
6
+ "PLY": "0x9ae13dd1FFd2008F68bC71d93C5a2381dC3F1D27",
7
+ "jumpRateModel": "0xA70d805Ed5B2DfF627Cf7046C131D73DFe11C59c",
8
+ "oracle": "0xC6e5185438e1730959c1eF3551059A3feC744E90",
12
9
  "auTokens": {
13
- "USDC": "0x7D9F7B4734E274Ff10531bBD5aE8fE6069164d28",
14
- "ETH": "0x580Ac375176A4e9B26977490656c3B2F00Abf624",
15
- "WBTC": "0x705b9d83222c4EeDeaD1A0E399cDeB917173E1F6",
16
- "USDT": "0xF9739783b767b358b21A1373140296c09271d6F5",
17
- "DAI": "0x4d2c286D74597B13642dd311D1050dFf9E7eF666",
18
- "PLY": "0x367E3fD10006bC64D279e5F1F499DcfA92518A35",
19
- "WNEAR": "0x7FDe6C1C53DD4E94a8CD4c60BF1418613c90c42F"
10
+ "USDC": "0x9728d8920707a5C12958E4cB2979Ae5588F85EcA",
11
+ "ETH": "0xc263e92038139879918C0DE0e97eA2F3f3984F72",
12
+ "WBTC": "0xC08FF86edF64c2d3816Eb43c5Ec95475a2d47BD0",
13
+ "USDT": "0x22AE568df8D8AeE3Ed9Ab0f135Ca8cFeF5d2Cf18",
14
+ "DAI": "0x6664d272c820d70c923DE9b1992De02A12C8a7d8",
15
+ "PLY": "0xD204fD43bFe4aAEB9aB993c116c1dECdDF1b9F1A",
16
+ "WNEAR": "0xa64F1875080B91Db293dE1f547DC1D6Bc5d3Ef55"
20
17
  },
21
- "supportedTokens": {
22
- "USDC": "0xb12bfca5a55806aaf64e99521918a4bf0fc40802",
23
- "WBTC": "0xf4eb217ba2454613b15dbdea6e5f22276410e89e",
24
- "USDT": "0x4988a896b1227218e4a686fde5eabdcabd91571f",
25
- "DAI": "0xe3520349f477a5f6eb06107066048508498a291b",
26
- "PLY": "0x07a4f270836F2B2B5CACb00b09552e690276aC33",
27
- "WNEAR": "0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d"
28
- },
29
- "PLY_AUR_LP": "",
30
- "faucet": "0xA3923309CF9069b4945Dec09c760b70fC53373Db"
31
- }
18
+ "tokenLock": "0xE28339435478245CB1c57f84D246b67EECb3E204",
19
+ "fairLaunch": "0x451d4e8964d79081EFFDAEde236354b20b678640",
20
+ "auriLens": "0xe8b53eE0443620fB8DcEaEB6DE98ED117971c329"
21
+ }
@@ -101,7 +101,7 @@ export async function fetchPrice(address: Address, provider: providers.Provider)
101
101
  });
102
102
  if (matchingAuToken !== undefined) {
103
103
  return fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider);
104
- } else if (isSameAddress(address, networkAddresses.misc.AUPLYLP)) {
104
+ } else if (isSameAddress(address, networkAddresses.tokens.AUPLYLP)) {
105
105
  return fetchLPPrice(address, provider);
106
106
  } else {
107
107
  return fetchPriceFromCoingecko(address);