@aurigami/sdk 1.14.0 → 1.15.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": "1.14.0",
2
+ "version": "1.15.1",
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.11.3",
65
+ "@aurigami/contracts": "3.16.0",
66
66
  "axios": "^0.26.1",
67
67
  "bignumber.js": "^9.0.2",
68
68
  "cache-decorator": "^0.1.6",
package/src/SDK.ts CHANGED
@@ -4,6 +4,7 @@ import { ALL_STAKING_POOLS } from './consts';
4
4
  import { AuriEnv, BlockchainEntity, BlockchainEntityRead, Token, TokenAmount } from './entities';
5
5
  import { MiscRead, StakingRead, StakingReadWrite } from './interactors';
6
6
  import * as types from './types';
7
+ import * as NotificationApi from './helpers/notification-api';
7
8
 
8
9
  export class SdkRead extends BlockchainEntityRead {
9
10
  protected env: AuriEnv;
@@ -101,6 +102,40 @@ export class SdkRead extends BlockchainEntityRead {
101
102
  const miscRead = new MiscRead(this._networkConnection);
102
103
  return miscRead.getNetApyWithIncentive(userAddress);
103
104
  }
105
+
106
+ public async setUserNotificationSettings(
107
+ address: types.Address,
108
+ mail: string,
109
+ utilisation: number,
110
+ liquidation: boolean,
111
+ captchaResponse: string
112
+ ) {
113
+ const body = {
114
+ address,
115
+ mail,
116
+ setting: {
117
+ utilisation,
118
+ liquidation,
119
+ },
120
+ captchaResponse,
121
+ };
122
+ const response = await NotificationApi.postApi('alert-setting/set', body);
123
+ return response;
124
+ }
125
+
126
+ public async unsetUserNotificationSettings(address: types.Address, captchaResponse: string) {
127
+ const body = {
128
+ address,
129
+ mail: '',
130
+ setting: {
131
+ utilisation: null,
132
+ liquidation: false,
133
+ },
134
+ captchaResponse,
135
+ };
136
+ const response = await NotificationApi.postApi('alert-setting/set', body);
137
+ return response;
138
+ }
104
139
  }
105
140
 
106
141
  export class SdkReadWrite extends SdkRead {
@@ -0,0 +1,22 @@
1
+ import axios from 'axios';
2
+
3
+ const NOTIFICATION_API_END_POINT = 'https://api.aurigami.finance/notification/';
4
+
5
+ export async function getApi(url: string, params: Record<string, any> = {}): Promise<any> {
6
+ const resp = await axios.get(
7
+ NOTIFICATION_API_END_POINT + url + '?' + new URLSearchParams(params),
8
+ {
9
+ headers: { 'Content-Type': 'application/json' },
10
+ }
11
+ );
12
+
13
+ return resp.data;
14
+ }
15
+
16
+ export async function postApi(url: string, body: Record<string, any>): Promise<any> {
17
+ const resp = await axios.post(NOTIFICATION_API_END_POINT + url, body, {
18
+ headers: { 'Content-Type': 'application/json' },
19
+ });
20
+
21
+ return resp.data;
22
+ }
@@ -8,7 +8,7 @@ import {
8
8
  DECIMAL_PRECISION,
9
9
  HARDCODE_PRICE_TOKENS,
10
10
  networkAddresses,
11
- PRICE_WHITELISTED
11
+ PRICE_WHITELISTED,
12
12
  } from '../consts/constants';
13
13
  import { TokenAmount } from '../entities/tokenAmount';
14
14
  import { Address, TokenValuation } from '../types';
@@ -113,12 +113,12 @@ export class MiscRead extends BlockchainEntityRead {
113
113
  .div(userMarketDetails[i].underlyingPrice);
114
114
  userMarketDetails[i].maxWithdrawableAmount =
115
115
  userMarketDetails[i].isCollateral &&
116
- maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount())
116
+ maxWithdrawCap.lt(userMarketDetails[i].depositBalance.formattedAmount())
117
117
  ? new TokenAmount(moneyMarket.underlying, maxWithdrawCap.toFixed(24), false)
118
118
  : new TokenAmount(
119
- moneyMarket.underlying,
120
- userMarketDetails[i].depositBalance.rawAmount()
121
- );
119
+ moneyMarket.underlying,
120
+ userMarketDetails[i].depositBalance.rawAmount()
121
+ );
122
122
  }
123
123
 
124
124
  return {
@@ -258,7 +258,7 @@ export class MiscRead extends BlockchainEntityRead {
258
258
  }
259
259
 
260
260
  public async getUtilisation(userAddr: types.Address): Promise<BigNumber> {
261
- let accountDetail = await this.env.auriInternalLens.getAccountLiquidity(userAddr);
261
+ let accountDetail = await this.env.auriInternalLens.callStatic.getAccountLiquidityAccrueInterest(userAddr);
262
262
  let sumBorrow = new BigNumber(accountDetail.sumBorrowPlusEffects.toString());
263
263
  let sumCol = new BigNumber(accountDetail.sumCollateral.toString());
264
264
  return sumBorrow.dividedBy(sumCol);