@aurigami/sdk 1.20.8 → 1.22.0
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 +3 -2
- package/dist/entities/auriEnv.d.ts +1 -1
- package/dist/helpers/aurigami-api.d.ts +1 -1
- package/dist/sdk.cjs.development.js +34 -30
- 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 +34 -30
- package/dist/sdk.esm.js.map +1 -1
- package/dist/types/index.d.ts +11 -13
- package/package.json +2 -2
- package/src/SDK.ts +18 -24
- package/src/consts/constants.ts +3 -2
- package/src/entities/auriEnv.ts +4 -4
- package/src/helpers/aurigami-api.ts +2 -2
- package/src/helpers/helpers.ts +2 -2
- package/src/helpers/historicalPriceFetcher.ts +8 -1
- package/src/helpers/priceFetcher.ts +5 -5
- package/src/interactors/misc.ts +2 -5
- package/src/types/index.ts +11 -14
|
@@ -57,7 +57,8 @@ export declare const networkAddresses: {
|
|
|
57
57
|
}];
|
|
58
58
|
readonly misc: {
|
|
59
59
|
readonly COMPTROLLER: string;
|
|
60
|
-
readonly
|
|
60
|
+
readonly DEPRECATED_OLD_ORACLE: string;
|
|
61
|
+
readonly PYTH_ORACLE: string;
|
|
61
62
|
readonly AURIFAIRLAUNCH: string;
|
|
62
63
|
readonly AURILENS: string;
|
|
63
64
|
readonly ETHREPAYHELPER: string;
|
|
@@ -125,4 +126,4 @@ export declare const SD_INCENTIVE_IN_SD = 83.35;
|
|
|
125
126
|
export declare const STADER_ETH: string;
|
|
126
127
|
export declare const USDT_ETH: string;
|
|
127
128
|
export declare const AURIGAMI_SUBGRAPH_URL = "https://api.thegraph.com/subgraphs/name/takao-aurigami/aurigami-feb-27";
|
|
128
|
-
export declare const GRAPHQL_URL = "https://explorer.
|
|
129
|
+
export declare const GRAPHQL_URL = "https://old.explorer.aurora.dev/api/v1/graphql";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuErc20, AuriAirdrop, AuriFairLaunch, AuriInternalLens, AuriLens, AuriOracle, Comptroller, IERC20, PlyGame,
|
|
1
|
+
import { AuErc20, AuriAirdrop, AuriFairLaunch, AuriInternalLens, AuriLens, AuriOracle, Comptroller, IERC20, PULP, PlyGame, PlyTokenLock, ReferralDirectoryV2 } from '@aurigami/contracts/typechain';
|
|
2
2
|
import { Contract } from 'ethers';
|
|
3
3
|
import { AuTokenWithUnderlying } from '../types';
|
|
4
4
|
import { BlockchainEntityRead } from './BlockchainEntity';
|
|
@@ -10,4 +10,4 @@ export declare type PaginagedApiResponse<T> = {
|
|
|
10
10
|
items: T[];
|
|
11
11
|
meta: MetaApiResponse;
|
|
12
12
|
};
|
|
13
|
-
export declare function getPaginatedApi(url: string, params?: Record<string, any>, page?: number, pageSize?: number): Promise<PaginagedApiResponse<
|
|
13
|
+
export declare function getPaginatedApi<T = any>(url: string, params?: Record<string, any>, page?: number, pageSize?: number): Promise<PaginagedApiResponse<T>>;
|
|
@@ -111,7 +111,8 @@ var networkAddresses = {
|
|
|
111
111
|
}],
|
|
112
112
|
misc: {
|
|
113
113
|
COMPTROLLER: /*#__PURE__*/MAINNET_ADDRESSES.comptroller.toLowerCase(),
|
|
114
|
-
|
|
114
|
+
DEPRECATED_OLD_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.oracle.toLowerCase(),
|
|
115
|
+
PYTH_ORACLE: /*#__PURE__*/MAINNET_ADDRESSES.pythOracle.toLowerCase(),
|
|
115
116
|
AURIFAIRLAUNCH: /*#__PURE__*/MAINNET_ADDRESSES.fairLaunch.toLowerCase(),
|
|
116
117
|
AURILENS: /*#__PURE__*/MAINNET_ADDRESSES.auriLens.toLowerCase(),
|
|
117
118
|
ETHREPAYHELPER: /*#__PURE__*/MAINNET_ADDRESSES.ethRepayHelper.toLowerCase(),
|
|
@@ -211,7 +212,7 @@ var SD_INCENTIVE_IN_SD = 83.35;
|
|
|
211
212
|
var STADER_ETH = /*#__PURE__*/'0x30D20208d987713f46DFD34EF128Bb16C404D10f'.toLowerCase();
|
|
212
213
|
var USDT_ETH = /*#__PURE__*/'0xdAC17F958D2ee523a2206206994597C13D831ec7'.toLowerCase();
|
|
213
214
|
var AURIGAMI_SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/takao-aurigami/aurigami-feb-27';
|
|
214
|
-
var GRAPHQL_URL = 'https://explorer.
|
|
215
|
+
var GRAPHQL_URL = 'https://old.explorer.aurora.dev/api/v1/graphql';
|
|
215
216
|
|
|
216
217
|
var decimalRecords = {
|
|
217
218
|
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee': 18,
|
|
@@ -936,7 +937,7 @@ function _getBlocksTimestamp() {
|
|
|
936
937
|
case 8:
|
|
937
938
|
results = _context5.sent.reduce(function (acc, cur) {
|
|
938
939
|
return _extends({}, acc, cur);
|
|
939
|
-
});
|
|
940
|
+
}, {});
|
|
940
941
|
missingBlocks = blockNumbers.filter(function (blockNumber) {
|
|
941
942
|
return !results["b" + blockNumber];
|
|
942
943
|
});
|
|
@@ -1181,7 +1182,7 @@ var AuriEnv = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
1181
1182
|
key: "oracle",
|
|
1182
1183
|
get: function get() {
|
|
1183
1184
|
if (!this._oracle) {
|
|
1184
|
-
this._oracle = this.getContract(networkAddresses.misc.
|
|
1185
|
+
this._oracle = this.getContract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi);
|
|
1185
1186
|
}
|
|
1186
1187
|
return this._oracle;
|
|
1187
1188
|
}
|
|
@@ -1814,7 +1815,7 @@ function _fetchPriceFromOracle() {
|
|
|
1814
1815
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1815
1816
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1816
1817
|
case 0:
|
|
1817
|
-
oracleContract = new ethers.Contract(networkAddresses.misc.
|
|
1818
|
+
oracleContract = new ethers.Contract(networkAddresses.misc.PYTH_ORACLE, AuriOracleABI.abi, provider);
|
|
1818
1819
|
_context12.next = 3;
|
|
1819
1820
|
return oracleContract.getUnderlyingPrice(auTokenAddress)["catch"](function (e) {
|
|
1820
1821
|
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
@@ -2308,22 +2309,25 @@ function fetchHistoricalPriceFromOracle(_x7, _x8, _x9, _x10) {
|
|
|
2308
2309
|
}
|
|
2309
2310
|
function _fetchHistoricalPriceFromOracle() {
|
|
2310
2311
|
_fetchHistoricalPriceFromOracle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(auTokenAddress, underlyingDecimal, provider, block) {
|
|
2311
|
-
var oracleContract, rawPrice;
|
|
2312
|
+
var oracleAddress, oracleContract, rawPrice;
|
|
2312
2313
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
2313
2314
|
while (1) switch (_context4.prev = _context4.next) {
|
|
2314
2315
|
case 0:
|
|
2315
|
-
|
|
2316
|
-
|
|
2316
|
+
// from this block, we switch to use pyth
|
|
2317
|
+
// TODO: add to consts
|
|
2318
|
+
oracleAddress = block < 102438637 ? networkAddresses.misc.DEPRECATED_OLD_ORACLE : networkAddresses.misc.PYTH_ORACLE;
|
|
2319
|
+
oracleContract = new ethers.Contract(oracleAddress, AuriOracleABI.abi, provider);
|
|
2320
|
+
_context4.next = 4;
|
|
2317
2321
|
return oracleContract.getUnderlyingPrice(auTokenAddress, {
|
|
2318
2322
|
blockTag: block
|
|
2319
2323
|
})["catch"](function (e) {
|
|
2320
2324
|
console.log("Unable to fetch price from oracle for " + auTokenAddress);
|
|
2321
2325
|
return ethers.BigNumber.from(0);
|
|
2322
2326
|
});
|
|
2323
|
-
case
|
|
2327
|
+
case 4:
|
|
2324
2328
|
rawPrice = _context4.sent;
|
|
2325
2329
|
return _context4.abrupt("return", processPriceFromOracle$1(rawPrice, underlyingDecimal));
|
|
2326
|
-
case
|
|
2330
|
+
case 6:
|
|
2327
2331
|
case "end":
|
|
2328
2332
|
return _context4.stop();
|
|
2329
2333
|
}
|
|
@@ -5340,7 +5344,7 @@ var MiscRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
5340
5344
|
dust = /*#__PURE__*/new BigNumber(0.1);
|
|
5341
5345
|
}
|
|
5342
5346
|
_1E18 = ethers.BigNumber.from(10).pow(18);
|
|
5343
|
-
oracle = this.env.
|
|
5347
|
+
oracle = this.env.oracle;
|
|
5344
5348
|
tokens = tokenAddresses.map(function (addr) {
|
|
5345
5349
|
return _this2.env.getContract(addr, abis$5.abi);
|
|
5346
5350
|
});
|
|
@@ -5702,10 +5706,6 @@ function _postApi() {
|
|
|
5702
5706
|
return _postApi.apply(this, arguments);
|
|
5703
5707
|
}
|
|
5704
5708
|
|
|
5705
|
-
function getLiquidationEventsQuery(address, limit) {
|
|
5706
|
-
return "{\n liquidationEvents(\n first: " + limit + ",\n where: {from: \"" + address.toLowerCase() + "\"}\n ) {\n amount\n auTokenSymbol\n blockTime\n from\n id\n underlyingRepayAmountUSD\n underlyingSymbol\n underlyingRepayAmount\n }\n }";
|
|
5707
|
-
}
|
|
5708
|
-
|
|
5709
5709
|
var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
5710
5710
|
_inheritsLoose(SdkRead, _BlockchainEntityRead);
|
|
5711
5711
|
function SdkRead(networkConnection) {
|
|
@@ -6049,38 +6049,42 @@ var SdkRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
6049
6049
|
}();
|
|
6050
6050
|
_proto.getLiquidationHistory = /*#__PURE__*/function () {
|
|
6051
6051
|
var _getLiquidationHistory = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(address) {
|
|
6052
|
-
var
|
|
6052
|
+
var liquidationHistoryResp, blocks, blocksTimestamp, liquidationEvents;
|
|
6053
6053
|
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
6054
6054
|
while (1) switch (_context16.prev = _context16.next) {
|
|
6055
6055
|
case 0:
|
|
6056
6056
|
_context16.next = 2;
|
|
6057
|
-
return
|
|
6057
|
+
return getPaginatedApi('/liquidate/history', {
|
|
6058
|
+
user: address
|
|
6059
|
+
});
|
|
6058
6060
|
case 2:
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6061
|
+
liquidationHistoryResp = _context16.sent;
|
|
6062
|
+
blocks = liquidationHistoryResp.items.map(function (event) {
|
|
6063
|
+
return event.blockNumber;
|
|
6064
|
+
});
|
|
6065
|
+
_context16.next = 6;
|
|
6066
|
+
return getBlocksTimestamp(this._networkConnection.provider, blocks);
|
|
6067
|
+
case 6:
|
|
6068
|
+
blocksTimestamp = _context16.sent;
|
|
6069
|
+
liquidationEvents = liquidationHistoryResp.items.map(function (event, idx) {
|
|
6065
6070
|
var underlyingAddress = networkAddresses.auTokens.find(function (auToken) {
|
|
6066
|
-
return auToken.
|
|
6071
|
+
return auToken.address.toLowerCase() === event.marketRepayToken.toLowerCase();
|
|
6067
6072
|
}).underlying;
|
|
6068
6073
|
var decimal = getDecimal(underlyingAddress);
|
|
6069
6074
|
var token = new Token(underlyingAddress, decimal);
|
|
6070
|
-
var tokenAmount = new TokenAmount(token, event.
|
|
6075
|
+
var tokenAmount = new TokenAmount(token, event.repayAmount.toString(), true);
|
|
6071
6076
|
return {
|
|
6072
|
-
liquidationTime:
|
|
6077
|
+
liquidationTime: blocksTimestamp[idx],
|
|
6073
6078
|
tokenAmount: tokenAmount,
|
|
6074
|
-
|
|
6075
|
-
transactionId: event.id.split('-')[0]
|
|
6079
|
+
transactionId: event.txnHash
|
|
6076
6080
|
};
|
|
6077
6081
|
});
|
|
6078
6082
|
return _context16.abrupt("return", liquidationEvents);
|
|
6079
|
-
case
|
|
6083
|
+
case 9:
|
|
6080
6084
|
case "end":
|
|
6081
6085
|
return _context16.stop();
|
|
6082
6086
|
}
|
|
6083
|
-
}, _callee16);
|
|
6087
|
+
}, _callee16, this);
|
|
6084
6088
|
}));
|
|
6085
6089
|
function getLiquidationHistory(_x21) {
|
|
6086
6090
|
return _getLiquidationHistory.apply(this, arguments);
|