@sonarwatch/portfolio-plugins 0.5.22 → 0.5.24

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/package.json +2 -2
  3. package/src/index.js +8 -0
  4. package/src/index.js.map +1 -1
  5. package/src/platforms.d.ts +8 -0
  6. package/src/platforms.js +41 -1
  7. package/src/platforms.js.map +1 -1
  8. package/src/plugins/auxexchange/aptosLpJob.d.ts +3 -0
  9. package/src/plugins/auxexchange/aptosLpJob.js +75 -0
  10. package/src/plugins/auxexchange/aptosLpJob.js.map +1 -0
  11. package/src/plugins/auxexchange/constants.d.ts +4 -0
  12. package/src/plugins/auxexchange/constants.js +9 -0
  13. package/src/plugins/auxexchange/constants.js.map +1 -0
  14. package/src/plugins/auxexchange/index.d.ts +4 -0
  15. package/src/plugins/auxexchange/index.js +10 -0
  16. package/src/plugins/auxexchange/index.js.map +1 -0
  17. package/src/plugins/drift/struct.d.ts +1 -1
  18. package/src/plugins/liquidswap/aptosLpJob.d.ts +3 -0
  19. package/src/plugins/liquidswap/aptosLpJob.js +89 -0
  20. package/src/plugins/liquidswap/aptosLpJob.js.map +1 -0
  21. package/src/plugins/liquidswap/constants.d.ts +5 -0
  22. package/src/plugins/liquidswap/constants.js +10 -0
  23. package/src/plugins/liquidswap/constants.js.map +1 -0
  24. package/src/plugins/liquidswap/index.d.ts +4 -0
  25. package/src/plugins/liquidswap/index.js +10 -0
  26. package/src/plugins/liquidswap/index.js.map +1 -0
  27. package/src/plugins/liquidswap/types.d.ts +10 -0
  28. package/src/plugins/liquidswap/types.js +3 -0
  29. package/src/plugins/liquidswap/types.js.map +1 -0
  30. package/src/plugins/native-stake/aptosFetcher.js +2 -1
  31. package/src/plugins/native-stake/aptosFetcher.js.map +1 -1
  32. package/src/plugins/native-stake/solanaFetcher.js +2 -1
  33. package/src/plugins/native-stake/solanaFetcher.js.map +1 -1
  34. package/src/plugins/native-stake/structs.d.ts +1 -1
  35. package/src/plugins/native-stake/suiFetcher.js +2 -1
  36. package/src/plugins/native-stake/suiFetcher.js.map +1 -1
  37. package/src/plugins/pancakeswap/aptosLpJob.d.ts +3 -0
  38. package/src/plugins/pancakeswap/aptosLpJob.js +85 -0
  39. package/src/plugins/pancakeswap/aptosLpJob.js.map +1 -0
  40. package/src/plugins/pancakeswap/constants.d.ts +4 -0
  41. package/src/plugins/pancakeswap/constants.js +9 -0
  42. package/src/plugins/pancakeswap/constants.js.map +1 -0
  43. package/src/plugins/pancakeswap/index.d.ts +4 -0
  44. package/src/plugins/pancakeswap/index.js +10 -0
  45. package/src/plugins/pancakeswap/index.js.map +1 -0
  46. package/src/plugins/pancakeswap/types.d.ts +8 -0
  47. package/src/plugins/pancakeswap/types.js +3 -0
  48. package/src/plugins/pancakeswap/types.js.map +1 -0
  49. package/src/plugins/staking-aptos/constants.d.ts +4 -0
  50. package/src/plugins/staking-aptos/constants.js +32 -0
  51. package/src/plugins/staking-aptos/constants.js.map +1 -0
  52. package/src/plugins/staking-aptos/fetcherFetcher.d.ts +3 -0
  53. package/src/plugins/staking-aptos/fetcherFetcher.js +83 -0
  54. package/src/plugins/staking-aptos/fetcherFetcher.js.map +1 -0
  55. package/src/plugins/staking-aptos/index.d.ts +4 -0
  56. package/src/plugins/staking-aptos/index.js +10 -0
  57. package/src/plugins/staking-aptos/index.js.map +1 -0
  58. package/src/plugins/staking-aptos/types.d.ts +20 -0
  59. package/src/plugins/staking-aptos/types.js +3 -0
  60. package/src/plugins/staking-aptos/types.js.map +1 -0
  61. package/src/plugins/thala/constants.d.ts +1 -1
  62. package/src/plugins/thala/constants.js +1 -2
  63. package/src/plugins/thala/constants.js.map +1 -1
  64. package/src/plugins/tokens/fetchers/solana-nfts.d.ts +3 -0
  65. package/src/plugins/tokens/fetchers/solana-nfts.js +77 -0
  66. package/src/plugins/tokens/fetchers/solana-nfts.js.map +1 -0
  67. package/src/plugins/tokens/index.js +2 -0
  68. package/src/plugins/tokens/index.js.map +1 -1
  69. package/src/utils/aptos/constants.d.ts +1 -0
  70. package/src/utils/aptos/constants.js +2 -1
  71. package/src/utils/aptos/constants.js.map +1 -1
  72. package/src/utils/misc/getDecimalsForToken.d.ts +10 -0
  73. package/src/utils/misc/getDecimalsForToken.js +43 -0
  74. package/src/utils/misc/getDecimalsForToken.js.map +1 -0
  75. package/src/utils/misc/getSourceWeight.d.ts +9 -0
  76. package/src/utils/misc/getSourceWeight.js +24 -0
  77. package/src/utils/misc/getSourceWeight.js.map +1 -0
  78. package/src/utils/misc/setLpPriceSource.d.ts +25 -0
  79. package/src/utils/misc/setLpPriceSource.js +126 -0
  80. package/src/utils/misc/setLpPriceSource.js.map +1 -0
