@sonarwatch/portfolio-plugins 0.11.139 → 0.11.140
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 +3 -3
- package/src/plugins/aptin/depositsFetcher.js +9 -9
- package/src/plugins/aptin/depositsFetcher.js.map +1 -1
- package/src/plugins/native-stake/activeValidatorsJob.js +9 -4
- package/src/plugins/native-stake/activeValidatorsJob.js.map +1 -1
- package/src/plugins/native-stake/aptosFetcher.js +5 -3
- package/src/plugins/native-stake/aptosFetcher.js.map +1 -1
- package/src/plugins/pancakeswap/aptosLpJob.js +22 -17
- package/src/plugins/pancakeswap/aptosLpJob.js.map +1 -1
- package/src/plugins/thala/constants.d.ts +3 -10
- package/src/plugins/thala/constants.js +4 -4
- package/src/plugins/thala/constants.js.map +1 -1
- package/src/plugins/thala/stabilityPoolFetcher.js +4 -1
- package/src/plugins/thala/stabilityPoolFetcher.js.map +1 -1
- package/src/utils/aptos/getAccountCoinsData.d.ts +26 -0
- package/src/utils/aptos/getAccountCoinsData.js +10 -0
- package/src/utils/aptos/getAccountCoinsData.js.map +1 -0
- package/src/utils/aptos/getAccountResource.d.ts +2 -3
- package/src/utils/aptos/getAccountResource.js +4 -1
- package/src/utils/aptos/getAccountResource.js.map +1 -1
- package/src/utils/aptos/getAccountResources.d.ts +2 -5
- package/src/utils/aptos/getAccountResources.js +3 -1
- package/src/utils/aptos/getAccountResources.js.map +1 -1
- package/src/utils/aptos/getCoinInfoResource.d.ts +2 -2
- package/src/utils/aptos/getCoinStoreResource.d.ts +2 -2
- package/src/utils/aptos/getCoinStoreResources.d.ts +2 -5
- package/src/utils/aptos/getDecimals.d.ts +1 -1
- package/src/utils/aptos/getDecimals.js +1 -1
- package/src/utils/aptos/getDecimals.js.map +1 -1
- package/src/utils/aptos/getNestedType.d.ts +4 -0
- package/src/utils/aptos/getNestedType.js +4 -0
- package/src/utils/aptos/getNestedType.js.map +1 -1
- package/src/utils/aptos/getTableItem.d.ts +3 -3
- package/src/utils/aptos/getTableItem.js +1 -1
- package/src/utils/aptos/getTableItem.js.map +1 -1
- package/src/utils/aptos/getTableItemsByHandles.d.ts +3 -3
- package/src/utils/aptos/getTableItemsByHandles.js.map +1 -1
- package/src/utils/aptos/getTableItemsByKeys.d.ts +2 -2
- package/src/utils/aptos/getView.d.ts +3 -3
- package/src/utils/aptos/getView.js +1 -1
- package/src/utils/aptos/getView.js.map +1 -1
- package/src/utils/aptos/types.d.ts +0 -10
- package/src/utils/blank/isBlankAddressAptos.js +5 -1
- package/src/utils/blank/isBlankAddressAptos.js.map +1 -1
- package/src/utils/clients/constants.js +1 -1
- package/src/utils/clients/constants.js.map +1 -1
- package/src/utils/clients/getClientAptos.d.ts +1 -1
- package/src/utils/clients/getClientAptos.js +8 -3
- package/src/utils/clients/getClientAptos.js.map +1 -1
- package/src/utils/clients/types.d.ts +2 -0
- package/src/utils/misc/checkComputeAndStoreTokensPrices.d.ts +8 -0
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js +8 -0
- package/src/utils/misc/checkComputeAndStoreTokensPrices.js.map +1 -1
- package/src/utils/misc/getDecimalsForToken.js +5 -3
- package/src/utils/misc/getDecimalsForToken.js.map +1 -1
- package/src/plugins/tokens/fetchers/aptos-nfts.d.ts +0 -3
- package/src/plugins/tokens/fetchers/aptos-nfts.js +0 -117
- package/src/plugins/tokens/fetchers/aptos-nfts.js.map +0 -1
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.140](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.139...plugins-0.11.140) (2024-03-21)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
## [0.11.139](https://github.com/sonarwatch/portfolio/compare/plugins-0.11.138...plugins-0.11.139) (2024-03-21)
|
6
10
|
|
7
11
|
|
package/package.json
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sonarwatch/portfolio-plugins",
|
3
|
-
"version": "0.11.
|
3
|
+
"version": "0.11.140",
|
4
4
|
"type": "commonjs",
|
5
5
|
"generators": "./generators.json",
|
6
6
|
"dependencies": {
|
7
7
|
"@aave/contract-helpers": "^1.18.3",
|
8
8
|
"@aave/math-utils": "^1.18.3",
|
9
|
+
"@aptos-labs/ts-sdk": "^1.10.0",
|
9
10
|
"@bonfida/spl-name-service": "^1.0.10",
|
10
11
|
"@cosmjs/cosmwasm-stargate": "^0.31.1",
|
11
12
|
"@ethersproject/address": "^5.7.0",
|
@@ -23,7 +24,6 @@
|
|
23
24
|
"@sei-js/core": "^3.0.1",
|
24
25
|
"@sei-js/proto": "^3.0.1",
|
25
26
|
"@solana/web3.js": "^1.89.1",
|
26
|
-
"aptos": "^1.13.1",
|
27
27
|
"axios": "^1.4.0",
|
28
28
|
"bignumber.js": "^9.1.1",
|
29
29
|
"bitcoin-address-validation": "^2.2.1",
|
@@ -41,7 +41,7 @@
|
|
41
41
|
"web3-v1": "npm:web3@^1.5.0"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@sonarwatch/portfolio-core": "0.11.
|
44
|
+
"@sonarwatch/portfolio-core": "0.11.140"
|
45
45
|
},
|
46
46
|
"main": "./src/index.js",
|
47
47
|
"types": "./src/index.d.ts"
|
@@ -23,8 +23,8 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
23
23
|
const poolPositions = yield (0, aptos_1.getAccountResource)(client, owner, constants_1.poolPositionsType);
|
24
24
|
if (!poolPositions)
|
25
25
|
return [];
|
26
|
-
if (poolPositions.
|
27
|
-
poolPositions.
|
26
|
+
if (poolPositions.supply_coins.length === 0 &&
|
27
|
+
poolPositions.borrow_coins.length === 0)
|
28
28
|
return [];
|
29
29
|
const configStores = yield cache.getItem(constants_1.configStoresKey, {
|
30
30
|
prefix: constants_1.platformId,
|
@@ -32,12 +32,12 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
32
32
|
});
|
33
33
|
if (!configStores)
|
34
34
|
return [];
|
35
|
-
const supplyPositions = poolPositions.
|
35
|
+
const supplyPositions = poolPositions.supply_coins.length === 0
|
36
36
|
? []
|
37
|
-
: yield (0, aptos_1.getTableItemsByKeys)(client, poolPositions.
|
38
|
-
const borrowPositions = poolPositions.
|
37
|
+
: yield (0, aptos_1.getTableItemsByKeys)(client, poolPositions.supply_position.handle, poolPositions.supply_coins, '0x1::string::String', '0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::pool::SupplyPosition');
|
38
|
+
const borrowPositions = poolPositions.borrow_coins.length === 0
|
39
39
|
? []
|
40
|
-
: yield (0, aptos_1.getTableItemsByKeys)(client, poolPositions.
|
40
|
+
: yield (0, aptos_1.getTableItemsByKeys)(client, poolPositions.borrow_position.handle, poolPositions.borrow_coins, '0x1::string::String', '0x3c1d4a86594d681ff7e5d5a233965daeabdc6a15fe5672ceeda5260038857183::pool::BorrowPosition');
|
41
41
|
const borrowedAssets = [];
|
42
42
|
const borrowedYields = [];
|
43
43
|
const suppliedAssets = [];
|
@@ -45,7 +45,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
45
45
|
const rewardAssets = [];
|
46
46
|
const suppliedLtvs = [];
|
47
47
|
// Token prices
|
48
|
-
const tokenPricesRes = yield cache.getTokenPrices([...poolPositions.
|
48
|
+
const tokenPricesRes = yield cache.getTokenPrices([...poolPositions.supply_coins, ...poolPositions.borrow_coins], portfolio_core_1.NetworkId.aptos);
|
49
49
|
const tokenPrices = {};
|
50
50
|
tokenPricesRes.forEach((tp) => {
|
51
51
|
if (!tp)
|
@@ -58,7 +58,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
58
58
|
continue;
|
59
59
|
if (supplyPosition.amount === '0')
|
60
60
|
continue;
|
61
|
-
const coinType = poolPositions.
|
61
|
+
const coinType = poolPositions.supply_coins[i];
|
62
62
|
const address = (0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.aptos);
|
63
63
|
const { decimals, ltv } = configStores[coinType];
|
64
64
|
const amount = new bignumber_js_1.default(supplyPosition.amount)
|
@@ -74,7 +74,7 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
74
74
|
continue;
|
75
75
|
if (borrowPosition.amount === '0')
|
76
76
|
continue;
|
77
|
-
const coinType = poolPositions.
|
77
|
+
const coinType = poolPositions.borrow_coins[i];
|
78
78
|
const address = (0, portfolio_core_1.formatTokenAddress)(coinType, portfolio_core_1.NetworkId.aptos);
|
79
79
|
const { decimals } = configStores[coinType];
|
80
80
|
const amount = new bignumber_js_1.default(borrowPosition.amount)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aptin/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAA6E;AAO7E,qGAA6E;AAC7E,iDAAqD;AACrD,6CAA4E;AAE5E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAEhC,MAAM,aAAa,GAAG,MAAM,IAAA,0BAAkB,EAC5C,MAAM,EACN,KAAK,EACL,6BAAiB,CAClB,CAAC;IACF,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,CAAC;IAC9B,IACE,aAAa,CAAC,
|
1
|
+
{"version":3,"file":"depositsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/aptin/depositsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DASoC;AACpC,gEAAqC;AAGrC,2CAA6E;AAO7E,qGAA6E;AAC7E,iDAAqD;AACrD,6CAA4E;AAE5E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EA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K;QAC1B,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,WAAW;IAC5B,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -14,16 +14,21 @@ const clients_1 = require("../../utils/clients");
|
|
14
14
|
const constants_1 = require("./constants");
|
15
15
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
16
16
|
const client = (0, clients_1.getClientAptos)();
|
17
|
-
const resources = (yield client.getAccountResource(
|
17
|
+
const resources = (yield client.getAccountResource({
|
18
|
+
accountAddress: '0x1',
|
19
|
+
resourceType: '0x1::stake::ValidatorSet',
|
20
|
+
}));
|
18
21
|
const activeValidators = resources.data.active_validators;
|
19
22
|
const validatorsWithStake = [];
|
20
23
|
for (let i = 0; i < activeValidators.length; i++) {
|
21
24
|
const validator = activeValidators[i];
|
22
25
|
const hasStake = yield client
|
23
26
|
.view({
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
payload: {
|
28
|
+
function: '0x1::delegation_pool::operator_commission_percentage',
|
29
|
+
typeArguments: [],
|
30
|
+
functionArguments: [validator.addr],
|
31
|
+
},
|
27
32
|
})
|
28
33
|
.catch(() => { });
|
29
34
|
if (hasStake)
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"activeValidatorsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/native-stake/activeValidatorsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAqD;AACrD,2CAA0E;AAG1E,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,
|
1
|
+
{"version":3,"file":"activeValidatorsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/native-stake/activeValidatorsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,iDAAqD;AACrD,2CAA0E;AAG1E,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC;QACjD,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,0BAA0B;KACzC,CAAC,CAAiB,CAAC;IACpB,MAAM,gBAAgB,GAAG,SAAS,CAAC,IAAI,CAAC,iBAAiB,CAAC;IAC1D,MAAM,mBAAmB,GAAa,EAAE,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,MAAM,SAAS,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,MAAM;aAC1B,IAAI,CAAC;YACJ,OAAO,EAAE;gBACP,QAAQ,EAAE,sDAAsD;gBAChE,aAAa,EAAE,EAAE;gBACjB,iBAAiB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;aACpC;SACF,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnB,IAAI,QAAQ;YAAE,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,KAAK,CAAC,OAAO,CAAC,yBAAa,EAAE,mBAAmB,EAAE;QACtD,MAAM,EAAE,4BAAgB;QACxB,SAAS,EAAE,0BAAS,CAAC,KAAK;KAC3B,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,oBAAoB;IACrC,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -32,9 +32,11 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
32
32
|
for (let i = 0; i < activeValidators.length; i++) {
|
33
33
|
const validatorAddress = activeValidators[i];
|
34
34
|
const stakedValuesInValidator = (yield client.view({
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
payload: {
|
36
|
+
function: '0x1::delegation_pool::get_stake',
|
37
|
+
typeArguments: [],
|
38
|
+
functionArguments: [validatorAddress, owner],
|
39
|
+
},
|
38
40
|
}));
|
39
41
|
const amount = stakedValuesInValidator
|
40
42
|
.filter((item) => item !== '0')
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"aptosFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/native-stake/aptosFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAIoC;AACpC,gEAAqC;AAGrC,2CAKqB;AACrB,iDAAqD;AACrD,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,OAAO,CAAW,yBAAa,EAAE;QACpE,MAAM,EAAE,4BAAgB;QACxB,SAAS,EAAE,0BAAS,CAAC,KAAK;KAC3B,CAAC,CAAC;IACH,IAAI,CAAC,gBAAgB;QAAE,OAAO,EAAE,CAAC;IAEjC,MAAM,UAAU,GAAG,MAAM,KAAK,CAAC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QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -17,12 +17,11 @@ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
|
17
17
|
const constants_1 = require("./constants");
|
18
18
|
const clients_1 = require("../../utils/clients");
|
19
19
|
const aptos_1 = require("../../utils/aptos");
|
20
|
-
const getTokensPricesMap_1 = __importDefault(require("../../utils/misc/getTokensPricesMap"));
|
21
20
|
const getLpUnderlyingTokenSource_1 = __importDefault(require("../../utils/misc/getLpUnderlyingTokenSource"));
|
22
|
-
const getDecimalsForToken_1 = require("../../utils/misc/getDecimalsForToken");
|
23
21
|
const getLpTokenSourceRaw_1 = __importDefault(require("../../utils/misc/getLpTokenSourceRaw"));
|
22
|
+
const getDecimals_1 = require("../../utils/aptos/getDecimals");
|
24
23
|
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
25
|
-
var _a, _b, _c;
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
26
25
|
const client = (0, clients_1.getClientAptos)();
|
27
26
|
const resources = yield (0, aptos_1.getAccountResources)(client, constants_1.programAddress);
|
28
27
|
if (!resources)
|
@@ -31,34 +30,39 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
30
|
resources.forEach((resource) => {
|
32
31
|
resourcesByType.set(resource.type, resource);
|
33
32
|
});
|
34
|
-
const tokenPriceById = yield
|
33
|
+
const tokenPriceById = yield cache.getTokenPricesAsMap(resources
|
35
34
|
.map((ressource) => {
|
36
35
|
const { keys } = (0, aptos_1.parseTypeString)(ressource.type);
|
37
36
|
return keys ? keys.map((key) => key.type) : [];
|
38
37
|
})
|
39
|
-
.flat(), portfolio_core_1.NetworkId.aptos
|
38
|
+
.flat(), portfolio_core_1.NetworkId.aptos);
|
39
|
+
const lpSources = [];
|
40
40
|
for (let i = 0; i < resources.length; i++) {
|
41
41
|
const resource = resources[i];
|
42
42
|
if (!resource.type.startsWith(constants_1.lpCoinInfoTypePrefix))
|
43
43
|
continue;
|
44
|
-
const lpType = (0, aptos_1.
|
44
|
+
const lpType = (_b = (_a = (0, aptos_1.parseTypeString)(resource.type).keys) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.type;
|
45
|
+
if (!lpType)
|
46
|
+
continue;
|
45
47
|
const lpInfoData = resource.data;
|
46
|
-
const lpSupplyString = (
|
48
|
+
const lpSupplyString = (_e = (_d = (_c = lpInfoData.supply) === null || _c === void 0 ? void 0 : _c.vec[0]) === null || _d === void 0 ? void 0 : _d.integer.vec[0]) === null || _e === void 0 ? void 0 : _e.value;
|
47
49
|
if (!lpSupplyString)
|
48
50
|
continue;
|
49
51
|
const lpDecimals = lpInfoData.decimals;
|
50
52
|
const lpSupply = new bignumber_js_1.default(lpSupplyString);
|
51
53
|
if (lpSupply.isZero())
|
52
54
|
continue;
|
53
|
-
const tokenPairId = (0, aptos_1.
|
55
|
+
const tokenPairId = (_f = (0, aptos_1.parseTypeString)(lpType)
|
56
|
+
.keys) === null || _f === void 0 ? void 0 : _f.map((t) => t.type).join(', ');
|
57
|
+
if (!tokenPairId)
|
58
|
+
continue;
|
54
59
|
// TODO : get ride of those by using parseTypeString() instead of getNestedType()
|
55
60
|
if (tokenPairId.includes('swap::LPToken') ||
|
56
61
|
tokenPairId.includes('LPCoinV1::LPCoin') ||
|
57
62
|
tokenPairId.includes('lp_coin::LP'))
|
58
63
|
continue;
|
59
|
-
const
|
60
|
-
const
|
61
|
-
const typeY = splits.at(1);
|
64
|
+
const typeX = (_h = (_g = (0, aptos_1.parseTypeString)(lpType).keys) === null || _g === void 0 ? void 0 : _g.at(0)) === null || _h === void 0 ? void 0 : _h.type;
|
65
|
+
const typeY = (_k = (_j = (0, aptos_1.parseTypeString)(lpType).keys) === null || _j === void 0 ? void 0 : _j.at(1)) === null || _k === void 0 ? void 0 : _k.type;
|
62
66
|
const tokenPairResource = resourcesByType.get(`${constants_1.programAddress}::swap::TokenPairMetadata<${tokenPairId}>`);
|
63
67
|
if (!tokenPairResource)
|
64
68
|
throw new Error(`Failed to get tokenPairResource: ${lpType}`);
|
@@ -73,12 +77,12 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
77
|
tokenPairData.balance_y.value === '0')
|
74
78
|
continue;
|
75
79
|
const [tokenPriceX, tokenPriceY] = [
|
76
|
-
tokenPriceById.get(typeX),
|
77
|
-
tokenPriceById.get(typeY),
|
80
|
+
tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(typeX, portfolio_core_1.NetworkId.aptos)),
|
81
|
+
tokenPriceById.get((0, portfolio_core_1.formatTokenAddress)(typeY, portfolio_core_1.NetworkId.aptos)),
|
78
82
|
];
|
79
83
|
const [decimalsX, decimalsY] = yield Promise.all([
|
80
|
-
(0,
|
81
|
-
(0,
|
84
|
+
(0, getDecimals_1.getDecimals)(client, typeX),
|
85
|
+
(0, getDecimals_1.getDecimals)(client, typeY),
|
82
86
|
]);
|
83
87
|
const [reserveAmountRawX, reserveAmountRawY] = [
|
84
88
|
new bignumber_js_1.default(tokenPairData.balance_x.value),
|
@@ -98,7 +102,7 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
102
|
tokenPrice: tokenPriceY,
|
99
103
|
});
|
100
104
|
if (underlyingSource)
|
101
|
-
|
105
|
+
lpSources.push(underlyingSource);
|
102
106
|
if (!tokenPriceX || !tokenPriceY)
|
103
107
|
continue;
|
104
108
|
const lpSource = (0, getLpTokenSourceRaw_1.default)(portfolio_core_1.NetworkId.aptos, lpType, constants_1.platformId, {
|
@@ -119,8 +123,9 @@ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
123
|
reserveAmountRaw: reserveAmountRawY,
|
120
124
|
},
|
121
125
|
], '');
|
122
|
-
|
126
|
+
lpSources.push(lpSource);
|
123
127
|
}
|
128
|
+
yield cache.setTokenPriceSources(lpSources);
|
124
129
|
});
|
125
130
|
const job = {
|
126
131
|
id: `${constants_1.platformId}-aptos-lp`,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+
|
1
|
+
{"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAIoC;AAGpC,2CAA+E;AAE/E,iDAAqD;AACrD,6CAK2B;AAC3B,6GAAqF;AACrF,+FAAuE;AACvE,+DAA4D;AAE5D,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;;IACnD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,0BAAc,CAAC,CAAC;IACpE,IAAI,CAAC,SAAS;QAAE,OAAO;IAEvB,MAAM,eAAe,GAAuC,IAAI,GAAG,EAAE,CAAC;IACtE,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC7B,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,MAAM,KAAK,CAAC,mBAAmB,CACpD,SAAS;SACN,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE;QACjB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,uBAAe,EAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;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AC,OAAO;gBAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;gBAC9B,KAAK,EAAE,WAAW,CAAC,KAAK;gBACxB,gBAAgB,EAAE,iBAAiB;aACpC;SACF,EACD,EAAE,CACH,CAAC;QACF,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3B,CAAC;IACD,MAAM,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;IACR,KAAK,EAAE,QAAQ;CAChB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Platform } from '@sonarwatch/portfolio-core';
|
2
|
+
import { InputViewRequestData } from '@aptos-labs/ts-sdk';
|
2
3
|
export declare const platformId = "thala";
|
3
4
|
export declare const thalaPlatform: Platform;
|
4
5
|
export declare const programAdressThala = "0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01";
|
@@ -14,13 +15,5 @@ export declare const lpStableTypePrefix = "0x48271d39d0b05bd6efca2278f22277d6fcc
|
|
14
15
|
export declare const lpWeightedTypePrefix = "0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af::weighted_pool::WeightedPool";
|
15
16
|
export declare const lpStableCoinInfoTypePrefix = "0x1::coin::CoinInfo<0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af::stable_pool::StablePoolToken";
|
16
17
|
export declare const lpWeightedCoinInfoTypePrefix = "0x1::coin::CoinInfo<0x48271d39d0b05bd6efca2278f22277d6fcc375504f9839fd73f74ace240861af::weighted_pool::WeightedPoolToken";
|
17
|
-
export declare const stabilityDepositPayload: (owner: string) =>
|
18
|
-
|
19
|
-
type_arguments: string[];
|
20
|
-
arguments: string[];
|
21
|
-
};
|
22
|
-
export declare const stabilityClaimablePayload: (owner: string) => {
|
23
|
-
function: string;
|
24
|
-
type_arguments: never[];
|
25
|
-
arguments: string[];
|
26
|
-
};
|
18
|
+
export declare const stabilityDepositPayload: (owner: string) => InputViewRequestData;
|
19
|
+
export declare const stabilityClaimablePayload: (owner: string) => InputViewRequestData;
|
@@ -30,14 +30,14 @@ exports.lpStableCoinInfoTypePrefix = `${aptos_1.coinInfo}<${exports.lpStableType
|
|
30
30
|
exports.lpWeightedCoinInfoTypePrefix = `${aptos_1.coinInfo}<${exports.lpWeightedTypeTokenPrefix}`;
|
31
31
|
const stabilityDepositPayload = (owner) => ({
|
32
32
|
function: liquidityDeposit,
|
33
|
-
|
34
|
-
|
33
|
+
typeArguments: [cryptoType],
|
34
|
+
functionArguments: [owner],
|
35
35
|
});
|
36
36
|
exports.stabilityDepositPayload = stabilityDepositPayload;
|
37
37
|
const stabilityClaimablePayload = (owner) => ({
|
38
38
|
function: liquidityClaimable,
|
39
|
-
|
40
|
-
|
39
|
+
typeArguments: [],
|
40
|
+
functionArguments: [owner],
|
41
41
|
});
|
42
42
|
exports.stabilityClaimablePayload = stabilityClaimablePayload;
|
43
43
|
//# sourceMappingURL=constants.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/constants.ts"],"names":[],"mappings":";;;
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/constants.ts"],"names":[],"mappings":";;;AAEA,6CAA6C;AAEhC,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,aAAa,GAAa;IACrC,EAAE,EAAE,kBAAU;IACd,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,6CAA6C;IACpD,WAAW,EAAE,mBAAmB;IAChC,OAAO,EAAE,uBAAuB;CACjC,CAAC;AACW,QAAA,kBAAkB,GAC7B,oEAAoE,CAAC;AAEvE,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,W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BAAiB,EAAE,CAAC,KAAK,CAAC;CAC3B,CAAC,CAAC;AANU,QAAA,yBAAyB,6BAMnC"}
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
13
|
};
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
16
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
16
17
|
const constants_1 = require("./constants");
|
17
18
|
const aptos_1 = require("../../utils/aptos");
|
18
19
|
const clients_1 = require("../../utils/clients");
|
@@ -25,7 +26,9 @@ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* (
|
|
25
26
|
const depositAmountString = stabilityPoolDepositView.at(0);
|
26
27
|
if (!depositAmountString)
|
27
28
|
return [];
|
28
|
-
const depositAmount =
|
29
|
+
const depositAmount = new bignumber_js_1.default(depositAmountString.toString())
|
30
|
+
.div(Math.pow(10, portfolio_core_1.aptosNetwork.native.decimals))
|
31
|
+
.toNumber();
|
29
32
|
if (depositAmount === 0)
|
30
33
|
return [];
|
31
34
|
const depositTokenPrice = yield cache.getTokenPrice(constants_1.modCoin.toString(), portfolio_core_1.NetworkId.aptos);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stabilityPoolFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/stabilityPoolFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;
|
1
|
+
{"version":3,"file":"stabilityPoolFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/stabilityPoolFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAQoC;AACpC,gEAAqC;AAGrC,2CAMqB;AACrB,6CAA4C;AAC5C,iDAAqD;AACrD,qGAA6E;AAE7E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,UAAU,GAAG,IAA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AAI,EAAE,qCAAoB,CAAC,SAAS;QACpC,KAAK,EAAE,QAAQ;QACf,KAAK;QACL,IAAI,EAAE;YACJ,WAAW;SACZ;KACF,CAAC;IACF,OAAO,CAAC,eAAe,CAAC,CAAC;AAC3B,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,iBAAiB;IAClC,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getAccountCoinsData(client: AptosClient, coinType: string): Promise<{
|
3
|
+
amount: any;
|
4
|
+
asset_type: string;
|
5
|
+
is_frozen: boolean;
|
6
|
+
is_primary: boolean;
|
7
|
+
last_transaction_timestamp: any;
|
8
|
+
last_transaction_version: any;
|
9
|
+
owner_address: string;
|
10
|
+
storage_id: string;
|
11
|
+
token_standard: string;
|
12
|
+
metadata?: {
|
13
|
+
token_standard: string;
|
14
|
+
symbol: string;
|
15
|
+
supply_aggregator_table_key_v1?: string | null | undefined;
|
16
|
+
supply_aggregator_table_handle_v1?: string | null | undefined;
|
17
|
+
project_uri?: string | null | undefined;
|
18
|
+
name: string;
|
19
|
+
last_transaction_version: any;
|
20
|
+
last_transaction_timestamp: any;
|
21
|
+
icon_uri?: string | null | undefined;
|
22
|
+
decimals: number;
|
23
|
+
creator_address: string;
|
24
|
+
asset_type: string;
|
25
|
+
} | null | undefined;
|
26
|
+
}[]>;
|
@@ -0,0 +1,10 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getAccountCoinsData = void 0;
|
4
|
+
function getAccountCoinsData(client, coinType) {
|
5
|
+
return client.getAccountCoinsData({
|
6
|
+
accountAddress: coinType,
|
7
|
+
});
|
8
|
+
}
|
9
|
+
exports.getAccountCoinsData = getAccountCoinsData;
|
10
|
+
//# sourceMappingURL=getAccountCoinsData.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getAccountCoinsData.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getAccountCoinsData.ts"],"names":[],"mappings":";;;AAEA,SAAgB,mBAAmB,CAAC,MAAmB,EAAE,QAAgB;IACvE,OAAO,MAAM,CAAC,mBAAmB,CAAC;QAChC,cAAc,EAAE,QAAQ;KACzB,CAAC,CAAC;AACL,CAAC;AAJD,kDAIC"}
|
@@ -1,3 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
2
|
-
|
3
|
-
export declare function getAccountResource<T>(client: AptosClient, accountAddress: string, resourceType: string): Promise<MoveResource<T> | null>;
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getAccountResource<T extends object>(client: AptosClient, accountAddress: string, resourceType: `${string}::${string}::${string}`): Promise<T | null>;
|
@@ -13,7 +13,10 @@ exports.getAccountResource = void 0;
|
|
13
13
|
function getAccountResource(client, accountAddress, resourceType) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
15
|
const resource = yield client
|
16
|
-
.getAccountResource(
|
16
|
+
.getAccountResource({
|
17
|
+
accountAddress,
|
18
|
+
resourceType,
|
19
|
+
})
|
17
20
|
.catch((e) => {
|
18
21
|
if (!e.status || e.status !== 404)
|
19
22
|
throw e;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getAccountResource.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getAccountResource.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"getAccountResource.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getAccountResource.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,kBAAkB,CACtC,MAAmB,EACnB,cAAsB,EACtB,YAA+C;;QAE/C,MAAM,QAAQ,GAAG,MAAM,MAAM;aAC1B,kBAAkB,CAAI;YACrB,cAAc;YACd,YAAY;SACb,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AAfD,gDAeC"}
|
@@ -1,5 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
2
|
-
export declare function getAccountResources(client: AptosClient, accountAddress: string): Promise<
|
3
|
-
type: string;
|
4
|
-
data: {};
|
5
|
-
}[] | null>;
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getAccountResources(client: AptosClient, accountAddress: string): Promise<import("@aptos-labs/ts-sdk").MoveResource[] | null>;
|
@@ -13,7 +13,9 @@ exports.getAccountResources = void 0;
|
|
13
13
|
function getAccountResources(client, accountAddress) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
15
|
const resources = yield client
|
16
|
-
.getAccountResources(
|
16
|
+
.getAccountResources({
|
17
|
+
accountAddress,
|
18
|
+
})
|
17
19
|
.catch((e) => {
|
18
20
|
if (!e.status || e.status !== 404)
|
19
21
|
throw e;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getAccountResources.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getAccountResources.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,mBAAmB,CACvC,MAAmB,EACnB,cAAsB;;QAEtB,MAAM,SAAS,GAAG,MAAM,MAAM;aAC3B,mBAAmB,CAAC,cAAc,CAAC;
|
1
|
+
{"version":3,"file":"getAccountResources.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getAccountResources.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,SAAsB,mBAAmB,CACvC,MAAmB,EACnB,cAAsB;;QAEtB,MAAM,SAAS,GAAG,MAAM,MAAM;aAC3B,mBAAmB,CAAC;YACnB,cAAc;SACf,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACL,OAAO,SAAS,IAAI,IAAI,CAAC;IAC3B,CAAC;CAAA;AAZD,kDAYC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { AptosClient } from '
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
2
|
import { CoinInfoData } from './resources/coinInfo';
|
3
|
-
export declare function getCoinInfoResource(client: AptosClient, coinType: string): Promise<
|
3
|
+
export declare function getCoinInfoResource(client: AptosClient, coinType: string): Promise<CoinInfoData | null>;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import { AptosClient } from '
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
2
|
import { CoinStoreData } from './resources/coinStore';
|
3
|
-
export declare function getCoinStoreResource(client: AptosClient, owner: string, coinType: string): Promise<
|
3
|
+
export declare function getCoinStoreResource(client: AptosClient, owner: string, coinType: string): Promise<CoinStoreData | null>;
|
@@ -1,5 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
2
|
-
export declare function getCoinStoreResources(client: AptosClient, owner: string): Promise<
|
3
|
-
type: string;
|
4
|
-
data: {};
|
5
|
-
}[] | null>;
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getCoinStoreResources(client: AptosClient, owner: string): Promise<import("@aptos-labs/ts-sdk").MoveResource[] | null>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
2
|
export declare function getDecimals(client: AptosClient, coinType: string): Promise<number | null>;
|
@@ -16,7 +16,7 @@ function getDecimals(client, coinType) {
|
|
16
16
|
const coinInfoResource = yield (0, getCoinInfoResource_1.getCoinInfoResource)(client, coinType);
|
17
17
|
if (!coinInfoResource)
|
18
18
|
return null;
|
19
|
-
return coinInfoResource.
|
19
|
+
return coinInfoResource.decimals;
|
20
20
|
});
|
21
21
|
}
|
22
22
|
exports.getDecimals = getDecimals;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+DAA4D;AAE5D,SAAsB,WAAW,CAAC,MAAmB,EAAE,QAAgB;;QACrE,MAAM,gBAAgB,GAAG,MAAM,IAAA,yCAAmB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAC;QACnC,OAAO,gBAAgB,CAAC,
|
1
|
+
{"version":3,"file":"getDecimals.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getDecimals.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,+DAA4D;AAE5D,SAAsB,WAAW,CAAC,MAAmB,EAAE,QAAgB;;QACrE,MAAM,gBAAgB,GAAG,MAAM,IAAA,yCAAmB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACrE,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAC;QACnC,OAAO,gBAAgB,CAAC,QAAQ,CAAC;IACnC,CAAC;CAAA;AAJD,kCAIC"}
|
@@ -1,6 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getNestedType = void 0;
|
4
|
+
/**
|
5
|
+
* @deprecated
|
6
|
+
* This function has been deprecated. Use the parseTypeString instead.
|
7
|
+
*/
|
4
8
|
function getNestedType(type) {
|
5
9
|
const index = type.indexOf('<');
|
6
10
|
return type.slice(index + 1, -1);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getNestedType.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getNestedType.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAHD,sCAGC"}
|
1
|
+
{"version":3,"file":"getNestedType.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getNestedType.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,SAAgB,aAAa,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC;AAHD,sCAGC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export declare function getTableItem<T>(client: AptosClient, handle: string, data: TableItemRequest): Promise<NonNullable<T
|
1
|
+
import { TableItemRequest } from '@aptos-labs/ts-sdk';
|
2
|
+
import { AptosClient } from '../clients/types';
|
3
|
+
export declare function getTableItem<T>(client: AptosClient, handle: string, data: TableItemRequest): Promise<NonNullable<Awaited<T>> | null>;
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getTableItem = void 0;
|
13
13
|
function getTableItem(client, handle, data) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
|
-
const item = yield client.getTableItem(handle, data).catch((e) => {
|
15
|
+
const item = yield client.getTableItem({ handle, data }).catch((e) => {
|
16
16
|
if (!e.status || e.status !== 404)
|
17
17
|
throw e;
|
18
18
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getTableItem.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItem.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,YAAY,CAChC,MAAmB,EACnB,MAAc,EACd,IAAsB;;QAEtB,MAAM,IAAI,
|
1
|
+
{"version":3,"file":"getTableItem.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItem.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,YAAY,CAChC,MAAmB,EACnB,MAAc,EACd,IAAsB;;QAEtB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACtE,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,IAAI,IAAI,CAAC;IACtB,CAAC;CAAA;AATD,oCASC"}
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export declare function getTableItemsByHandles<T>(client: AptosClient, handles: string[], data: TableItemRequest): Promise<(Awaited<NonNullable<T
|
1
|
+
import { TableItemRequest } from '@aptos-labs/ts-sdk';
|
2
|
+
import { AptosClient } from '../clients/types';
|
3
|
+
export declare function getTableItemsByHandles<T>(client: AptosClient, handles: string[], data: TableItemRequest): Promise<(Awaited<NonNullable<Awaited<T>>> | null)[]>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getTableItemsByHandles.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItemsByHandles.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"getTableItemsByHandles.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getTableItemsByHandles.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,iDAA8C;AAE9C,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf,SAAsB,sBAAsB,CAC1C,MAAmB,EACnB,OAAiB,EACjB,IAAsB;;QAEtB,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,MAAM,cAAc,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;QACpC,OAAO,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YACzD,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAC7C,MAAM,EACN,kBAAkB,EAClB,IAAI,CACL,CAAC;YACF,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAjBD,wDAiBC;AAED,SAAe,uBAAuB,CACpC,MAAmB,EACnB,OAAiB,EACjB,IAAsB;;QAEtB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CACtC,IAAA,2BAAY,EAAI,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CACtC,CAAC;QACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YAC5B,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;gBAAE,OAAO,IAAI,CAAC;YAC9C,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
2
|
-
export declare function getTableItemsByKeys<T>(client: AptosClient, handle: string, keys: string[], keyType: string, valueType: string): Promise<(Awaited<NonNullable<T
|
1
|
+
import { AptosClient } from '../clients/types';
|
2
|
+
export declare function getTableItemsByKeys<T>(client: AptosClient, handle: string, keys: string[], keyType: string, valueType: string): Promise<(Awaited<NonNullable<Awaited<T>>> | null)[]>;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export declare function getView(client: AptosClient, payload:
|
1
|
+
import { InputViewRequestData } from '@aptos-labs/ts-sdk';
|
2
|
+
import { AptosClient } from '../clients/types';
|
3
|
+
export declare function getView(client: AptosClient, payload: InputViewRequestData): Promise<import("@aptos-labs/ts-sdk").MoveValue[] | null>;
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getView = void 0;
|
13
13
|
function getView(client, payload) {
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
15
|
-
const resource = yield client.view(payload).catch((e) => {
|
15
|
+
const resource = yield client.view({ payload }).catch((e) => {
|
16
16
|
if (!e.status || e.status !== 404)
|
17
17
|
throw e;
|
18
18
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getView.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,OAAO,
|
1
|
+
{"version":3,"file":"getView.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/getView.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,SAAsB,OAAO,CAC3B,MAAmB,EACnB,OAA6B;;QAE7B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YAC1D,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG;gBAAE,MAAM,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA;AATD,0BASC"}
|
@@ -1,13 +1,3 @@
|
|
1
|
-
export type TableItemRequest = {
|
2
|
-
key_type: string;
|
3
|
-
value_type: string;
|
4
|
-
key: string;
|
5
|
-
};
|
6
|
-
export type ViewRequest = {
|
7
|
-
function: string;
|
8
|
-
type_arguments: string[];
|
9
|
-
arguments: string[];
|
10
|
-
};
|
11
1
|
export type MoveType = {
|
12
2
|
type: string;
|
13
3
|
root: string;
|
@@ -14,7 +14,11 @@ const clients_1 = require("../clients");
|
|
14
14
|
function isBlankAddressAptos(address) {
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
16
16
|
const client = (0, clients_1.getClientAptos)();
|
17
|
-
const ressources = yield client
|
17
|
+
const ressources = yield client
|
18
|
+
.getAccountResources({
|
19
|
+
accountAddress: address,
|
20
|
+
})
|
21
|
+
.catch(() => []);
|
18
22
|
return ressources.length === 0;
|
19
23
|
});
|
20
24
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isBlankAddressAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/blank/isBlankAddressAptos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAE5C,SAAsB,mBAAmB,CAAC,OAAe;;QACvD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,MAAM,
|
1
|
+
{"version":3,"file":"isBlankAddressAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/blank/isBlankAddressAptos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAE5C,SAAsB,mBAAmB,CAAC,OAAe;;QACvD,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,MAAM;aAC5B,mBAAmB,CAAC;YACnB,cAAc,EAAE,OAAO;SACxB,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QACnB,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC;IACjC,CAAC;CAAA;AARD,kDAQC"}
|
@@ -24,7 +24,7 @@ function getUrlEndpoints() {
|
|
24
24
|
'https://api.avax.network/ext/bc/C/rpc',
|
25
25
|
polygon: process.env['PORTFOLIO_POLYGON_RPC'] || 'https://1rpc.io/matic',
|
26
26
|
aptos: process.env['PORTFOLIO_APTOS_RPC'] ||
|
27
|
-
'https://
|
27
|
+
'https://api.mainnet.aptoslabs.com/v1',
|
28
28
|
sui: process.env['PORTFOLIO_SUI_RPC'] || 'https://sui-rpc.publicnode.com',
|
29
29
|
};
|
30
30
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/constants.ts"],"names":[],"mappings":";;;;;;AAKA,wCAAsE;AACtE,0EAAkD;AAErC,QAAA,qBAAqB,GAAoC;IACpE,QAAQ,EAAE,gBAAO;IACjB,SAAS,EAAT,kBAAS;IACT,OAAO,EAAP,gBAAO;IACP,GAAG,EAAE,YAAG;CACT,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,+BAA+B;QACxE,OAAO,EACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,+BAA+B;QACzE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,8BAA8B;QACvE,MAAM,EACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;YACnC,qCAAqC;QACvC,QAAQ,EACN,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,0BAA0B;QACrE,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACtC,uCAAuC;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,uBAAuB;QACxE,KAAK,EACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAClC,
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/constants.ts"],"names":[],"mappings":";;;;;;AAKA,wCAAsE;AACtE,0EAAkD;AAErC,QAAA,qBAAqB,GAAoC;IACpE,QAAQ,EAAE,gBAAO;IACjB,SAAS,EAAT,kBAAS;IACT,OAAO,EAAP,gBAAO;IACP,GAAG,EAAE,YAAG;CACT,CAAC;AAEF,SAAgB,eAAe;IAC7B,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,+BAA+B;QACxE,OAAO,EACL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,+BAA+B;QACzE,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,8BAA8B;QACvE,MAAM,EACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;YACnC,qCAAqC;QACvC,QAAQ,EACN,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,IAAI,0BAA0B;QACrE,SAAS,EACP,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACtC,uCAAuC;QACzC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,uBAAuB;QACxE,KAAK,EACH,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;YAClC,sCAAsC;QACxC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,gCAAgC;KAC1E,CAAC;AACJ,CAAC;AApBD,0CAoBC;AAED,SAAgB,cAAc,CAAC,SAAwB;IACrD,OAAO,eAAe,EAAE,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAFD,wCAEC;AAED,SAAgB,eAAe;IAC7B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;QACjD,GAAG;QACH,IAAA,0BAAgB,EAAC,KAAK,CAAC;KACxB,CAAC,CACmC,CAAC;AAC1C,CAAC;AARD,0CAQC;AAED,SAAgB,cAAc,CAAC,SAAwB;IACrD,OAAO,eAAe,EAAE,CAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAFD,wCAEC"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { AptosClient } from '
|
1
|
+
import { AptosClient } from './types';
|
2
2
|
export default function getClientAptos(): AptosClient;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
4
|
-
const
|
4
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
5
5
|
const constants_1 = require("./constants");
|
6
6
|
const getBasicAuthHeaders_1 = require("../misc/getBasicAuthHeaders");
|
7
7
|
function getClientAptos() {
|
@@ -10,9 +10,14 @@ function getClientAptos() {
|
|
10
10
|
const headers = rpcEndpoint.basicAuth
|
11
11
|
? (0, getBasicAuthHeaders_1.getBasicAuthHeaders)((_a = rpcEndpoint.basicAuth) === null || _a === void 0 ? void 0 : _a.username, (_b = rpcEndpoint.basicAuth) === null || _b === void 0 ? void 0 : _b.password)
|
12
12
|
: undefined;
|
13
|
-
|
14
|
-
|
13
|
+
const config = new ts_sdk_1.AptosConfig({
|
14
|
+
network: ts_sdk_1.Network.MAINNET,
|
15
|
+
clientConfig: {
|
16
|
+
HEADERS: headers,
|
17
|
+
},
|
18
|
+
fullnode: rpcEndpoint.url,
|
15
19
|
});
|
20
|
+
return new ts_sdk_1.Aptos(config);
|
16
21
|
}
|
17
22
|
exports.default = getClientAptos;
|
18
23
|
//# sourceMappingURL=getClientAptos.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getClientAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/getClientAptos.ts"],"names":[],"mappings":";;AAAA,+DAAuD;AACvD
|
1
|
+
{"version":3,"file":"getClientAptos.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/clients/getClientAptos.ts"],"names":[],"mappings":";;AAAA,+DAAuD;AACvD,+CAAiE;AACjE,2CAA6C;AAC7C,qEAAkE;AAGlE,SAAwB,cAAc;;IACpC,MAAM,WAAW,GAAG,IAAA,0BAAc,EAAC,0BAAS,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS;QACnC,CAAC,CAAC,IAAA,yCAAmB,EACjB,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,EAC/B,MAAA,WAAW,CAAC,SAAS,0CAAE,QAAQ,CAChC;QACH,CAAC,CAAC,SAAS,CAAC;IACd,MAAM,MAAM,GAAG,IAAI,oBAAW,CAAC;QAC7B,OAAO,EAAE,gBAAO,CAAC,OAAO;QACxB,YAAY,EAAE;YACZ,OAAO,EAAE,OAAO;SACjB;QACD,QAAQ,EAAE,WAAW,CAAC,GAAG;KAC1B,CAAC,CAAC;IACH,OAAO,IAAI,cAAK,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAhBD,iCAgBC"}
|
@@ -1,6 +1,8 @@
|
|
1
|
+
import { Aptos } from '@aptos-labs/ts-sdk';
|
1
2
|
import { SuiClient as MystenSuiClient } from '@mysten/sui.js/client';
|
2
3
|
import { Connection } from '@solana/web3.js';
|
3
4
|
import { PublicClient } from 'viem';
|
4
5
|
export type EvmClient = PublicClient;
|
5
6
|
export type SuiClient = MystenSuiClient;
|
6
7
|
export type SolanaClient = Connection;
|
8
|
+
export type AptosClient = Aptos;
|
@@ -23,6 +23,14 @@ export type PartialTokenUnderlying = {
|
|
23
23
|
* If you think other tokens should be added to this list, please send a PR.
|
24
24
|
*/
|
25
25
|
export declare const tokensToRelyOnByNetwork: Map<NetworkIdType, string[]>;
|
26
|
+
/**
|
27
|
+
* @deprecated
|
28
|
+
* This function has been deprecated. Use the getLpUnderlyingTokenSource instead.
|
29
|
+
* This list is used to avoid calulating low liquidity tokens with others low liquidity tokens.
|
30
|
+
* To prevent wrong prices (with very low precision) to be calculated, we setup a list of tokens to rely on.
|
31
|
+
* These tokens have very low chance of having price manipulation.
|
32
|
+
* Therefore, they can be safely used to compute other tokens prices.
|
33
|
+
*/
|
26
34
|
export default function checkComputeAndStoreTokensPrices(cache: Cache, source: string, networkId: NetworkIdType, tokenX: TokenInfo, tokenY: TokenInfo): Promise<{
|
27
35
|
partialTokenUnderlyingX: PartialTokenUnderlying;
|
28
36
|
partialTokenUnderlyingY: PartialTokenUnderlying;
|
@@ -66,6 +66,14 @@ exports.tokensToRelyOnByNetwork = new Map([
|
|
66
66
|
],
|
67
67
|
],
|
68
68
|
]);
|
69
|
+
/**
|
70
|
+
* @deprecated
|
71
|
+
* This function has been deprecated. Use the getLpUnderlyingTokenSource instead.
|
72
|
+
* This list is used to avoid calulating low liquidity tokens with others low liquidity tokens.
|
73
|
+
* To prevent wrong prices (with very low precision) to be calculated, we setup a list of tokens to rely on.
|
74
|
+
* These tokens have very low chance of having price manipulation.
|
75
|
+
* Therefore, they can be safely used to compute other tokens prices.
|
76
|
+
*/
|
69
77
|
function checkComputeAndStoreTokensPrices(cache, source, networkId, tokenX, tokenY) {
|
70
78
|
return __awaiter(this, void 0, void 0, function* () {
|
71
79
|
const tokensToRelyOn = exports.tokensToRelyOnByNetwork.get(networkId);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;Q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AAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;YAC/D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAE7C,MAAM,oBAAoB,GAAqB;gBAC7C,EAAE,EAAE,MAAM;gBACV,MAAM;gBACN,OAAO;gBACP,SAAS;gBACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;gBACnC,QAAQ;gBACR,KAAK;gBACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YACtD,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA;AArID,mDAqIC"}
|
1
|
+
{"version":3,"file":"checkComputeAndStoreTokensPrices.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/checkComputeAndStoreTokensPrices.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+DAMoC;AAGpC,wEAAgD;AAChD,+DAA4D;AAC5D,8DAAsE;AAetE;;;;;;;;;GASG;AACU,QAAA,uBAAuB,GAAiC,IAAI,GAAG,CAAC;IAC3E;QACE,0BAAS,CAAC,GAAG;QACb;YACE,yBAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO;YAC3B,sEAAsE,EAAE,OAAO;YAC/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GAAG,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;YAC/D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAE7C,MAAM,oBAAoB,GAAqB;gBAC7C,EAAE,EAAE,MAAM;gBACV,MAAM;gBACN,OAAO;gBACP,SAAS;gBACT,UAAU,EAAE,gCAAoB,CAAC,EAAE;gBACnC,QAAQ;gBACR,KAAK;gBACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,uBAAuB,GAAG;gBACxB,SAAS;gBACT,OAAO,EAAE,MAAM,CAAC,IAAI;gBACpB,QAAQ,EAAE,cAAc;gBACxB,KAAK,EAAE,MAAM;aACd,CAAC;YAEF,MAAM,KAAK,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;YACtD,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,CAAC;QAC9D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CAAA;AArID,mDAqIC"}
|
@@ -40,9 +40,11 @@ function getDecimalsForToken(cache, address, networkId) {
|
|
40
40
|
case 'aptos': {
|
41
41
|
const client = (0, clients_1.getClientAptos)();
|
42
42
|
const viewRes = (yield client.view({
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
payload: {
|
44
|
+
function: aptos_1.coinDecimals,
|
45
|
+
typeArguments: [address],
|
46
|
+
functionArguments: [],
|
47
|
+
},
|
46
48
|
}));
|
47
49
|
if (viewRes.length !== 1)
|
48
50
|
return undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AACpC,6CAA4C;AAC5C,uCAAiD;AACjD,wCAKoB;AACpB,oCAAwC;AACxC,oDAAsD;AACtD,gCAAsD;AAEtD,8DAAyE;AAGzE,MAAM,QAAQ,GAAG,CAAC,oCAAmB,EAAE,2CAA0B,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,SAAsB,mBAAmB,CACvC,KAAY,EACZ,OAAe,EACf,SAAwB;;QAExB,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CACtC,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC,EACtC;YACE,MAAM,EAAE,mCAAuB;YAC/B,SAAS;SACV,CACF,CAAC;QACF,IAAI,YAAY;YAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;QAE/C,QAAQ,SAAS,EAAE,CAAC;YAClB,KAAK,OAAO,CAAC,CAAC,CAAC;gBACb,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;gBAChC,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC;oBACjC,QAAQ,EAAE,oBAAY;
|
1
|
+
{"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAMoC;AACpC,6CAA4C;AAC5C,uCAAiD;AACjD,wCAKoB;AACpB,oCAAwC;AACxC,oDAAsD;AACtD,gCAAsD;AAEtD,8DAAyE;AAGzE,MAAM,QAAQ,GAAG,CAAC,oCAAmB,EAAE,2CAA0B,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACH,SAAsB,mBAAmB,CACvC,KAAY,EACZ,OAAe,EACf,SAAwB;;QAExB,MAAM,YAAY,GAAG,MAAM,KAAK,CAAC,OAAO,CACtC,IAAA,mCAAkB,EAAC,OAAO,EAAE,SAAS,CAAC,EACtC;YACE,MAAM,EAAE,mCAAuB;YAC/B,SAAS;SACV,CACF,CAAC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AAG,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;oBACvC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAC5C,CAAC;gBACD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,iCAAiC;oBACjC,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAiB,EAAC,IAAA,0BAAc,EAAC,0BAAS,CAAC,GAAG,CAAC,CAAC,CAAC;oBACtE,MAAM,SAAS,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAChD,OAAO,EACP,uBAAiB,CAClB,CAAc,CAAC;oBAChB,OAAO,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC;gBACzC,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,KAAK,KAAK,CAAC,CAAC,CAAC;gBACX,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;gBAC9B,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;gBACzE,IAAI,YAAY;oBAAE,OAAO,YAAY,CAAC,QAAQ,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACnB,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;CAAA;AAnED,kDAmEC"}
|
@@ -1,117 +0,0 @@
|
|
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
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
16
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
-
const aptos_1 = require("aptos");
|
18
|
-
const runInBatch_1 = __importDefault(require("../../../utils/misc/runInBatch"));
|
19
|
-
const getImagefromUri_1 = require("../../../utils/misc/getImagefromUri");
|
20
|
-
const constants_1 = require("../constants");
|
21
|
-
const prefix = 'nft-images-aptos';
|
22
|
-
const noImageValue = 'noimage';
|
23
|
-
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
24
|
-
const provider = new aptos_1.Provider(aptos_1.Network.MAINNET);
|
25
|
-
const ownedTokensRes = yield provider.getOwnedTokens(owner);
|
26
|
-
const nfts = ownedTokensRes.current_token_ownerships_v2.filter((nft) => nft.current_token_data);
|
27
|
-
const cachedImages = yield cache.getItems(nfts
|
28
|
-
.map((o) => (o.current_token_data ? o.current_token_data.token_uri : []))
|
29
|
-
.flat(), {
|
30
|
-
prefix,
|
31
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
32
|
-
});
|
33
|
-
const images = new Map();
|
34
|
-
const missings = [];
|
35
|
-
nfts.forEach((o, i) => __awaiter(void 0, void 0, void 0, function* () {
|
36
|
-
if (!o.current_token_data)
|
37
|
-
return;
|
38
|
-
const cachedImage = cachedImages[i];
|
39
|
-
const address = o.current_token_data.token_uri;
|
40
|
-
if (cachedImage) {
|
41
|
-
images.set(address, cachedImage);
|
42
|
-
}
|
43
|
-
else
|
44
|
-
missings.push(o);
|
45
|
-
}));
|
46
|
-
const res = yield (0, runInBatch_1.default)(missings.map((o) => () => { var _a; return (0, getImagefromUri_1.getImagefromUri)((_a = o.current_token_data) === null || _a === void 0 ? void 0 : _a.token_uri, portfolio_core_1.NetworkId.aptos, cache); }), 10);
|
47
|
-
const promises = res.map((r, i) => {
|
48
|
-
var _a;
|
49
|
-
const image = r.status !== 'rejected' ? r.value : undefined;
|
50
|
-
const address = (_a = missings[i].current_token_data) === null || _a === void 0 ? void 0 : _a.token_uri;
|
51
|
-
if (!address)
|
52
|
-
return undefined;
|
53
|
-
if (r.status === 'rejected' || !image) {
|
54
|
-
return cache.setItem(address, noImageValue, {
|
55
|
-
prefix,
|
56
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
57
|
-
});
|
58
|
-
}
|
59
|
-
images.set(address, image);
|
60
|
-
return cache.setItem(address, image, {
|
61
|
-
prefix,
|
62
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
63
|
-
});
|
64
|
-
});
|
65
|
-
yield Promise.allSettled(promises);
|
66
|
-
const assets = nfts
|
67
|
-
.map((nft) => {
|
68
|
-
var _a;
|
69
|
-
if (!nft.current_token_data)
|
70
|
-
return [];
|
71
|
-
const address = nft.current_token_data.token_data_id;
|
72
|
-
const dataUri = nft.current_token_data.token_uri;
|
73
|
-
const { amount } = nft;
|
74
|
-
let image = images.get(dataUri);
|
75
|
-
if (image === noImageValue)
|
76
|
-
image = undefined;
|
77
|
-
return {
|
78
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
79
|
-
type: portfolio_core_1.PortfolioAssetType.collectible,
|
80
|
-
value: null,
|
81
|
-
attributes: {},
|
82
|
-
data: {
|
83
|
-
address,
|
84
|
-
amount,
|
85
|
-
dataUri,
|
86
|
-
price: null,
|
87
|
-
value: null,
|
88
|
-
floorPrice: null,
|
89
|
-
image,
|
90
|
-
imageUri: image,
|
91
|
-
name: nft.current_token_data.token_name,
|
92
|
-
collectionId: (_a = nft.current_token_data.current_collection) === null || _a === void 0 ? void 0 : _a.collection_id,
|
93
|
-
},
|
94
|
-
};
|
95
|
-
})
|
96
|
-
.flat();
|
97
|
-
if (assets.length === 0)
|
98
|
-
return [];
|
99
|
-
const element = {
|
100
|
-
type: portfolio_core_1.PortfolioElementType.multiple,
|
101
|
-
networkId: portfolio_core_1.NetworkId.aptos,
|
102
|
-
platformId: constants_1.walletNftsPlatform.id,
|
103
|
-
label: 'Wallet',
|
104
|
-
value: null,
|
105
|
-
data: {
|
106
|
-
assets,
|
107
|
-
},
|
108
|
-
};
|
109
|
-
return [element];
|
110
|
-
});
|
111
|
-
const fetcher = {
|
112
|
-
id: `${constants_1.walletNftsPlatform.id}-${portfolio_core_1.NetworkId.aptos}`,
|
113
|
-
networkId: portfolio_core_1.NetworkId.sui,
|
114
|
-
executor,
|
115
|
-
};
|
116
|
-
exports.default = fetcher;
|
117
|
-
//# sourceMappingURL=aptos-nfts.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"aptos-nfts.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/aptos-nfts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,+DAMoC;AACpC,iCAA0C;AAG1C,gFAAwD;AACxD,yEAAsE;AACtE,4CAAkD;AAElD,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,YAAY,GAAG,SAAS,CAAC;AA2C/B,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,QAAQ,GAAG,IAAI,gBAAQ,CAAC,eAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,cAAc,GAAG,MAAM,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,cAAc,CAAC,2BAA2B,CAAC,MAAM,CAC5D,CAAC,GAAG,EAAE,EAAE,CAAC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