@pioneer-platform/markets 8.11.1 → 8.11.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/CHANGELOG.md +13 -0
- package/lib/index.js +50 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @pioneer-platform/markets
|
|
2
2
|
|
|
3
|
+
## 8.11.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @pioneer-platform/pioneer-discovery@4.21.15
|
|
9
|
+
|
|
10
|
+
## 8.11.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Update pioneer-discovery dependency to latest version
|
|
15
|
+
|
|
3
16
|
## 8.11.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/lib/index.js
CHANGED
|
@@ -792,18 +792,64 @@ var get_price_from_coincap = function (symbol) {
|
|
|
792
792
|
});
|
|
793
793
|
});
|
|
794
794
|
};
|
|
795
|
+
/**
|
|
796
|
+
* Get price from MayaScan for MAYA token
|
|
797
|
+
* MAYA token is different from CACAO (the gas token)
|
|
798
|
+
*/
|
|
799
|
+
var get_price_from_mayascan = function () {
|
|
800
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
801
|
+
var tag, url, response, price, error_4;
|
|
802
|
+
return __generator(this, function (_a) {
|
|
803
|
+
switch (_a.label) {
|
|
804
|
+
case 0:
|
|
805
|
+
tag = TAG + ' | get_price_from_mayascan | ';
|
|
806
|
+
_a.label = 1;
|
|
807
|
+
case 1:
|
|
808
|
+
_a.trys.push([1, 3, , 4]);
|
|
809
|
+
url = 'https://www.mayascan.org/api/maya/price?days=1';
|
|
810
|
+
log.debug(tag, "Fetching MAYA token price from MayaScan: ".concat(url));
|
|
811
|
+
return [4 /*yield*/, axios.get(url)];
|
|
812
|
+
case 2:
|
|
813
|
+
response = _a.sent();
|
|
814
|
+
if (response.data && response.data.mayaPriceInUsd) {
|
|
815
|
+
price = parseFloat(response.data.mayaPriceInUsd);
|
|
816
|
+
log.debug(tag, "\u2705 MayaScan price for MAYA token: $".concat(price));
|
|
817
|
+
return [2 /*return*/, price];
|
|
818
|
+
}
|
|
819
|
+
log.debug(tag, 'No MAYA price data from MayaScan');
|
|
820
|
+
return [2 /*return*/, 0];
|
|
821
|
+
case 3:
|
|
822
|
+
error_4 = _a.sent();
|
|
823
|
+
log.debug(tag, "MayaScan error: ".concat(error_4.message));
|
|
824
|
+
return [2 /*return*/, 0];
|
|
825
|
+
case 4: return [2 /*return*/];
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
});
|
|
829
|
+
};
|
|
795
830
|
/**
|
|
796
831
|
* Main function: Get asset price by CAIP
|
|
797
832
|
* Tries all APIs in order: CoinGecko → CoinMarketCap → CoinCap
|
|
798
833
|
*/
|
|
799
834
|
var get_asset_price_by_caip = function (caip) {
|
|
800
835
|
return __awaiter(this, void 0, void 0, function () {
|
|
801
|
-
var tag, identifiers, price;
|
|
836
|
+
var tag, mayaPrice, identifiers, price;
|
|
802
837
|
return __generator(this, function (_a) {
|
|
803
838
|
switch (_a.label) {
|
|
804
839
|
case 0:
|
|
805
840
|
tag = TAG + ' | get_asset_price_by_caip | ';
|
|
806
841
|
log.debug(tag, "Looking up price for: ".concat(caip));
|
|
842
|
+
if (!(caip === 'cosmos:mayachain-mainnet-v1/denom:maya' || caip.toLowerCase().includes('denom:maya'))) return [3 /*break*/, 2];
|
|
843
|
+
log.debug(tag, 'MAYA token detected, using MayaScan API');
|
|
844
|
+
return [4 /*yield*/, get_price_from_mayascan()];
|
|
845
|
+
case 1:
|
|
846
|
+
mayaPrice = _a.sent();
|
|
847
|
+
if (mayaPrice > 0) {
|
|
848
|
+
return [2 /*return*/, mayaPrice];
|
|
849
|
+
}
|
|
850
|
+
log.warn(tag, '❌ Failed to get MAYA price from MayaScan, trying standard APIs');
|
|
851
|
+
_a.label = 2;
|
|
852
|
+
case 2:
|
|
807
853
|
identifiers = caip_to_identifiers(caip);
|
|
808
854
|
if (!identifiers) {
|
|
809
855
|
log.warn(tag, "No identifier mapping found for CAIP: ".concat(caip));
|
|
@@ -811,20 +857,20 @@ var get_asset_price_by_caip = function (caip) {
|
|
|
811
857
|
}
|
|
812
858
|
log.debug(tag, "Identifiers for ".concat(caip, ":"), identifiers);
|
|
813
859
|
return [4 /*yield*/, get_price_from_coingecko(identifiers.coingeckoId)];
|
|
814
|
-
case
|
|
860
|
+
case 3:
|
|
815
861
|
price = _a.sent();
|
|
816
862
|
if (price > 0) {
|
|
817
863
|
return [2 /*return*/, price];
|
|
818
864
|
}
|
|
819
865
|
return [4 /*yield*/, get_price_from_coinmarketcap(identifiers.cmcSymbol)];
|
|
820
|
-
case
|
|
866
|
+
case 4:
|
|
821
867
|
// Try CoinMarketCap second (requires API key, very comprehensive)
|
|
822
868
|
price = _a.sent();
|
|
823
869
|
if (price > 0) {
|
|
824
870
|
return [2 /*return*/, price];
|
|
825
871
|
}
|
|
826
872
|
return [4 /*yield*/, get_price_from_coincap(identifiers.coincapSymbol)];
|
|
827
|
-
case
|
|
873
|
+
case 5:
|
|
828
874
|
// Try CoinCap last (requires API key, currently rate limited)
|
|
829
875
|
price = _a.sent();
|
|
830
876
|
if (price > 0) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/markets",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.3",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@pioneer-platform/default-redis": "^8.11.0",
|
|
8
8
|
"@pioneer-platform/loggerdog": "^8.11.0",
|
|
9
9
|
"@pioneer-platform/pioneer-coins": "^9.11.0",
|
|
10
|
-
"@pioneer-platform/pioneer-discovery": "^
|
|
10
|
+
"@pioneer-platform/pioneer-discovery": "^4.21.15",
|
|
11
11
|
"@pioneer-platform/pioneer-types": "^8.11.0",
|
|
12
12
|
"@pioneer-platform/pro-token": "^0.8.0",
|
|
13
13
|
"axios": "^1.6.0",
|