@sonarwatch/portfolio-plugins 0.11.212 → 0.11.213
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +2 -2
- package/src/plugins/navi/collateralFetcher.js +18 -2
- package/src/plugins/navi/collateralFetcher.js.map +1 -1
- package/src/plugins/navi/constants.d.ts +21 -0
- package/src/plugins/navi/constants.js +22 -1
- package/src/plugins/navi/constants.js.map +1 -1
- package/src/plugins/navi/getAvailableRewards.d.ts +2 -0
- package/src/plugins/navi/getAvailableRewards.js +100 -0
- package/src/plugins/navi/getAvailableRewards.js.map +1 -0
- package/src/plugins/navi/types.d.ts +4 -0
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
4
4
|
|
5
|
+
## [0.11.213](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.212...plugins-0.11.213) (2024-05-24)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.11.212](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.211...plugins-0.11.212) (2024-05-23)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.213",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
@@ -42,7 +42,7 @@
|
|
42
42
|
"web3-v1": "npm:web3@^1.5.0"
|
43
43
|
},
|
44
44
|
"peerDependencies": {
|
45
|
-
"@sonarwatch/portfolio-core": "0.11.
|
45
|
+
"@sonarwatch/portfolio-core": "0.11.213"
|
46
46
|
},
|
47
47
|
"main": "./src/index.js",
|
48
48
|
"types": "./src/index.d.ts"
|
@@ -18,6 +18,7 @@ const constants_1 = require("./constants");
|
|
18
18
|
const clients_1 = require("../../utils/clients");
|
19
19
|
const tokenPriceToAssetToken_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetToken"));
|
20
20
|
const getDynamicFieldObject_1 = require("../../utils/sui/getDynamicFieldObject");
|
21
|
+
const getAvailableRewards_1 = require("./getAvailableRewards");
|
21
22
|
const amountFactor = new bignumber_js_1.default(Math.pow(10, 36));
|
22
23
|
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
24
|
var _a, _b, _c, _d;
|
@@ -34,7 +35,10 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
34
35
|
});
|
35
36
|
if (!reservesData)
|
36
37
|
return [];
|
37
|
-
const tokenPrices = yield
|
38
|
+
const [tokenPrices, rewards] = yield Promise.all([
|
39
|
+
cache.getTokenPricesAsMap(reservesData.map((r) => r.value.fields.coin_type), portfolio_core_1.NetworkId.sui),
|
40
|
+
(0, getAvailableRewards_1.getAvailableRewards)(client, owner),
|
41
|
+
]);
|
38
42
|
for (const rData of reservesData) {
|
39
43
|
const borrowBalancePromise = (0, getDynamicFieldObject_1.getDynamicFieldObject)(client, {
|
40
44
|
parentId: rData.value.fields.borrow_balance.fields.user_state.fields.id.id,
|
@@ -92,7 +96,19 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
92
96
|
}
|
93
97
|
}
|
94
98
|
}
|
95
|
-
if (
|
99
|
+
if (rewards.size > 0) {
|
100
|
+
rewards.forEach((amount, coinType) => {
|
101
|
+
const tokenPrice = tokenPrices.get((0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.sui));
|
102
|
+
if (tokenPrice) {
|
103
|
+
rewardAssets.push((0, tokenPriceToAssetToken_1.default)(coinType, new bignumber_js_1.default(amount)
|
104
|
+
.dividedBy(Math.pow(10, tokenPrice.decimals))
|
105
|
+
.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrice));
|
106
|
+
}
|
107
|
+
});
|
108
|
+
}
|
109
|
+
if (suppliedAssets.length === 0 &&
|
110
|
+
borrowedAssets.length === 0 &&
|
111
|
+
rewardAssets.length === 0)
|
96
112
|
return [];
|
97
113
|
const { borrowedValue, suppliedValue, value, healthRatio, rewardValue } = (0, portfolio_core_1.getElementLendingValues)(suppliedAssets, borrowedAssets, rewardAssets, suppliedLtvs);
|
98
114
|
const element = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qGAA6E;AAE7E,iFAA8E;
|
1
|
+
{"version":3,"file":"collateralFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/collateralFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAmD;AACnD,qGAA6E;AAE7E,iFAA8E;AAC9E,+DAA4D;AAE5D,MAAM,YAAY,GAAG,IAAI,sBAAS,CAAC,SAAA,EAAE,EAAI,EAAE,CAAA,CAAC,CAAC;AAE7C,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,cAAc,GAAqB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAc,EAAE,CAAC;IACrC,MAAM,YAAY,GAAqB,EAAE,CAAC;IAC1C,MAAM,YAAY,GAAa,EAAE,CAAC;IAElC,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CAAgB,uBAAW,EAAE;QACnE,MAAM,EAAE,0BAAc;QACtB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IACH,IAAI,CAAC,YAAY;QAAE,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S,CAAC,SAAA,EAAE,EAAI,UAAU,CAAC,QAAQ,CAAA,CAAC;qBACpC,QAAQ,EAAE,EACb,0BAAS,CAAC,GAAG,EACb,UAAU,CACX,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IACE,cAAc,CAAC,MAAM,KAAK,CAAC;QAC3B,cAAc,CAAC,MAAM,KAAK,CAAC;QAC3B,YAAY,CAAC,MAAM,KAAK,CAAC;QAEzB,OAAO,EAAE,CAAC;IAEZ,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,GACrE,IAAA,wCAAuB,EACrB,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY,CACb,CAAC;IACJ,MAAM,OAAO,GAAqB;QAChC,IAAI,EAAE,qCAAoB,CAAC,UAAU;QACrC,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,KAAK,EAAE,SAAS;QAChB,KAAK;QACL,IAAI,EAAE;YACJ,cAAc;YACd,aAAa;YACb,cAAc;YACd,cAAc;YACd,aAAa;YACb,cAAc;YACd,eAAe,EAAE,IAAI;YACrB,WAAW;YACX,YAAY;YACZ,WAAW;YACX,KAAK;SACN;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,aAAa;IAC9B,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -14,3 +14,24 @@ export declare const poolsInfos: {
|
|
14
14
|
borrowBalanceParentId: string;
|
15
15
|
supplyBalanceParentId: string;
|
16
16
|
}[];
|
17
|
+
export declare const rewardsFunds: {
|
18
|
+
f975bc2d4cca10e3ace8887e20afd77b46c383b4465eac694c4688344955dea4: {
|
19
|
+
coinType: string;
|
20
|
+
oracleId: number;
|
21
|
+
};
|
22
|
+
e2b5ada45273676e0da8ae10f8fe079a7cec3d0f59187d3d20b1549c275b07ea: {
|
23
|
+
coinType: string;
|
24
|
+
oracleId: number;
|
25
|
+
};
|
26
|
+
a20e18085ce04be8aa722fbe85423f1ad6b1ae3b1be81ffac00a30f1d6d6ab51: {
|
27
|
+
coinType: string;
|
28
|
+
oracleId: number;
|
29
|
+
};
|
30
|
+
'9dae0cf104a193217904f88a48ce2cf0221e8cd9073878edd05101d6b771fa09': {
|
31
|
+
coinType: string;
|
32
|
+
oracleId: number;
|
33
|
+
};
|
34
|
+
};
|
35
|
+
export declare const incentiveFunction = "0x64372b54147adb0ac8a603adab92c81e3d732c8cafafa368d8f3ff9dcb6a53af::incentive_getter::get_incentive_pools_group_by_phase";
|
36
|
+
export declare const incentiveObjectId = "0xf87a8acb8b81d14307894d12595541a73f19933f88e1326d5be349c7a6f7559c";
|
37
|
+
export declare const incentiveStorageObjectId = "0xbb4e2f4b6205c2e2a2db47aeb4f830796ec7c005f88537ee775986639bc442fe";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.poolsInfos = exports.rateFactor = exports.reserveParentId = exports.reservesKey = exports.reservesPrefix = exports.platform = exports.platformId = void 0;
|
3
|
+
exports.incentiveStorageObjectId = exports.incentiveObjectId = exports.incentiveFunction = exports.rewardsFunds = exports.poolsInfos = exports.rateFactor = exports.reserveParentId = exports.reservesKey = exports.reservesPrefix = exports.platform = exports.platformId = void 0;
|
4
4
|
exports.platformId = 'navi';
|
5
5
|
exports.platform = {
|
6
6
|
id: exports.platformId,
|
@@ -61,4 +61,25 @@ exports.poolsInfos = [
|
|
61
61
|
supplyBalanceParentId: '0x6adc72faf2a9a15a583c9fb04f457c6a5f0b456bc9b4832413a131dfd4faddae',
|
62
62
|
},
|
63
63
|
];
|
64
|
+
exports.rewardsFunds = {
|
65
|
+
f975bc2d4cca10e3ace8887e20afd77b46c383b4465eac694c4688344955dea4: {
|
66
|
+
coinType: '0x2::sui::SUI',
|
67
|
+
oracleId: 0,
|
68
|
+
},
|
69
|
+
e2b5ada45273676e0da8ae10f8fe079a7cec3d0f59187d3d20b1549c275b07ea: {
|
70
|
+
coinType: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT',
|
71
|
+
oracleId: 5,
|
72
|
+
},
|
73
|
+
a20e18085ce04be8aa722fbe85423f1ad6b1ae3b1be81ffac00a30f1d6d6ab51: {
|
74
|
+
coinType: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI',
|
75
|
+
oracleId: 6,
|
76
|
+
},
|
77
|
+
'9dae0cf104a193217904f88a48ce2cf0221e8cd9073878edd05101d6b771fa09': {
|
78
|
+
coinType: '0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX',
|
79
|
+
oracleId: 7,
|
80
|
+
},
|
81
|
+
};
|
82
|
+
exports.incentiveFunction = '0x64372b54147adb0ac8a603adab92c81e3d732c8cafafa368d8f3ff9dcb6a53af::incentive_getter::get_incentive_pools_group_by_phase';
|
83
|
+
exports.incentiveObjectId = '0xf87a8acb8b81d14307894d12595541a73f19933f88e1326d5be349c7a6f7559c';
|
84
|
+
exports.incentiveStorageObjectId = '0xbb4e2f4b6205c2e2a2db47aeb4f830796ec7c005f88537ee775986639bc442fe';
|
64
85
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,qCAAqC,kBAAU,MAAM;I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;CACF,CAAC"}
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/navi/constants.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAG,MAAM,CAAC;AACpB,QAAA,QAAQ,GAAa;IAChC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,qCAAqC,kBAAU,MAAM;IAC5D,WAAW,EAAE,sBAAsB;IACnC,OAAO,EAAE,8BAA8B;IACvC,OAAO,EAAE,mCAAmC;CAC7C,CAAC;AAEW,QAAA,cAAc,GAAG,kBAAU,CAAC;AAC5B,QAAA,WAAW,GAAG,UAAU,CAAC;AAEzB,QAAA,eAAe,GAC1B,oEAAoE,CAAC;AAE1D,QAAA,UAAU,GAAG,EAAE,CAAC;AAEhB,QAAA,UAAU,GAAG;IACxB;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,8EAA8E;QACpF,WAAW,EACT,oEAAoE;QACtE,IAAI,EAAE,oEAAoE;QAC1E,qBAAqB,EACnB,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;KACvE;IACD;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gFAAgF;QACtF,WAAW,EACT,oEAAoE;QACtE,IAAI,EAAE,oEAAoE;QAC1E,qBAAqB,EACnB,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;KACvE;IACD;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gFAAgF;QACtF,WAAW,EACT,oEAAoE;QACtE,IAAI,EAAE,EAAE;QACR,qBAAqB,EACnB,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;KACvE;IACD;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,gFAAgF;QACtF,IAAI,EAAE,oEAAoE;QAC1E,WAAW,EACT,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;KACvE;IACD;QACE,EAAE,EAAE,CAAC;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,kFAAkF;QACxF,IAAI,EAAE,oEAAoE;QAC1E,WAAW,EACT,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;QACtE,qBAAqB,EACnB,oEAAoE;KACvE;CACF,CAAC;AAEW,QAAA,YAAY,GAAG;IAC1B,gEAAgE,EAAE;QAChE,QAAQ,EAAE,eAAe;QACzB,QAAQ,EAAE,CAAC;KACZ;IACD,gEAAgE,EAAE;QAChE,QAAQ,EACN,gFAAgF;QAClF,QAAQ,EAAE,CAAC;KACZ;IACD,gEAAgE,EAAE;QAChE,QAAQ,EACN,kFAAkF;QACpF,QAAQ,EAAE,CAAC;KACZ;IACD,kEAAkE,EAAE;QAClE,QAAQ,EACN,gFAAgF;QAClF,QAAQ,EAAE,CAAC;KACZ;CACF,CAAC;AAEW,QAAA,iBAAiB,GAC5B,0HAA0H,CAAC;AAChH,QAAA,iBAAiB,GAC5B,oEAAoE,CAAC;AAC1D,QAAA,wBAAwB,GACnC,oEAAoE,CAAC"}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
exports.getAvailableRewards = void 0;
|
16
|
+
const transactions_1 = require("@mysten/sui.js/transactions");
|
17
|
+
const bcs_1 = require("@mysten/bcs");
|
18
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
19
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
20
|
+
const constants_1 = require("./constants");
|
21
|
+
const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
|
22
|
+
bcs.registerStructType('IncentivePoolInfo', {
|
23
|
+
pool_id: 'address',
|
24
|
+
funds: 'address',
|
25
|
+
phase: 'u64',
|
26
|
+
start_at: 'u64',
|
27
|
+
end_at: 'u64',
|
28
|
+
closed_at: 'u64',
|
29
|
+
total_supply: 'u64',
|
30
|
+
asset_id: 'u8',
|
31
|
+
option: 'u8',
|
32
|
+
factor: 'u256',
|
33
|
+
distributed: 'u64',
|
34
|
+
available: 'u256',
|
35
|
+
total: 'u256',
|
36
|
+
});
|
37
|
+
bcs.registerStructType('IncentivePoolInfoByPhase', {
|
38
|
+
phase: 'u64',
|
39
|
+
pools: 'vector<IncentivePoolInfo>',
|
40
|
+
});
|
41
|
+
function getTransactionBlock(owner, optionType) {
|
42
|
+
const tx = new transactions_1.TransactionBlock();
|
43
|
+
tx.moveCall({
|
44
|
+
target: constants_1.incentiveFunction,
|
45
|
+
arguments: [
|
46
|
+
tx.object(portfolio_core_1.suiClockAddress),
|
47
|
+
tx.object(constants_1.incentiveObjectId),
|
48
|
+
tx.object(constants_1.incentiveStorageObjectId),
|
49
|
+
tx.pure(0),
|
50
|
+
tx.pure(optionType),
|
51
|
+
tx.pure(owner),
|
52
|
+
],
|
53
|
+
});
|
54
|
+
return tx;
|
55
|
+
}
|
56
|
+
function getRewardPoolsData(client, tx, owner) {
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
58
|
+
try {
|
59
|
+
const rewardsPoolsInfos = yield client.devInspectTransactionBlock({
|
60
|
+
transactionBlock: tx,
|
61
|
+
sender: owner,
|
62
|
+
});
|
63
|
+
if (rewardsPoolsInfos.results &&
|
64
|
+
rewardsPoolsInfos.results[0].returnValues) {
|
65
|
+
const o = rewardsPoolsInfos.results[0].returnValues;
|
66
|
+
return o
|
67
|
+
.map((e) => bcs.de('vector<IncentivePoolInfoByPhase>', Uint8Array.from(e[0])))
|
68
|
+
.flat()
|
69
|
+
.sort((e, n) => Number(n.phase) - Number(e.phase));
|
70
|
+
}
|
71
|
+
}
|
72
|
+
catch (e) {
|
73
|
+
//
|
74
|
+
}
|
75
|
+
return [];
|
76
|
+
});
|
77
|
+
}
|
78
|
+
function getAvailableRewards(client, owner) {
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
80
|
+
const rewards = new Map();
|
81
|
+
const [supplyRewardPoolsData, borrowRewardPoolsData] = yield Promise.all([
|
82
|
+
getRewardPoolsData(client, getTransactionBlock(owner, 1), owner),
|
83
|
+
getRewardPoolsData(client, getTransactionBlock(owner, 3), owner),
|
84
|
+
]);
|
85
|
+
const browseRewardPoolData = (e) => {
|
86
|
+
e.pools.forEach((pool) => {
|
87
|
+
const funds = pool.funds;
|
88
|
+
const { coinType } = constants_1.rewardsFunds[funds];
|
89
|
+
const aggAmount = rewards.get(coinType) || 0;
|
90
|
+
rewards.set(coinType, aggAmount +
|
91
|
+
new bignumber_js_1.default(pool.available).shiftedBy(-1 * constants_1.rateFactor).toNumber());
|
92
|
+
});
|
93
|
+
};
|
94
|
+
supplyRewardPoolsData.forEach(browseRewardPoolData);
|
95
|
+
borrowRewardPoolsData.forEach(browseRewardPoolData);
|
96
|
+
return rewards;
|
97
|
+
});
|
98
|
+
}
|
99
|
+
exports.getAvailableRewards = getAvailableRewards;
|
100
|
+
//# sourceMappingURL=getAvailableRewards.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getAvailableRewards.js","sourceRoot":"","sources":["../../../../../../pack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