@@ -0,0 +1,85 @@
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
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
16
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
17
+ const constants_1 = require("./constants");
18
+ const clients_1 = require("../../utils/clients");
19
+ const aptos_1 = require("../../utils/aptos");
20
+ const setLpPriceSource_1 = __importDefault(require("../../utils/misc/setLpPriceSource"));
21
+ const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
22
+ var _a, _b, _c;
23
+ const client = (0, clients_1.getClientAptos)();
24
+ const resources = yield (0, aptos_1.getAccountResources)(client, constants_1.programAddress);
25
+ if (!resources)
26
+ return;
27
+ const resourcesByType = new Map();
28
+ resources.forEach((resource) => {
29
+ resourcesByType.set(resource.type, resource);
30
+ });
31
+ for (let i = 0; i < resources.length; i++) {
32
+ const resource = resources[i];
33
+ if (!resource.type.startsWith(constants_1.lpCoinInfoTypePrefix))
34
+ continue;
35
+ const lpType = (0, aptos_1.getNestedType)(resource.type);
36
+ const lpInfoData = resource.data;
37
+ const lpSupplyString = (_c = (_b = (_a = lpInfoData.supply) === null || _a === void 0 ? void 0 : _a.vec[0]) === null || _b === void 0 ? void 0 : _b.integer.vec[0]) === null || _c === void 0 ? void 0 : _c.value;
38
+ if (!lpSupplyString)
39
+ continue;
40
+ const lpDecimals = lpInfoData.decimals;
41
+ const lpSupply = new bignumber_js_1.default(lpSupplyString)
42
+ .div(Math.pow(10, lpDecimals))
43
+ .toNumber();
44
+ if (lpSupply === 0)
45
+ continue;
46
+ const tokenPairId = (0, aptos_1.getNestedType)(lpType);
47
+ // TODO : get ride of those by using parseTypeString() instead of getNestedType()
48
+ if (tokenPairId.includes('swap::LPToken') ||
49
+ tokenPairId.includes('LPCoinV1::LPCoin') ||
50
+ tokenPairId.includes('lp_coin::LP'))
51
+ continue;
52
+ const splits = tokenPairId.split(', ');
53
+ const typeX = splits.at(0);
54
+ const typeY = splits.at(1);
55
+ const tokenPairResource = resourcesByType.get(`${constants_1.programAddress}::swap::TokenPairMetadata<${tokenPairId}>`);
56
+ if (!tokenPairResource)
57
+ throw new Error(`Failed to get tokenPairResource: ${lpType}`);
58
+ if (!typeX)
59
+ throw new Error(`Failed to get typeX: ${typeX}`);
60
+ if (!typeY)
61
+ throw new Error(`Failed to get typeY: ${typeY}`);
62
+ if (typeX.includes('TestToken') || typeY.includes('TestToken'))
63
+ continue;
64
+ const tokenPairData = tokenPairResource.data;
65
+ if (tokenPairData.balance_x.value === '0' &&
66
+ tokenPairData.balance_y.value === '0')
67
+ continue;
68
+ const poolData = {
69
+ id: lpType,
70
+ lpDecimals,
71
+ supply: new bignumber_js_1.default(lpSupply),
72
+ mintTokenX: typeX,
73
+ mintTokenY: typeY,
74
+ reserveTokenX: new bignumber_js_1.default(tokenPairData.balance_x.value),
75
+ reserveTokenY: new bignumber_js_1.default(tokenPairData.balance_y.value),
76
+ };
77
+ yield (0, setLpPriceSource_1.default)(cache, poolData, portfolio_core_1.NetworkId.aptos, constants_1.platformId);
78
+ }
79
+ });
80
+ const job = {
81
+ id: `${constants_1.platformId}-aptos-lp`,
82
+ executor,
83
+ };
84
+ exports.default = job;
85
+ //# sourceMappingURL=aptosLpJob.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aptosLpJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/aptosLpJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,+DAAuD;AAGvD,2CAA+E;AAE/E,iDAAqD;AACrD,6CAK2B;AAC3B,yFAA+E;AAE/E,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,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9B,IAA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;QAChE,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,EAAE,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC;YAAE,SAAS;QAEzE,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC;QAC7C,IACE,aAAa,CAAC,SAAS,CAAC,KAAK,KAAK,GAAG;YACrC,aAAa,CAAC,SAAS,CAAC,KAAK,KAAK,GAAG;YAErC,SAAS;QAEX,MAAM,QAAQ,GAAa;YACzB,EAAE,EAAE,MAAM;YACV,UAAU;YACV,MAAM,EAAE,IAAI,sBAAS,CAAC,QAAQ,CAAC;YAC/B,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,IAAI,sBAAS,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC;YAC3D,aAAa,EAAE,IAAI,sBAAS,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC;SAC5D,CAAC;QACF,MAAM,IAAA,0BAAgB,EAAC,KAAK,EAAE,QAAQ,EAAE,0BAAS,CAAC,KAAK,EAAE,sBAAU,CAAC,CAAC;KACtE;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,WAAW;IAC5B,QAAQ;CACT,CAAC;AACF,kBAAe,GAAG,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const platformId = "pancakeswap";
2
+ export declare const programAddress = "0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa";
3
+ export declare const lpTypePrefix: string;
4
+ export declare const lpCoinInfoTypePrefix: string;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.lpCoinInfoTypePrefix = exports.lpTypePrefix = exports.programAddress = exports.platformId = void 0;
4
+ const aptos_1 = require("../../utils/aptos");
5
+ exports.platformId = 'pancakeswap';
6
+ exports.programAddress = '0xc7efb4076dbe143cbcd98cfaaa929ecfc8f299203dfff63b95ccb6bfe19850fa';
7
+ exports.lpTypePrefix = `${exports.programAddress}::swap::LPToken<`;
8
+ exports.lpCoinInfoTypePrefix = `${aptos_1.coinInfo}<${exports.lpTypePrefix}`;
9
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAEhC,QAAA,UAAU,GAAG,aAAa,CAAC;AAE3B,QAAA,cAAc,GACzB,oEAAoE,CAAC;AAE1D,QAAA,YAAY,GAAG,GAAG,sBAAc,kBAAkB,CAAC;AACnD,QAAA,oBAAoB,GAAG,GAAG,gBAAQ,IAAI,oBAAY,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Job } from '../../Job';
2
+ import { Fetcher } from '../../Fetcher';
3
+ export declare const jobs: Job[];
4
+ export declare const fetchers: Fetcher[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchers = exports.jobs = void 0;
7
+ const aptosLpJob_1 = __importDefault(require("./aptosLpJob"));
8
+ exports.jobs = [aptosLpJob_1.default];
9
+ exports.fetchers = [];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/index.ts"],"names":[],"mappings":";;;;;;AAEA,8DAAoC;AAEvB,QAAA,IAAI,GAAU,CAAC,oBAAQ,CAAC,CAAC;AACzB,QAAA,QAAQ,GAAc,EAAE,CAAC"}
@@ -0,0 +1,8 @@
1
+ export type PancakeSwapTokenPairMetadataData = {
2
+ balance_x: {
3
+ value: string;
4
+ };
5
+ balance_y: {
6
+ value: string;
7
+ };
8
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { StakeConfig } from './types';
2
+ export declare const stakeConfigs: StakeConfig[];
3
+ export declare const stakingAptosPlatformIds: string[];
4
+ export declare const platformId = "staking-aptos";
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.platformId = exports.stakingAptosPlatformIds = exports.stakeConfigs = void 0;
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ const aptos_1 = require("../../utils/aptos");
9
+ const platforms_1 = require("../../platforms");
10
+ // Meeiro
11
+ const programMeeiro = '0x514cfb77665f99a2e4c65a5614039c66d13e00e98daf4c86305651d29fd953e5';
12
+ const prefixMeeiro = `${programMeeiro}::Staking::StakeInfo<`;
13
+ const parseResourceMeeiro = (r) => {
14
+ var _a, _b;
15
+ return ({
16
+ amountBn: new bignumber_js_1.default(r.data.amount),
17
+ tokenAddress: ((_b = (_a = (0, aptos_1.parseTypeString)(r.type).keys) === null || _a === void 0 ? void 0 : _a.at(0)) === null || _b === void 0 ? void 0 : _b.type) || '',
18
+ });
19
+ };
20
+ exports.stakeConfigs = [
21
+ {
22
+ platformId: platforms_1.meeiroPlatform.id,
23
+ typeLabel: 'Staked',
24
+ prefixes: [prefixMeeiro],
25
+ parseResource: parseResourceMeeiro,
26
+ },
27
+ ];
28
+ exports.stakingAptosPlatformIds = [
29
+ ...new Set(exports.stakeConfigs.map((c) => c.platformId)),
30
+ ];
31
+ exports.platformId = 'staking-aptos';
32
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/staking-aptos/constants.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAqC;AACrC,6CAAkE;AAElE,+CAAiD;AAEjD,SAAS;AACT,MAAM,aAAa,GACjB,oEAAoE,CAAC;AACvE,MAAM,YAAY,GAAG,GAAG,aAAa,uBAAuB,CAAC;AAC7D,MAAM,mBAAmB,GAAG,CAAC,CAAwB,EAAa,EAAE;;IAAC,OAAA,CAAC;QACpE,QAAQ,EAAE,IAAI,sBAAS,CAAE,CAAmC,CAAC,IAAI,CAAC,MAAM,CAAC;QACzE,YAAY,EAAE,CAAA,MAAA,MAAA,IAAA,uBAAe,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,0CAAE,EAAE,CAAC,CAAC,CAAC,0CAAE,IAAI,KAAI,EAAE;KAC9D,CAAC,CAAA;CAAA,CAAC;AAEU,QAAA,YAAY,GAAkB;IACzC;QACE,UAAU,EAAE,0BAAc,CAAC,EAAE;QAC7B,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,CAAC,YAAY,CAAC;QACxB,aAAa,EAAE,mBAAmB;KACnC;CACF,CAAC;AAEW,QAAA,uBAAuB,GAAG;IACrC,GAAG,IAAI,GAAG,CAAC,oBAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;CAClD,CAAC;AAEW,QAAA,UAAU,GAAG,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,83 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const constants_1 = require("./constants");
17
+ const clients_1 = require("../../utils/clients");
18
+ const aptos_1 = require("../../utils/aptos");
19
+ const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
20
+ const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const client = (0, clients_1.getClientAptos)();
22
+ const resources = yield (0, aptos_1.getAccountResources)(client, owner);
23
+ if (!resources)
24
+ return [];
25
+ const promises = constants_1.stakeConfigs.flatMap((sConfig) => {
26
+ if (!constants_1.stakingAptosPlatformIds.includes(sConfig.platformId))
27
+ return [];
28
+ return fetchByStakeConfig(resources, sConfig, cache);
29
+ });
30
+ const elements = (yield Promise.all(promises)).flat(1);
31
+ return elements;
32
+ });
33
+ function fetchByStakeConfig(resources, config, cache) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const assetPromises = resources.map((resource) => __awaiter(this, void 0, void 0, function* () {
36
+ const isMatching = config.prefixes.some((p) => resource.type.startsWith(p));
37
+ if (!isMatching)
38
+ return undefined;
39
+ const { amountBn, tokenAddress } = config.parseResource(resource);
40
+ const tokenPrice = yield cache.getTokenPrice(tokenAddress, portfolio_core_1.NetworkId.aptos);
41
+ if (!tokenPrice)
42
+ return undefined;
43
+ const amount = amountBn.div(Math.pow(10, tokenPrice.decimals)).toNumber();
44
+ const value = amount * tokenPrice.price;
45
+ const assets = (0, tokenPriceToAssetTokens_1.default)(tokenAddress, amount, portfolio_core_1.NetworkId.aptos, tokenPrice);
46
+ const liquidity = {
47
+ value,
48
+ assets,
49
+ assetsValue: value,
50
+ rewardAssets: [],
51
+ rewardAssetsValue: 0,
52
+ yields: [],
53
+ };
54
+ return liquidity;
55
+ }));
56
+ const results = yield Promise.allSettled(assetPromises);
57
+ const liquidities = results.reduce((liqu, result) => {
58
+ if (result.status === 'fulfilled' && result.value)
59
+ liqu.push(result.value);
60
+ return liqu;
61
+ }, []);
62
+ if (liquidities.length === 0)
63
+ return [];
64
+ const elementMultiple = {
65
+ networkId: portfolio_core_1.NetworkId.aptos,
66
+ platformId: config.platformId,
67
+ type: portfolio_core_1.PortfolioElementType.liquidity,
68
+ label: config.typeLabel,
69
+ value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((a) => a.value)),
70
+ data: {
71
+ liquidities,
72
+ },
73
+ };
74
+ return [elementMultiple];
75
+ });
76
+ }
77
+ const fetcher = {
78
+ id: `${constants_1.platformId}-fetcher`,
79
+ networkId: portfolio_core_1.NetworkId.aptos,
80
+ executor,
81
+ };
82
+ exports.default = fetcher;
83
+ //# sourceMappingURL=fetcherFetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetcherFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/staking-aptos/fetcherFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAOoC;AAGpC,2CAAgF;AAChF,iDAAqD;AACrD,6CAAsE;AAEtE,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;IAChC,MAAM,SAAS,G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,EAAE,EAAE,GAAG,sBAAU,UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Job } from '../../Job';
2
+ import { Fetcher } from '../../Fetcher';
3
+ export declare const jobs: Job[];
4
+ export declare const fetchers: Fetcher[];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchers = exports.jobs = void 0;
7
+ const fetcherFetcher_1 = __importDefault(require("./fetcherFetcher"));
8
+ exports.jobs = [];
9
+ exports.fetchers = [fetcherFetcher_1.default];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/staking-aptos/index.ts"],"names":[],"mappings":";;;;;;AAEA,sEAAuC;AAE1B,QAAA,IAAI,GAAU,EAAE,CAAC;AACjB,QAAA,QAAQ,GAAc,CAAC,wBAAO,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { PortfolioElementLabel } from '@sonarwatch/portfolio-core';
2
+ import BigNumber from 'bignumber.js';
3
+ import { MoveResource } from '../../utils/aptos';
4
+ export type MeeiroStakeData = {
5
+ amount: string;
6
+ reward_amount: string;
7
+ reward_debt: string;
8
+ unlocking_amount: string;
9
+ unlocking_start_time: string;
10
+ };
11
+ export type StakeInfo = {
12
+ amountBn: BigNumber;
13
+ tokenAddress: string;
14
+ };
15
+ export type StakeConfig = {
16
+ platformId: string;
17
+ typeLabel: PortfolioElementLabel;
18
+ prefixes: string[];
19
+ parseResource: (rData: MoveResource<unknown>) => StakeInfo;
20
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/staking-aptos/types.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- export declare const platformId: string;
1
+ export declare const platformId = "thala";
2
2
  export declare const programAdressThala = "0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01";
3
3
  export declare const vaultFilter: string;
4
4
  export declare const vaultCollateralParamsFilter: string;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stabilityClaimablePayload = exports.stabilityDepositPayload = exports.lpWeightedCoinInfoTypePrefix = exports.lpStableCoinInfoTypePrefix = exports.lpWeightedTypePrefix = exports.lpStableTypePrefix = exports.lpWeightedTypeTokenPrefix = exports.lpStableTypeTokenPrefix = exports.programAddressLP = exports.stabilityEndpoint = exports.modCoin = exports.thlCoin = exports.vaultCollateralParamsFilter = exports.vaultFilter = exports.programAdressThala = exports.platformId = void 0;
4
- const platforms_1 = require("../../platforms");
5
4
  const aptos_1 = require("../../utils/aptos");
6
- exports.platformId = platforms_1.thalaPlatform.id;
5
+ exports.platformId = 'thala';
7
6
  exports.programAdressThala = '0x6f986d146e4a90b828d8c12c14b6f4e003fdff11a8eecceceb63744363eaac01';
8
7
  const stabilityModule = 'stability_pool';
9
8
  const vaultModule = 'vault';
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/constants.ts"],"names":[],"mappings":";;;AAAA,+CAAgD;AAChD,6CAA6C;AAEhC,QAAA,UAAU,GAAG,yBAAa,CAAC,EAAE,CAAC;AAC9B,QAAA,kBAAkB,GAC7B,oEAAoE,CAAC;AAEvE,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,MAAM,gBAAgB,GAAG,GAAG,0BAAkB,KAAK,eA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AAc,EAAE,CAAC,UAAU,CAAC;IAC5B,SAAS,EAAE,CAAC,KAAK,CAAC;CACnB,CAAC,CAAC;AAJU,QAAA,uBAAuB,2BAIjC;AAEI,MAAM,yBAAyB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC;IAC3D,QAAQ,EAAE,kBAAkB;IAC5B,cAAc,EAAE,EAAE;IAClB,SAAS,EAAE,CAAC,KAAK,CAAC;CACnB,CAAC,CAAC;AAJU,QAAA,yBAAyB,6BAInC"}
@@ -0,0 +1,3 @@
1
+ import { Fetcher } from '../../../Fetcher';
2
+ declare const fetcher: Fetcher;
3
+ export default fetcher;
@@ -0,0 +1,77 @@
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
+ const portfolio_core_1 = require("@sonarwatch/portfolio-core");
16
+ const web3_js_1 = require("@solana/web3.js");
17
+ const js_1 = require("@metaplex-foundation/js");
18
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
19
+ const platforms_1 = require("../../../platforms");
20
+ const clients_1 = require("../../../utils/clients");
21
+ const executor = (owner) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const client = (0, clients_1.getClientSolana)();
23
+ const ownerPubKey = new web3_js_1.PublicKey(owner);
24
+ const metaplex = new js_1.Metaplex(client);
25
+ if (!owner)
26
+ return [];
27
+ const outputs = yield metaplex.nfts().findAllByOwner({
28
+ owner: ownerPubKey,
29
+ });
30
+ const assets = outputs.map((output) => {
31
+ var _a;
32
+ const address = output.model === 'metadata'
33
+ ? output.mintAddress.toString()
34
+ : output.mint.address.toString();
35
+ const token = (0, js_1.isNftWithToken)(output) || (0, js_1.isSftWithToken)(output) ? output.token : null;
36
+ const amount = (token === null || token === void 0 ? void 0 : token.amount)
37
+ ? new bignumber_js_1.default(token.amount.basisPoints.toString())
38
+ .div(Math.pow(10, token.amount.currency.decimals))
39
+ .toNumber()
40
+ : 1;
41
+ return {
42
+ networkId: portfolio_core_1.NetworkId.solana,
43
+ type: portfolio_core_1.PortfolioAssetType.collectible,
44
+ value: null,
45
+ data: {
46
+ address,
47
+ amount,
48
+ dataUri: output.uri,
49
+ price: null,
50
+ value: null,
51
+ floorPrice: null,
52
+ name: output.name,
53
+ collectionId: (_a = output.collection) === null || _a === void 0 ? void 0 : _a.address.toString(),
54
+ },
55
+ };
56
+ });
57
+ if (assets.length === 0)
58
+ return [];
59
+ const element = {
60
+ type: portfolio_core_1.PortfolioElementType.multiple,
61
+ networkId: portfolio_core_1.NetworkId.solana,
62
+ platformId: platforms_1.walletNftsPlatform.id,
63
+ label: 'Wallet',
64
+ value: null,
65
+ data: {
66
+ assets,
67
+ },
68
+ };
69
+ return [element];
70
+ });
71
+ const fetcher = {
72
+ id: `${platforms_1.walletTokensPlatform.id}-solana-nfts`,
73
+ networkId: portfolio_core_1.NetworkId.solana,
74
+ executor,
75
+ };
76
+ exports.default = fetcher;
77
+ //# sourceMappingURL=solana-nfts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-nfts.js","sourceRoot":"","sources":["../../../../../../../packages/plugins/src/plugins/tokens/fetchers/solana-nfts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,6CAA4C;AAC5C,gDAKiC;AACjC,gEAAqC;AAErC,kDAA8E;AAC9E,oDAAyD;AAEzD,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AAE;gBACJ,OAAO;gBACP,MAAM;gBACN,OAAO,EAAE,MAAM,CAAC,GAAG;gBACnB,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,IAAI;gBACX,UAAU,EAAE,IAAI;gBAChB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,YAAY,EAAE,MAAA,MAAM,CAAC,UAAU,0CAAE,OAAO,CAAC,QAAQ,EAAE;aACpD;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnC,MAAM,OAAO,GAA6B;QACxC,IAAI,EAAE,qCAAoB,CAAC,QAAQ;QACnC,SAAS,EAAE,0BAAS,CAAC,MAAM;QAC3B,UAAU,EAAE,8BAAkB,CAAC,EAAE;QACjC,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,IAAI;QACX,IAAI,EAAE;YACJ,MAAM;SACP;KACF,CAAC;IACF,OAAO,CAAC,OAAO,CAAC,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,cAAc;IAC5C,SAAS,EAAE,0BAAS,CAAC,MAAM;IAC3B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
@@ -11,6 +11,7 @@ const aptos_1 = __importDefault(require("./fetchers/aptos"));
11
11
  const solana_1 = __importDefault(require("./fetchers/solana"));
