@aurigami/sdk 1.4.0 → 1.4.2
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/aurora-api-helpers.d.ts +1 -0
- package/dist/helpers.d.ts +1 -2
- package/dist/sdk.cjs.development.js +110 -115
- 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 +111 -115
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/airdrop-lottery.ts +3 -5
- package/src/aurora-api-helpers.ts +15 -0
- package/src/constants.ts +1 -0
- package/src/helpers.ts +15 -53
- package/src/priceFetcher.ts +10 -6
package/dist/sdk.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ 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
4
|
import { Signer } from '@ethersproject/abstract-signer';
|
|
5
|
-
import
|
|
5
|
+
import fetch from 'node-fetch';
|
|
6
6
|
import AuErc20ABI from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
|
|
7
7
|
import AuETHABI from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
|
|
8
8
|
import ComptrollerABI from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
@@ -52,6 +52,24 @@ function _asyncToGenerator(fn) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function _extends() {
|
|
56
|
+
_extends = Object.assign || function (target) {
|
|
57
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
58
|
+
var source = arguments[i];
|
|
59
|
+
|
|
60
|
+
for (var key in source) {
|
|
61
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
62
|
+
target[key] = source[key];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return target;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return _extends.apply(this, arguments);
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
function _inheritsLoose(subClass, superClass) {
|
|
56
74
|
subClass.prototype = Object.create(superClass.prototype);
|
|
57
75
|
subClass.prototype.constructor = subClass;
|
|
@@ -973,6 +991,7 @@ var networkAddresses = {
|
|
|
973
991
|
USDC: /*#__PURE__*/'0xb12bfca5a55806aaf64e99521918a4bf0fc40802'.toLowerCase(),
|
|
974
992
|
WNEAR: /*#__PURE__*/'0xC42C30aC6Cc15faC9bD938618BcaA1a1FaE8501d'.toLowerCase(),
|
|
975
993
|
TRI: /*#__PURE__*/'0xFa94348467f64D5A457F75F8bc40495D33c65aBB'.toLowerCase(),
|
|
994
|
+
META: /*#__PURE__*/'0xc21ff01229e982d7c8b8691163b0a3cb8f357453'.toLocaleLowerCase(),
|
|
976
995
|
AURPLY: /*#__PURE__*/dummyAddress.toLowerCase()
|
|
977
996
|
}
|
|
978
997
|
};
|
|
@@ -998,6 +1017,52 @@ var DEPOSIT_NEAR_REWARDS_PER_WEEK = /*#__PURE__*/Object.fromEntries( /*#__PURE__
|
|
|
998
1017
|
}));
|
|
999
1018
|
var BORROW_NEAR_REWARDS_PER_WEEK = {};
|
|
1000
1019
|
|
|
1020
|
+
var AURORA_API_BASE_URL = 'https://api.aurorascan.dev/api';
|
|
1021
|
+
function getQuery(_x, _x2, _x3) {
|
|
1022
|
+
return _getQuery.apply(this, arguments);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
function _getQuery() {
|
|
1026
|
+
_getQuery = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(module, action, params) {
|
|
1027
|
+
var resp;
|
|
1028
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1029
|
+
while (1) {
|
|
1030
|
+
switch (_context.prev = _context.next) {
|
|
1031
|
+
case 0:
|
|
1032
|
+
if (params === void 0) {
|
|
1033
|
+
params = {};
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
params = _extends({}, params, {
|
|
1037
|
+
'module': module,
|
|
1038
|
+
'action': action
|
|
1039
|
+
});
|
|
1040
|
+
_context.next = 4;
|
|
1041
|
+
return fetch(AURORA_API_BASE_URL + '?' + new URLSearchParams(params), {
|
|
1042
|
+
headers: {
|
|
1043
|
+
'Content-Type': 'application/json'
|
|
1044
|
+
},
|
|
1045
|
+
method: 'GET'
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
case 4:
|
|
1049
|
+
resp = _context.sent;
|
|
1050
|
+
_context.next = 7;
|
|
1051
|
+
return resp.json();
|
|
1052
|
+
|
|
1053
|
+
case 7:
|
|
1054
|
+
return _context.abrupt("return", _context.sent.result);
|
|
1055
|
+
|
|
1056
|
+
case 8:
|
|
1057
|
+
case "end":
|
|
1058
|
+
return _context.stop();
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
}, _callee);
|
|
1062
|
+
}));
|
|
1063
|
+
return _getQuery.apply(this, arguments);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1001
1066
|
var decimalRecords = {
|
|
1002
1067
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
1003
1068
|
'0x981bd5832eab9c8f607940e0e9facbf8c09ee20a': 18,
|
|
@@ -1043,40 +1108,6 @@ function validateAndParseAddress(address) {
|
|
|
1043
1108
|
function getDecimal(address) {
|
|
1044
1109
|
return decimalRecords[address.toLowerCase()];
|
|
1045
1110
|
}
|
|
1046
|
-
function getDecimalsViaContract(_x, _x2) {
|
|
1047
|
-
return _getDecimalsViaContract.apply(this, arguments);
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
function _getDecimalsViaContract() {
|
|
1051
|
-
_getDecimalsViaContract = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(address, provider) {
|
|
1052
|
-
var result, token;
|
|
1053
|
-
return runtime_1.wrap(function _callee$(_context) {
|
|
1054
|
-
while (1) {
|
|
1055
|
-
switch (_context.prev = _context.next) {
|
|
1056
|
-
case 0:
|
|
1057
|
-
result = getDecimal(address);
|
|
1058
|
-
|
|
1059
|
-
if (!result) {
|
|
1060
|
-
_context.next = 3;
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
return _context.abrupt("return", result);
|
|
1065
|
-
|
|
1066
|
-
case 3:
|
|
1067
|
-
token = new Contract(address, EIP20InterfaceABI.abi, provider);
|
|
1068
|
-
return _context.abrupt("return", token.decimals());
|
|
1069
|
-
|
|
1070
|
-
case 5:
|
|
1071
|
-
case "end":
|
|
1072
|
-
return _context.stop();
|
|
1073
|
-
}
|
|
1074
|
-
}
|
|
1075
|
-
}, _callee);
|
|
1076
|
-
}));
|
|
1077
|
-
return _getDecimalsViaContract.apply(this, arguments);
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
1111
|
function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
1081
1112
|
if (totalStakeValue.lte(0)) {
|
|
1082
1113
|
return new BigNumber('999999999');
|
|
@@ -1084,113 +1115,75 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1084
1115
|
|
|
1085
1116
|
return rewardsValue.multipliedBy(frequencyPerYear).dividedBy(totalStakeValue);
|
|
1086
1117
|
}
|
|
1087
|
-
function getBlockTimestamp(
|
|
1118
|
+
function getBlockTimestamp(_x, _x2) {
|
|
1088
1119
|
return _getBlockTimestamp.apply(this, arguments);
|
|
1089
1120
|
}
|
|
1090
1121
|
|
|
1091
1122
|
function _getBlockTimestamp() {
|
|
1092
|
-
_getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1123
|
+
_getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider, blockNumber) {
|
|
1093
1124
|
var block;
|
|
1094
|
-
return runtime_1.wrap(function
|
|
1125
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1095
1126
|
while (1) {
|
|
1096
|
-
switch (
|
|
1127
|
+
switch (_context.prev = _context.next) {
|
|
1097
1128
|
case 0:
|
|
1098
|
-
|
|
1129
|
+
_context.next = 2;
|
|
1099
1130
|
return provider.getBlock(blockNumber);
|
|
1100
1131
|
|
|
1101
1132
|
case 2:
|
|
1102
|
-
block =
|
|
1103
|
-
return
|
|
1133
|
+
block = _context.sent;
|
|
1134
|
+
return _context.abrupt("return", block.timestamp);
|
|
1104
1135
|
|
|
1105
1136
|
case 4:
|
|
1106
1137
|
case "end":
|
|
1107
|
-
return
|
|
1138
|
+
return _context.stop();
|
|
1108
1139
|
}
|
|
1109
1140
|
}
|
|
1110
|
-
},
|
|
1141
|
+
}, _callee);
|
|
1111
1142
|
}));
|
|
1112
1143
|
return _getBlockTimestamp.apply(this, arguments);
|
|
1113
1144
|
}
|
|
1114
1145
|
|
|
1115
|
-
function getBlockBeforeTimestamp(
|
|
1146
|
+
function getBlockBeforeTimestamp(_x3, _x4) {
|
|
1116
1147
|
return _getBlockBeforeTimestamp.apply(this, arguments);
|
|
1117
1148
|
}
|
|
1118
1149
|
|
|
1119
1150
|
function _getBlockBeforeTimestamp() {
|
|
1120
|
-
_getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1123
|
-
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1151
|
+
_getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(provider, timestamp) {
|
|
1152
|
+
var result;
|
|
1153
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1124
1154
|
while (1) {
|
|
1125
|
-
switch (
|
|
1155
|
+
switch (_context2.prev = _context2.next) {
|
|
1126
1156
|
case 0:
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
case 5:
|
|
1134
|
-
rightBlock = _context3.sent;
|
|
1135
|
-
_context3.next = 8;
|
|
1136
|
-
return getBlockTimestamp(provider, rightBlock);
|
|
1137
|
-
|
|
1138
|
-
case 8:
|
|
1139
|
-
_context3.t0 = _context3.sent;
|
|
1140
|
-
_context3.t1 = timestamp;
|
|
1141
|
-
|
|
1142
|
-
if (!(_context3.t0 < _context3.t1)) {
|
|
1143
|
-
_context3.next = 12;
|
|
1144
|
-
break;
|
|
1145
|
-
}
|
|
1157
|
+
_context2.next = 2;
|
|
1158
|
+
return getQuery('block', 'getblocknobytime', {
|
|
1159
|
+
'timestamp': timestamp,
|
|
1160
|
+
'closest': 'before'
|
|
1161
|
+
});
|
|
1146
1162
|
|
|
1147
|
-
|
|
1163
|
+
case 2:
|
|
1164
|
+
result = _context2.sent;
|
|
1165
|
+
_context2.t0 = parseInt(result);
|
|
1148
1166
|
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
_context3.next = 25;
|
|
1167
|
+
if (_context2.t0) {
|
|
1168
|
+
_context2.next = 8;
|
|
1152
1169
|
break;
|
|
1153
1170
|
}
|
|
1154
1171
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
for (i = 1; i < K; i++) {
|
|
1159
|
-
promises.push(getBlockTimestamp(provider, leftBlock + i * size));
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
_context3.next = 18;
|
|
1163
|
-
return Promise.all(promises);
|
|
1164
|
-
|
|
1165
|
-
case 18:
|
|
1166
|
-
blockTimestamps = _context3.sent;
|
|
1167
|
-
nextLeftBlock = leftBlock;
|
|
1168
|
-
|
|
1169
|
-
for (_i = 1; _i < K; _i++) {
|
|
1170
|
-
if (blockTimestamps[_i - 1] <= timestamp) {
|
|
1171
|
-
nextLeftBlock = leftBlock + _i * size;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
for (_i2 = K - 1; _i2 >= 1; _i2--) {
|
|
1176
|
-
if (blockTimestamps[_i2 - 1] > timestamp) {
|
|
1177
|
-
rightBlock = leftBlock + _i2 * size - 1;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1172
|
+
_context2.next = 7;
|
|
1173
|
+
return provider.getBlockNumber();
|
|
1180
1174
|
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
break;
|
|
1175
|
+
case 7:
|
|
1176
|
+
_context2.t0 = _context2.sent;
|
|
1184
1177
|
|
|
1185
|
-
case
|
|
1186
|
-
return
|
|
1178
|
+
case 8:
|
|
1179
|
+
return _context2.abrupt("return", _context2.t0);
|
|
1187
1180
|
|
|
1188
|
-
case
|
|
1181
|
+
case 9:
|
|
1189
1182
|
case "end":
|
|
1190
|
-
return
|
|
1183
|
+
return _context2.stop();
|
|
1191
1184
|
}
|
|
1192
1185
|
}
|
|
1193
|
-
},
|
|
1186
|
+
}, _callee2);
|
|
1194
1187
|
}));
|
|
1195
1188
|
return _getBlockBeforeTimestamp.apply(this, arguments);
|
|
1196
1189
|
}
|
|
@@ -2220,7 +2213,7 @@ function _fetchPriceFromCoingecko() {
|
|
|
2220
2213
|
switch (_context2.prev = _context2.next) {
|
|
2221
2214
|
case 0:
|
|
2222
2215
|
_context2.t0 = id.toLowerCase();
|
|
2223
|
-
_context2.next = _context2.t0 === networkAddresses.tokens.AURORA ? 3 : _context2.t0 === networkAddresses.tokens.TRI ? 4 : 5;
|
|
2216
|
+
_context2.next = _context2.t0 === networkAddresses.tokens.AURORA ? 3 : _context2.t0 === networkAddresses.tokens.TRI ? 4 : _context2.t0 === networkAddresses.tokens.META ? 5 : 6;
|
|
2224
2217
|
break;
|
|
2225
2218
|
|
|
2226
2219
|
case 3:
|
|
@@ -2230,9 +2223,12 @@ function _fetchPriceFromCoingecko() {
|
|
|
2230
2223
|
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('trisolaris'));
|
|
2231
2224
|
|
|
2232
2225
|
case 5:
|
|
2233
|
-
|
|
2226
|
+
return _context2.abrupt("return", fetchPriceFromCoingeckoAPI('meta-pool'));
|
|
2234
2227
|
|
|
2235
2228
|
case 6:
|
|
2229
|
+
throw Error("Unknown token " + id + " in fetchPriceFromCoingecko");
|
|
2230
|
+
|
|
2231
|
+
case 7:
|
|
2236
2232
|
case "end":
|
|
2237
2233
|
return _context2.stop();
|
|
2238
2234
|
}
|
|
@@ -2446,7 +2442,7 @@ function _fetchStNEARPrice() {
|
|
|
2446
2442
|
|
|
2447
2443
|
function shouldFetchFromCoingecko(address) {
|
|
2448
2444
|
address = address.toLowerCase();
|
|
2449
|
-
return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI;
|
|
2445
|
+
return address == networkAddresses.tokens.AURORA || address == networkAddresses.tokens.TRI || address == networkAddresses.tokens.META;
|
|
2450
2446
|
}
|
|
2451
2447
|
|
|
2452
2448
|
function fetchPrice(_x11, _x12) {
|
|
@@ -2488,7 +2484,7 @@ function _fetchPrice() {
|
|
|
2488
2484
|
return _context8.abrupt("return", fetchPriceFromOracle(matchingAuToken.address, getDecimal(address), provider));
|
|
2489
2485
|
|
|
2490
2486
|
case 9:
|
|
2491
|
-
if (!isSameAddress(address, networkAddresses.tokens.
|
|
2487
|
+
if (!isSameAddress(address, networkAddresses.tokens.AURPLY)) {
|
|
2492
2488
|
_context8.next = 13;
|
|
2493
2489
|
break;
|
|
2494
2490
|
}
|
|
@@ -106505,12 +106501,12 @@ var AirdropSettings = /*#__PURE__*/function () {
|
|
|
106505
106501
|
case 2:
|
|
106506
106502
|
settings = new AirdropSettings();
|
|
106507
106503
|
_context.next = 5;
|
|
106508
|
-
return getBlockBeforeTimestamp(provider, settings.airdropStartTimestamp
|
|
106504
|
+
return getBlockBeforeTimestamp(provider, settings.airdropStartTimestamp);
|
|
106509
106505
|
|
|
106510
106506
|
case 5:
|
|
106511
106507
|
settings.airdropStartBlock = _context.sent;
|
|
106512
106508
|
_context.next = 8;
|
|
106513
|
-
return getBlockBeforeTimestamp(provider, settings.airdropEndTimestamp
|
|
106509
|
+
return getBlockBeforeTimestamp(provider, settings.airdropEndTimestamp);
|
|
106514
106510
|
|
|
106515
106511
|
case 8:
|
|
106516
106512
|
settings.airdropEndBlock = _context.sent;
|
|
@@ -106597,11 +106593,11 @@ var AirdropAuTokenKeepTracker = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
106597
106593
|
|
|
106598
106594
|
_step$value = _step.value, from = _step$value.from, to = _step$value.to, amount = _step$value.amount, blockNumber = _step$value.blockNumber;
|
|
106599
106595
|
|
|
106600
|
-
if (from
|
|
106596
|
+
if (isSameAddress(from, address)) {
|
|
106601
106597
|
balance = balance.sub(amount);
|
|
106602
106598
|
}
|
|
106603
106599
|
|
|
106604
|
-
if (to
|
|
106600
|
+
if (isSameAddress(to, address)) {
|
|
106605
106601
|
balance = balance.add(amount);
|
|
106606
106602
|
}
|
|
106607
106603
|
|
|
@@ -106910,5 +106906,5 @@ BigNumber.config({
|
|
|
106910
106906
|
DECIMAL_PLACES: 50
|
|
106911
106907
|
});
|
|
106912
106908
|
|
|
106913
|
-
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, AURORA_CHAINID, AURPLYToken, Airdrop, AirdropRead, AirdropReadWrite, AurPlyPid, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, ETHAddress, INF, MarketAction, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_YEAR, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, TransferEventQuery, calcLMRewardApr, calcValuation, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getBlockBeforeTimestamp, getBlockTimestamp, getCurrentTimestamp, getDecimal,
|
|
106909
|
+
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, AURORA_CHAINID, AURPLYToken, Airdrop, AirdropRead, AirdropReadWrite, AurPlyPid, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, ETHAddress, INF, MarketAction, MoneyMarket, MoneyMarketRead, MoneyMarketReadWrite, ONE_DAY, ONE_YEAR, PLYToken, REWARDCLAIMSTART, SDK, SdkRead, SdkReadWrite, Token, TokenAmount, TransferEventQuery, calcLMRewardApr, calcValuation, decimalFactor, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getBlockBeforeTimestamp, getBlockTimestamp, getCurrentTimestamp, getDecimal, isSameAddress, networkAddresses, validateAndParseAddress };
|
|
106914
106910
|
//# sourceMappingURL=sdk.esm.js.map
|