@aurigami/sdk 1.12.7 → 1.12.9-hf
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/ChangeLog.md +371 -0
- package/dist/helpers/historicalPriceFetcher.d.ts +15 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/interactors/MoneyMarket.d.ts +2 -0
- package/dist/interactors/PlyGame.d.ts +1 -0
- package/dist/sdk.cjs.development.js +557 -95
- 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 +569 -113
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/consts/constants.ts +3 -0
- package/src/consts/decimals.ts +2 -0
- package/src/helpers/historicalPriceFetcher.ts +196 -0
- package/src/helpers/index.ts +1 -0
- package/src/interactors/MoneyMarket.ts +12 -0
- package/src/interactors/PlyGame.ts +10 -1
- package/src/interactors/misc.ts +8 -5
package/dist/sdk.esm.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { BigNumber as BigNumber$1, utils, Contract, ethers } from 'ethers';
|
|
3
3
|
import { Logger } from 'ethers/lib/utils';
|
|
4
|
-
import abis$
|
|
5
|
-
import abis$
|
|
6
|
-
import abis$
|
|
7
|
-
import abis$
|
|
8
|
-
import abis$
|
|
9
|
-
import
|
|
10
|
-
import abis
|
|
11
|
-
import abis$
|
|
12
|
-
import abis$
|
|
13
|
-
import abis$
|
|
14
|
-
import abis$
|
|
4
|
+
import abis$7 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
|
|
5
|
+
import abis$8 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
|
|
6
|
+
import abis$1 from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
|
|
7
|
+
import abis$2 from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
|
|
8
|
+
import abis$3 from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
9
|
+
import AuriOracleABI from '@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json';
|
|
10
|
+
import abis from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
|
|
11
|
+
import abis$4 from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
12
|
+
import abis$9 from '@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json';
|
|
13
|
+
import abis$5 from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
14
|
+
import abis$c from '@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json';
|
|
15
15
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
16
|
-
import abis$
|
|
17
|
-
import abis$
|
|
18
|
-
import abis$
|
|
19
|
-
import abis$
|
|
16
|
+
import abis$a from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
17
|
+
import abis$b from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
18
|
+
import abis$6 from '@aurigami/contracts/artifacts/contracts/ReferralDirectoryV2.sol/ReferralDirectoryV2.json';
|
|
19
|
+
import abis$d from '@aurigami/contracts/artifacts/contracts/plygame/PlyGame.sol/PlyGame.json';
|
|
20
20
|
import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
21
21
|
export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
22
22
|
export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
|
|
@@ -27,22 +27,22 @@ import { Signer } from '@ethersproject/abstract-signer';
|
|
|
27
27
|
|
|
28
28
|
var index = {
|
|
29
29
|
__proto__: null,
|
|
30
|
-
AuriOracleABI:
|
|
31
|
-
AuTokenABI: abis
|
|
30
|
+
AuriOracleABI: AuriOracleABI,
|
|
31
|
+
AuTokenABI: abis,
|
|
32
32
|
IUniswapV2PairABI: IUniswapV2PairABI,
|
|
33
|
-
AuriAirdropABI: abis$
|
|
34
|
-
AuriFairLaunchABI: abis$
|
|
35
|
-
AuriLensABI: abis$
|
|
36
|
-
ComptrollerABI: abis$
|
|
37
|
-
EIP20InterfaceABI: abis$
|
|
38
|
-
ReferralDirectoryV2ABI: abis$
|
|
39
|
-
AuErc20ABI: abis$
|
|
40
|
-
AuETHABI: abis$
|
|
41
|
-
EthRepayHelperABI: abis$
|
|
42
|
-
Multicall2ABI: abis$
|
|
43
|
-
PulpABI: abis$
|
|
44
|
-
AuriInternalLensABI: abis$
|
|
45
|
-
PlyGameABI: abis$
|
|
33
|
+
AuriAirdropABI: abis$1,
|
|
34
|
+
AuriFairLaunchABI: abis$2,
|
|
35
|
+
AuriLensABI: abis$3,
|
|
36
|
+
ComptrollerABI: abis$4,
|
|
37
|
+
EIP20InterfaceABI: abis$5,
|
|
38
|
+
ReferralDirectoryV2ABI: abis$6,
|
|
39
|
+
AuErc20ABI: abis$7,
|
|
40
|
+
AuETHABI: abis$8,
|
|
41
|
+
EthRepayHelperABI: abis$9,
|
|
42
|
+
Multicall2ABI: abis$a,
|
|
43
|
+
PulpABI: abis$b,
|
|
44
|
+
AuriInternalLensABI: abis$c,
|
|
45
|
+
PlyGameABI: abis$d
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
|
|
@@ -124,7 +124,10 @@ var networkAddresses = {
|
|
|
124
124
|
META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLowerCase(),
|
|
125
125
|
PULP: /*#__PURE__*/MAINNET_ADDRESSES.PULP.toLowerCase(),
|
|
126
126
|
PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
|
|
127
|
-
USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
|
|
127
|
+
USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase(),
|
|
128
|
+
PLY_WNEAR: /*#__PURE__*/'0x044b6b0cd3bb13d2b9057781df4459c66781dce7'.toLowerCase(),
|
|
129
|
+
WNEAR_TRI: /*#__PURE__*/'0x84b123875f0f36b966d0b6ca14b31121bd9676ad'.toLowerCase(),
|
|
130
|
+
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
|
|
128
131
|
}
|
|
129
132
|
};
|
|
130
133
|
var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.STNEAR.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.AURORA.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.TRI.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.PLY.toLowerCase(), /*#__PURE__*/MAINNET_ADDRESSES.auTokens.USN.toLowerCase()]; // All token that we can calculate the price via oracle + coingecko
|
|
@@ -212,7 +215,9 @@ var decimalRecords = {
|
|
|
212
215
|
'0xc21ff01229e982d7c8b8691163b0a3cb8f357453': 24,
|
|
213
216
|
'0x04ac48711bcdc45b4d223fb021e09da73c71095e': 18,
|
|
214
217
|
'0x044b6b0cd3bb13d2b9057781df4459c66781dce7': 18,
|
|
215
|
-
'0x5183e1b1091804bc2602586919e6880ac1cf2896': 18
|
|
218
|
+
'0x5183e1b1091804bc2602586919e6880ac1cf2896': 18,
|
|
219
|
+
'0x84b123875f0f36b966d0b6ca14b31121bd9676ad': 18,
|
|
220
|
+
'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008': 18
|
|
216
221
|
};
|
|
217
222
|
|
|
218
223
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1588,7 +1593,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1588
1593
|
var _this2 = this;
|
|
1589
1594
|
|
|
1590
1595
|
return networkAddresses.auTokens.map(function (auToken) {
|
|
1591
|
-
var contract = _this2.getContract(auToken.address, abis
|
|
1596
|
+
var contract = _this2.getContract(auToken.address, abis.abi);
|
|
1592
1597
|
|
|
1593
1598
|
contract.underlying = auToken.underlying;
|
|
1594
1599
|
return contract;
|
|
@@ -1616,14 +1621,14 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1616
1621
|
assert(address !== undefined, "AuToken with underlying " + underlyingName + " not found");
|
|
1617
1622
|
}
|
|
1618
1623
|
|
|
1619
|
-
return this.getContract(address, abis$
|
|
1624
|
+
return this.getContract(address, abis$7.abi);
|
|
1620
1625
|
};
|
|
1621
1626
|
|
|
1622
1627
|
_createClass(AuriEnv, [{
|
|
1623
1628
|
key: "comptroller",
|
|
1624
1629
|
get: function get() {
|
|
1625
1630
|
if (!this._comptroller) {
|
|
1626
|
-
this._comptroller = this.getContract(networkAddresses.misc.COMPTROLLER, abis$
|
|
1631
|
+
this._comptroller = this.getContract(networkAddresses.misc.COMPTROLLER, abis$4.abi);
|
|
1627
1632
|
}
|
|
1628
1633
|
|
|
1629
1634
|
return this._comptroller;
|
|
@@ -1632,7 +1637,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1632
1637
|
key: "auriFairLaunch",
|
|
1633
1638
|
get: function get() {
|
|
1634
1639
|
if (!this._auriFairLaunch) {
|
|
1635
|
-
this._auriFairLaunch = this.getContract(networkAddresses.misc.AURIFAIRLAUNCH, abis$
|
|
1640
|
+
this._auriFairLaunch = this.getContract(networkAddresses.misc.AURIFAIRLAUNCH, abis$2.abi);
|
|
1636
1641
|
}
|
|
1637
1642
|
|
|
1638
1643
|
return this._auriFairLaunch;
|
|
@@ -1641,7 +1646,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1641
1646
|
key: "auriLens",
|
|
1642
1647
|
get: function get() {
|
|
1643
1648
|
if (!this._auriLens) {
|
|
1644
|
-
this._auriLens = this.getContract(networkAddresses.misc.AURILENS, abis$
|
|
1649
|
+
this._auriLens = this.getContract(networkAddresses.misc.AURILENS, abis$3.abi);
|
|
1645
1650
|
}
|
|
1646
1651
|
|
|
1647
1652
|
return this._auriLens;
|
|
@@ -1650,7 +1655,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1650
1655
|
key: "ply",
|
|
1651
1656
|
get: function get() {
|
|
1652
1657
|
if (!this._ply) {
|
|
1653
|
-
this._ply = this.getContract(networkAddresses.tokens.PLY, abis$
|
|
1658
|
+
this._ply = this.getContract(networkAddresses.tokens.PLY, abis$5.abi);
|
|
1654
1659
|
}
|
|
1655
1660
|
|
|
1656
1661
|
return this._ply;
|
|
@@ -1659,7 +1664,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1659
1664
|
key: "pulp",
|
|
1660
1665
|
get: function get() {
|
|
1661
1666
|
if (!this._pulp) {
|
|
1662
|
-
this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$
|
|
1667
|
+
this._pulp = this.getContract(networkAddresses.tokens.PULP, abis$b.abi);
|
|
1663
1668
|
}
|
|
1664
1669
|
|
|
1665
1670
|
return this._pulp;
|
|
@@ -1668,7 +1673,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1668
1673
|
key: "auriInternalLens",
|
|
1669
1674
|
get: function get() {
|
|
1670
1675
|
if (!this._auriInternalLens) {
|
|
1671
|
-
this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$
|
|
1676
|
+
this._auriInternalLens = this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$c.abi);
|
|
1672
1677
|
}
|
|
1673
1678
|
|
|
1674
1679
|
return this._auriInternalLens;
|
|
@@ -1677,7 +1682,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1677
1682
|
key: "auriAirdrop",
|
|
1678
1683
|
get: function get() {
|
|
1679
1684
|
if (!this._auriAirdrop) {
|
|
1680
|
-
this._auriAirdrop = this.getContract(networkAddresses.misc.AURI_AIRDROP, abis$
|
|
1685
|
+
this._auriAirdrop = this.getContract(networkAddresses.misc.AURI_AIRDROP, abis$1.abi);
|
|
1681
1686
|
}
|
|
1682
1687
|
|
|
1683
1688
|
return this._auriAirdrop;
|
|
@@ -1686,7 +1691,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1686
1691
|
key: "referralDirectoryV2",
|
|
1687
1692
|
get: function get() {
|
|
1688
1693
|
if (!this._referralDirectoryV2) {
|
|
1689
|
-
this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$
|
|
1694
|
+
this._referralDirectoryV2 = this.getContract(networkAddresses.misc.REFERRAL_V2, abis$6.abi);
|
|
1690
1695
|
}
|
|
1691
1696
|
|
|
1692
1697
|
return this._referralDirectoryV2;
|
|
@@ -1695,7 +1700,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1695
1700
|
key: "oracle",
|
|
1696
1701
|
get: function get() {
|
|
1697
1702
|
if (!this._oracle) {
|
|
1698
|
-
this._oracle = this.getContract(networkAddresses.misc.oracle,
|
|
1703
|
+
this._oracle = this.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
|
|
1699
1704
|
}
|
|
1700
1705
|
|
|
1701
1706
|
return this._oracle;
|
|
@@ -1704,7 +1709,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1704
1709
|
key: "plygame",
|
|
1705
1710
|
get: function get() {
|
|
1706
1711
|
if (!this._plygame) {
|
|
1707
|
-
this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$
|
|
1712
|
+
this._plygame = this.getContract(networkAddresses.misc.PLYGAME, abis$d.abi);
|
|
1708
1713
|
}
|
|
1709
1714
|
|
|
1710
1715
|
return this._plygame;
|
|
@@ -2227,7 +2232,7 @@ function _fetchPriceFromOracle() {
|
|
|
2227
2232
|
while (1) {
|
|
2228
2233
|
switch (_context9.prev = _context9.next) {
|
|
2229
2234
|
case 0:
|
|
2230
|
-
oracleContract = new Contract(networkAddresses.misc.oracle,
|
|
2235
|
+
oracleContract = new Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
|
|
2231
2236
|
_context9.next = 3;
|
|
2232
2237
|
return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
|
|
2233
2238
|
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
@@ -2277,7 +2282,7 @@ function _fetchUnderlyingTokensPrices() {
|
|
|
2277
2282
|
while (1) {
|
|
2278
2283
|
switch (_context10.prev = _context10.next) {
|
|
2279
2284
|
case 0:
|
|
2280
|
-
auriLens = new Contract(networkAddresses.misc.AURILENS, abis$
|
|
2285
|
+
auriLens = new Contract(networkAddresses.misc.AURILENS, abis$3.abi, provider);
|
|
2281
2286
|
auTokenAddresses = networkAddresses.auTokens.map(function (auToken) {
|
|
2282
2287
|
return auToken.address;
|
|
2283
2288
|
});
|
|
@@ -2593,7 +2598,7 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2593
2598
|
var _this;
|
|
2594
2599
|
|
|
2595
2600
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2596
|
-
_this.auToken = new Contract(tokenAddr, abis
|
|
2601
|
+
_this.auToken = new Contract(tokenAddr, abis.abi, _this._networkConnection.provider);
|
|
2597
2602
|
return _this;
|
|
2598
2603
|
}
|
|
2599
2604
|
/**
|
|
@@ -2687,6 +2692,351 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2687
2692
|
return TransferEventQuery;
|
|
2688
2693
|
}(BlockchainEntityRead);
|
|
2689
2694
|
|
|
2695
|
+
function fetchHistoricalLPPositions(_x, _x2, _x3) {
|
|
2696
|
+
return _fetchHistoricalLPPositions.apply(this, arguments);
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
function _fetchHistoricalLPPositions() {
|
|
2700
|
+
_fetchHistoricalLPPositions = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(LPAddress, provider, block) {
|
|
2701
|
+
var LPContract, promises, values;
|
|
2702
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
2703
|
+
while (1) {
|
|
2704
|
+
switch (_context.prev = _context.next) {
|
|
2705
|
+
case 0:
|
|
2706
|
+
LPContract = new Contract(LPAddress, IUniswapV2PairABI.abi, provider);
|
|
2707
|
+
promises = [];
|
|
2708
|
+
promises.push(LPContract.token0());
|
|
2709
|
+
promises.push(LPContract.token1());
|
|
2710
|
+
promises.push(LPContract.getReserves({
|
|
2711
|
+
blockTag: block
|
|
2712
|
+
}));
|
|
2713
|
+
promises.push(LPContract.totalSupply({
|
|
2714
|
+
blockTag: block
|
|
2715
|
+
}));
|
|
2716
|
+
_context.next = 8;
|
|
2717
|
+
return Promise.all(promises);
|
|
2718
|
+
|
|
2719
|
+
case 8:
|
|
2720
|
+
values = _context.sent;
|
|
2721
|
+
return _context.abrupt("return", {
|
|
2722
|
+
token0: values[0],
|
|
2723
|
+
token1: values[1],
|
|
2724
|
+
reserve0: values[2].reserve0,
|
|
2725
|
+
reserve1: values[2].reserve1,
|
|
2726
|
+
totalSupply: values[3]
|
|
2727
|
+
});
|
|
2728
|
+
|
|
2729
|
+
case 10:
|
|
2730
|
+
case "end":
|
|
2731
|
+
return _context.stop();
|
|
2732
|
+
}
|
|
2733
|
+
}
|
|
2734
|
+
}, _callee);
|
|
2735
|
+
}));
|
|
2736
|
+
return _fetchHistoricalLPPositions.apply(this, arguments);
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
function fetchHistoricalLPPrice(_x4, _x5, _x6) {
|
|
2740
|
+
return _fetchHistoricalLPPrice.apply(this, arguments);
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
function _fetchHistoricalLPPrice() {
|
|
2744
|
+
_fetchHistoricalLPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(address, provider, block) {
|
|
2745
|
+
var LPInfo, LPDecimal, fetchLPPriceBy, _fetchLPPriceBy, lpPrice;
|
|
2746
|
+
|
|
2747
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2748
|
+
while (1) {
|
|
2749
|
+
switch (_context3.prev = _context3.next) {
|
|
2750
|
+
case 0:
|
|
2751
|
+
_fetchLPPriceBy = function _fetchLPPriceBy3() {
|
|
2752
|
+
_fetchLPPriceBy = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(tokenReverse, block) {
|
|
2753
|
+
var tokenPrice, tokenDecimal, reserveUSD;
|
|
2754
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
2755
|
+
while (1) {
|
|
2756
|
+
switch (_context2.prev = _context2.next) {
|
|
2757
|
+
case 0:
|
|
2758
|
+
if (!tokenReverse.reserve.isZero()) {
|
|
2759
|
+
_context2.next = 2;
|
|
2760
|
+
break;
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
return _context2.abrupt("return", new BigNumber(0));
|
|
2764
|
+
|
|
2765
|
+
case 2:
|
|
2766
|
+
_context2.next = 4;
|
|
2767
|
+
return fetchHistoricalPrice(tokenReverse.address, provider, block);
|
|
2768
|
+
|
|
2769
|
+
case 4:
|
|
2770
|
+
tokenPrice = _context2.sent;
|
|
2771
|
+
tokenDecimal = getDecimal(tokenReverse.address); // reserveUSD will be divided by 10^tokenDecimal later for more precision
|
|
2772
|
+
|
|
2773
|
+
reserveUSD = tokenPrice.multipliedBy(tokenReverse.reserve.toString()).multipliedBy(2);
|
|
2774
|
+
return _context2.abrupt("return", reserveUSD.multipliedBy(decimalFactor(LPDecimal)).dividedBy(new BigNumber(LPInfo.totalSupply.toString())).dividedBy(decimalFactor(tokenDecimal)));
|
|
2775
|
+
|
|
2776
|
+
case 8:
|
|
2777
|
+
case "end":
|
|
2778
|
+
return _context2.stop();
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
}, _callee2);
|
|
2782
|
+
}));
|
|
2783
|
+
return _fetchLPPriceBy.apply(this, arguments);
|
|
2784
|
+
};
|
|
2785
|
+
|
|
2786
|
+
fetchLPPriceBy = function _fetchLPPriceBy2(_x19, _x20) {
|
|
2787
|
+
return _fetchLPPriceBy.apply(this, arguments);
|
|
2788
|
+
};
|
|
2789
|
+
|
|
2790
|
+
_context3.next = 4;
|
|
2791
|
+
return fetchHistoricalLPPositions(address, provider, block);
|
|
2792
|
+
|
|
2793
|
+
case 4:
|
|
2794
|
+
LPInfo = _context3.sent;
|
|
2795
|
+
LPDecimal = getDecimal(address);
|
|
2796
|
+
_context3.prev = 6;
|
|
2797
|
+
_context3.next = 9;
|
|
2798
|
+
return fetchLPPriceBy({
|
|
2799
|
+
address: LPInfo.token0,
|
|
2800
|
+
reserve: LPInfo.reserve0
|
|
2801
|
+
}, block);
|
|
2802
|
+
|
|
2803
|
+
case 9:
|
|
2804
|
+
lpPrice = _context3.sent;
|
|
2805
|
+
|
|
2806
|
+
if (!lpPrice.isZero()) {
|
|
2807
|
+
_context3.next = 12;
|
|
2808
|
+
break;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
throw Error("Price is zero");
|
|
2812
|
+
|
|
2813
|
+
case 12:
|
|
2814
|
+
return _context3.abrupt("return", lpPrice);
|
|
2815
|
+
|
|
2816
|
+
case 15:
|
|
2817
|
+
_context3.prev = 15;
|
|
2818
|
+
_context3.t0 = _context3["catch"](6);
|
|
2819
|
+
devLog("fetchLPPriceBy " + LPInfo.token0 + " failed", _context3.t0);
|
|
2820
|
+
_context3.prev = 18;
|
|
2821
|
+
_context3.next = 21;
|
|
2822
|
+
return fetchLPPriceBy({
|
|
2823
|
+
address: LPInfo.token1,
|
|
2824
|
+
reserve: LPInfo.reserve1
|
|
2825
|
+
}, block);
|
|
2826
|
+
|
|
2827
|
+
case 21:
|
|
2828
|
+
return _context3.abrupt("return", _context3.sent);
|
|
2829
|
+
|
|
2830
|
+
case 24:
|
|
2831
|
+
_context3.prev = 24;
|
|
2832
|
+
_context3.t1 = _context3["catch"](18);
|
|
2833
|
+
devLog("fetchLPPriceBy " + LPInfo.token1 + " failed", _context3.t1);
|
|
2834
|
+
throw Error("Unable to fetch price for both tokens of LP " + address);
|
|
2835
|
+
|
|
2836
|
+
case 28:
|
|
2837
|
+
case "end":
|
|
2838
|
+
return _context3.stop();
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}, _callee3, null, [[6, 15], [18, 24]]);
|
|
2842
|
+
}));
|
|
2843
|
+
return _fetchHistoricalLPPrice.apply(this, arguments);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
function processPriceFromOracle$1(rawPrice, underlyingDecimal) {
|
|
2847
|
+
return new BigNumber(rawPrice.toString()).div(decimalFactor(36 - underlyingDecimal));
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
function fetchHistoricalPriceFromOracle(_x7, _x8, _x9, _x10) {
|
|
2851
|
+
return _fetchHistoricalPriceFromOracle.apply(this, arguments);
|
|
2852
|
+
}
|
|
2853
|
+
|
|
2854
|
+
function _fetchHistoricalPriceFromOracle() {
|
|
2855
|
+
_fetchHistoricalPriceFromOracle = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(auTokenAddress, underlyingDecimal, provider, block) {
|
|
2856
|
+
var oracleContract, rawPrice;
|
|
2857
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2858
|
+
while (1) {
|
|
2859
|
+
switch (_context4.prev = _context4.next) {
|
|
2860
|
+
case 0:
|
|
2861
|
+
oracleContract = new Contract(networkAddresses.misc.oracle, AuriOracleABI.abi, provider);
|
|
2862
|
+
_context4.next = 3;
|
|
2863
|
+
return oracleContract.getUnderlyingPrice(auTokenAddress, {
|
|
2864
|
+
blockTag: block
|
|
2865
|
+
})["catch"](function (e) {
|
|
2866
|
+
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
2867
|
+
return BigNumber$1.from(0);
|
|
2868
|
+
});
|
|
2869
|
+
|
|
2870
|
+
case 3:
|
|
2871
|
+
rawPrice = _context4.sent;
|
|
2872
|
+
return _context4.abrupt("return", processPriceFromOracle$1(rawPrice, underlyingDecimal));
|
|
2873
|
+
|
|
2874
|
+
case 5:
|
|
2875
|
+
case "end":
|
|
2876
|
+
return _context4.stop();
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}, _callee4);
|
|
2880
|
+
}));
|
|
2881
|
+
return _fetchHistoricalPriceFromOracle.apply(this, arguments);
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
function fetchHistoricalPrice(_x11, _x12, _x13) {
|
|
2885
|
+
return _fetchHistoricalPrice.apply(this, arguments);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
function _fetchHistoricalPrice() {
|
|
2889
|
+
_fetchHistoricalPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(address, provider, block) {
|
|
2890
|
+
var matchingAuToken;
|
|
2891
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2892
|
+
while (1) {
|
|
2893
|
+
switch (_context5.prev = _context5.next) {
|
|
2894
|
+
case 0:
|
|
2895
|
+
if (!(address.toLowerCase() in HARDCODE_PRICE_TOKENS)) {
|
|
2896
|
+
_context5.next = 4;
|
|
2897
|
+
break;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
return _context5.abrupt("return", new BigNumber(HARDCODE_PRICE_TOKENS[address.toLowerCase()]));
|
|
2901
|
+
|
|
2902
|
+
case 4:
|
|
2903
|
+
if (!(isSameAddress(address, networkAddresses.tokens.PLY_WNEAR) || isSameAddress(address, networkAddresses.tokens.WNEAR_TRI) || isSameAddress(address, networkAddresses.tokens.AURORA_WNEAR))) {
|
|
2904
|
+
_context5.next = 8;
|
|
2905
|
+
break;
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
return _context5.abrupt("return", fetchHistoricalLPPrice(address, provider, block));
|
|
2909
|
+
|
|
2910
|
+
case 8:
|
|
2911
|
+
if (!isSameAddress(address, networkAddresses.tokens.PLY)) {
|
|
2912
|
+
_context5.next = 12;
|
|
2913
|
+
break;
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.PLY_WNEAR, provider, block));
|
|
2917
|
+
|
|
2918
|
+
case 12:
|
|
2919
|
+
if (!isSameAddress(address, networkAddresses.tokens.TRI)) {
|
|
2920
|
+
_context5.next = 16;
|
|
2921
|
+
break;
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.WNEAR_TRI, provider, block, 1));
|
|
2925
|
+
|
|
2926
|
+
case 16:
|
|
2927
|
+
if (!isSameAddress(address, networkAddresses.tokens.AURORA)) {
|
|
2928
|
+
_context5.next = 18;
|
|
2929
|
+
break;
|
|
2930
|
+
}
|
|
2931
|
+
|
|
2932
|
+
return _context5.abrupt("return", fetchHistoricalPriceByLP(networkAddresses.tokens.AURORA_WNEAR, provider, block));
|
|
2933
|
+
|
|
2934
|
+
case 18:
|
|
2935
|
+
matchingAuToken = networkAddresses.auTokens.find(function (auToken) {
|
|
2936
|
+
return isSameAddress(auToken.underlying, address);
|
|
2937
|
+
});
|
|
2938
|
+
|
|
2939
|
+
if (!(matchingAuToken !== undefined)) {
|
|
2940
|
+
_context5.next = 23;
|
|
2941
|
+
break;
|
|
2942
|
+
}
|
|
2943
|
+
|
|
2944
|
+
return _context5.abrupt("return", fetchHistoricalPriceFromOracle(matchingAuToken.address, getDecimal(address), provider, block));
|
|
2945
|
+
|
|
2946
|
+
case 23:
|
|
2947
|
+
throw Error("Unable to fetch price for " + address);
|
|
2948
|
+
|
|
2949
|
+
case 24:
|
|
2950
|
+
case "end":
|
|
2951
|
+
return _context5.stop();
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
}, _callee5);
|
|
2955
|
+
}));
|
|
2956
|
+
return _fetchHistoricalPrice.apply(this, arguments);
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
function fetchHistoricalPULPPrice(_x14) {
|
|
2960
|
+
return _fetchHistoricalPULPPrice.apply(this, arguments);
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
function _fetchHistoricalPULPPrice() {
|
|
2964
|
+
_fetchHistoricalPULPPrice = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(provider) {
|
|
2965
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2966
|
+
while (1) {
|
|
2967
|
+
switch (_context6.prev = _context6.next) {
|
|
2968
|
+
case 0:
|
|
2969
|
+
return _context6.abrupt("return", new BigNumber(0));
|
|
2970
|
+
|
|
2971
|
+
case 1:
|
|
2972
|
+
case "end":
|
|
2973
|
+
return _context6.stop();
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
}, _callee6);
|
|
2977
|
+
}));
|
|
2978
|
+
return _fetchHistoricalPULPPrice.apply(this, arguments);
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2981
|
+
function fetchHistoricalPriceByLP(_x15, _x16, _x17, _x18) {
|
|
2982
|
+
return _fetchHistoricalPriceByLP.apply(this, arguments);
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
function _fetchHistoricalPriceByLP() {
|
|
2986
|
+
_fetchHistoricalPriceByLP = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(LP, provider, block, tokenNumber) {
|
|
2987
|
+
var LPInfo, token0Decimal, token1Decimal;
|
|
2988
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2989
|
+
while (1) {
|
|
2990
|
+
switch (_context7.prev = _context7.next) {
|
|
2991
|
+
case 0:
|
|
2992
|
+
if (tokenNumber === void 0) {
|
|
2993
|
+
tokenNumber = 0;
|
|
2994
|
+
}
|
|
2995
|
+
|
|
2996
|
+
_context7.next = 3;
|
|
2997
|
+
return fetchHistoricalLPPositions(LP, provider, block);
|
|
2998
|
+
|
|
2999
|
+
case 3:
|
|
3000
|
+
LPInfo = _context7.sent;
|
|
3001
|
+
|
|
3002
|
+
if (tokenNumber === 1) {
|
|
3003
|
+
LPInfo = {
|
|
3004
|
+
token0: LPInfo.token1,
|
|
3005
|
+
token1: LPInfo.token0,
|
|
3006
|
+
reserve0: LPInfo.reserve1,
|
|
3007
|
+
reserve1: LPInfo.reserve0,
|
|
3008
|
+
totalSupply: LPInfo.totalSupply
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
|
|
3012
|
+
if (!LPInfo.reserve1.isZero()) {
|
|
3013
|
+
_context7.next = 7;
|
|
3014
|
+
break;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
return _context7.abrupt("return", new BigNumber(0));
|
|
3018
|
+
|
|
3019
|
+
case 7:
|
|
3020
|
+
token0Decimal = getDecimal(LPInfo.token0);
|
|
3021
|
+
token1Decimal = getDecimal(LPInfo.token1); // (token0Price * reserve0) / 10^decimal0 = (token1Price * reserve1) / 10^decimal1
|
|
3022
|
+
// token0Price = (token1Price * reserve1) * 10^decimal0 / 10^decimal1 / reserve0
|
|
3023
|
+
|
|
3024
|
+
_context7.next = 11;
|
|
3025
|
+
return fetchHistoricalPrice(LPInfo.token1, provider, block);
|
|
3026
|
+
|
|
3027
|
+
case 11:
|
|
3028
|
+
return _context7.abrupt("return", _context7.sent.multipliedBy(LPInfo.reserve1.toString()).multipliedBy(decimalFactor(token0Decimal)).dividedBy(decimalFactor(token1Decimal)).dividedBy(LPInfo.reserve0.toString()));
|
|
3029
|
+
|
|
3030
|
+
case 12:
|
|
3031
|
+
case "end":
|
|
3032
|
+
return _context7.stop();
|
|
3033
|
+
}
|
|
3034
|
+
}
|
|
3035
|
+
}, _callee7);
|
|
3036
|
+
}));
|
|
3037
|
+
return _fetchHistoricalPriceByLP.apply(this, arguments);
|
|
3038
|
+
}
|
|
3039
|
+
|
|
2690
3040
|
|
|
2691
3041
|
|
|
2692
3042
|
var helpers = {
|
|
@@ -2728,7 +3078,13 @@ var helpers = {
|
|
|
2728
3078
|
fetchValuation: fetchValuation,
|
|
2729
3079
|
calcValuation: calcValuation,
|
|
2730
3080
|
valuateToken: valuateToken,
|
|
2731
|
-
TransferEventQuery: TransferEventQuery
|
|
3081
|
+
TransferEventQuery: TransferEventQuery,
|
|
3082
|
+
fetchHistoricalLPPositions: fetchHistoricalLPPositions,
|
|
3083
|
+
fetchHistoricalLPPrice: fetchHistoricalLPPrice,
|
|
3084
|
+
fetchHistoricalPriceFromOracle: fetchHistoricalPriceFromOracle,
|
|
3085
|
+
fetchHistoricalPrice: fetchHistoricalPrice,
|
|
3086
|
+
fetchHistoricalPULPPrice: fetchHistoricalPULPPrice,
|
|
3087
|
+
fetchHistoricalPriceByLP: fetchHistoricalPriceByLP
|
|
2732
3088
|
};
|
|
2733
3089
|
|
|
2734
3090
|
var AirdropRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
@@ -2909,9 +3265,9 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2909
3265
|
_this.env = new AuriEnv(networkConnection);
|
|
2910
3266
|
|
|
2911
3267
|
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2912
|
-
_this.auToken = new Contract(auToken, abis$9.abi, networkConnection.provider);
|
|
2913
|
-
} else {
|
|
2914
3268
|
_this.auToken = new Contract(auToken, abis$8.abi, networkConnection.provider);
|
|
3269
|
+
} else {
|
|
3270
|
+
_this.auToken = new Contract(auToken, abis$7.abi, networkConnection.provider);
|
|
2915
3271
|
}
|
|
2916
3272
|
|
|
2917
3273
|
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
@@ -3381,6 +3737,66 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3381
3737
|
}
|
|
3382
3738
|
};
|
|
3383
3739
|
|
|
3740
|
+
_proto.mintCap = /*#__PURE__*/function () {
|
|
3741
|
+
var _mintCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee12() {
|
|
3742
|
+
return runtime_1.wrap(function _callee12$(_context12) {
|
|
3743
|
+
while (1) {
|
|
3744
|
+
switch (_context12.prev = _context12.next) {
|
|
3745
|
+
case 0:
|
|
3746
|
+
_context12.t0 = TokenAmount;
|
|
3747
|
+
_context12.t1 = this.underlying;
|
|
3748
|
+
_context12.next = 4;
|
|
3749
|
+
return this.env.comptroller.mintCaps(this.auToken.address);
|
|
3750
|
+
|
|
3751
|
+
case 4:
|
|
3752
|
+
_context12.t2 = _context12.sent.toString();
|
|
3753
|
+
return _context12.abrupt("return", new _context12.t0(_context12.t1, _context12.t2));
|
|
3754
|
+
|
|
3755
|
+
case 6:
|
|
3756
|
+
case "end":
|
|
3757
|
+
return _context12.stop();
|
|
3758
|
+
}
|
|
3759
|
+
}
|
|
3760
|
+
}, _callee12, this);
|
|
3761
|
+
}));
|
|
3762
|
+
|
|
3763
|
+
function mintCap() {
|
|
3764
|
+
return _mintCap.apply(this, arguments);
|
|
3765
|
+
}
|
|
3766
|
+
|
|
3767
|
+
return mintCap;
|
|
3768
|
+
}();
|
|
3769
|
+
|
|
3770
|
+
_proto.borrowCap = /*#__PURE__*/function () {
|
|
3771
|
+
var _borrowCap = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee13() {
|
|
3772
|
+
return runtime_1.wrap(function _callee13$(_context13) {
|
|
3773
|
+
while (1) {
|
|
3774
|
+
switch (_context13.prev = _context13.next) {
|
|
3775
|
+
case 0:
|
|
3776
|
+
_context13.t0 = TokenAmount;
|
|
3777
|
+
_context13.t1 = this.underlying;
|
|
3778
|
+
_context13.next = 4;
|
|
3779
|
+
return this.env.comptroller.borrowCaps(this.auToken.address);
|
|
3780
|
+
|
|
3781
|
+
case 4:
|
|
3782
|
+
_context13.t2 = _context13.sent.toString();
|
|
3783
|
+
return _context13.abrupt("return", new _context13.t0(_context13.t1, _context13.t2));
|
|
3784
|
+
|
|
3785
|
+
case 6:
|
|
3786
|
+
case "end":
|
|
3787
|
+
return _context13.stop();
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
}, _callee13, this);
|
|
3791
|
+
}));
|
|
3792
|
+
|
|
3793
|
+
function borrowCap() {
|
|
3794
|
+
return _borrowCap.apply(this, arguments);
|
|
3795
|
+
}
|
|
3796
|
+
|
|
3797
|
+
return borrowCap;
|
|
3798
|
+
}();
|
|
3799
|
+
|
|
3384
3800
|
return MoneyMarketRead;
|
|
3385
3801
|
}(BlockchainEntityRead);
|
|
3386
3802
|
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
@@ -3390,36 +3806,36 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3390
3806
|
var _this3;
|
|
3391
3807
|
|
|
3392
3808
|
_this3 = _MoneyMarketRead.call(this, networkConnection, auToken, underlyingAsset) || this;
|
|
3393
|
-
_this3._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, abis$
|
|
3809
|
+
_this3._EthRepayHelper = new Contract(networkAddresses.misc.ETHREPAYHELPER, abis$9.abi, networkConnection.provider);
|
|
3394
3810
|
return _this3;
|
|
3395
3811
|
}
|
|
3396
3812
|
|
|
3397
3813
|
var _proto2 = MoneyMarketReadWrite.prototype;
|
|
3398
3814
|
|
|
3399
3815
|
_proto2.deposit = /*#__PURE__*/function () {
|
|
3400
|
-
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3401
|
-
return runtime_1.wrap(function
|
|
3816
|
+
var _deposit = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee14(amount) {
|
|
3817
|
+
return runtime_1.wrap(function _callee14$(_context14) {
|
|
3402
3818
|
while (1) {
|
|
3403
|
-
switch (
|
|
3819
|
+
switch (_context14.prev = _context14.next) {
|
|
3404
3820
|
case 0:
|
|
3405
3821
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
3406
|
-
|
|
3822
|
+
_context14.next = 4;
|
|
3407
3823
|
break;
|
|
3408
3824
|
}
|
|
3409
3825
|
|
|
3410
|
-
return
|
|
3826
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint({
|
|
3411
3827
|
value: amount.rawAmount()
|
|
3412
3828
|
}));
|
|
3413
3829
|
|
|
3414
3830
|
case 4:
|
|
3415
|
-
return
|
|
3831
|
+
return _context14.abrupt("return", this.auToken.connect(this._networkConnection.signer).mint(amount.rawAmount()));
|
|
3416
3832
|
|
|
3417
3833
|
case 5:
|
|
3418
3834
|
case "end":
|
|
3419
|
-
return
|
|
3835
|
+
return _context14.stop();
|
|
3420
3836
|
}
|
|
3421
3837
|
}
|
|
3422
|
-
},
|
|
3838
|
+
}, _callee14, this);
|
|
3423
3839
|
}));
|
|
3424
3840
|
|
|
3425
3841
|
function deposit(_x3) {
|
|
@@ -3430,19 +3846,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3430
3846
|
}();
|
|
3431
3847
|
|
|
3432
3848
|
_proto2.borrow = /*#__PURE__*/function () {
|
|
3433
|
-
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3434
|
-
return runtime_1.wrap(function
|
|
3849
|
+
var _borrow = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee15(amount) {
|
|
3850
|
+
return runtime_1.wrap(function _callee15$(_context15) {
|
|
3435
3851
|
while (1) {
|
|
3436
|
-
switch (
|
|
3852
|
+
switch (_context15.prev = _context15.next) {
|
|
3437
3853
|
case 0:
|
|
3438
|
-
return
|
|
3854
|
+
return _context15.abrupt("return", this.auToken.connect(this._networkConnection.signer).borrow(amount.rawAmount()));
|
|
3439
3855
|
|
|
3440
3856
|
case 1:
|
|
3441
3857
|
case "end":
|
|
3442
|
-
return
|
|
3858
|
+
return _context15.stop();
|
|
3443
3859
|
}
|
|
3444
3860
|
}
|
|
3445
|
-
},
|
|
3861
|
+
}, _callee15, this);
|
|
3446
3862
|
}));
|
|
3447
3863
|
|
|
3448
3864
|
function borrow(_x4) {
|
|
@@ -3453,27 +3869,27 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3453
3869
|
}();
|
|
3454
3870
|
|
|
3455
3871
|
_proto2.withdraw = /*#__PURE__*/function () {
|
|
3456
|
-
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3457
|
-
return runtime_1.wrap(function
|
|
3872
|
+
var _withdraw = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee16(amount) {
|
|
3873
|
+
return runtime_1.wrap(function _callee16$(_context16) {
|
|
3458
3874
|
while (1) {
|
|
3459
|
-
switch (
|
|
3875
|
+
switch (_context16.prev = _context16.next) {
|
|
3460
3876
|
case 0:
|
|
3461
3877
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
3462
|
-
|
|
3878
|
+
_context16.next = 2;
|
|
3463
3879
|
break;
|
|
3464
3880
|
}
|
|
3465
3881
|
|
|
3466
|
-
return
|
|
3882
|
+
return _context16.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(INF));
|
|
3467
3883
|
|
|
3468
3884
|
case 2:
|
|
3469
|
-
return
|
|
3885
|
+
return _context16.abrupt("return", this.auToken.connect(this._networkConnection.signer).redeemUnderlying(amount.rawAmount()));
|
|
3470
3886
|
|
|
3471
3887
|
case 3:
|
|
3472
3888
|
case "end":
|
|
3473
|
-
return
|
|
3889
|
+
return _context16.stop();
|
|
3474
3890
|
}
|
|
3475
3891
|
}
|
|
3476
|
-
},
|
|
3892
|
+
}, _callee16, this);
|
|
3477
3893
|
}));
|
|
3478
3894
|
|
|
3479
3895
|
function withdraw(_x5) {
|
|
@@ -3484,37 +3900,37 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3484
3900
|
}();
|
|
3485
3901
|
|
|
3486
3902
|
_proto2.repay = /*#__PURE__*/function () {
|
|
3487
|
-
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3488
|
-
return runtime_1.wrap(function
|
|
3903
|
+
var _repay = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee17(amount) {
|
|
3904
|
+
return runtime_1.wrap(function _callee17$(_context17) {
|
|
3489
3905
|
while (1) {
|
|
3490
|
-
switch (
|
|
3906
|
+
switch (_context17.prev = _context17.next) {
|
|
3491
3907
|
case 0:
|
|
3492
3908
|
if (!isSameAddress(amount.token.address, ETHAddress)) {
|
|
3493
|
-
|
|
3909
|
+
_context17.next = 4;
|
|
3494
3910
|
break;
|
|
3495
3911
|
}
|
|
3496
3912
|
|
|
3497
|
-
return
|
|
3913
|
+
return _context17.abrupt("return", this._EthRepayHelper.connect(this._networkConnection.signer).repayBorrow({
|
|
3498
3914
|
value: amount.rawAmount()
|
|
3499
3915
|
}));
|
|
3500
3916
|
|
|
3501
3917
|
case 4:
|
|
3502
3918
|
if (!new BigNumber(amount.rawAmount()).lt(0)) {
|
|
3503
|
-
|
|
3919
|
+
_context17.next = 8;
|
|
3504
3920
|
break;
|
|
3505
3921
|
}
|
|
3506
3922
|
|
|
3507
|
-
return
|
|
3923
|
+
return _context17.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(INF));
|
|
3508
3924
|
|
|
3509
3925
|
case 8:
|
|
3510
|
-
return
|
|
3926
|
+
return _context17.abrupt("return", this.auToken.connect(this._networkConnection.signer).repayBorrow(amount.rawAmount()));
|
|
3511
3927
|
|
|
3512
3928
|
case 9:
|
|
3513
3929
|
case "end":
|
|
3514
|
-
return
|
|
3930
|
+
return _context17.stop();
|
|
3515
3931
|
}
|
|
3516
3932
|
}
|
|
3517
|
-
},
|
|
3933
|
+
}, _callee17, this);
|
|
3518
3934
|
}));
|
|
3519
3935
|
|
|
3520
3936
|
function repay(_x6) {
|
|
@@ -3525,19 +3941,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3525
3941
|
}();
|
|
3526
3942
|
|
|
3527
3943
|
_proto2.enableCollateral = /*#__PURE__*/function () {
|
|
3528
|
-
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3529
|
-
return runtime_1.wrap(function
|
|
3944
|
+
var _enableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee18() {
|
|
3945
|
+
return runtime_1.wrap(function _callee18$(_context18) {
|
|
3530
3946
|
while (1) {
|
|
3531
|
-
switch (
|
|
3947
|
+
switch (_context18.prev = _context18.next) {
|
|
3532
3948
|
case 0:
|
|
3533
|
-
return
|
|
3949
|
+
return _context18.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).enterMarkets([this.auToken.address]));
|
|
3534
3950
|
|
|
3535
3951
|
case 1:
|
|
3536
3952
|
case "end":
|
|
3537
|
-
return
|
|
3953
|
+
return _context18.stop();
|
|
3538
3954
|
}
|
|
3539
3955
|
}
|
|
3540
|
-
},
|
|
3956
|
+
}, _callee18, this);
|
|
3541
3957
|
}));
|
|
3542
3958
|
|
|
3543
3959
|
function enableCollateral() {
|
|
@@ -3548,19 +3964,19 @@ var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
|
3548
3964
|
}();
|
|
3549
3965
|
|
|
3550
3966
|
_proto2.disableCollateral = /*#__PURE__*/function () {
|
|
3551
|
-
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
3552
|
-
return runtime_1.wrap(function
|
|
3967
|
+
var _disableCollateral = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee19() {
|
|
3968
|
+
return runtime_1.wrap(function _callee19$(_context19) {
|
|
3553
3969
|
while (1) {
|
|
3554
|
-
switch (
|
|
3970
|
+
switch (_context19.prev = _context19.next) {
|
|
3555
3971
|
case 0:
|
|
3556
|
-
return
|
|
3972
|
+
return _context19.abrupt("return", this.env.comptroller.connect(this._networkConnection.signer).exitMarket(this.auToken.address));
|
|
3557
3973
|
|
|
3558
3974
|
case 1:
|
|
3559
3975
|
case "end":
|
|
3560
|
-
return
|
|
3976
|
+
return _context19.stop();
|
|
3561
3977
|
}
|
|
3562
3978
|
}
|
|
3563
|
-
},
|
|
3979
|
+
}, _callee19, this);
|
|
3564
3980
|
}));
|
|
3565
3981
|
|
|
3566
3982
|
function disableCollateral() {
|
|
@@ -3604,7 +4020,7 @@ var MulticallRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3604
4020
|
var _this;
|
|
3605
4021
|
|
|
3606
4022
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
3607
|
-
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$
|
|
4023
|
+
_this.multicall = new Contract(networkAddresses.misc.MULTICALL, abis$a.abi, networkConnection.provider);
|
|
3608
4024
|
return _this;
|
|
3609
4025
|
}
|
|
3610
4026
|
/**
|
|
@@ -4176,7 +4592,7 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4176
4592
|
while (1) {
|
|
4177
4593
|
switch (_context3.prev = _context3.next) {
|
|
4178
4594
|
case 0:
|
|
4179
|
-
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$
|
|
4595
|
+
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$5.abi, this._networkConnection.provider);
|
|
4180
4596
|
_context3.next = 3;
|
|
4181
4597
|
return lpContract.balanceOf(user);
|
|
4182
4598
|
|
|
@@ -4420,7 +4836,10 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4420
4836
|
return p;
|
|
4421
4837
|
}, new BigNumber(0));
|
|
4422
4838
|
_context.next = 19;
|
|
4423
|
-
return this.env.comptroller.getAccountLiquidity(userAddress)
|
|
4839
|
+
return this.env.comptroller.getAccountLiquidity(userAddress)["catch"](function (e) {
|
|
4840
|
+
console.log(e);
|
|
4841
|
+
return [BigNumber$1.from(0), BigNumber$1.from(0)];
|
|
4842
|
+
});
|
|
4424
4843
|
|
|
4425
4844
|
case 19:
|
|
4426
4845
|
accountLiquidity = _context.sent;
|
|
@@ -4656,9 +5075,9 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4656
5075
|
}
|
|
4657
5076
|
|
|
4658
5077
|
_1E18 = BigNumber$1.from(10).pow(18);
|
|
4659
|
-
oracle = this.env.getContract(networkAddresses.misc.oracle,
|
|
5078
|
+
oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
|
|
4660
5079
|
tokens = tokenAddresses.map(function (addr) {
|
|
4661
|
-
return _this3.env.getContract(addr, abis
|
|
5080
|
+
return _this3.env.getContract(addr, abis.abi);
|
|
4662
5081
|
});
|
|
4663
5082
|
_context5.next = 6;
|
|
4664
5083
|
return oracle.getUnderlyingPrices(tokenAddresses);
|
|
@@ -5096,6 +5515,43 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
5096
5515
|
return getLastJackpotResult;
|
|
5097
5516
|
}();
|
|
5098
5517
|
|
|
5518
|
+
_proto.overallLeaderboard = /*#__PURE__*/function () {
|
|
5519
|
+
var _overallLeaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
5520
|
+
var _this5 = this;
|
|
5521
|
+
|
|
5522
|
+
var result;
|
|
5523
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
5524
|
+
while (1) {
|
|
5525
|
+
switch (_context8.prev = _context8.next) {
|
|
5526
|
+
case 0:
|
|
5527
|
+
_context8.next = 2;
|
|
5528
|
+
return getPaginatedApi('/plygame/overallLeaderboard');
|
|
5529
|
+
|
|
5530
|
+
case 2:
|
|
5531
|
+
result = _context8.sent;
|
|
5532
|
+
return _context8.abrupt("return", result.items.map(function (item) {
|
|
5533
|
+
return {
|
|
5534
|
+
player: item.user,
|
|
5535
|
+
unlockedPulpAmount: new TokenAmount(_this5.pulpToken, item.unlockedAmount),
|
|
5536
|
+
gamesPlayed: item.count
|
|
5537
|
+
};
|
|
5538
|
+
}));
|
|
5539
|
+
|
|
5540
|
+
case 4:
|
|
5541
|
+
case "end":
|
|
5542
|
+
return _context8.stop();
|
|
5543
|
+
}
|
|
5544
|
+
}
|
|
5545
|
+
}, _callee8);
|
|
5546
|
+
}));
|
|
5547
|
+
|
|
5548
|
+
function overallLeaderboard() {
|
|
5549
|
+
return _overallLeaderboard.apply(this, arguments);
|
|
5550
|
+
}
|
|
5551
|
+
|
|
5552
|
+
return overallLeaderboard;
|
|
5553
|
+
}();
|
|
5554
|
+
|
|
5099
5555
|
return PlyGameRead;
|
|
5100
5556
|
}(BlockchainEntityRead);
|
|
5101
5557
|
var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
@@ -5113,19 +5569,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
|
5113
5569
|
_proto2.makeBetOnce =
|
|
5114
5570
|
/*#__PURE__*/
|
|
5115
5571
|
function () {
|
|
5116
|
-
var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
5117
|
-
return runtime_1.wrap(function
|
|
5572
|
+
var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(amount) {
|
|
5573
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
5118
5574
|
while (1) {
|
|
5119
|
-
switch (
|
|
5575
|
+
switch (_context9.prev = _context9.next) {
|
|
5120
5576
|
case 0:
|
|
5121
|
-
return
|
|
5577
|
+
return _context9.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
|
|
5122
5578
|
|
|
5123
5579
|
case 1:
|
|
5124
5580
|
case "end":
|
|
5125
|
-
return
|
|
5581
|
+
return _context9.stop();
|
|
5126
5582
|
}
|
|
5127
5583
|
}
|
|
5128
|
-
},
|
|
5584
|
+
}, _callee9, this);
|
|
5129
5585
|
}));
|
|
5130
5586
|
|
|
5131
5587
|
function makeBetOnce(_x5) {
|
|
@@ -5136,19 +5592,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
|
5136
5592
|
}();
|
|
5137
5593
|
|
|
5138
5594
|
_proto2.approve = /*#__PURE__*/function () {
|
|
5139
|
-
var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
5140
|
-
return runtime_1.wrap(function
|
|
5595
|
+
var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(amount) {
|
|
5596
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
5141
5597
|
while (1) {
|
|
5142
|
-
switch (
|
|
5598
|
+
switch (_context10.prev = _context10.next) {
|
|
5143
5599
|
case 0:
|
|
5144
|
-
return
|
|
5600
|
+
return _context10.abrupt("return", this.env.ply.connect(this._networkConnection.signer).approve(this.env.plygame.address, amount.rawAmount()));
|
|
5145
5601
|
|
|
5146
5602
|
case 1:
|
|
5147
5603
|
case "end":
|
|
5148
|
-
return
|
|
5604
|
+
return _context10.stop();
|
|
5149
5605
|
}
|
|
5150
5606
|
}
|
|
5151
|
-
},
|
|
5607
|
+
}, _callee10, this);
|
|
5152
5608
|
}));
|
|
5153
5609
|
|
|
5154
5610
|
function approve(_x6) {
|
|
@@ -6232,5 +6688,5 @@ BigNumber.config({
|
|
|
6232
6688
|
DECIMAL_PLACES: 50
|
|
6233
6689
|
});
|
|
6234
6690
|
|
|
6235
|
-
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, AURORA_PLUS_API_PREFIX, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromDefiLlama, fetchPriceFromDefiLlamaAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sleep, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
|
|
6691
|
+
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, AURORA_PLUS_API_PREFIX, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, DEPOSIT_ONLY_TOKENS, ETHAddress, HARDCODE_PRICE_TOKENS, INF, MarketAction, MiscRead, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_WEEK, ONE_YEAR, PLYToken, PLYWNEARToken, PLYWNEAR_POOL_ID, PLYWNEAR_REWARD_TOKENS, PRICE_WHITELISTED, Papermill, PapermillRead, PapermillReadWrite, PlyGame, PlyGameRead, PlyGameReadWrite, REFERRAL_CAMPAIGNS, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, index as abis, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchHistoricalLPPositions, fetchHistoricalLPPrice, fetchHistoricalPULPPrice, fetchHistoricalPrice, fetchHistoricalPriceByLP, fetchHistoricalPriceFromOracle, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromDefiLlama, fetchPriceFromDefiLlamaAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, referralRewardDummy1, referralRewardDummy2, sleep, sortEvents, symbolRecords, validateAndParseAddress, valuateToken };
|
|
6236
6692
|
//# sourceMappingURL=sdk.esm.js.map
|