@sonarwatch/portfolio-plugins 0.5.23 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/package.json +2 -2
- package/src/index.js +8 -0
- package/src/index.js.map +1 -1
- package/src/platforms.d.ts +8 -0
- package/src/platforms.js +41 -1
- package/src/platforms.js.map +1 -1
- package/src/plugins/auxexchange/aptosLpJob.d.ts +3 -0
- package/src/plugins/auxexchange/aptosLpJob.js +75 -0
- package/src/plugins/auxexchange/aptosLpJob.js.map +1 -0
- package/src/plugins/auxexchange/constants.d.ts +4 -0
- package/src/plugins/auxexchange/constants.js +9 -0
- package/src/plugins/auxexchange/constants.js.map +1 -0
- package/src/plugins/auxexchange/index.d.ts +4 -0
- package/src/plugins/auxexchange/index.js +10 -0
- package/src/plugins/auxexchange/index.js.map +1 -0
- package/src/plugins/liquidswap/aptosLpJob.d.ts +3 -0
- package/src/plugins/liquidswap/aptosLpJob.js +89 -0
- package/src/plugins/liquidswap/aptosLpJob.js.map +1 -0
- package/src/plugins/liquidswap/constants.d.ts +5 -0
- package/src/plugins/liquidswap/constants.js +10 -0
- package/src/plugins/liquidswap/constants.js.map +1 -0
- package/src/plugins/liquidswap/index.d.ts +4 -0
- package/src/plugins/liquidswap/index.js +10 -0
- package/src/plugins/liquidswap/index.js.map +1 -0
- package/src/plugins/liquidswap/types.d.ts +10 -0
- package/src/plugins/liquidswap/types.js +3 -0
- package/src/plugins/liquidswap/types.js.map +1 -0
- package/src/plugins/native-stake/aptosFetcher.js +2 -1
- package/src/plugins/native-stake/aptosFetcher.js.map +1 -1
- package/src/plugins/native-stake/solanaFetcher.js +2 -1
- package/src/plugins/native-stake/solanaFetcher.js.map +1 -1
- package/src/plugins/native-stake/suiFetcher.js +2 -1
- package/src/plugins/native-stake/suiFetcher.js.map +1 -1
- package/src/plugins/pancakeswap/aptosLpJob.d.ts +3 -0
- package/src/plugins/pancakeswap/aptosLpJob.js +85 -0
- package/src/plugins/pancakeswap/aptosLpJob.js.map +1 -0
- package/src/plugins/pancakeswap/constants.d.ts +4 -0
- package/src/plugins/pancakeswap/constants.js +9 -0
- package/src/plugins/pancakeswap/constants.js.map +1 -0
- package/src/plugins/pancakeswap/index.d.ts +4 -0
- package/src/plugins/pancakeswap/index.js +10 -0
- package/src/plugins/pancakeswap/index.js.map +1 -0
- package/src/plugins/pancakeswap/types.d.ts +8 -0
- package/src/plugins/pancakeswap/types.js +3 -0
- package/src/plugins/pancakeswap/types.js.map +1 -0
- package/src/plugins/staking-aptos/constants.d.ts +4 -0
- package/src/plugins/staking-aptos/constants.js +32 -0
- package/src/plugins/staking-aptos/constants.js.map +1 -0
- package/src/plugins/staking-aptos/fetcherFetcher.d.ts +3 -0
- package/src/plugins/staking-aptos/fetcherFetcher.js +83 -0
- package/src/plugins/staking-aptos/fetcherFetcher.js.map +1 -0
- package/src/plugins/staking-aptos/index.d.ts +4 -0
- package/src/plugins/staking-aptos/index.js +10 -0
- package/src/plugins/staking-aptos/index.js.map +1 -0
- package/src/plugins/staking-aptos/types.d.ts +20 -0
- package/src/plugins/staking-aptos/types.js +3 -0
- package/src/plugins/staking-aptos/types.js.map +1 -0
- package/src/plugins/thala/constants.d.ts +1 -1
- package/src/plugins/thala/constants.js +1 -2
- package/src/plugins/thala/constants.js.map +1 -1
- package/src/utils/aptos/constants.d.ts +1 -0
- package/src/utils/aptos/constants.js +2 -1
- package/src/utils/aptos/constants.js.map +1 -1
- package/src/utils/misc/getDecimalsForToken.d.ts +10 -0
- package/src/utils/misc/getDecimalsForToken.js +43 -0
- package/src/utils/misc/getDecimalsForToken.js.map +1 -0
- package/src/utils/misc/getSourceWeight.d.ts +9 -0
- package/src/utils/misc/getSourceWeight.js +24 -0
- package/src/utils/misc/getSourceWeight.js.map +1 -0
- package/src/utils/misc/setLpPriceSource.d.ts +25 -0
- package/src/utils/misc/setLpPriceSource.js +126 -0
- 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,IAAI,CAAC,QAAQ,CAAC,IA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;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,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,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 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/pancakeswap/types.ts"],"names":[],"mappings":""}
|
@@ -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,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,GAAG,MAAM,IAAA,2BAAmB,E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UAAU;IAC3B,SAAS,EAAE,0BAAS,CAAC,KAAK;IAC1B,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -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 @@
|
|
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
|
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 =
|
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
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/thala/constants.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAEhC,QAAA,UAAU,GAAG,OAAO,CAAC;AACrB,QAAA,kBAAkB,GAC7B,oEAAoE,CAAC;AAEvE,MAAM,eAAe,GAAG,gBAAgB,CAAC;AACzC,MAAM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SAAS,EAAE,CAAC,KAAK,CAAC;CACnB,CAAC,CAAC;AAJU,QAAA,yBAAyB,6BAInC"}
|
@@ -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"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { NetworkIdType } from '@sonarwatch/portfolio-core';
|
2
|
+
import BigNumber from 'bignumber.js';
|
3
|
+
import { Cache } from '../../Cache';
|
4
|
+
export type PoolData = {
|
5
|
+
id: string;
|
6
|
+
supply: BigNumber;
|
7
|
+
lpDecimals: number;
|
8
|
+
reserveTokenX: BigNumber;
|
9
|
+
reserveTokenY: BigNumber;
|
10
|
+
mintTokenX: string;
|
11
|
+
mintTokenY: string;
|
12
|
+
};
|
13
|
+
/**
|
14
|
+
* Add a price source for a pool in the cache.
|
15
|
+
* If one of the token composing the pool doesn't have a price in the cache, add a new token price source for it.
|
16
|
+
*
|
17
|
+
* @param cache The cache on which the LP price will be stored
|
18
|
+
* @param tokenMintX The address/mint of the first token
|
19
|
+
* @param tokenMintY The address/mint of the second token
|
20
|
+
* @param poolData An object with informmations about the pool
|
21
|
+
* @param networkId The network for which the LP price source is stored
|
22
|
+
* @param platformId The platform from which the price is calculated
|
23
|
+
*
|
24
|
+
*/
|
25
|
+
export default function setLpPriceSource(cache: Cache, poolData: PoolData, networkId: NetworkIdType, platformId: string): Promise<void>;
|