@sonarwatch/portfolio-plugins 0.11.206 → 0.11.208
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +1565 -1557
- package/README.md +3 -3
- package/package.json +3 -2
- package/src/Job.d.ts +1 -1
- package/src/index.js +4 -0
- package/src/index.js.map +1 -1
- package/src/plugins/balancer/helpers/pools.js +21 -21
- package/src/plugins/flowx/constants.d.ts +1 -0
- package/src/plugins/flowx/constants.js +2 -1
- package/src/plugins/flowx/constants.js.map +1 -1
- package/src/plugins/flowx/index.js +6 -1
- package/src/plugins/flowx/index.js.map +1 -1
- package/src/plugins/flowx/stakingPoolV3Fetcher.d.ts +3 -0
- package/src/plugins/flowx/stakingPoolV3Fetcher.js +100 -0
- package/src/plugins/flowx/stakingPoolV3Fetcher.js.map +1 -0
- package/src/plugins/flowx/types.d.ts +31 -0
- package/src/plugins/mole/constants.d.ts +12 -0
- package/src/plugins/mole/constants.js +25 -0
- package/src/plugins/mole/constants.js.map +1 -0
- package/src/plugins/mole/dataJob.d.ts +3 -0
- package/src/plugins/mole/dataJob.js +49 -0
- package/src/plugins/mole/dataJob.js.map +1 -0
- package/src/plugins/mole/depositsFetcher.d.ts +3 -0
- package/src/plugins/mole/depositsFetcher.js +133 -0
- package/src/plugins/mole/depositsFetcher.js.map +1 -0
- package/src/plugins/mole/farmsFetcher.d.ts +3 -0
- package/src/plugins/mole/farmsFetcher.js +132 -0
- package/src/plugins/mole/farmsFetcher.js.map +1 -0
- package/src/plugins/mole/farmsJob.d.ts +3 -0
- package/src/plugins/mole/farmsJob.js +52 -0
- package/src/plugins/mole/farmsJob.js.map +1 -0
- package/src/plugins/mole/helpers.d.ts +1 -0
- package/src/plugins/mole/helpers.js +15 -0
- package/src/plugins/mole/helpers.js.map +1 -0
- package/src/plugins/mole/index.d.ts +6 -0
- package/src/plugins/mole/index.js +15 -0
- package/src/plugins/mole/index.js.map +1 -0
- package/src/plugins/mole/types.d.ts +68 -0
- package/src/plugins/mole/types.js +3 -0
- package/src/plugins/mole/types.js.map +1 -0
- package/src/plugins/sushiswap/helpers.js +24 -24
- package/src/plugins/uniswap-v2/helpers.js +22 -22
- package/src/utils/sei/constants.js +8 -8
- package/src/utils/sei/getQueryBalanceByOwner.js +4 -4
@@ -0,0 +1,132 @@
|
|
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 transactions_1 = require("@mysten/sui.js/transactions");
|
16
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
17
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
18
|
+
const constants_1 = require("./constants");
|
19
|
+
const clients_1 = require("../../utils/clients");
|
20
|
+
const helpers_1 = require("./helpers");
|
21
|
+
const tokenPriceToAssetTokens_1 = __importDefault(require("../../utils/misc/tokenPriceToAssetTokens"));
|
22
|
+
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
23
|
+
const client = (0, clients_1.getClientSui)();
|
24
|
+
const elements = [];
|
25
|
+
const [data, positions] = yield Promise.all([
|
26
|
+
cache.getItem(constants_1.dataKey, {
|
27
|
+
prefix: constants_1.vaultsPrefix,
|
28
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
29
|
+
}),
|
30
|
+
cache.getItem(constants_1.positionsKey, {
|
31
|
+
prefix: constants_1.vaultsPrefix,
|
32
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
33
|
+
}),
|
34
|
+
]);
|
35
|
+
if (!data || !data.farms || !data.vaults || !data.others || !positions)
|
36
|
+
return [];
|
37
|
+
const coinsTypes = data.vaults.map((v) => (0, portfolio_core_1.formatMoveTokenAddress)(v.baseToken));
|
38
|
+
const tokenPrices = yield cache.getTokenPricesAsMap(coinsTypes, portfolio_core_1.NetworkId.sui);
|
39
|
+
const myPositions = positions.filter((position) => position.owner === owner);
|
40
|
+
if (myPositions.length === 0)
|
41
|
+
return [];
|
42
|
+
const liquidities = [];
|
43
|
+
yield Promise.all(myPositions.map((position) => __awaiter(void 0, void 0, void 0, function* () {
|
44
|
+
const positionId = position.id;
|
45
|
+
const positionWorker = position.worker;
|
46
|
+
let farm;
|
47
|
+
let borrowingInterest;
|
48
|
+
data.farms.forEach((f) => {
|
49
|
+
f.borrowingInterests.forEach((b) => {
|
50
|
+
if (b.address === positionWorker) {
|
51
|
+
farm = f;
|
52
|
+
borrowingInterest = b;
|
53
|
+
}
|
54
|
+
});
|
55
|
+
});
|
56
|
+
if (!farm || !borrowingInterest) {
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
const packageObjectId = borrowingInterest.upgradeAddr;
|
60
|
+
const module = 'cetus_clmm_worker';
|
61
|
+
const func = borrowingInterest.isReverse
|
62
|
+
? 'position_info_reverse'
|
63
|
+
: 'position_info';
|
64
|
+
const tx = new transactions_1.TransactionBlock();
|
65
|
+
tx.moveCall({
|
66
|
+
target: `${packageObjectId}::${module}::${func}`,
|
67
|
+
arguments: [
|
68
|
+
tx.object(borrowingInterest.workerInfo),
|
69
|
+
tx.object(data.others.globalStorage),
|
70
|
+
tx.object(borrowingInterest.pool),
|
71
|
+
tx.pure(positionId),
|
72
|
+
],
|
73
|
+
typeArguments: [
|
74
|
+
borrowingInterest.isReverse
|
75
|
+
? farm.symbol1Address
|
76
|
+
: farm.symbol2Address, // baseCoinType
|
77
|
+
borrowingInterest.isReverse
|
78
|
+
? farm.symbol2Address
|
79
|
+
: farm.symbol1Address, // farmingCoinType
|
80
|
+
farm.lpAddress,
|
81
|
+
],
|
82
|
+
});
|
83
|
+
const dir = yield client.devInspectTransactionBlock({
|
84
|
+
sender: '0x7ca96e9760a722923f94e692faa26806b311565dbbfb707ed4f9fc1e336f2c73',
|
85
|
+
transactionBlock: tx,
|
86
|
+
});
|
87
|
+
if (!dir.results || !dir.results[0].returnValues)
|
88
|
+
return;
|
89
|
+
const health = new bignumber_js_1.default((0, helpers_1.serializeReturnValue)(dir.results[0].returnValues[0])).dividedBy(Math.pow(10, (borrowingInterest.isReverse
|
90
|
+
? farm.symbol1Decimals
|
91
|
+
: farm.symbol2Decimals)));
|
92
|
+
const debtValue = new bignumber_js_1.default((0, helpers_1.serializeReturnValue)(dir.results[0].returnValues[1])).dividedBy(Math.pow(10, (borrowingInterest.isReverse
|
93
|
+
? farm.symbol1Decimals
|
94
|
+
: farm.symbol2Decimals)));
|
95
|
+
const equityValue = health.minus(debtValue);
|
96
|
+
// const leverage = health.dividedBy(equityValue);
|
97
|
+
// const debtRatio = debtValue.dividedBy(health);
|
98
|
+
const assets = [];
|
99
|
+
assets.push(...(0, tokenPriceToAssetTokens_1.default)(farm.symbol1Address, borrowingInterest.isReverse ? equityValue.toNumber() : 0, portfolio_core_1.NetworkId.sui, tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(farm.symbol1Address))));
|
100
|
+
assets.push(...(0, tokenPriceToAssetTokens_1.default)(farm.symbol2Address, borrowingInterest.isReverse ? 0 : equityValue.toNumber(), portfolio_core_1.NetworkId.sui, tokenPrices.get((0, portfolio_core_1.formatMoveTokenAddress)(farm.symbol2Address))));
|
101
|
+
const assetsValue = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
|
102
|
+
const value = assetsValue;
|
103
|
+
liquidities.push({
|
104
|
+
value,
|
105
|
+
assets,
|
106
|
+
assetsValue,
|
107
|
+
rewardAssets: [],
|
108
|
+
rewardAssetsValue: null,
|
109
|
+
yields: [],
|
110
|
+
});
|
111
|
+
})));
|
112
|
+
if (liquidities.length === 0)
|
113
|
+
return [];
|
114
|
+
elements.push({
|
115
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
116
|
+
platformId: constants_1.platformId,
|
117
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
118
|
+
label: 'Leverage',
|
119
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
120
|
+
data: {
|
121
|
+
liquidities,
|
122
|
+
},
|
123
|
+
});
|
124
|
+
return elements;
|
125
|
+
});
|
126
|
+
const fetcher = {
|
127
|
+
id: `${constants_1.platformId}-farms`,
|
128
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
129
|
+
executor,
|
130
|
+
};
|
131
|
+
exports.default = fetcher;
|
132
|
+
//# sourceMappingURL=farmsFetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"farmsFetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mole/farmsFetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAA+D;AAC/D,+DASoC;AACpC,gEAAqC;AAGrC,2CAA8E;AAC9E,iDAAmD;AAEnD,uCAAiD;AACjD,uGAA+E;AAE/E,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,MAAM,GAAG,IAAA,sBAAY,GAAE,CAAC;IAE9B,MAAM,QAAQ,GAAuB,EAAE,CAAC;IAExC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,KAAK,CAAC,OAAO,CAAW,mBAAO,EAAE;YAC/B,MAAM,EAAE,wBAAY;YACpB,SAAS,EAAE,0BAAS,CAAC,GAAG;SACzB,CAAC;QACF,KAAK,CAAC,OAAO,CAA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,GAAG,EACb,WAAW,CAAC,GAAG,CAAC,IAAA,uCAAsB,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAC7D,CACF,CAAC;QAEF,MAAM,WAAW,GAAG,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAC/D,MAAM,KAAK,GAAG,WAAW,CAAC;QAE1B,WAAW,CAAC,IAAI,CAAC;YACf,KAAK;YACL,MAAM;YACN,WAAW;YACX,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,IAAI;YACvB,MAAM,EAAE,EAAE;SACX,CAAC,CAAC;IACL,CAAC,CAAA,CAAC,CACH,CAAC;IAEF,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,QAAQ,CAAC,IAAI,CAAC;QACZ,SAAS,EAAE,0BAAS,CAAC,GAAG;QACxB,UAAU,EAAV,sBAAU;QACV,IAAI,EAAE,qCAAoB,CAAC,SAAS;QACpC,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,EAAE;YACJ,WAAW;SACZ;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,MAAM,OAAO,GAAY;IACvB,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,SAAS,EAAE,0BAAS,CAAC,GAAG;IACxB,QAAQ;CACT,CAAC;AAEF,kBAAe,OAAO,CAAC"}
|
@@ -0,0 +1,52 @@
|
|
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
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
+
const constants_1 = require("./constants");
|
14
|
+
const clients_1 = require("../../utils/clients");
|
15
|
+
const multiGetObjects_1 = require("../../utils/sui/multiGetObjects");
|
16
|
+
const getDynamicFieldObjects_1 = require("../../utils/sui/getDynamicFieldObjects");
|
17
|
+
const executor = (cache) => __awaiter(void 0, void 0, void 0, function* () {
|
18
|
+
const data = yield cache.getItem(constants_1.dataKey, {
|
19
|
+
prefix: constants_1.vaultsPrefix,
|
20
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
21
|
+
});
|
22
|
+
if (!data || !data.farms || !data.vaults || !data.others)
|
23
|
+
return;
|
24
|
+
const client = (0, clients_1.getClientSui)();
|
25
|
+
const vaultInfos = yield (0, multiGetObjects_1.multiGetObjects)(client, data.vaults.map((v) => v.vaultInfo));
|
26
|
+
const positionObjectIds = [];
|
27
|
+
vaultInfos.forEach((vaultInfo) => {
|
28
|
+
var _a, _b, _c, _d;
|
29
|
+
if ((_b = (_a = vaultInfo.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.value.fields.positions.fields.id.id)
|
30
|
+
positionObjectIds.push((_d = (_c = vaultInfo.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.value.fields.positions.fields.id.id);
|
31
|
+
});
|
32
|
+
const positionsByVault = yield Promise.all(positionObjectIds.map((positionObjectId) => (0, getDynamicFieldObjects_1.getDynamicFieldObjects)(client, positionObjectId)));
|
33
|
+
const positions = positionsByVault.flat().map((position) => {
|
34
|
+
var _a, _b, _c, _d, _e, _f;
|
35
|
+
return ({
|
36
|
+
id: (_b = (_a = position.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.fields.name,
|
37
|
+
owner: (_d = (_c = position.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.value.fields.owner,
|
38
|
+
worker: (_f = (_e = position.data) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f.fields.value.fields.worker,
|
39
|
+
});
|
40
|
+
});
|
41
|
+
yield cache.setItem(constants_1.positionsKey, positions, {
|
42
|
+
prefix: constants_1.vaultsPrefix,
|
43
|
+
networkId: portfolio_core_1.NetworkId.sui,
|
44
|
+
});
|
45
|
+
});
|
46
|
+
const job = {
|
47
|
+
id: `${constants_1.platformId}-farms`,
|
48
|
+
executor,
|
49
|
+
label: 'realtime',
|
50
|
+
};
|
51
|
+
exports.default = job;
|
52
|
+
//# sourceMappingURL=farmsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"farmsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mole/farmsJob.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAAuD;AAGvD,2CAA8E;AAE9E,iDAAmD;AACnD,qEAAkE;AAClE,mFAAgF;AAEhF,MAAM,QAAQ,GAAgB,CAAO,KAAY,EAAE,EAAE;IACnD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAW,mBAAO,EAAE;QAClD,MAAM,EAAE,wBAAY;QACpB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;IAEH,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;QAAE,OAAO;IAEjE,MAAM,MAAM,GAAG,IA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,CAAC,CAAA;KAAA,CAAC,CAAC;IAEJ,MAAM,KAAK,CAAC,OAAO,CAAC,wBAAY,EAAE,SAAS,EAAE;QAC3C,MAAM,EAAE,wBAAY;QACpB,SAAS,EAAE,0BAAS,CAAC,GAAG;KACzB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAQ;IACf,EAAE,EAAE,GAAG,sBAAU,QAAQ;IACzB,QAAQ;IACR,KAAK,EAAE,UAAU;CAClB,CAAC;AACF,kBAAe,GAAG,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const serializeReturnValue: (e: any) => any;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.serializeReturnValue = void 0;
|
4
|
+
const bcs_1 = require("@mysten/bcs");
|
5
|
+
const bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7
|
+
const serializeReturnValue = (e) => {
|
8
|
+
let t = e[0];
|
9
|
+
if (t instanceof Array)
|
10
|
+
t = Uint8Array.from(t);
|
11
|
+
const n = bcs.de(e[1], t);
|
12
|
+
return e[1] === 'u64' ? BigInt(n) : n;
|
13
|
+
};
|
14
|
+
exports.serializeReturnValue = serializeReturnValue;
|
15
|
+
//# sourceMappingURL=helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mole/helpers.ts"],"names":[],"mappings":";;;AAAA,qCAAoD;AAEpD,MAAM,GAAG,GAAG,IAAI,SAAG,CAAC,IAAA,sBAAgB,GAAE,CAAC,CAAC;AAExC,8DAA8D;AACvD,MAAM,oBAAoB,GAAG,CAAC,CAAM,EAAE,EAAE;IAC7C,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAEb,IAAI,CAAC,YAAY,KAAK;QAAE,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE/C,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B"}
|
@@ -0,0 +1,15 @@
|
|
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 = exports.platforms = void 0;
|
7
|
+
const constants_1 = require("./constants");
|
8
|
+
const depositsFetcher_1 = __importDefault(require("./depositsFetcher"));
|
9
|
+
const farmsFetcher_1 = __importDefault(require("./farmsFetcher"));
|
10
|
+
const farmsJob_1 = __importDefault(require("./farmsJob"));
|
11
|
+
const dataJob_1 = __importDefault(require("./dataJob"));
|
12
|
+
exports.platforms = [constants_1.platform];
|
13
|
+
exports.jobs = [dataJob_1.default, farmsJob_1.default];
|
14
|
+
exports.fetchers = [depositsFetcher_1.default, farmsFetcher_1.default];
|
15
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mole/index.ts"],"names":[],"mappings":";;;;;;AAGA,2CAAuC;AACvC,wEAAgD;AAChD,kEAA0C;AAC1C,0DAAkC;AAClC,wDAAgC;AAEnB,QAAA,SAAS,GAAe,CAAC,oBAAQ,CAAC,CAAC;AACnC,QAAA,IAAI,GAAU,CAAC,iBAAO,EAAE,kBAAQ,CAAC,CAAC;AAClC,QAAA,QAAQ,GAAc,CAAC,yBAAe,EAAE,sBAAY,CAAC,CAAC"}
|
@@ -0,0 +1,68 @@
|
|
1
|
+
export type Vault = {
|
2
|
+
vaultInfo: string;
|
3
|
+
baseDecimals: number;
|
4
|
+
baseToken: string;
|
5
|
+
baseTokenPerIbToken: number;
|
6
|
+
};
|
7
|
+
export type UserInfo = {
|
8
|
+
value: {
|
9
|
+
fields: {
|
10
|
+
amount: number;
|
11
|
+
};
|
12
|
+
type: string;
|
13
|
+
};
|
14
|
+
};
|
15
|
+
export type MoleData = {
|
16
|
+
vaults: Vault[];
|
17
|
+
farms: Farm[];
|
18
|
+
others: {
|
19
|
+
globalStorage: string;
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export type Farm = {
|
23
|
+
symbol1Address: string;
|
24
|
+
symbol1Decimals: number;
|
25
|
+
symbol2Address: string;
|
26
|
+
symbol2Decimals: number;
|
27
|
+
lpAddress: string;
|
28
|
+
borrowingInterests: BorrowingInterest[];
|
29
|
+
};
|
30
|
+
export type BorrowingInterest = {
|
31
|
+
address: string;
|
32
|
+
isReverse: boolean;
|
33
|
+
upgradeAddr: string;
|
34
|
+
workerInfo: string;
|
35
|
+
pool: string;
|
36
|
+
};
|
37
|
+
export type VaultInfo = {
|
38
|
+
value: {
|
39
|
+
fields: {
|
40
|
+
positions: {
|
41
|
+
fields: {
|
42
|
+
id: {
|
43
|
+
id: string;
|
44
|
+
};
|
45
|
+
};
|
46
|
+
};
|
47
|
+
};
|
48
|
+
};
|
49
|
+
};
|
50
|
+
export type PositionInfo = {
|
51
|
+
id: {
|
52
|
+
id: string;
|
53
|
+
};
|
54
|
+
name: string;
|
55
|
+
value: {
|
56
|
+
fields: {
|
57
|
+
debt_share: string;
|
58
|
+
owner: string;
|
59
|
+
worker: string;
|
60
|
+
};
|
61
|
+
type: string;
|
62
|
+
};
|
63
|
+
};
|
64
|
+
export type PositionSummary = {
|
65
|
+
id: string;
|
66
|
+
owner: string;
|
67
|
+
worker: string;
|
68
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/mole/types.ts"],"names":[],"mappings":""}
|
@@ -54,30 +54,30 @@ function sushiV3PairToUniV2(pair) {
|
|
54
54
|
}
|
55
55
|
function getV3PairsAddresses(url, length = 300) {
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
57
|
-
const query = (0, graphql_request_1.gql) `
|
58
|
-
{
|
59
|
-
pools(
|
60
|
-
orderBy: totalValueLockedUSD
|
61
|
-
first: ${length}
|
62
|
-
orderDirection: desc
|
63
|
-
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
-
) {
|
65
|
-
id
|
66
|
-
token0Price
|
67
|
-
token1Price
|
68
|
-
liquidity
|
69
|
-
token0 {
|
70
|
-
id
|
71
|
-
totalSupply
|
72
|
-
decimals
|
73
|
-
}
|
74
|
-
token1 {
|
75
|
-
id
|
76
|
-
totalSupply
|
77
|
-
decimals
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
57
|
+
const query = (0, graphql_request_1.gql) `
|
58
|
+
{
|
59
|
+
pools(
|
60
|
+
orderBy: totalValueLockedUSD
|
61
|
+
first: ${length}
|
62
|
+
orderDirection: desc
|
63
|
+
where: { volumeUSD_not: "0", liquidity_not: "0" }
|
64
|
+
) {
|
65
|
+
id
|
66
|
+
token0Price
|
67
|
+
token1Price
|
68
|
+
liquidity
|
69
|
+
token0 {
|
70
|
+
id
|
71
|
+
totalSupply
|
72
|
+
decimals
|
73
|
+
}
|
74
|
+
token1 {
|
75
|
+
id
|
76
|
+
totalSupply
|
77
|
+
decimals
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
81
|
`;
|
82
82
|
const res = yield (0, graphql_request_1.default)(url, query);
|
83
83
|
const pools = res.pools;
|
@@ -40,28 +40,28 @@ function getPairKey(version) {
|
|
40
40
|
exports.getPairKey = getPairKey;
|
41
41
|
function getPairsV2FromTheGraph(url, length = 300) {
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
43
|
-
const query = (0, graphql_request_1.gql) `
|
44
|
-
{
|
45
|
-
pairs(
|
46
|
-
orderBy: reserveUSD
|
47
|
-
first: ${length}
|
48
|
-
orderDirection: desc
|
49
|
-
where: { trackedReserveETH_not: "0" }
|
50
|
-
) {
|
51
|
-
id
|
52
|
-
reserve0
|
53
|
-
reserve1
|
54
|
-
totalSupply
|
55
|
-
token0 {
|
56
|
-
id
|
57
|
-
decimals
|
58
|
-
}
|
59
|
-
token1 {
|
60
|
-
id
|
61
|
-
decimals
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
43
|
+
const query = (0, graphql_request_1.gql) `
|
44
|
+
{
|
45
|
+
pairs(
|
46
|
+
orderBy: reserveUSD
|
47
|
+
first: ${length}
|
48
|
+
orderDirection: desc
|
49
|
+
where: { trackedReserveETH_not: "0" }
|
50
|
+
) {
|
51
|
+
id
|
52
|
+
reserve0
|
53
|
+
reserve1
|
54
|
+
totalSupply
|
55
|
+
token0 {
|
56
|
+
id
|
57
|
+
decimals
|
58
|
+
}
|
59
|
+
token1 {
|
60
|
+
id
|
61
|
+
decimals
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
65
|
`;
|
66
66
|
const res = yield (0, graphql_request_1.default)(url, query);
|
67
67
|
const pairs = res.pairs;
|
@@ -1,16 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.poolQueryMsg = exports.minterQueryMsg = exports.tokenInfoQueryMsg = exports.infoQueryMsg = void 0;
|
4
|
-
exports.infoQueryMsg = JSON.parse(`{
|
5
|
-
"info": {}
|
4
|
+
exports.infoQueryMsg = JSON.parse(`{
|
5
|
+
"info": {}
|
6
6
|
}`);
|
7
|
-
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
-
"token_info": {}
|
7
|
+
exports.tokenInfoQueryMsg = JSON.parse(`{
|
8
|
+
"token_info": {}
|
9
9
|
}`);
|
10
|
-
exports.minterQueryMsg = JSON.parse(`{
|
11
|
-
"minter": {}
|
10
|
+
exports.minterQueryMsg = JSON.parse(`{
|
11
|
+
"minter": {}
|
12
12
|
}`);
|
13
|
-
exports.poolQueryMsg = JSON.parse(`{
|
14
|
-
"pool": {}
|
13
|
+
exports.poolQueryMsg = JSON.parse(`{
|
14
|
+
"pool": {}
|
15
15
|
}`);
|
16
16
|
//# sourceMappingURL=constants.js.map
|
@@ -1,10 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
function getQueryBalanceByOwner(owner) {
|
4
|
-
return JSON.parse(`{
|
5
|
-
"balance": {
|
6
|
-
"address": "${owner}"
|
7
|
-
}
|
4
|
+
return JSON.parse(`{
|
5
|
+
"balance": {
|
6
|
+
"address": "${owner}"
|
7
|
+
}
|
8
8
|
}`);
|
9
9
|
}
|
10
10
|
exports.default = getQueryBalanceByOwner;
|