@aurigami/sdk 1.6.11 → 1.7.1
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/contracts/Referral.d.ts +7 -0
- package/dist/helpers/aurigami-api.d.ts +13 -0
- package/dist/helpers/graphql-helpers.d.ts +1 -0
- package/dist/helpers/helpers.d.ts +7 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/sdk.cjs.development.js +360 -35
- 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 +356 -36
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +4 -1
- package/src/contracts/Referral.ts +16 -0
- package/src/helpers/aurigami-api.ts +42 -0
- package/src/helpers/graphql-helpers.ts +12 -0
- package/src/helpers/helpers.ts +56 -0
- package/src/helpers/index.ts +2 -0
|
@@ -24,6 +24,13 @@ export declare class ReferralRead extends BlockchainEntityRead {
|
|
|
24
24
|
* Get owner of a referral code, returns zero address if not found.
|
|
25
25
|
*/
|
|
26
26
|
getReferralCodeOwner(code: string): Promise<Address>;
|
|
27
|
+
/**
|
|
28
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
29
|
+
*/
|
|
30
|
+
getReferralsList(userAddr: Address): Promise<{
|
|
31
|
+
user: string;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
}[]>;
|
|
27
34
|
}
|
|
28
35
|
export declare class ReferralReadWrite extends ReferralRead {
|
|
29
36
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function getApi(url: string, params?: Record<string, any>): Promise<any>;
|
|
2
|
+
export declare type MetaApiResponse = {
|
|
3
|
+
totalItems: number;
|
|
4
|
+
itemCount: number;
|
|
5
|
+
itemsPerPage: number;
|
|
6
|
+
totalPages: number;
|
|
7
|
+
currentPage: number;
|
|
8
|
+
};
|
|
9
|
+
export declare type PaginagedApiResponse<T> = {
|
|
10
|
+
items: T[];
|
|
11
|
+
meta: MetaApiResponse;
|
|
12
|
+
};
|
|
13
|
+
export declare function getPaginatedApi(url: string, params?: Record<string, any>, page?: number, pageSize?: number): Promise<PaginagedApiResponse<any>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function queryGraphQL(query: string): Promise<any>;
|
|
@@ -11,6 +11,13 @@ export declare function getDecimal(address: Address): number;
|
|
|
11
11
|
export declare function getSymbol(address: Address): string;
|
|
12
12
|
export declare function calcLMRewardApr(rewardsValue: BigNumber, totalStakeValue: BigNumber, frequencyPerYear: number): BigNumber;
|
|
13
13
|
export declare function getBlockTimestamp(provider: Provider, blockNumber: number): Promise<number>;
|
|
14
|
+
export declare function getBlocksTimestampViaRPC(provider: Provider, blocksNumber: number[]): Promise<number[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get timestamp of multiple blocks.
|
|
17
|
+
* @note the getBlockTimestamp function is too slow because of the RPC call, even with Promise.all.
|
|
18
|
+
* So I use the GraphQL endpoint of Aurora instead. You can check it here: https://explorer.mainnet.aurora.dev/graphiql
|
|
19
|
+
*/
|
|
20
|
+
export declare function getBlocksTimestamp(provider: Provider, blockNumbers: number[]): Promise<number[]>;
|
|
14
21
|
/**
|
|
15
22
|
* Get the block number of the last block that has a timestamp before the given timestamp
|
|
16
23
|
* @param timestamp input timestamp
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ var abis$9 = _interopDefault(require('@aurigami/contracts/artifacts/contracts/PU
|
|
|
26
26
|
var abis$a = _interopDefault(require('@aurigami/contracts/artifacts/contracts/ReferralDirectory.sol/ReferralDirectory.json'));
|
|
27
27
|
var abstractSigner = require('@ethersproject/abstract-signer');
|
|
28
28
|
var axios = _interopDefault(require('axios'));
|
|
29
|
+
var fetch = _interopDefault(require('node-fetch'));
|
|
29
30
|
|
|
30
31
|
var dummyAddress = '0xDEADbeEfEEeEEEeEEEeEEeeeeeEeEEeeeeEEEEeE';
|
|
31
32
|
var ETHAddress = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
@@ -1137,6 +1138,47 @@ function _getQuery() {
|
|
|
1137
1138
|
return _getQuery.apply(this, arguments);
|
|
1138
1139
|
}
|
|
1139
1140
|
|
|
1141
|
+
var GRAPHQL_URL = 'https://explorer.mainnet.aurora.dev/graphiql';
|
|
1142
|
+
function queryGraphQL(_x) {
|
|
1143
|
+
return _queryGraphQL.apply(this, arguments);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
function _queryGraphQL() {
|
|
1147
|
+
_queryGraphQL = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(query) {
|
|
1148
|
+
var resp;
|
|
1149
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1150
|
+
while (1) {
|
|
1151
|
+
switch (_context.prev = _context.next) {
|
|
1152
|
+
case 0:
|
|
1153
|
+
_context.next = 2;
|
|
1154
|
+
return fetch(GRAPHQL_URL, {
|
|
1155
|
+
headers: {
|
|
1156
|
+
'Content-Type': 'application/json'
|
|
1157
|
+
},
|
|
1158
|
+
method: 'POST',
|
|
1159
|
+
body: JSON.stringify({
|
|
1160
|
+
query: query
|
|
1161
|
+
})
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
case 2:
|
|
1165
|
+
resp = _context.sent;
|
|
1166
|
+
_context.next = 5;
|
|
1167
|
+
return resp.json();
|
|
1168
|
+
|
|
1169
|
+
case 5:
|
|
1170
|
+
return _context.abrupt("return", _context.sent.data);
|
|
1171
|
+
|
|
1172
|
+
case 6:
|
|
1173
|
+
case "end":
|
|
1174
|
+
return _context.stop();
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}, _callee);
|
|
1178
|
+
}));
|
|
1179
|
+
return _queryGraphQL.apply(this, arguments);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1140
1182
|
function assert(condition, message) {
|
|
1141
1183
|
if (message === void 0) {
|
|
1142
1184
|
message = '';
|
|
@@ -1191,14 +1233,6 @@ function calcLMRewardApr(rewardsValue, totalStakeValue, frequencyPerYear) {
|
|
|
1191
1233
|
function getBlockTimestamp(_x, _x2) {
|
|
1192
1234
|
return _getBlockTimestamp.apply(this, arguments);
|
|
1193
1235
|
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Get the block number of the last block that has a timestamp before the given timestamp
|
|
1196
|
-
* @param timestamp input timestamp
|
|
1197
|
-
* @returns return the last block that its timestamp <= the give timestamp
|
|
1198
|
-
* @note Check this API for more information: https://aurorascan.dev/apis#blocks
|
|
1199
|
-
*
|
|
1200
|
-
* This function is much faster than using binary search.
|
|
1201
|
-
*/
|
|
1202
1236
|
|
|
1203
1237
|
function _getBlockTimestamp() {
|
|
1204
1238
|
_getBlockTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(provider, blockNumber) {
|
|
@@ -1224,47 +1258,192 @@ function _getBlockTimestamp() {
|
|
|
1224
1258
|
return _getBlockTimestamp.apply(this, arguments);
|
|
1225
1259
|
}
|
|
1226
1260
|
|
|
1227
|
-
function
|
|
1261
|
+
function getBlocksTimestampViaRPC(_x3, _x4) {
|
|
1262
|
+
return _getBlocksTimestampViaRPC.apply(this, arguments);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Get timestamp of multiple blocks.
|
|
1266
|
+
* @note the getBlockTimestamp function is too slow because of the RPC call, even with Promise.all.
|
|
1267
|
+
* So I use the GraphQL endpoint of Aurora instead. You can check it here: https://explorer.mainnet.aurora.dev/graphiql
|
|
1268
|
+
*/
|
|
1269
|
+
|
|
1270
|
+
function _getBlocksTimestampViaRPC() {
|
|
1271
|
+
_getBlocksTimestampViaRPC = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(provider, blocksNumber) {
|
|
1272
|
+
var CHUNK_SIZE, results, i, slice, promises;
|
|
1273
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1274
|
+
while (1) {
|
|
1275
|
+
switch (_context3.prev = _context3.next) {
|
|
1276
|
+
case 0:
|
|
1277
|
+
// Promise all 200 blocks at a time, using too many blocks at once will cause the RPC call timeout.
|
|
1278
|
+
CHUNK_SIZE = 200;
|
|
1279
|
+
results = [];
|
|
1280
|
+
i = 0;
|
|
1281
|
+
|
|
1282
|
+
case 3:
|
|
1283
|
+
if (!(i < blocksNumber.length)) {
|
|
1284
|
+
_context3.next = 14;
|
|
1285
|
+
break;
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
slice = blocksNumber.slice(i, i + CHUNK_SIZE);
|
|
1289
|
+
promises = slice.map( /*#__PURE__*/function () {
|
|
1290
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(blockNumber) {
|
|
1291
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1292
|
+
while (1) {
|
|
1293
|
+
switch (_context2.prev = _context2.next) {
|
|
1294
|
+
case 0:
|
|
1295
|
+
return _context2.abrupt("return", getBlockTimestamp(provider, blockNumber));
|
|
1296
|
+
|
|
1297
|
+
case 1:
|
|
1298
|
+
case "end":
|
|
1299
|
+
return _context2.stop();
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
}, _callee2);
|
|
1303
|
+
}));
|
|
1304
|
+
|
|
1305
|
+
return function (_x9) {
|
|
1306
|
+
return _ref.apply(this, arguments);
|
|
1307
|
+
};
|
|
1308
|
+
}());
|
|
1309
|
+
_context3.t0 = results;
|
|
1310
|
+
_context3.next = 9;
|
|
1311
|
+
return Promise.all(promises);
|
|
1312
|
+
|
|
1313
|
+
case 9:
|
|
1314
|
+
_context3.t1 = _context3.sent;
|
|
1315
|
+
results = _context3.t0.concat.call(_context3.t0, _context3.t1);
|
|
1316
|
+
|
|
1317
|
+
case 11:
|
|
1318
|
+
i += CHUNK_SIZE;
|
|
1319
|
+
_context3.next = 3;
|
|
1320
|
+
break;
|
|
1321
|
+
|
|
1322
|
+
case 14:
|
|
1323
|
+
return _context3.abrupt("return", results);
|
|
1324
|
+
|
|
1325
|
+
case 15:
|
|
1326
|
+
case "end":
|
|
1327
|
+
return _context3.stop();
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}, _callee3);
|
|
1331
|
+
}));
|
|
1332
|
+
return _getBlocksTimestampViaRPC.apply(this, arguments);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
function getBlocksTimestamp(_x5, _x6) {
|
|
1336
|
+
return _getBlocksTimestamp.apply(this, arguments);
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Get the block number of the last block that has a timestamp before the given timestamp
|
|
1340
|
+
* @param timestamp input timestamp
|
|
1341
|
+
* @returns return the last block that its timestamp <= the give timestamp
|
|
1342
|
+
* @note Check this API for more information: https://aurorascan.dev/apis#blocks
|
|
1343
|
+
*
|
|
1344
|
+
* This function is much faster than using binary search.
|
|
1345
|
+
*/
|
|
1346
|
+
|
|
1347
|
+
function _getBlocksTimestamp() {
|
|
1348
|
+
_getBlocksTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(provider, blockNumbers) {
|
|
1349
|
+
var CHUNK_SIZE, promises, lines, i, query, results, missingBlocks, missingBlocksTimestamps;
|
|
1350
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1351
|
+
while (1) {
|
|
1352
|
+
switch (_context4.prev = _context4.next) {
|
|
1353
|
+
case 0:
|
|
1354
|
+
CHUNK_SIZE = 100; // graphql query limit
|
|
1355
|
+
|
|
1356
|
+
promises = [];
|
|
1357
|
+
lines = blockNumbers.map(function (x) {
|
|
1358
|
+
return "b" + x + ": block(number: " + x + ") { timestamp }";
|
|
1359
|
+
});
|
|
1360
|
+
|
|
1361
|
+
for (i = 0; i < lines.length; i += CHUNK_SIZE) {
|
|
1362
|
+
query = "{ " + lines.slice(i, i + CHUNK_SIZE).join('\n') + " }";
|
|
1363
|
+
promises.push(queryGraphQL(query));
|
|
1364
|
+
} // merge all the json objects
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
_context4.next = 6;
|
|
1368
|
+
return Promise.all(promises);
|
|
1369
|
+
|
|
1370
|
+
case 6:
|
|
1371
|
+
results = _context4.sent.reduce(function (acc, cur) {
|
|
1372
|
+
return _extends({}, acc, cur);
|
|
1373
|
+
});
|
|
1374
|
+
missingBlocks = blockNumbers.filter(function (blockNumber) {
|
|
1375
|
+
return !results["b" + blockNumber];
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
if (missingBlocks.length > 0) {
|
|
1379
|
+
devLog("These blocks are missing from Aurora GraphQL endpoint: " + missingBlocks.join(', '));
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
_context4.next = 11;
|
|
1383
|
+
return getBlocksTimestampViaRPC(provider, missingBlocks);
|
|
1384
|
+
|
|
1385
|
+
case 11:
|
|
1386
|
+
missingBlocksTimestamps = _context4.sent;
|
|
1387
|
+
missingBlocksTimestamps.forEach(function (timestamp, index) {
|
|
1388
|
+
results["b" + missingBlocks[index]] = {
|
|
1389
|
+
timestamp: new Date(timestamp * 1000).toISOString()
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
return _context4.abrupt("return", blockNumbers.map(function (blockNumber) {
|
|
1393
|
+
return Math.trunc(new Date(results["b" + blockNumber].timestamp).getTime() / 1000);
|
|
1394
|
+
}));
|
|
1395
|
+
|
|
1396
|
+
case 14:
|
|
1397
|
+
case "end":
|
|
1398
|
+
return _context4.stop();
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}, _callee4);
|
|
1402
|
+
}));
|
|
1403
|
+
return _getBlocksTimestamp.apply(this, arguments);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
function getBlockBeforeTimestamp(_x7, _x8) {
|
|
1228
1407
|
return _getBlockBeforeTimestamp.apply(this, arguments);
|
|
1229
1408
|
}
|
|
1230
1409
|
|
|
1231
1410
|
function _getBlockBeforeTimestamp() {
|
|
1232
|
-
_getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
1411
|
+
_getBlockBeforeTimestamp = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(provider, timestamp) {
|
|
1233
1412
|
var result;
|
|
1234
|
-
return runtime_1.wrap(function
|
|
1413
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1235
1414
|
while (1) {
|
|
1236
|
-
switch (
|
|
1415
|
+
switch (_context5.prev = _context5.next) {
|
|
1237
1416
|
case 0:
|
|
1238
|
-
|
|
1417
|
+
_context5.next = 2;
|
|
1239
1418
|
return getQuery('block', 'getblocknobytime', {
|
|
1240
1419
|
timestamp: timestamp,
|
|
1241
1420
|
closest: 'before'
|
|
1242
1421
|
});
|
|
1243
1422
|
|
|
1244
1423
|
case 2:
|
|
1245
|
-
result =
|
|
1246
|
-
|
|
1424
|
+
result = _context5.sent;
|
|
1425
|
+
_context5.t0 = parseInt(result);
|
|
1247
1426
|
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1427
|
+
if (_context5.t0) {
|
|
1428
|
+
_context5.next = 8;
|
|
1250
1429
|
break;
|
|
1251
1430
|
}
|
|
1252
1431
|
|
|
1253
|
-
|
|
1432
|
+
_context5.next = 7;
|
|
1254
1433
|
return provider.getBlockNumber();
|
|
1255
1434
|
|
|
1256
1435
|
case 7:
|
|
1257
|
-
|
|
1436
|
+
_context5.t0 = _context5.sent;
|
|
1258
1437
|
|
|
1259
1438
|
case 8:
|
|
1260
|
-
return
|
|
1439
|
+
return _context5.abrupt("return", _context5.t0);
|
|
1261
1440
|
|
|
1262
1441
|
case 9:
|
|
1263
1442
|
case "end":
|
|
1264
|
-
return
|
|
1443
|
+
return _context5.stop();
|
|
1265
1444
|
}
|
|
1266
1445
|
}
|
|
1267
|
-
},
|
|
1446
|
+
}, _callee5);
|
|
1268
1447
|
}));
|
|
1269
1448
|
return _getBlockBeforeTimestamp.apply(this, arguments);
|
|
1270
1449
|
}
|
|
@@ -1343,6 +1522,91 @@ var dummyUserMarketDetails = {
|
|
|
1343
1522
|
underlyingPrice: '1'
|
|
1344
1523
|
};
|
|
1345
1524
|
|
|
1525
|
+
var AURIGAMI_API_END_POINT = 'https://api.aurigami.finance/app/';
|
|
1526
|
+
function getApi(_x, _x2) {
|
|
1527
|
+
return _getApi.apply(this, arguments);
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1530
|
+
function _getApi() {
|
|
1531
|
+
_getApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(url, params) {
|
|
1532
|
+
var resp;
|
|
1533
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1534
|
+
while (1) {
|
|
1535
|
+
switch (_context.prev = _context.next) {
|
|
1536
|
+
case 0:
|
|
1537
|
+
if (params === void 0) {
|
|
1538
|
+
params = {};
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
_context.next = 3;
|
|
1542
|
+
return axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
1543
|
+
headers: {
|
|
1544
|
+
'Content-Type': 'application/json'
|
|
1545
|
+
}
|
|
1546
|
+
});
|
|
1547
|
+
|
|
1548
|
+
case 3:
|
|
1549
|
+
resp = _context.sent;
|
|
1550
|
+
return _context.abrupt("return", resp.data);
|
|
1551
|
+
|
|
1552
|
+
case 5:
|
|
1553
|
+
case "end":
|
|
1554
|
+
return _context.stop();
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}, _callee);
|
|
1558
|
+
}));
|
|
1559
|
+
return _getApi.apply(this, arguments);
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
function getPaginatedApi(_x3, _x4, _x5, _x6) {
|
|
1563
|
+
return _getPaginatedApi.apply(this, arguments);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
function _getPaginatedApi() {
|
|
1567
|
+
_getPaginatedApi = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(url, params, page, pageSize) {
|
|
1568
|
+
var resp;
|
|
1569
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1570
|
+
while (1) {
|
|
1571
|
+
switch (_context2.prev = _context2.next) {
|
|
1572
|
+
case 0:
|
|
1573
|
+
if (params === void 0) {
|
|
1574
|
+
params = {};
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
if (page === void 0) {
|
|
1578
|
+
page = 1;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
if (pageSize === void 0) {
|
|
1582
|
+
pageSize = 50;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
params = _extends({}, params, {
|
|
1586
|
+
page: page,
|
|
1587
|
+
limit: pageSize
|
|
1588
|
+
});
|
|
1589
|
+
_context2.next = 6;
|
|
1590
|
+
return axios.get(AURIGAMI_API_END_POINT + url + '?' + new URLSearchParams(params), {
|
|
1591
|
+
headers: {
|
|
1592
|
+
'Content-Type': 'application/json'
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
case 6:
|
|
1597
|
+
resp = _context2.sent;
|
|
1598
|
+
return _context2.abrupt("return", resp.data);
|
|
1599
|
+
|
|
1600
|
+
case 8:
|
|
1601
|
+
case "end":
|
|
1602
|
+
return _context2.stop();
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
}, _callee2);
|
|
1606
|
+
}));
|
|
1607
|
+
return _getPaginatedApi.apply(this, arguments);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1346
1610
|
function fetchPriceFromCoingeckoAPI(_x) {
|
|
1347
1611
|
return _fetchPriceFromCoingeckoAPI.apply(this, arguments);
|
|
1348
1612
|
}
|
|
@@ -2038,7 +2302,10 @@ var TransferEventQuery = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
2038
2302
|
|
|
2039
2303
|
var helpers = {
|
|
2040
2304
|
__proto__: null,
|
|
2305
|
+
getApi: getApi,
|
|
2306
|
+
getPaginatedApi: getPaginatedApi,
|
|
2041
2307
|
getQuery: getQuery,
|
|
2308
|
+
queryGraphQL: queryGraphQL,
|
|
2042
2309
|
assert: assert,
|
|
2043
2310
|
formatObject: formatObject,
|
|
2044
2311
|
decimalFactor: decimalFactor,
|
|
@@ -2049,6 +2316,8 @@ var helpers = {
|
|
|
2049
2316
|
getSymbol: getSymbol,
|
|
2050
2317
|
calcLMRewardApr: calcLMRewardApr,
|
|
2051
2318
|
getBlockTimestamp: getBlockTimestamp,
|
|
2319
|
+
getBlocksTimestampViaRPC: getBlocksTimestampViaRPC,
|
|
2320
|
+
getBlocksTimestamp: getBlocksTimestamp,
|
|
2052
2321
|
getBlockBeforeTimestamp: getBlockBeforeTimestamp,
|
|
2053
2322
|
devLog: devLog,
|
|
2054
2323
|
fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
|
|
@@ -4209,6 +4478,57 @@ var ReferralRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4209
4478
|
}
|
|
4210
4479
|
|
|
4211
4480
|
return getReferralCodeOwner;
|
|
4481
|
+
}()
|
|
4482
|
+
/**
|
|
4483
|
+
* Get referrals of a user, sorted descending by timestamp.
|
|
4484
|
+
*/
|
|
4485
|
+
;
|
|
4486
|
+
|
|
4487
|
+
_proto.getReferralsList =
|
|
4488
|
+
/*#__PURE__*/
|
|
4489
|
+
function () {
|
|
4490
|
+
var _getReferralsList = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(userAddr) {
|
|
4491
|
+
var result, blocks, blocksTimestamp, items;
|
|
4492
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
4493
|
+
while (1) {
|
|
4494
|
+
switch (_context4.prev = _context4.next) {
|
|
4495
|
+
case 0:
|
|
4496
|
+
_context4.next = 2;
|
|
4497
|
+
return getPaginatedApi('/referral/list', {
|
|
4498
|
+
address: userAddr
|
|
4499
|
+
});
|
|
4500
|
+
|
|
4501
|
+
case 2:
|
|
4502
|
+
result = _context4.sent;
|
|
4503
|
+
blocks = result.items.map(function (item) {
|
|
4504
|
+
return item.blockNumber;
|
|
4505
|
+
});
|
|
4506
|
+
_context4.next = 6;
|
|
4507
|
+
return getBlocksTimestamp(this._networkConnection.provider, blocks);
|
|
4508
|
+
|
|
4509
|
+
case 6:
|
|
4510
|
+
blocksTimestamp = _context4.sent;
|
|
4511
|
+
items = result.items.map(function (item, i) {
|
|
4512
|
+
return {
|
|
4513
|
+
user: item.user,
|
|
4514
|
+
timestamp: blocksTimestamp[i]
|
|
4515
|
+
};
|
|
4516
|
+
});
|
|
4517
|
+
return _context4.abrupt("return", items);
|
|
4518
|
+
|
|
4519
|
+
case 9:
|
|
4520
|
+
case "end":
|
|
4521
|
+
return _context4.stop();
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
}, _callee4, this);
|
|
4525
|
+
}));
|
|
4526
|
+
|
|
4527
|
+
function getReferralsList(_x4) {
|
|
4528
|
+
return _getReferralsList.apply(this, arguments);
|
|
4529
|
+
}
|
|
4530
|
+
|
|
4531
|
+
return getReferralsList;
|
|
4212
4532
|
}();
|
|
4213
4533
|
|
|
4214
4534
|
return ReferralRead;
|
|
@@ -4230,21 +4550,21 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
|
4230
4550
|
_proto2.registerNewReferralCode =
|
|
4231
4551
|
/*#__PURE__*/
|
|
4232
4552
|
function () {
|
|
4233
|
-
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4553
|
+
var _registerNewReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
4234
4554
|
var referralCode;
|
|
4235
|
-
return runtime_1.wrap(function
|
|
4555
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
4236
4556
|
while (1) {
|
|
4237
|
-
switch (
|
|
4557
|
+
switch (_context5.prev = _context5.next) {
|
|
4238
4558
|
case 0:
|
|
4239
4559
|
referralCode = ethers.ethers.utils.formatBytes32String(this.generateReferralCode());
|
|
4240
|
-
return
|
|
4560
|
+
return _context5.abrupt("return", this.referral.connect(this._networkConnection.signer).registerNewUserReferralCode(referralCode));
|
|
4241
4561
|
|
|
4242
4562
|
case 2:
|
|
4243
4563
|
case "end":
|
|
4244
|
-
return
|
|
4564
|
+
return _context5.stop();
|
|
4245
4565
|
}
|
|
4246
4566
|
}
|
|
4247
|
-
},
|
|
4567
|
+
}, _callee5, this);
|
|
4248
4568
|
}));
|
|
4249
4569
|
|
|
4250
4570
|
function registerNewReferralCode() {
|
|
@@ -4261,24 +4581,24 @@ var ReferralReadWrite = /*#__PURE__*/function (_ReferralRead) {
|
|
|
4261
4581
|
_proto2.useReferralCode =
|
|
4262
4582
|
/*#__PURE__*/
|
|
4263
4583
|
function () {
|
|
4264
|
-
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
4584
|
+
var _useReferralCode = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(code) {
|
|
4265
4585
|
var referralCode;
|
|
4266
|
-
return runtime_1.wrap(function
|
|
4586
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
4267
4587
|
while (1) {
|
|
4268
|
-
switch (
|
|
4588
|
+
switch (_context6.prev = _context6.next) {
|
|
4269
4589
|
case 0:
|
|
4270
4590
|
referralCode = ethers.ethers.utils.formatBytes32String(code);
|
|
4271
|
-
return
|
|
4591
|
+
return _context6.abrupt("return", this.referral.connect(this._networkConnection.signer).registerReferralCodeUsed(referralCode));
|
|
4272
4592
|
|
|
4273
4593
|
case 2:
|
|
4274
4594
|
case "end":
|
|
4275
|
-
return
|
|
4595
|
+
return _context6.stop();
|
|
4276
4596
|
}
|
|
4277
4597
|
}
|
|
4278
|
-
},
|
|
4598
|
+
}, _callee6, this);
|
|
4279
4599
|
}));
|
|
4280
4600
|
|
|
4281
|
-
function useReferralCode(
|
|
4601
|
+
function useReferralCode(_x5) {
|
|
4282
4602
|
return _useReferralCode.apply(this, arguments);
|
|
4283
4603
|
}
|
|
4284
4604
|
|
|
@@ -4793,14 +5113,19 @@ exports.fetchToken0PriceByLP = fetchToken0PriceByLP;
|
|
|
4793
5113
|
exports.fetchUnderlyingTokensPrices = fetchUnderlyingTokensPrices;
|
|
4794
5114
|
exports.fetchValuation = fetchValuation;
|
|
4795
5115
|
exports.formatObject = formatObject;
|
|
5116
|
+
exports.getApi = getApi;
|
|
4796
5117
|
exports.getBlockBeforeTimestamp = getBlockBeforeTimestamp;
|
|
4797
5118
|
exports.getBlockTimestamp = getBlockTimestamp;
|
|
5119
|
+
exports.getBlocksTimestamp = getBlocksTimestamp;
|
|
5120
|
+
exports.getBlocksTimestampViaRPC = getBlocksTimestampViaRPC;
|
|
4798
5121
|
exports.getCurrentTimestamp = getCurrentTimestamp;
|
|
4799
5122
|
exports.getDecimal = getDecimal;
|
|
5123
|
+
exports.getPaginatedApi = getPaginatedApi;
|
|
4800
5124
|
exports.getQuery = getQuery;
|
|
4801
5125
|
exports.getSymbol = getSymbol;
|
|
4802
5126
|
exports.isSameAddress = isSameAddress;
|
|
4803
5127
|
exports.networkAddresses = networkAddresses;
|
|
5128
|
+
exports.queryGraphQL = queryGraphQL;
|
|
4804
5129
|
exports.symbolRecords = symbolRecords;
|
|
4805
5130
|
exports.validateAndParseAddress = validateAndParseAddress;
|
|
4806
5131
|
exports.valuateToken = valuateToken;
|