@aurigami/sdk 1.7.1 → 1.7.3
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/consts/constants.d.ts +1 -0
- package/dist/entities/auriEnv.d.ts +2 -1
- package/dist/entities/tokenAmount.d.ts +1 -0
- package/dist/helpers/helpers.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/sdk.cjs.development.js +81 -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 +80 -39
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/consts/constants.ts +8 -0
- package/src/consts/symbols.ts +3 -1
- package/src/entities/auriEnv.ts +13 -1
- package/src/entities/tokenAmount.ts +5 -1
- package/src/helpers/graphql-helpers.ts +4 -6
- package/src/helpers/helpers.ts +10 -0
- package/src/index.ts +1 -0
- package/src/types/index.ts +5 -0
package/dist/sdk.esm.js
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { BigNumber as BigNumber$1, Contract, utils, ethers } from 'ethers';
|
|
3
3
|
import { Logger } from 'ethers/lib/utils';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
|
|
7
|
-
import abis$7 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
|
|
8
|
-
import abis$6 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
|
|
4
|
+
import abis$6 from '@aurigami/contracts/artifacts/contracts/AuErc20.sol/AuErc20.json';
|
|
5
|
+
import abis$7 from '@aurigami/contracts/artifacts/contracts/AuETH.sol/AuETH.json';
|
|
9
6
|
import AuriAirdropABI from '@aurigami/contracts/artifacts/contracts/AuriAirdrop.sol/AuriAirdrop.json';
|
|
10
7
|
import abis$1 from '@aurigami/contracts/artifacts/contracts/AuriFairLaunch.sol/AuriFairLaunch.json';
|
|
11
8
|
import abis$2 from '@aurigami/contracts/artifacts/contracts/AuriLens.sol/AuriLens.json';
|
|
12
9
|
import AuriOracleABI from '@aurigami/contracts/artifacts/contracts/AuriOracle.sol/AuriOracle.json';
|
|
13
|
-
import
|
|
14
|
-
import abis from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
10
|
+
import abis from '@aurigami/contracts/artifacts/contracts/AuToken.sol/AuToken.json';
|
|
11
|
+
import abis$3 from '@aurigami/contracts/artifacts/contracts/Comptroller.sol/Comptroller.json';
|
|
15
12
|
import abis$8 from '@aurigami/contracts/artifacts/contracts/EthRepayHelper.sol/EthRepayHelper.json';
|
|
16
|
-
import abis$
|
|
17
|
-
import abis$
|
|
13
|
+
import abis$4 from '@aurigami/contracts/artifacts/contracts/interfaces/EIP20Interface.sol/EIP20Interface.json';
|
|
14
|
+
import abis$b from '@aurigami/contracts/artifacts/contracts/mock/AuriInternalLens.sol/AuriInternalLens.json';
|
|
18
15
|
import IUniswapV2PairABI from '@aurigami/contracts/artifacts/contracts/mock/IUniswapV2Pair.sol/IUniswapV2Pair.json';
|
|
19
16
|
import abis$9 from '@aurigami/contracts/artifacts/contracts/mock/Multicall2.sol/Multicall2.json';
|
|
20
|
-
import abis$
|
|
21
|
-
import abis$
|
|
17
|
+
import abis$a from '@aurigami/contracts/artifacts/contracts/PULP.sol/PULP.json';
|
|
18
|
+
import abis$5 from '@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json';
|
|
19
|
+
import MAINNET_ADDRESSES from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
20
|
+
export { default as MAINNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_mainnet.json';
|
|
21
|
+
export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/aurora_testnet.json';
|
|
22
22
|
import { Signer } from '@ethersproject/abstract-signer';
|
|
23
23
|
import axios from 'axios';
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var index = {
|
|
28
|
+
__proto__: null,
|
|
29
|
+
AuriOracleABI: AuriOracleABI,
|
|
30
|
+
AuTokenABI: abis,
|
|
31
|
+
IUniswapV2PairABI: IUniswapV2PairABI,
|
|
32
|
+
AuriAirdropABI: AuriAirdropABI,
|
|
33
|
+
AuriFairLaunchABI: abis$1,
|
|
34
|
+
AuriLensABI: abis$2,
|
|
35
|
+
ComptrollerABI: abis$3,
|
|
36
|
+
EIP20InterfaceABI: abis$4,
|
|
37
|
+
ReferralDirectoryABI: abis$5,
|
|
38
|
+
AuErc20ABI: abis$6,
|
|
39
|
+
AuETHABI: abis$7,
|
|
40
|
+
EthRepayHelperABI: abis$8,
|
|
41
|
+
Multicall2ABI: abis$9,
|
|
42
|
+
PulpABI: abis$a,
|
|
43
|
+
AuriInternalLensABI: abis$b
|
|
44
|
+
};
|
|
25
45
|
|
|
26
46
|
var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
|
|
27
47
|
var ETHAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
@@ -98,7 +118,8 @@ var networkAddresses = {
|
|
|
98
118
|
PLYWNEAR: /*#__PURE__*/MAINNET_ADDRESSES.ply_wnear_lp.toLowerCase(),
|
|
99
119
|
USN: /*#__PURE__*/'0x5183e1b1091804bc2602586919e6880ac1cf2896'.toLowerCase()
|
|
100
120
|
}
|
|
101
|
-
};
|
|
121
|
+
};
|
|
122
|
+
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
|
|
102
123
|
|
|
103
124
|
var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
|
|
104
125
|
return t.underlying;
|
|
@@ -308,13 +329,13 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
308
329
|
var _this;
|
|
309
330
|
|
|
310
331
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
311
|
-
_this.comptroller = _this.getContract(networkAddresses.misc.COMPTROLLER, abis.abi);
|
|
332
|
+
_this.comptroller = _this.getContract(networkAddresses.misc.COMPTROLLER, abis$3.abi);
|
|
312
333
|
_this.auriFairLaunch = _this.getContract(networkAddresses.misc.AURIFAIRLAUNCH, abis$1.abi);
|
|
313
334
|
_this.auriLens = _this.getContract(networkAddresses.misc.AURILENS, abis$2.abi);
|
|
314
|
-
_this.ply = _this.getContract(networkAddresses.tokens.PLY, abis$
|
|
315
|
-
_this.pulp = _this.getContract(networkAddresses.tokens.PULP, abis$
|
|
335
|
+
_this.ply = _this.getContract(networkAddresses.tokens.PLY, abis$4.abi);
|
|
336
|
+
_this.pulp = _this.getContract(networkAddresses.tokens.PULP, abis$a.abi); // this.faucet = this.getContract<Faucet>(networkAddresses.misc.FAUCET, abis.FaucetABI.abi);
|
|
316
337
|
|
|
317
|
-
_this.auriInternalLens = _this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$
|
|
338
|
+
_this.auriInternalLens = _this.getContract(networkAddresses.misc.AURI_INTERNAL_LENS, abis$b.abi);
|
|
318
339
|
return _this;
|
|
319
340
|
} // public faucet: Faucet;
|
|
320
341
|
|
|
@@ -325,6 +346,17 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
325
346
|
return new Contract(address, abi, this._networkConnection.provider);
|
|
326
347
|
};
|
|
327
348
|
|
|
349
|
+
_proto.getAuTokenContracts = function getAuTokenContracts() {
|
|
350
|
+
var _this2 = this;
|
|
351
|
+
|
|
352
|
+
return networkAddresses.auTokens.map(function (auToken) {
|
|
353
|
+
var contract = _this2.getContract(auToken.address, abis.abi);
|
|
354
|
+
|
|
355
|
+
contract.underlying = auToken.underlying;
|
|
356
|
+
return contract;
|
|
357
|
+
});
|
|
358
|
+
};
|
|
359
|
+
|
|
328
360
|
return AuriEnv;
|
|
329
361
|
}(BlockchainEntityRead);
|
|
330
362
|
|
|
@@ -1090,7 +1122,9 @@ try {
|
|
|
1090
1122
|
|
|
1091
1123
|
var symbolRecords = /*#__PURE__*/Object.fromEntries( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
|
|
1092
1124
|
return [e.address.toLowerCase(), e.name];
|
|
1093
|
-
}))
|
|
1125
|
+
}).concat( /*#__PURE__*/networkAddresses.auTokens.map(function (e) {
|
|
1126
|
+
return [e.underlying.toLowerCase(), e.name.slice(2)];
|
|
1127
|
+
})));
|
|
1094
1128
|
|
|
1095
1129
|
var AURORA_API_BASE_URL = 'https://api.aurorascan.dev/api';
|
|
1096
1130
|
function getQuery(_x, _x2, _x3) {
|
|
@@ -1146,25 +1180,15 @@ function _queryGraphQL() {
|
|
|
1146
1180
|
switch (_context.prev = _context.next) {
|
|
1147
1181
|
case 0:
|
|
1148
1182
|
_context.next = 2;
|
|
1149
|
-
return
|
|
1150
|
-
|
|
1151
|
-
'Content-Type': 'application/json'
|
|
1152
|
-
},
|
|
1153
|
-
method: 'POST',
|
|
1154
|
-
body: JSON.stringify({
|
|
1155
|
-
query: query
|
|
1156
|
-
})
|
|
1183
|
+
return axios.post(GRAPHQL_URL, {
|
|
1184
|
+
query: query
|
|
1157
1185
|
});
|
|
1158
1186
|
|
|
1159
1187
|
case 2:
|
|
1160
1188
|
resp = _context.sent;
|
|
1161
|
-
_context.
|
|
1162
|
-
return resp.json();
|
|
1189
|
+
return _context.abrupt("return", resp.data.data);
|
|
1163
1190
|
|
|
1164
|
-
case
|
|
1165
|
-
return _context.abrupt("return", _context.sent.data);
|
|
1166
|
-
|
|
1167
|
-
case 6:
|
|
1191
|
+
case 4:
|
|
1168
1192
|
case "end":
|
|
1169
1193
|
return _context.stop();
|
|
1170
1194
|
}
|
|
@@ -1213,6 +1237,18 @@ function getSymbol(address) {
|
|
|
1213
1237
|
assert(symbolRecords[addressLowercase] != undefined, 'Symbol not found for ' + address);
|
|
1214
1238
|
return symbolRecords[addressLowercase];
|
|
1215
1239
|
}
|
|
1240
|
+
function getUnderlying(address) {
|
|
1241
|
+
var addressLowercase = address.toLowerCase();
|
|
1242
|
+
var matching = networkAddresses.auTokens.filter(function (e) {
|
|
1243
|
+
return e.address == addressLowercase;
|
|
1244
|
+
});
|
|
1245
|
+
|
|
1246
|
+
if (matching.length == 0) {
|
|
1247
|
+
throw new Error('Underlying not found for ' + address);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
return matching[0].underlying;
|
|
1251
|
+
}
|
|
1216
1252
|
function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
1217
1253
|
if (rewardsValue.isZero()) {
|
|
1218
1254
|
return new BigNumber(0);
|
|
@@ -1483,6 +1519,10 @@ var TokenAmount = /*#__PURE__*/function () {
|
|
|
1483
1519
|
return new BigNumber(this.rawAmnt).div(decimalFactor(this.token.decimals)).toString();
|
|
1484
1520
|
};
|
|
1485
1521
|
|
|
1522
|
+
_proto.formattedAmountWithSymbol = function formattedAmountWithSymbol() {
|
|
1523
|
+
return this.formattedAmount() + " " + getSymbol(this.token.address);
|
|
1524
|
+
};
|
|
1525
|
+
|
|
1486
1526
|
_proto.rawAmount = function rawAmount() {
|
|
1487
1527
|
return this.rawAmnt;
|
|
1488
1528
|
};
|
|
@@ -2199,7 +2239,7 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2199
2239
|
var _this;
|
|
2200
2240
|
|
|
2201
2241
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
2202
|
-
_this.auToken = new Contract(tokenAddr,
|
|
2242
|
+
_this.auToken = new Contract(tokenAddr, abis.abi, _this._networkConnection.provider);
|
|
2203
2243
|
return _this;
|
|
2204
2244
|
}
|
|
2205
2245
|
/**
|
|
@@ -2309,6 +2349,7 @@ var helpers = {
|
|
|
2309
2349
|
validateAndParseAddress: validateAndParseAddress,
|
|
2310
2350
|
getDecimal: getDecimal,
|
|
2311
2351
|
getSymbol: getSymbol,
|
|
2352
|
+
getUnderlying: getUnderlying,
|
|
2312
2353
|
calcLMRewardApr: calcLMRewardApr,
|
|
2313
2354
|
getBlockTimestamp: getBlockTimestamp,
|
|
2314
2355
|
getBlocksTimestampViaRPC: getBlocksTimestampViaRPC,
|
|
@@ -2510,9 +2551,9 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2510
2551
|
_this.env = new AuriEnv(networkConnection);
|
|
2511
2552
|
|
|
2512
2553
|
if (isSameAddress(underlyingAsset, ETHAddress)) {
|
|
2513
|
-
_this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
|
|
2514
|
-
} else {
|
|
2515
2554
|
_this.auToken = new Contract(auToken, abis$7.abi, networkConnection.provider);
|
|
2555
|
+
} else {
|
|
2556
|
+
_this.auToken = new Contract(auToken, abis$6.abi, networkConnection.provider);
|
|
2516
2557
|
}
|
|
2517
2558
|
|
|
2518
2559
|
_this.underlying = new Token(underlyingAsset, getDecimal(underlyingAsset));
|
|
@@ -3761,7 +3802,7 @@ var StakingRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
3761
3802
|
while (1) {
|
|
3762
3803
|
switch (_context3.prev = _context3.next) {
|
|
3763
3804
|
case 0:
|
|
3764
|
-
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$
|
|
3805
|
+
lpContract = new Contract(networkAddresses.tokens.PLYWNEAR, abis$4.abi, this._networkConnection.provider);
|
|
3765
3806
|
_context3.next = 3;
|
|
3766
3807
|
return lpContract.balanceOf(user);
|
|
3767
3808
|
|
|
@@ -4254,7 +4295,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4254
4295
|
dust = new BigNumber(0.1);
|
|
4255
4296
|
oracle = this.env.getContract(networkAddresses.misc.oracle, AuriOracleABI.abi);
|
|
4256
4297
|
tokens = tokenAddresses.map(function (addr) {
|
|
4257
|
-
return _this3.env.getContract(addr,
|
|
4298
|
+
return _this3.env.getContract(addr, abis.abi);
|
|
4258
4299
|
});
|
|
4259
4300
|
_context5.next = 6;
|
|
4260
4301
|
return oracle.getUnderlyingPrices(tokenAddresses);
|
|
@@ -4352,7 +4393,7 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4352
4393
|
var _this;
|
|
4353
4394
|
|
|
4354
4395
|
_this = _BlockchainEntityRead.call(this, networkConnection) || this;
|
|
4355
|
-
_this.referral = new Contract(networkAddresses.misc.REFERRAL, abis$
|
|
4396
|
+
_this.referral = new Contract(networkAddresses.misc.REFERRAL, abis$5.abi, networkConnection.provider);
|
|
4356
4397
|
return _this;
|
|
4357
4398
|
}
|
|
4358
4399
|
/**
|
|
@@ -5034,5 +5075,5 @@ BigNumber.config({
|
|
|
5034
5075
|
DECIMAL_PLACES: 50
|
|
5035
5076
|
});
|
|
5036
5077
|
|
|
5037
|
-
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, Airdrop, AirdropRead, AirdropReadWrite, AuriEnv, BORROW_LIMIT_BUFFER, BORROW_NEAR_REWARDS_PER_WEEK, BlockchainEntity, BlockchainEntityRead, BlockchainEntityReadWrite, ComptrollerRewardType, DECIMAL_PRECISION, DEPOSIT_NEAR_REWARDS_PER_WEEK, 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, REWARD_CLAIM_START, Referral, ReferralRead, ReferralReadWrite, SDK, SdkRead, SdkReadWrite, Staking, StakingRead, StakingReadWrite, Token, TokenAmount, TransferEventQuery, assert, calcLMRewardApr, calcValuation, decimalFactor, decimalRecords, devLog, dummyAddress, dummyMarketAddress, dummyPly, dummyPlyAurora, dummyToken, dummyTokenAmount, dummyTokenAmount2, dummyTokenAmount3, dummyUserMarketDetails, dummyZeroTokenAmount, fetchLPPositions, fetchLPPrice, fetchPLYPrice, fetchPULPPrice, fetchPrice, fetchPriceFromCoingecko, fetchPriceFromCoingeckoAPI, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5078
|
+
export { AIRDROP_END_TIMESTAMP, AIRDROP_KEEP_THRESHOLD, AIRDROP_START_TIMESTAMP, ALL_STAKING_POOLS, AURORA_CHAINID, 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, 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, fetchPriceFromOracle, fetchStNEARPrice, fetchToken0PriceByLP, fetchUnderlyingTokensPrices, fetchValuation, formatObject, getApi, getBlockBeforeTimestamp, getBlockTimestamp, getBlocksTimestamp, getBlocksTimestampViaRPC, getCurrentTimestamp, getDecimal, getPaginatedApi, getQuery, getSymbol, getUnderlying, isSameAddress, networkAddresses, queryGraphQL, symbolRecords, validateAndParseAddress, valuateToken };
|
|
5038
5079
|
//# sourceMappingURL=sdk.esm.js.map
|