12
12
  const sui_1 = __importDefault(require("./fetchers/sui"));
13
13
  const solana_native_1 = __importDefault(require("./fetchers/solana-native"));
14
+ const solana_nfts_1 = __importDefault(require("./fetchers/solana-nfts"));
14
15
  const tokenListsJob_1 = __importDefault(require("./tokenListsJob"));
15
16
  const evms_1 = require("./fetchers/evms");
16
17
  exports.jobs = [
@@ -44,6 +45,7 @@ exports.fetchers = [
44
45
  aptos_1.default,
45
46
  solana_1.default,
46
47
  solana_native_1.default,
48
+ solana_nfts_1.default,
47
49
  sui_1.default,
48
50
  ...evms_1.fetchers,
49
51
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuD;AACvD,+CAAuD;AACvD,kFAA0D;AAC1D,6DAA4C;AAC5C,+DAA8C;AAC9C,yDAAwC;AACxC,6EAA2D;AAE3D,oEAA4C;AAE5C,0CAA0D;AAE7C,QAAA,IAAI,GAAU;IACzB;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,KAAK,EAAE;QACnD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,KAAK,CAAC;KAChD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,MAAM,EAAE;QACpD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,MAAM,CAAC;KACjD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,QAAQ,EAAE;QACtD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,QAAQ,CAAC;KACnD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,SAAS,EAAE;QACvD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,SAAS,CAAC;KACpD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,OAAO,EAAE;QACrD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,OAAO,CAAC;KAClD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,GAAG,EAAE;QACjD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,GAAG,CAAC;KAC9C;IACD,uBAAa;CACd,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,eAAY;IACZ,gBAAa;IACb,uBAAmB;IACnB,aAAU;IACV,GAAG,eAAW;CACf,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/tokens/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuD;AACvD,+CAAuD;AACvD,kFAA0D;AAC1D,6DAA4C;AAC5C,+DAA8C;AAC9C,yDAAwC;AACxC,6EAA2D;AAC3D,yEAAuD;AAEvD,oEAA4C;AAE5C,0CAA0D;AAE7C,QAAA,IAAI,GAAU;IACzB;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,KAAK,EAAE;QACnD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,KAAK,CAAC;KAChD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,MAAM,EAAE;QACpD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,MAAM,CAAC;KACjD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,QAAQ,EAAE;QACtD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,QAAQ,CAAC;KACnD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,SAAS,EAAE;QACvD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,SAAS,CAAC;KACpD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,OAAO,EAAE;QACrD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,OAAO,CAAC;KAClD;IACD;QACE,EAAE,EAAE,GAAG,gCAAoB,CAAC,EAAE,IAAI,0BAAS,CAAC,GAAG,EAAE;QACjD,QAAQ,EAAE,IAAA,8BAAoB,EAAC,0BAAS,CAAC,GAAG,CAAC;KAC9C;IACD,uBAAa;CACd,CAAC;AAEW,QAAA,QAAQ,GAAc;IACjC,eAAY;IACZ,gBAAa;IACb,uBAAmB;IACnB,qBAAiB;IACjB,aAAU;IACV,GAAG,eAAW;CACf,CAAC"}
@@ -3,3 +3,4 @@ export declare const nativeDecimals = 8;
3
3
  export declare const nativeFactor: number;
4
4
  export declare const coinInfo = "0x1::coin::CoinInfo";
5
5
  export declare const coinStore = "0x1::coin::CoinStore";
6
+ export declare const coinDecimals = "0x1::coin::decimals";
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.coinStore = exports.coinInfo = exports.nativeFactor = exports.nativeDecimals = exports.nativeType = void 0;
3
+ exports.coinDecimals = exports.coinStore = exports.coinInfo = exports.nativeFactor = exports.nativeDecimals = exports.nativeType = void 0;
4
4
  exports.nativeType = '0x1::aptos_coin::AptosCoin';
5
5
  exports.nativeDecimals = 8;
6
6
  exports.nativeFactor = Math.pow(10, exports.nativeDecimals);
7
7
  exports.coinInfo = '0x1::coin::CoinInfo';
8
8
  exports.coinStore = '0x1::coin::CoinStore';
9
+ exports.coinDecimals = '0x1::coin::decimals';
9
10
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,4BAA4B,CAAC;AAC1C,QAAA,cAAc,GAAG,CAAC,CAAC;AACnB,QAAA,YAAY,GAAG,SAAA,EAAE,EAAI,sBAAc,CAAA,CAAC;AACpC,QAAA,QAAQ,GAAG,qBAAqB,CAAC;AACjC,QAAA,SAAS,GAAG,sBAAsB,CAAC"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/aptos/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,UAAU,GAAG,4BAA4B,CAAC;AAC1C,QAAA,cAAc,GAAG,CAAC,CAAC;AACnB,QAAA,YAAY,GAAG,SAAA,EAAE,EAAI,sBAAc,CAAA,CAAC;AACpC,QAAA,QAAQ,GAAG,qBAAqB,CAAC;AACjC,QAAA,SAAS,GAAG,sBAAsB,CAAC;AACnC,QAAA,YAAY,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { NetworkIdType } from '@sonarwatch/portfolio-core';
2
+ /**
3
+ * Return the decimals of a token on any network using RPC calls.
4
+ *
5
+ * @param address The mint/address of the token.
6
+ * @param networkId The network on which to execute the request.
7
+ *
8
+ * @returns The number of decimals or undefined if unsucessful request.
9
+ */
10
+ export declare function getDecimalsForToken(address: string, networkId: NetworkIdType): Promise<number | undefined>;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getDecimalsForToken = void 0;
13
+ const clients_1 = require("../clients");
14
+ const aptos_1 = require("../aptos");
15
+ /**
16
+ * Return the decimals of a token on any network using RPC calls.
17
+ *
18
+ * @param address The mint/address of the token.
19
+ * @param networkId The network on which to execute the request.
20
+ *
21
+ * @returns The number of decimals or undefined if unsucessful request.
22
+ */
23
+ function getDecimalsForToken(address, networkId) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ switch (networkId) {
26
+ case 'aptos': {
27
+ const client = (0, clients_1.getClientAptos)();
28
+ const viewRes = (yield client.view({
29
+ function: aptos_1.coinDecimals,
30
+ type_arguments: [address],
31
+ arguments: [],
32
+ }));
33
+ if (viewRes.length !== 1)
34
+ return undefined;
35
+ return viewRes[0];
36
+ }
37
+ default:
38
+ throw new Error('getDecimalsForToken : Network not supported');
39
+ }
40
+ });
41
+ }
42
+ exports.getDecimalsForToken = getDecimalsForToken;
43
+ //# sourceMappingURL=getDecimalsForToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDecimalsForToken.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getDecimalsForToken.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,wCAA4C;AAC5C,oCAAwC;AAExC;;;;;;;GAOG;AACH,SAAsB,mBAAmB,CACvC,OAAe,EACf,SAAwB;;QAExB,QAAQ,SAAS,EAAE;YACjB,KAAK,OAAO,CAAC,CAAC;gBACZ,MAAM,MAAM,GAAG,IAAA,wBAAc,GAAE,CAAC;gBAChC,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC;oBACjC,QAAQ,EAAE,oBAAY;oBACtB,cAAc,EAAE,CAAC,OAAO,CAAC;oBACzB,SAAS,EAAE,EAAE;iBACd,CAAC,CAAa,CAAC;gBAChB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;oBAAE,OAAO,SAAS,CAAC;gBAC3C,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;aACnB;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;SAClE;IACH,CAAC;CAAA;AAlBD,kDAkBC"}
@@ -0,0 +1,9 @@
1
+ import BigNumber from 'bignumber.js';
2
+ /**
3
+ * Get the weight of a new TokenPriceSource depending on the size of the pool in USD$ value
4
+ *
5
+ * @param poolUsdValue Total value in USD$ of the pool
6
+ *
7
+ * @returns weight between 0 and 1
8
+ */
9
+ export default function getSourceWeight(poolUsdValue: BigNumber): number;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
7
+ const usdValueForWeightOfOne = new bignumber_js_1.default(10).pow(9);
8
+ /**
9
+ * Get the weight of a new TokenPriceSource depending on the size of the pool in USD$ value
10
+ *
11
+ * @param poolUsdValue Total value in USD$ of the pool
12
+ *
13
+ * @returns weight between 0 and 1
14
+ */
15
+ function getSourceWeight(poolUsdValue) {
16
+ if (poolUsdValue.isGreaterThan(usdValueForWeightOfOne))
17
+ return 1;
18
+ return poolUsdValue
19
+ .dividedBy(usdValueForWeightOfOne)
20
+ .decimalPlaces(3, bignumber_js_1.default.ROUND_CEIL)
21
+ .toNumber();
22
+ }
23
+ exports.default = getSourceWeight;
24
+ //# sourceMappingURL=getSourceWeight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSourceWeight.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/getSourceWeight.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAErC,MAAM,sBAAsB,GAAG,IAAI,sBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACxD;;;;;;GAMG;AACH,SAAwB,eAAe,CAAC,YAAuB;IAC7D,IAAI,YAAY,CAAC,aAAa,CAAC,sBAAsB,CAAC;QAAE,OAAO,CAAC,CAAC;IACjE,OAAO,YAAY;SAChB,SAAS,CAAC,sBAAsB,CAAC;SACjC,aAAa,CAAC,CAAC,EAAE,sBAAS,CAAC,UAAU,CAAC;SACtC,QAAQ,EAAE,CAAC;AAChB,CAAC;AAND,kCAMC"}