@aurigami/sdk 1.9.4 → 1.9.6
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/entities/auriEnv.d.ts +3 -1
- package/dist/sdk.cjs.development.js +49 -37
- 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 +65 -53
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/entities/auriEnv.ts +12 -0
- package/src/interactors/MoneyMarket.ts +8 -4
package/package.json
CHANGED
package/src/entities/auriEnv.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
AuriLens,
|
|
6
6
|
Comptroller,
|
|
7
7
|
IERC20,
|
|
8
|
+
AuriOracle,
|
|
8
9
|
PULP,
|
|
9
10
|
ReferralDirectory,
|
|
10
11
|
} from '@aurigami/contracts/typechain';
|
|
@@ -23,6 +24,7 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
23
24
|
private _auriInternalLens: AuriInternalLens | null = null;
|
|
24
25
|
private _auriAirdrop: AuriAirdrop | null = null;
|
|
25
26
|
private _referralDirectory: ReferralDirectory | null = null;
|
|
27
|
+
private _oracle: AuriOracle | null = null;
|
|
26
28
|
|
|
27
29
|
public getContract<CType extends Contract>(address: string, abi: any) {
|
|
28
30
|
return new Contract(address, abi, this._networkConnection.provider) as CType;
|
|
@@ -112,4 +114,14 @@ export class AuriEnv extends BlockchainEntityRead {
|
|
|
112
114
|
}
|
|
113
115
|
return this._referralDirectory;
|
|
114
116
|
}
|
|
117
|
+
|
|
118
|
+
get oracle(): AuriOracle {
|
|
119
|
+
if (!this._oracle) {
|
|
120
|
+
this._oracle = this.getContract<AuriOracle>(
|
|
121
|
+
networkAddresses.misc.PRICE_ORACLE,
|
|
122
|
+
abis.AuriOracleABI.abi
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return this._oracle;
|
|
126
|
+
}
|
|
115
127
|
}
|
|
@@ -4,6 +4,7 @@ import BigNumber from 'bignumber.js';
|
|
|
4
4
|
import { BigNumber as BN, Contract } from 'ethers';
|
|
5
5
|
import * as abis from '../abis';
|
|
6
6
|
import * as consts from '../consts';
|
|
7
|
+
import { ONE_DAY } from '../consts';
|
|
7
8
|
import {
|
|
8
9
|
AuriEnv,
|
|
9
10
|
BlockchainEntity,
|
|
@@ -74,16 +75,19 @@ export class MoneyMarketRead extends BlockchainEntityRead {
|
|
|
74
75
|
|
|
75
76
|
public async getDepositAPY(): Promise<BigNumber> {
|
|
76
77
|
const supplyRatePerTimestamp = await this.auToken.supplyRatePerTimestamp();
|
|
77
|
-
|
|
78
|
-
.multipliedBy(
|
|
78
|
+
const supplyRatePerDay = new BigNumber(supplyRatePerTimestamp.toString())
|
|
79
|
+
.multipliedBy(ONE_DAY)
|
|
79
80
|
.div(helpers.decimalFactor(18));
|
|
81
|
+
|
|
82
|
+
return new BigNumber(supplyRatePerDay.plus(1)).pow(365).minus(1);
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
public async getBorrowAPY(): Promise<BigNumber> {
|
|
83
86
|
const borrowRatePerTimestamp = await this.auToken.borrowRatePerTimestamp();
|
|
84
|
-
|
|
85
|
-
.multipliedBy(
|
|
87
|
+
const borrowRatePerDay = new BigNumber(borrowRatePerTimestamp.toString())
|
|
88
|
+
.multipliedBy(ONE_DAY)
|
|
86
89
|
.div(helpers.decimalFactor(18));
|
|
90
|
+
return new BigNumber(borrowRatePerDay.plus(1)).pow(365).minus(1);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
public async getCollateralRatio(): Promise<BigNumber> {
|