@aurigami/sdk 1.13.0 → 1.14.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/ChangeLog.md +376 -0
- package/dist/helpers/helpers.d.ts +0 -1
- package/dist/interactors/PlyGame.d.ts +1 -0
- package/dist/sdk.cjs.development.js +136 -71
- 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 +137 -71
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +2 -1
- package/src/.DS_Store +0 -0
- package/src/consts/constants.ts +0 -1
- package/src/helpers/helpers.ts +19 -19
- package/src/helpers/priceFetcher.ts +3 -1
- package/src/interactors/MoneyMarket.ts +15 -14
- package/src/interactors/PlyGame.ts +9 -0
package/dist/sdk.esm.js
CHANGED
|
@@ -23,6 +23,7 @@ export { default as TESTNET_ADDRESSES } from '@aurigami/contracts/deployments/au
|
|
|
23
23
|
import axios from 'axios';
|
|
24
24
|
import { Signer } from '@ethersproject/abstract-signer';
|
|
25
25
|
import { __decorate, __metadata } from 'tslib';
|
|
26
|
+
import { cache, CacheType } from 'cache-decorator';
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
@@ -131,7 +132,7 @@ var networkAddresses = {
|
|
|
131
132
|
AURORA_WNEAR: /*#__PURE__*/'0x1e0e812fbcd3eb75d8562ad6f310ed94d258d008'.toLowerCase()
|
|
132
133
|
}
|
|
133
134
|
};
|
|
134
|
-
var DEPOSIT_ONLY_TOKENS = [/*#__PURE__*/MAINNET_ADDRESSES.auTokens.
|
|
135
|
+
var DEPOSIT_ONLY_TOKENS = [/*#__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
|
|
135
136
|
|
|
136
137
|
var PRICE_WHITELISTED = /*#__PURE__*/new Set( /*#__PURE__*/[].concat( /*#__PURE__*/networkAddresses.auTokens.map(function (t) {
|
|
137
138
|
return t.underlying;
|
|
@@ -1534,37 +1535,25 @@ function sortEvents(events) {
|
|
|
1534
1535
|
|
|
1535
1536
|
return a.blockNumber - b.blockNumber;
|
|
1536
1537
|
});
|
|
1537
|
-
}
|
|
1538
|
-
function
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
return value;
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
var result = originalMethod.apply(this, args);
|
|
1561
|
-
cache.set(key, [Date.now(), result]);
|
|
1562
|
-
return result;
|
|
1563
|
-
};
|
|
1564
|
-
|
|
1565
|
-
return descriptor;
|
|
1566
|
-
};
|
|
1567
|
-
}
|
|
1538
|
+
} // export function Cache(cacheTimeout: number) {
|
|
1539
|
+
// return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
1540
|
+
// const originalMethod = descriptor.value;
|
|
1541
|
+
// let cache = new Map<string, any>();
|
|
1542
|
+
// descriptor.value = function (...args: any[]) {
|
|
1543
|
+
// let key = JSON.stringify(args);
|
|
1544
|
+
// if (cache.has(key)) {
|
|
1545
|
+
// let [timestamp, value] = cache.get(key);
|
|
1546
|
+
// if (Date.now() - timestamp < cacheTimeout) {
|
|
1547
|
+
// return value;
|
|
1548
|
+
// }
|
|
1549
|
+
// }
|
|
1550
|
+
// let result = originalMethod.apply(this, args);
|
|
1551
|
+
// cache.set(key, [Date.now(), result]);
|
|
1552
|
+
// return result;
|
|
1553
|
+
// };
|
|
1554
|
+
// return descriptor;
|
|
1555
|
+
// };
|
|
1556
|
+
// }
|
|
1568
1557
|
|
|
1569
1558
|
var BlockchainEntityRead = function BlockchainEntityRead(networkConnection) {
|
|
1570
1559
|
this._networkConnection = networkConnection;
|
|
@@ -1951,6 +1940,7 @@ function _fetchPriceFromDefiLlamaAPI() {
|
|
|
1951
1940
|
return res.data.coins[id].price;
|
|
1952
1941
|
})["catch"](function (err) {
|
|
1953
1942
|
console.log("unable to fetch price from DefiLlama API: " + err);
|
|
1943
|
+
console.error(err);
|
|
1954
1944
|
return 0;
|
|
1955
1945
|
});
|
|
1956
1946
|
|
|
@@ -1984,6 +1974,7 @@ function _fetchPriceFromCoingeckoAPI() {
|
|
|
1984
1974
|
return res.data[id];
|
|
1985
1975
|
})["catch"](function (err) {
|
|
1986
1976
|
console.log("Unable to fetch price from Coingecko API for " + id);
|
|
1977
|
+
console.error(err);
|
|
1987
1978
|
return {
|
|
1988
1979
|
usd: 0
|
|
1989
1980
|
};
|
|
@@ -3098,7 +3089,6 @@ var helpers = {
|
|
|
3098
3089
|
getBlockBeforeTimestamp: getBlockBeforeTimestamp,
|
|
3099
3090
|
devLog: devLog,
|
|
3100
3091
|
sortEvents: sortEvents,
|
|
3101
|
-
Cache: Cache,
|
|
3102
3092
|
fetchPriceFromDefiLlamaAPI: fetchPriceFromDefiLlamaAPI,
|
|
3103
3093
|
fetchPriceFromCoingeckoAPI: fetchPriceFromCoingeckoAPI,
|
|
3104
3094
|
fetchPriceFromDefiLlama: fetchPriceFromDefiLlama,
|
|
@@ -4042,31 +4032,70 @@ var MoneyMarketRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
4042
4032
|
return MoneyMarketRead;
|
|
4043
4033
|
}(BlockchainEntityRead);
|
|
4044
4034
|
|
|
4045
|
-
__decorate([
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
__decorate([
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
__decorate([
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4035
|
+
__decorate([cache({
|
|
4036
|
+
ttl: CACHE_TIMEOUT,
|
|
4037
|
+
type: CacheType.MEMO
|
|
4038
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getUnderlyingPrice", null);
|
|
4039
|
+
|
|
4040
|
+
__decorate([cache({
|
|
4041
|
+
ttl: CACHE_TIMEOUT,
|
|
4042
|
+
type: CacheType.MEMO
|
|
4043
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getPlyPrice", null);
|
|
4044
|
+
|
|
4045
|
+
__decorate([cache({
|
|
4046
|
+
ttl: CACHE_TIMEOUT,
|
|
4047
|
+
type: CacheType.MEMO
|
|
4048
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getRewardSpeeds", null);
|
|
4049
|
+
|
|
4050
|
+
__decorate([cache({
|
|
4051
|
+
ttl: CACHE_TIMEOUT,
|
|
4052
|
+
type: CacheType.MEMO
|
|
4053
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getTotalTokenBorrowed", null);
|
|
4054
|
+
|
|
4055
|
+
__decorate([cache({
|
|
4056
|
+
ttl: CACHE_TIMEOUT,
|
|
4057
|
+
type: CacheType.MEMO
|
|
4058
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getTotalTokenDeposited", null);
|
|
4059
|
+
|
|
4060
|
+
__decorate([cache({
|
|
4061
|
+
ttl: CACHE_TIMEOUT,
|
|
4062
|
+
type: CacheType.MEMO
|
|
4063
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositAPY", null);
|
|
4064
|
+
|
|
4065
|
+
__decorate([cache({
|
|
4066
|
+
ttl: CACHE_TIMEOUT,
|
|
4067
|
+
type: CacheType.MEMO
|
|
4068
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowAPY", null);
|
|
4069
|
+
|
|
4070
|
+
__decorate([cache({
|
|
4071
|
+
ttl: CACHE_TIMEOUT,
|
|
4072
|
+
type: CacheType.MEMO
|
|
4073
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getCollateralRatio", null);
|
|
4074
|
+
|
|
4075
|
+
__decorate([cache({
|
|
4076
|
+
ttl: CACHE_TIMEOUT,
|
|
4077
|
+
type: CacheType.MEMO
|
|
4078
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowPlyAPY", null);
|
|
4079
|
+
|
|
4080
|
+
__decorate([cache({
|
|
4081
|
+
ttl: CACHE_TIMEOUT,
|
|
4082
|
+
type: CacheType.MEMO
|
|
4083
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositPlyAPY", null);
|
|
4084
|
+
|
|
4085
|
+
__decorate([cache({
|
|
4086
|
+
ttl: CACHE_TIMEOUT,
|
|
4087
|
+
type: CacheType.MEMO
|
|
4088
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositNearAPY", null);
|
|
4089
|
+
|
|
4090
|
+
__decorate([cache({
|
|
4091
|
+
ttl: CACHE_TIMEOUT,
|
|
4092
|
+
type: CacheType.MEMO
|
|
4093
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getBorrowNearAPY", null);
|
|
4094
|
+
|
|
4095
|
+
__decorate([cache({
|
|
4096
|
+
ttl: CACHE_TIMEOUT,
|
|
4097
|
+
type: CacheType.MEMO
|
|
4098
|
+
}), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", Promise)], MoneyMarketRead.prototype, "getDepositMetaAPY", null);
|
|
4070
4099
|
|
|
4071
4100
|
var MoneyMarketReadWrite = /*#__PURE__*/function (_MoneyMarketRead) {
|
|
4072
4101
|
_inheritsLoose(MoneyMarketReadWrite, _MoneyMarketRead);
|
|
@@ -5880,6 +5909,43 @@ var PlyGameRead = /*#__PURE__*/function (_BlockchainEntityRead) {
|
|
|
5880
5909
|
return getLastJackpotResult;
|
|
5881
5910
|
}();
|
|
5882
5911
|
|
|
5912
|
+
_proto.overallLeaderboard = /*#__PURE__*/function () {
|
|
5913
|
+
var _overallLeaderboard = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee8() {
|
|
5914
|
+
var _this5 = this;
|
|
5915
|
+
|
|
5916
|
+
var result;
|
|
5917
|
+
return runtime_1.wrap(function _callee8$(_context8) {
|
|
5918
|
+
while (1) {
|
|
5919
|
+
switch (_context8.prev = _context8.next) {
|
|
5920
|
+
case 0:
|
|
5921
|
+
_context8.next = 2;
|
|
5922
|
+
return getPaginatedApi('/plygame/overallLeaderboard');
|
|
5923
|
+
|
|
5924
|
+
case 2:
|
|
5925
|
+
result = _context8.sent;
|
|
5926
|
+
return _context8.abrupt("return", result.items.map(function (item) {
|
|
5927
|
+
return {
|
|
5928
|
+
player: item.user,
|
|
5929
|
+
unlockedPulpAmount: new TokenAmount(_this5.pulpToken, item.unlockedAmount),
|
|
5930
|
+
gamesPlayed: item.count
|
|
5931
|
+
};
|
|
5932
|
+
}));
|
|
5933
|
+
|
|
5934
|
+
case 4:
|
|
5935
|
+
case "end":
|
|
5936
|
+
return _context8.stop();
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5939
|
+
}, _callee8);
|
|
5940
|
+
}));
|
|
5941
|
+
|
|
5942
|
+
function overallLeaderboard() {
|
|
5943
|
+
return _overallLeaderboard.apply(this, arguments);
|
|
5944
|
+
}
|
|
5945
|
+
|
|
5946
|
+
return overallLeaderboard;
|
|
5947
|
+
}();
|
|
5948
|
+
|
|
5883
5949
|
return PlyGameRead;
|
|
5884
5950
|
}(BlockchainEntityRead);
|
|
5885
5951
|
var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
@@ -5897,19 +5963,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
|
5897
5963
|
_proto2.makeBetOnce =
|
|
5898
5964
|
/*#__PURE__*/
|
|
5899
5965
|
function () {
|
|
5900
|
-
var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
5901
|
-
return runtime_1.wrap(function
|
|
5966
|
+
var _makeBetOnce = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee9(amount) {
|
|
5967
|
+
return runtime_1.wrap(function _callee9$(_context9) {
|
|
5902
5968
|
while (1) {
|
|
5903
|
-
switch (
|
|
5969
|
+
switch (_context9.prev = _context9.next) {
|
|
5904
5970
|
case 0:
|
|
5905
|
-
return
|
|
5971
|
+
return _context9.abrupt("return", this.env.plygame.connect(this._networkConnection.signer).makeBetOnce(amount.rawAmount()));
|
|
5906
5972
|
|
|
5907
5973
|
case 1:
|
|
5908
5974
|
case "end":
|
|
5909
|
-
return
|
|
5975
|
+
return _context9.stop();
|
|
5910
5976
|
}
|
|
5911
5977
|
}
|
|
5912
|
-
},
|
|
5978
|
+
}, _callee9, this);
|
|
5913
5979
|
}));
|
|
5914
5980
|
|
|
5915
5981
|
function makeBetOnce(_x5) {
|
|
@@ -5920,19 +5986,19 @@ var PlyGameReadWrite = /*#__PURE__*/function (_PlyGameRead) {
|
|
|
5920
5986
|
}();
|
|
5921
5987
|
|
|
5922
5988
|
_proto2.approve = /*#__PURE__*/function () {
|
|
5923
|
-
var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
5924
|
-
return runtime_1.wrap(function
|
|
5989
|
+
var _approve = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee10(amount) {
|
|
5990
|
+
return runtime_1.wrap(function _callee10$(_context10) {
|
|
5925
5991
|
while (1) {
|
|
5926
|
-
switch (
|
|
5992
|
+
switch (_context10.prev = _context10.next) {
|
|
5927
5993
|
case 0:
|
|
5928
|
-
return
|
|
5994
|
+
return _context10.abrupt("return", this.env.ply.connect(this._networkConnection.signer).approve(this.env.plygame.address, amount.rawAmount()));
|
|
5929
5995
|
|
|
5930
5996
|
case 1:
|
|
5931
5997
|
case "end":
|
|
5932
|
-
return
|
|
5998
|
+
return _context10.stop();
|
|
5933
5999
|
}
|
|
5934
6000
|
}
|
|
5935
|
-
},
|
|
6001
|
+
}, _callee10, this);
|
|
5936
6002
|
}));
|
|
5937
6003
|
|
|
5938
6004
|
function approve(_x6) {
|
|
@@ -7066,5 +7132,5 @@ BigNumber.config({
|
|
|
7066
7132
|
DECIMAL_PLACES: 50
|
|
7067
7133
|
});
|
|
7068
7134
|
|
|
7069
|
-
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, CACHE_TIMEOUT,
|
|
7135
|
+
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, CACHE_TIMEOUT, 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, calcNetApy, 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 };
|
|
7070
7136
|
//# sourceMappingURL=sdk.esm.js.map
|