@sonarwatch/portfolio-plugins 0.8.78 → 0.8.80
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 +10 -2
- package/package.json +2 -2
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/plugins/drift/deposits.js +1 -1
- package/src/plugins/drift/deposits.js.map +1 -1
- package/src/plugins/pancakeswap/abis.d.ts +184 -0
- package/src/plugins/pancakeswap/abis.js +159 -0
- package/src/plugins/pancakeswap/abis.js.map +1 -0
- package/src/plugins/pancakeswap/constants.d.ts +12 -0
- package/src/plugins/pancakeswap/constants.js +88 -1
- package/src/plugins/pancakeswap/constants.js.map +1 -1
- package/src/plugins/pancakeswap/getFarmsV2Fetcher.d.ts +3 -0
- package/src/plugins/pancakeswap/getFarmsV2Fetcher.js +119 -0
- package/src/plugins/pancakeswap/getFarmsV2Fetcher.js.map +1 -0
- package/src/plugins/pancakeswap/getStakersBalancesFetcher.d.ts +4 -0
- package/src/plugins/pancakeswap/getStakersBalancesFetcher.js +74 -0
- package/src/plugins/pancakeswap/getStakersBalancesFetcher.js.map +1 -0
- package/src/plugins/pancakeswap/index.js +63 -2
- package/src/plugins/pancakeswap/index.js.map +1 -1
- package/src/plugins/pancakeswap/stakerCakeFetcher.js +103 -0
- package/src/plugins/pancakeswap/stakerCakeFetcher.js.map +1 -0
- package/src/plugins/pancakeswap/types.d.ts +6 -0
- package/src/plugins/uniswap/constants.d.ts +2 -2
- package/src/plugins/uniswap/constants.js +5 -5
- package/src/plugins/uniswap/constants.js.map +1 -1
- package/src/plugins/uniswap/getPositionsV3Fetcher.d.ts +2 -2
- package/src/plugins/uniswap/getPositionsV3Fetcher.js +3 -3
- package/src/plugins/uniswap/getPositionsV3Fetcher.js.map +1 -1
- package/src/plugins/uniswap/index.js +1 -1
- package/src/plugins/uniswap/index.js.map +1 -1
- package/src/plugins/uniswap/types.d.ts +1 -1
- package/src/plugins/uniswap-v2/abis.d.ts +105 -0
- package/src/plugins/uniswap-v2/abis.js +79 -0
- package/src/plugins/uniswap-v2/abis.js.map +1 -0
- package/src/plugins/uniswap-v2/getPoolsJob.d.ts +3 -0
- package/src/plugins/uniswap-v2/getPoolsJob.js +199 -0
- package/src/plugins/uniswap-v2/getPoolsJob.js.map +1 -0
- package/src/plugins/uniswap-v2/getPositionsV2Fetcher.d.ts +3 -0
- package/src/plugins/uniswap-v2/getPositionsV2Fetcher.js +53 -0
- package/src/plugins/uniswap-v2/getPositionsV2Fetcher.js.map +1 -0
- package/src/plugins/uniswap-v2/helpers.d.ts +1 -1
- package/src/plugins/uniswap-v2/helpers.js +3 -3
- package/src/plugins/uniswap-v2/helpers.js.map +1 -1
- package/src/plugins/uniswap-v2/index.js +18 -4
- package/src/plugins/uniswap-v2/index.js.map +1 -1
- package/src/plugins/uniswap-v2/types.d.ts +4 -4
- package/src/utils/misc/upperCaseFirstLetter.d.ts +1 -0
- package/src/utils/misc/upperCaseFirstLetter.js +9 -0
- package/src/utils/misc/upperCaseFirstLetter.js.map +1 -0
- package/src/plugins/uniswap-v2/v2Fetcher.js +0 -57
- package/src/plugins/uniswap-v2/v2Fetcher.js.map +0 -1
- package/src/plugins/uniswap-v2/v2Job.d.ts +0 -3
- package/src/plugins/uniswap-v2/v2Job.js +0 -85
- package/src/plugins/uniswap-v2/v2Job.js.map +0 -1
- /package/src/plugins/{uniswap-v2/v2Fetcher.d.ts → pancakeswap/stakerCakeFetcher.d.ts} +0 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
export declare const abi: {
|
2
|
+
readonly allPairsLength: {
|
3
|
+
readonly constant: true;
|
4
|
+
readonly inputs: readonly [];
|
5
|
+
readonly name: "allPairsLength";
|
6
|
+
readonly outputs: readonly [{
|
7
|
+
readonly internalType: "uint256";
|
8
|
+
readonly name: "";
|
9
|
+
readonly type: "uint256";
|
10
|
+
}];
|
11
|
+
readonly payable: false;
|
12
|
+
readonly stateMutability: "view";
|
13
|
+
readonly type: "function";
|
14
|
+
};
|
15
|
+
readonly allPairs: {
|
16
|
+
readonly constant: true;
|
17
|
+
readonly inputs: readonly [{
|
18
|
+
readonly internalType: "uint256";
|
19
|
+
readonly name: "";
|
20
|
+
readonly type: "uint256";
|
21
|
+
}];
|
22
|
+
readonly name: "allPairs";
|
23
|
+
readonly outputs: readonly [{
|
24
|
+
readonly internalType: "address";
|
25
|
+
readonly name: "";
|
26
|
+
readonly type: "address";
|
27
|
+
}];
|
28
|
+
readonly payable: false;
|
29
|
+
readonly stateMutability: "view";
|
30
|
+
readonly type: "function";
|
31
|
+
};
|
32
|
+
readonly token0: {
|
33
|
+
readonly constant: true;
|
34
|
+
readonly inputs: readonly [];
|
35
|
+
readonly name: "token0";
|
36
|
+
readonly outputs: readonly [{
|
37
|
+
readonly internalType: "address";
|
38
|
+
readonly name: "";
|
39
|
+
readonly type: "address";
|
40
|
+
}];
|
41
|
+
readonly payable: false;
|
42
|
+
readonly stateMutability: "view";
|
43
|
+
readonly type: "function";
|
44
|
+
};
|
45
|
+
readonly token1: {
|
46
|
+
readonly constant: true;
|
47
|
+
readonly inputs: readonly [];
|
48
|
+
readonly name: "token1";
|
49
|
+
readonly outputs: readonly [{
|
50
|
+
readonly internalType: "address";
|
51
|
+
readonly name: "";
|
52
|
+
readonly type: "address";
|
53
|
+
}];
|
54
|
+
readonly payable: false;
|
55
|
+
readonly stateMutability: "view";
|
56
|
+
readonly type: "function";
|
57
|
+
};
|
58
|
+
readonly reserves: {
|
59
|
+
readonly constant: true;
|
60
|
+
readonly inputs: readonly [];
|
61
|
+
readonly name: "getReserves";
|
62
|
+
readonly outputs: readonly [{
|
63
|
+
readonly internalType: "uint112";
|
64
|
+
readonly name: "_reserve0";
|
65
|
+
readonly type: "uint112";
|
66
|
+
}, {
|
67
|
+
readonly internalType: "uint112";
|
68
|
+
readonly name: "_reserve1";
|
69
|
+
readonly type: "uint112";
|
70
|
+
}, {
|
71
|
+
readonly internalType: "uint32";
|
72
|
+
readonly name: "_blockTimestampLast";
|
73
|
+
readonly type: "uint32";
|
74
|
+
}];
|
75
|
+
readonly payable: false;
|
76
|
+
readonly stateMutability: "view";
|
77
|
+
readonly type: "function";
|
78
|
+
};
|
79
|
+
readonly totalSupply: {
|
80
|
+
readonly constant: true;
|
81
|
+
readonly inputs: readonly [];
|
82
|
+
readonly name: "totalSupply";
|
83
|
+
readonly outputs: readonly [{
|
84
|
+
readonly internalType: "uint256";
|
85
|
+
readonly name: "totalSupply";
|
86
|
+
readonly type: "uint256";
|
87
|
+
}];
|
88
|
+
readonly payable: false;
|
89
|
+
readonly stateMutability: "view";
|
90
|
+
readonly type: "function";
|
91
|
+
};
|
92
|
+
readonly decimals: {
|
93
|
+
readonly constant: true;
|
94
|
+
readonly inputs: readonly [];
|
95
|
+
readonly name: "decimals";
|
96
|
+
readonly outputs: readonly [{
|
97
|
+
readonly internalType: "uint8";
|
98
|
+
readonly name: "decimals";
|
99
|
+
readonly type: "uint8";
|
100
|
+
}];
|
101
|
+
readonly payable: false;
|
102
|
+
readonly stateMutability: "view";
|
103
|
+
readonly type: "function";
|
104
|
+
};
|
105
|
+
};
|
@@ -0,0 +1,79 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.abi = void 0;
|
4
|
+
exports.abi = {
|
5
|
+
allPairsLength: {
|
6
|
+
constant: true,
|
7
|
+
inputs: [],
|
8
|
+
name: 'allPairsLength',
|
9
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
10
|
+
payable: false,
|
11
|
+
stateMutability: 'view',
|
12
|
+
type: 'function',
|
13
|
+
},
|
14
|
+
allPairs: {
|
15
|
+
constant: true,
|
16
|
+
inputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
17
|
+
name: 'allPairs',
|
18
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
19
|
+
payable: false,
|
20
|
+
stateMutability: 'view',
|
21
|
+
type: 'function',
|
22
|
+
},
|
23
|
+
token0: {
|
24
|
+
constant: true,
|
25
|
+
inputs: [],
|
26
|
+
name: 'token0',
|
27
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
28
|
+
payable: false,
|
29
|
+
stateMutability: 'view',
|
30
|
+
type: 'function',
|
31
|
+
},
|
32
|
+
token1: {
|
33
|
+
constant: true,
|
34
|
+
inputs: [],
|
35
|
+
name: 'token1',
|
36
|
+
outputs: [{ internalType: 'address', name: '', type: 'address' }],
|
37
|
+
payable: false,
|
38
|
+
stateMutability: 'view',
|
39
|
+
type: 'function',
|
40
|
+
},
|
41
|
+
reserves: {
|
42
|
+
constant: true,
|
43
|
+
inputs: [],
|
44
|
+
name: 'getReserves',
|
45
|
+
outputs: [
|
46
|
+
{ internalType: 'uint112', name: '_reserve0', type: 'uint112' },
|
47
|
+
{ internalType: 'uint112', name: '_reserve1', type: 'uint112' },
|
48
|
+
{
|
49
|
+
internalType: 'uint32',
|
50
|
+
name: '_blockTimestampLast',
|
51
|
+
type: 'uint32',
|
52
|
+
},
|
53
|
+
],
|
54
|
+
payable: false,
|
55
|
+
stateMutability: 'view',
|
56
|
+
type: 'function',
|
57
|
+
},
|
58
|
+
totalSupply: {
|
59
|
+
constant: true,
|
60
|
+
inputs: [],
|
61
|
+
name: 'totalSupply',
|
62
|
+
outputs: [
|
63
|
+
{ internalType: 'uint256', name: 'totalSupply', type: 'uint256' },
|
64
|
+
],
|
65
|
+
payable: false,
|
66
|
+
stateMutability: 'view',
|
67
|
+
type: 'function',
|
68
|
+
},
|
69
|
+
decimals: {
|
70
|
+
constant: true,
|
71
|
+
inputs: [],
|
72
|
+
name: 'decimals',
|
73
|
+
outputs: [{ internalType: 'uint8', name: 'decimals', type: 'uint8' }],
|
74
|
+
payable: false,
|
75
|
+
stateMutability: 'view',
|
76
|
+
type: 'function',
|
77
|
+
},
|
78
|
+
};
|
79
|
+
//# sourceMappingURL=abis.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version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AK;QACd,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/D,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/D;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,qBAAqB;gBAC3B,IAAI,EAAE,QAAQ;aACf;SACF;QACD,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD,WAAW,EAAE;QACX,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;SAClE;QACD,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QACrE,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACO,CAAC"}
|
@@ -0,0 +1,199 @@
|
|
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 bignumber_js_1 = __importDefault(require("bignumber.js"));
|
17
|
+
const helpers_1 = require("./helpers");
|
18
|
+
const constants_1 = require("./constants");
|
19
|
+
const clients_1 = require("../../utils/clients");
|
20
|
+
const abis_1 = require("./abis");
|
21
|
+
const upperCaseFirstLetter_1 = __importDefault(require("../../utils/misc/upperCaseFirstLetter"));
|
22
|
+
const maxPairsToFetch = 100;
|
23
|
+
function getPoolsJob(contractOrTheGraphUrl, platformId, networkId, forcedPools) {
|
24
|
+
const client = (0, clients_1.getEvmClient)(networkId);
|
25
|
+
const elementName = `${(0, upperCaseFirstLetter_1.default)(platformId)} V2`;
|
26
|
+
return (cache) => __awaiter(this, void 0, void 0, function* () {
|
27
|
+
let pairs = [];
|
28
|
+
if (contractOrTheGraphUrl.startsWith('0x')) {
|
29
|
+
const contract = contractOrTheGraphUrl;
|
30
|
+
const allPairsLength = yield client.readContract({
|
31
|
+
abi: [abis_1.abi.allPairsLength],
|
32
|
+
address: contract,
|
33
|
+
functionName: abis_1.abi.allPairsLength.name,
|
34
|
+
});
|
35
|
+
const end = Math.min(maxPairsToFetch, Number(allPairsLength));
|
36
|
+
const allPairsContractBase = {
|
37
|
+
address: contract,
|
38
|
+
abi: [abis_1.abi.allPairs],
|
39
|
+
functionName: abis_1.abi.allPairs.name,
|
40
|
+
};
|
41
|
+
const allPairsContracts = [];
|
42
|
+
for (let pid = BigInt(0); pid < end; pid++) {
|
43
|
+
allPairsContracts.push(Object.assign(Object.assign({}, allPairsContractBase), { args: [pid] }));
|
44
|
+
}
|
45
|
+
const allPairsRes = yield client.multicall({
|
46
|
+
contracts: allPairsContracts,
|
47
|
+
});
|
48
|
+
const contracts = allPairsRes
|
49
|
+
.map((res) => (res.status === 'success' ? res.result : []))
|
50
|
+
.flat();
|
51
|
+
if (forcedPools)
|
52
|
+
contracts.push(...forcedPools);
|
53
|
+
pairs = yield getPairsDetails(contracts, networkId);
|
54
|
+
}
|
55
|
+
else if (contractOrTheGraphUrl.startsWith('https://api.thegraph.com/')) {
|
56
|
+
pairs = yield (0, helpers_1.getPairsV2FromTheGraph)(contractOrTheGraphUrl);
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
console.error('Wrong contract or TheGraph url :', contractOrTheGraphUrl);
|
60
|
+
return;
|
61
|
+
}
|
62
|
+
const tokenAddresses = [
|
63
|
+
...new Set(pairs.map((p) => [p.token0.id, p.token1.id]).flat()),
|
64
|
+
];
|
65
|
+
const tokenPrices = yield cache.getTokenPrices(tokenAddresses, networkId);
|
66
|
+
const tokenPricesByAddress = new Map();
|
67
|
+
tokenPrices.forEach((tp) => {
|
68
|
+
if (!tp)
|
69
|
+
return;
|
70
|
+
tokenPricesByAddress.set(tp.address, tp);
|
71
|
+
});
|
72
|
+
const pairAddresses = [];
|
73
|
+
for (let i = 0; i < pairs.length; i++) {
|
74
|
+
const pair = pairs[i];
|
75
|
+
const underlyingsTokens = [
|
76
|
+
[pair.token0.id, pair.reserve0],
|
77
|
+
[pair.token1.id, pair.reserve1],
|
78
|
+
];
|
79
|
+
const underlyings = [];
|
80
|
+
let tvl = new bignumber_js_1.default(0);
|
81
|
+
for (let j = 0; j < underlyingsTokens.length; j++) {
|
82
|
+
const [address, amount] = underlyingsTokens[j];
|
83
|
+
const fAddress = (0, portfolio_core_1.formatTokenAddress)(address, networkId);
|
84
|
+
const tokenPrice = tokenPricesByAddress.get(fAddress);
|
85
|
+
if (!tokenPrice)
|
86
|
+
break;
|
87
|
+
tvl = tvl.plus(new bignumber_js_1.default(amount).times(tokenPrice.price));
|
88
|
+
underlyings.push({
|
89
|
+
networkId,
|
90
|
+
address: fAddress,
|
91
|
+
decimals: tokenPrice.decimals,
|
92
|
+
price: tokenPrice.price,
|
93
|
+
amountPerLp: new bignumber_js_1.default(amount).div(pair.totalSupply).toNumber(),
|
94
|
+
});
|
95
|
+
}
|
96
|
+
if (underlyings.length !== underlyingsTokens.length)
|
97
|
+
continue;
|
98
|
+
const price = tvl.div(pair.totalSupply).toNumber();
|
99
|
+
const lpAddress = (0, portfolio_core_1.formatTokenAddress)(pair.id, networkId);
|
100
|
+
const source = {
|
101
|
+
id: platformId,
|
102
|
+
address: lpAddress,
|
103
|
+
decimals: 18,
|
104
|
+
networkId,
|
105
|
+
platformId,
|
106
|
+
price,
|
107
|
+
timestamp: Date.now(),
|
108
|
+
weight: 1,
|
109
|
+
elementName,
|
110
|
+
underlyings,
|
111
|
+
};
|
112
|
+
yield cache.setTokenPriceSource(source);
|
113
|
+
pairAddresses.push(lpAddress);
|
114
|
+
}
|
115
|
+
yield cache.setItem(constants_1.pairsV2Key, pairAddresses, {
|
116
|
+
prefix: platformId,
|
117
|
+
networkId,
|
118
|
+
});
|
119
|
+
});
|
120
|
+
}
|
121
|
+
exports.default = getPoolsJob;
|
122
|
+
function getPairsDetails(contracts, networkId) {
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
124
|
+
const client = (0, clients_1.getEvmClient)(networkId);
|
125
|
+
const contractToken0Base = {
|
126
|
+
abi: [abis_1.abi.token0],
|
127
|
+
functionName: abis_1.abi.token0.name,
|
128
|
+
};
|
129
|
+
const contractToken1Base = {
|
130
|
+
abi: [abis_1.abi.token1],
|
131
|
+
functionName: abis_1.abi.token1.name,
|
132
|
+
};
|
133
|
+
const contractReserveBase = {
|
134
|
+
abi: [abis_1.abi.reserves],
|
135
|
+
functionName: abis_1.abi.reserves.name,
|
136
|
+
};
|
137
|
+
const totalSupplyBase = {
|
138
|
+
abi: [abis_1.abi.totalSupply],
|
139
|
+
functionName: abis_1.abi.totalSupply.name,
|
140
|
+
};
|
141
|
+
const decimalsBase = {
|
142
|
+
abi: [abis_1.abi.decimals],
|
143
|
+
functionName: abis_1.abi.decimals.name,
|
144
|
+
};
|
145
|
+
const token0Contracts = [];
|
146
|
+
const token1Contracts = [];
|
147
|
+
const reservesContracts = [];
|
148
|
+
const totalSuppliesContracts = [];
|
149
|
+
const decimalsContracts = [];
|
150
|
+
for (const contract of contracts) {
|
151
|
+
token0Contracts.push(Object.assign(Object.assign({}, contractToken0Base), { address: contract }));
|
152
|
+
token1Contracts.push(Object.assign(Object.assign({}, contractToken1Base), { address: contract }));
|
153
|
+
reservesContracts.push(Object.assign(Object.assign({}, contractReserveBase), { address: contract }));
|
154
|
+
totalSuppliesContracts.push(Object.assign(Object.assign({}, totalSupplyBase), { address: contract }));
|
155
|
+
decimalsContracts.push(Object.assign(Object.assign({}, decimalsBase), { address: contract }));
|
156
|
+
}
|
157
|
+
const [token0Res, token1Res, reservesRes, totalSuppliesRes, decimalsRes] = yield Promise.all([
|
158
|
+
client.multicall({ contracts: token0Contracts }),
|
159
|
+
client.multicall({ contracts: token1Contracts }),
|
160
|
+
client.multicall({ contracts: reservesContracts }),
|
161
|
+
client.multicall({ contracts: totalSuppliesContracts }),
|
162
|
+
client.multicall({ contracts: decimalsContracts }),
|
163
|
+
]);
|
164
|
+
const pairs = [];
|
165
|
+
for (let i = 0; i < contracts.length; i++) {
|
166
|
+
const token0 = token0Res[i];
|
167
|
+
const token1 = token1Res[i];
|
168
|
+
const reserves = reservesRes[i];
|
169
|
+
const totalSupply = totalSuppliesRes[i];
|
170
|
+
const decimals = decimalsRes[i];
|
171
|
+
if (token0.status === 'success' &&
|
172
|
+
token1.status === 'success' &&
|
173
|
+
totalSupply.status === 'success' &&
|
174
|
+
decimals.status === 'success' &&
|
175
|
+
reserves.status === 'success') {
|
176
|
+
pairs.push({
|
177
|
+
id: contracts[i].toString(),
|
178
|
+
reserve0: new bignumber_js_1.default(reserves.result[0].toString())
|
179
|
+
.dividedBy(Math.pow(10, 18))
|
180
|
+
.toString(),
|
181
|
+
reserve1: new bignumber_js_1.default(reserves.result[1].toString())
|
182
|
+
.dividedBy(Math.pow(10, 18))
|
183
|
+
.toString(),
|
184
|
+
totalSupply: new bignumber_js_1.default(totalSupply.result.toString())
|
185
|
+
.dividedBy(Math.pow(10, decimals.result))
|
186
|
+
.toString(),
|
187
|
+
token0: {
|
188
|
+
id: token0.result,
|
189
|
+
},
|
190
|
+
token1: {
|
191
|
+
id: token1.result,
|
192
|
+
},
|
193
|
+
});
|
194
|
+
}
|
195
|
+
}
|
196
|
+
return pairs;
|
197
|
+
});
|
198
|
+
}
|
199
|
+
//# sourceMappingURL=getPoolsJob.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getPoolsJob.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/getPoolsJob.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+DAMoC;AACpC,gEAAqC;AAGrC,uCAAmD;AACnD,2CAAyC;AACzC,iDAAmD;AACnD,iCAA6B;AAE7B,iGAAyE;AAEzE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,SAAwB,WAAW,CACjC,qBAA6B,EAC7B,UAAkB,EAClB,SAA2B,EAC3B,WAA6B;IAE7B,MAAM,MAAM,GAAG,IAAA,sBAAY,EAAC,SAAS,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,GAAG,IAAA,8BAAoB,EAAC,UAAU,CAAC,KAAK,CAAC;IAE7D,OAAO,CAAO,KAAY,EAAE,EAAE;QAC5B,IAAI,KAAK,GAAsC,EAAE,CAAC;QAClD,IAAI,qBAAqB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC1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 +1,53 @@
|
|
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 getTokenAssets_1 = require("../../utils/evm/getTokenAssets");
|
15
|
+
function getPositionsV2Fetcher(platformId, networkId) {
|
16
|
+
return (owner, cache) => __awaiter(this, void 0, void 0, function* () {
|
17
|
+
const pairsV2 = yield cache.getItem(constants_1.pairsV2Key, {
|
18
|
+
networkId,
|
19
|
+
prefix: platformId,
|
20
|
+
});
|
21
|
+
if (!pairsV2)
|
22
|
+
return [];
|
23
|
+
const tokenAssets = yield (0, getTokenAssets_1.getTokenAssets)(owner, pairsV2, networkId, cache);
|
24
|
+
const liquidities = tokenAssets.map((assets) => {
|
25
|
+
const value = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
|
26
|
+
return {
|
27
|
+
assets,
|
28
|
+
assetsValue: value,
|
29
|
+
rewardAssets: [],
|
30
|
+
rewardAssetsValue: null,
|
31
|
+
value,
|
32
|
+
yields: [],
|
33
|
+
};
|
34
|
+
});
|
35
|
+
if (liquidities.length === 0)
|
36
|
+
return [];
|
37
|
+
return [
|
38
|
+
{
|
39
|
+
type: portfolio_core_1.PortfolioElementType.liquidity,
|
40
|
+
label: 'LiquidityPool',
|
41
|
+
networkId,
|
42
|
+
platformId,
|
43
|
+
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
44
|
+
name: 'V2',
|
45
|
+
data: {
|
46
|
+
liquidities,
|
47
|
+
},
|
48
|
+
},
|
49
|
+
];
|
50
|
+
});
|
51
|
+
}
|
52
|
+
exports.default = getPositionsV2Fetcher;
|
53
|
+
//# sourceMappingURL=getPositionsV2Fetcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"getPositionsV2Fetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/getPositionsV2Fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AAEpC,2CAAyC;AAEzC,mEAAgE;AAEhE,SAAwB,qBAAqB,CAC3C,UAAkB,EAClB,SAA2B;IAE3B,OAAO,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAW,sBAAU,EAAE;YACxD,SAAS;YACT,MAAM,EAAE,UAAU;SACnB,CAAC,CAAC;QACH,IAAI,CAAC,OAAO;YAAE,OAAO,EAAE,CAAC;QAExB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAc,EAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QAE3E,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAsB,EAAE;YACjE,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACzD,OAAO;gBACL,MAAM;gBACN,WAAW,EAAE,KAAK;gBAClB,YAAY,EAAE,EAAE;gBAChB,iBAAiB,EAAE,IAAI;gBACvB,KAAK;gBACL,MAAM,EAAE,EAAE;aACX,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACxC,OAAO;YACL;gBACE,IAAI,EAAE,qCAAoB,CAAC,SAAS;gBACpC,KAAK,EAAE,eAAe;gBACtB,SAAS;gBACT,UAAU;gBACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACtD,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE;oBACJ,WAAW;iBACZ;aACF;SACF,CAAC;IACJ,CAAC,CAAA,CAAC;AACJ,CAAC;AAxCD,wCAwCC"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { TheGraphUniV2Pair } from './types';
|
2
|
-
export declare function
|
2
|
+
export declare function getPairsV2FromTheGraph(url: string): Promise<TheGraphUniV2Pair[]>;
|
@@ -32,9 +32,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
32
32
|
});
|
33
33
|
};
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
35
|
-
exports.
|
35
|
+
exports.getPairsV2FromTheGraph = void 0;
|
36
36
|
const graphql_request_1 = __importStar(require("graphql-request"));
|
37
|
-
function
|
37
|
+
function getPairsV2FromTheGraph(url) {
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
39
39
|
const query = (0, graphql_request_1.gql) `
|
40
40
|
{
|
@@ -66,5 +66,5 @@ function getPairsV2(url) {
|
|
66
66
|
return pairs;
|
67
67
|
});
|
68
68
|
}
|
69
|
-
exports.
|
69
|
+
exports.getPairsV2FromTheGraph = getPairsV2FromTheGraph;
|
70
70
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA+C;AAI/C,SAAsB,
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA+C;AAI/C,SAAsB,sBAAsB,CAAC,GAAW;;QACtD,MAAM,KAAK,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;GAsBhB,CAAC;QACF,MAAM,GAAG,GAAG,MAAM,IAAA,yBAAO,EAAiC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtE,MAAM,KAAK,GAAG,GAAG,CAAC,KAA4B,CAAC;QAC/C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QACvC,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AA5BD,wDA4BC"}
|
@@ -4,8 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.fetchers = exports.jobs = void 0;
|
7
|
-
const
|
8
|
-
const
|
9
|
-
|
10
|
-
|
7
|
+
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
8
|
+
const constants_1 = require("./constants");
|
9
|
+
const getPoolsJob_1 = __importDefault(require("./getPoolsJob"));
|
10
|
+
const constants_2 = require("../uniswap/constants");
|
11
|
+
const getPositionsV2Fetcher_1 = __importDefault(require("./getPositionsV2Fetcher"));
|
12
|
+
exports.jobs = [
|
13
|
+
{
|
14
|
+
id: `${constants_2.platformId}-v2`,
|
15
|
+
executor: (0, getPoolsJob_1.default)(constants_1.theGraphUrl, constants_2.platformId, portfolio_core_1.NetworkId.ethereum),
|
16
|
+
},
|
17
|
+
];
|
18
|
+
exports.fetchers = [
|
19
|
+
{
|
20
|
+
id: `${constants_2.platformId}-v2`,
|
21
|
+
executor: (0, getPositionsV2Fetcher_1.default)(constants_2.platformId, portfolio_core_1.NetworkId.ethereum),
|
22
|
+
networkId: portfolio_core_1.NetworkId.ethereum,
|
23
|
+
},
|
24
|
+
];
|
11
25
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/index.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAAuD;AAGvD,2CAA0C;AAC1C,gEAAwC;AACxC,oDAAqE;AACrE,oFAA4D;AAE/C,QAAA,IAAI,GAAU;IACzB;QACE,EAAE,EAAE,GAAG,sBAAe,KAAK;QAC3B,QAAQ,EAAE,IAAA,qBAAW,EAAC,uBAAW,EAAE,sBAAe,EAAE,0BAAS,CAAC,QAAQ,CAAC;KACxE;CACF,CAAC;AACW,QAAA,QAAQ,GAAc;IACjC;QACE,EAAE,EAAE,GAAG,sBAAe,KAAK;QAC3B,QAAQ,EAAE,IAAA,+BAAqB,EAAC,sBAAe,EAAE,0BAAS,CAAC,QAAQ,CAAC;QACpE,SAAS,EAAE,0BAAS,CAAC,QAAQ;KAC9B;CACF,CAAC"}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
export type TheGraphUniV2Pair = {
|
2
|
-
id: string;
|
1
|
+
export type TheGraphUniV2Pair = UniV2Pair & {
|
3
2
|
reserveUSD: string;
|
4
3
|
volumeUSD: string;
|
5
4
|
trackedReserveETH: string;
|
6
5
|
reserveETH: string;
|
6
|
+
};
|
7
|
+
export type UniV2Pair = {
|
8
|
+
id: string;
|
7
9
|
reserve0: string;
|
8
10
|
reserve1: string;
|
9
11
|
totalSupply: string;
|
10
12
|
token0: {
|
11
13
|
id: string;
|
12
|
-
decimals: string;
|
13
14
|
};
|
14
15
|
token1: {
|
15
16
|
id: string;
|
16
|
-
decimals: string;
|
17
17
|
};
|
18
18
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export default function upperCaseFirstLetter(word: string): string;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
function upperCaseFirstLetter(word) {
|
4
|
+
if (word.length > 1)
|
5
|
+
return word.slice(0, 1).toUpperCase() + word.slice(1);
|
6
|
+
return word.toUpperCase();
|
7
|
+
}
|
8
|
+
exports.default = upperCaseFirstLetter;
|
9
|
+
//# sourceMappingURL=upperCaseFirstLetter.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"upperCaseFirstLetter.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/utils/misc/upperCaseFirstLetter.ts"],"names":[],"mappings":";;AAAA,SAAwB,oBAAoB,CAAC,IAAY;IACvD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAHD,uCAGC"}
|
@@ -1,57 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
-
const portfolio_core_1 = require("@sonarwatch/portfolio-core");
|
13
|
-
const constants_1 = require("./constants");
|
14
|
-
const constants_2 = require("../uniswap/constants");
|
15
|
-
const getTokenAssets_1 = require("../../utils/evm/getTokenAssets");
|
16
|
-
const executor = (owner, cache) => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
-
const pairsV2 = yield cache.getItem(constants_1.pairsV2Key, {
|
18
|
-
networkId: portfolio_core_1.NetworkId.ethereum,
|
19
|
-
prefix: constants_2.platformId,
|
20
|
-
});
|
21
|
-
if (!pairsV2)
|
22
|
-
return [];
|
23
|
-
const tokenAssets = yield (0, getTokenAssets_1.getTokenAssets)(owner, pairsV2, portfolio_core_1.NetworkId.ethereum, cache);
|
24
|
-
const liquidities = tokenAssets.map((assets) => {
|
25
|
-
const value = (0, portfolio_core_1.getUsdValueSum)(assets.map((a) => a.value));
|
26
|
-
return {
|
27
|
-
assets,
|
28
|
-
assetsValue: value,
|
29
|
-
rewardAssets: [],
|
30
|
-
rewardAssetsValue: null,
|
31
|
-
value,
|
32
|
-
yields: [],
|
33
|
-
};
|
34
|
-
});
|
35
|
-
if (liquidities.length === 0)
|
36
|
-
return [];
|
37
|
-
return [
|
38
|
-
{
|
39
|
-
type: portfolio_core_1.PortfolioElementType.liquidity,
|
40
|
-
label: 'LiquidityPool',
|
41
|
-
networkId: portfolio_core_1.NetworkId.ethereum,
|
42
|
-
platformId: constants_2.platformId,
|
43
|
-
value: (0, portfolio_core_1.getUsdValueSum)(liquidities.map((l) => l.value)),
|
44
|
-
name: 'Uniswap V2',
|
45
|
-
data: {
|
46
|
-
liquidities,
|
47
|
-
},
|
48
|
-
},
|
49
|
-
];
|
50
|
-
});
|
51
|
-
const fetcher = {
|
52
|
-
id: `${constants_2.platformId}-v2`,
|
53
|
-
networkId: portfolio_core_1.NetworkId.ethereum,
|
54
|
-
executor,
|
55
|
-
};
|
56
|
-
exports.default = fetcher;
|
57
|
-
//# sourceMappingURL=v2Fetcher.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"v2Fetcher.js","sourceRoot":"","sources":["../../../../../../packages/plugins/src/plugins/uniswap-v2/v2Fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,+DAKoC;AAEpC,2CAAyC;AAEzC,oDAAkD;AAClD,mEAAgE;AAEhE,MAAM,QAAQ,GAAoB,CAAO,KAAa,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,OAAO,CAAW,sBAAU,EAAE;QACxD,SAAS,EAAE,0BAAS,CAAC,QAAQ;QAC7B,MAAM,EAAE,sBAAU;KACnB,CAAC,CAAC;IACH,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAc,EACtC,KAAK,EACL,OAAO,EACP,0BAAS,CAAC,QAAQ,EAClB,KAAK,CACN,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAsB,EAAE;QACjE,MAAM,KAAK,GAAG,IAAA,+BAAc,EAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACzD,OAAO;YACL,MAAM;YACN,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,EAAE;YAChB,iBAAiB,EAAE,IAAI;YACvB,KAAK;YACL,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,OAAO;QACL;YACE,IAAI,EAAE,qCAAoB,CAAC,SAAS;YACpC,KAAK,EAAE,eAAe;YACtB,SAAS,EAAE,0BAAS,CAAC,QAAQ;YAC7B,UAAU,EAAV,sBAAU;YACV,KAAK,EAAE,IAAA,+BAAc,EAAC,WAAW,CAAC,GAAG,CAAC,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