@mento-protocol/mento-sdk 3.0.0-beta.8 → 3.0.0-beta.9
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/dist/core/abis/fpmm.d.ts +80 -0
- package/dist/core/abis/fpmm.d.ts.map +1 -1
- package/dist/core/abis/fpmm.js +8 -0
- package/dist/core/abis/fpmm.js.map +1 -1
- package/dist/core/abis/index.d.ts +1 -0
- package/dist/core/abis/index.d.ts.map +1 -1
- package/dist/core/abis/index.js +1 -0
- package/dist/core/abis/index.js.map +1 -1
- package/dist/core/abis/virtualPool.d.ts +30 -0
- package/dist/core/abis/virtualPool.d.ts.map +1 -1
- package/dist/core/abis/virtualPool.js +5 -1
- package/dist/core/abis/virtualPool.js.map +1 -1
- package/dist/core/constants/addresses.d.ts.map +1 -1
- package/dist/core/constants/addresses.js +3 -0
- package/dist/core/constants/addresses.js.map +1 -1
- package/dist/core/types/contractAddresses.d.ts +2 -0
- package/dist/core/types/contractAddresses.d.ts.map +1 -1
- package/dist/core/types/pool.d.ts +106 -0
- package/dist/core/types/pool.d.ts.map +1 -1
- package/dist/services/pools/PoolService.d.ts +21 -9
- package/dist/services/pools/PoolService.d.ts.map +1 -1
- package/dist/services/pools/PoolService.js +32 -106
- package/dist/services/pools/PoolService.js.map +1 -1
- package/dist/services/pools/poolDetails.d.ts +11 -0
- package/dist/services/pools/poolDetails.d.ts.map +1 -0
- package/dist/services/pools/poolDetails.js +136 -0
- package/dist/services/pools/poolDetails.js.map +1 -0
- package/dist/services/pools/poolDiscovery.d.ts +13 -0
- package/dist/services/pools/poolDiscovery.d.ts.map +1 -0
- package/dist/services/pools/poolDiscovery.js +115 -0
- package/dist/services/pools/poolDiscovery.js.map +1 -0
- package/package.json +1 -1
package/dist/core/abis/fpmm.d.ts
CHANGED
|
@@ -76,5 +76,85 @@ export declare const FPMM_ABI: readonly [{
|
|
|
76
76
|
}];
|
|
77
77
|
readonly name: "state";
|
|
78
78
|
}];
|
|
79
|
+
}, {
|
|
80
|
+
readonly name: "getReserves";
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
readonly inputs: readonly [];
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}, {
|
|
87
|
+
readonly type: "uint256";
|
|
88
|
+
}, {
|
|
89
|
+
readonly type: "uint256";
|
|
90
|
+
}];
|
|
91
|
+
}, {
|
|
92
|
+
readonly name: "getPrices";
|
|
93
|
+
readonly type: "function";
|
|
94
|
+
readonly stateMutability: "view";
|
|
95
|
+
readonly inputs: readonly [];
|
|
96
|
+
readonly outputs: readonly [{
|
|
97
|
+
readonly type: "uint256";
|
|
98
|
+
}, {
|
|
99
|
+
readonly type: "uint256";
|
|
100
|
+
}, {
|
|
101
|
+
readonly type: "uint256";
|
|
102
|
+
}, {
|
|
103
|
+
readonly type: "uint256";
|
|
104
|
+
}, {
|
|
105
|
+
readonly type: "uint256";
|
|
106
|
+
}, {
|
|
107
|
+
readonly type: "bool";
|
|
108
|
+
}];
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "decimals0";
|
|
111
|
+
readonly type: "function";
|
|
112
|
+
readonly stateMutability: "view";
|
|
113
|
+
readonly inputs: readonly [];
|
|
114
|
+
readonly outputs: readonly [{
|
|
115
|
+
readonly type: "uint256";
|
|
116
|
+
}];
|
|
117
|
+
}, {
|
|
118
|
+
readonly name: "decimals1";
|
|
119
|
+
readonly type: "function";
|
|
120
|
+
readonly stateMutability: "view";
|
|
121
|
+
readonly inputs: readonly [];
|
|
122
|
+
readonly outputs: readonly [{
|
|
123
|
+
readonly type: "uint256";
|
|
124
|
+
}];
|
|
125
|
+
}, {
|
|
126
|
+
readonly name: "rebalanceIncentive";
|
|
127
|
+
readonly type: "function";
|
|
128
|
+
readonly stateMutability: "view";
|
|
129
|
+
readonly inputs: readonly [];
|
|
130
|
+
readonly outputs: readonly [{
|
|
131
|
+
readonly type: "uint256";
|
|
132
|
+
}];
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "rebalanceThresholdAbove";
|
|
135
|
+
readonly type: "function";
|
|
136
|
+
readonly stateMutability: "view";
|
|
137
|
+
readonly inputs: readonly [];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly type: "uint256";
|
|
140
|
+
}];
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "rebalanceThresholdBelow";
|
|
143
|
+
readonly type: "function";
|
|
144
|
+
readonly stateMutability: "view";
|
|
145
|
+
readonly inputs: readonly [];
|
|
146
|
+
readonly outputs: readonly [{
|
|
147
|
+
readonly type: "uint256";
|
|
148
|
+
}];
|
|
149
|
+
}, {
|
|
150
|
+
readonly name: "liquidityStrategy";
|
|
151
|
+
readonly type: "function";
|
|
152
|
+
readonly stateMutability: "view";
|
|
153
|
+
readonly inputs: readonly [{
|
|
154
|
+
readonly type: "address";
|
|
155
|
+
}];
|
|
156
|
+
readonly outputs: readonly [{
|
|
157
|
+
readonly type: "bool";
|
|
158
|
+
}];
|
|
79
159
|
}];
|
|
80
160
|
//# sourceMappingURL=fpmm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fpmm.d.ts","sourceRoot":"","sources":["../../../src/core/abis/fpmm.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"fpmm.d.ts","sourceRoot":"","sources":["../../../src/core/abis/fpmm.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAenB,CAAA"}
|
package/dist/core/abis/fpmm.js
CHANGED
|
@@ -9,5 +9,13 @@ exports.FPMM_ABI = (0, viem_1.parseAbi)([
|
|
|
9
9
|
'function protocolFee() view returns (uint256)',
|
|
10
10
|
'function referenceRateFeedID() view returns (address)',
|
|
11
11
|
'function getTradingLimits(address token) view returns ((int120 limit0, int120 limit1, uint8 decimals) config, (uint32 lastUpdated0, uint32 lastUpdated1, int96 netflow0, int96 netflow1) state)',
|
|
12
|
+
'function getReserves() view returns (uint256, uint256, uint256)',
|
|
13
|
+
'function getPrices() view returns (uint256, uint256, uint256, uint256, uint256, bool)',
|
|
14
|
+
'function decimals0() view returns (uint256)',
|
|
15
|
+
'function decimals1() view returns (uint256)',
|
|
16
|
+
'function rebalanceIncentive() view returns (uint256)',
|
|
17
|
+
'function rebalanceThresholdAbove() view returns (uint256)',
|
|
18
|
+
'function rebalanceThresholdBelow() view returns (uint256)',
|
|
19
|
+
'function liquidityStrategy(address) view returns (bool)',
|
|
12
20
|
]);
|
|
13
21
|
//# sourceMappingURL=fpmm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fpmm.js","sourceRoot":"","sources":["../../../src/core/abis/fpmm.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAElB,QAAA,QAAQ,GAAG,IAAA,eAAQ,EAAC;IAC/B,0CAA0C;IAC1C,0CAA0C;IAC1C,yCAAyC;IACzC,+CAA+C;IAC/C,uDAAuD;IACvD,iMAAiM;
|
|
1
|
+
{"version":3,"file":"fpmm.js","sourceRoot":"","sources":["../../../src/core/abis/fpmm.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAElB,QAAA,QAAQ,GAAG,IAAA,eAAQ,EAAC;IAC/B,0CAA0C;IAC1C,0CAA0C;IAC1C,yCAAyC;IACzC,+CAA+C;IAC/C,uDAAuD;IACvD,iMAAiM;IACjM,iEAAiE;IACjE,uFAAuF;IACvF,6CAA6C;IAC7C,6CAA6C;IAC7C,sDAAsD;IACtD,2DAA2D;IAC3D,2DAA2D;IAC3D,yDAAyD;CAC1D,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/abis/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,sBAAsB,CAAA;AACpC,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/abis/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,QAAQ,CAAA;AACtB,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
|
package/dist/core/abis/index.js
CHANGED
|
@@ -22,6 +22,7 @@ __exportStar(require("./broker"), exports);
|
|
|
22
22
|
__exportStar(require("./fpmmFactory"), exports);
|
|
23
23
|
__exportStar(require("./fpmm"), exports);
|
|
24
24
|
__exportStar(require("./virtualPoolFactory"), exports);
|
|
25
|
+
__exportStar(require("./virtualPool"), exports);
|
|
25
26
|
__exportStar(require("./router"), exports);
|
|
26
27
|
__exportStar(require("./breakerbox"), exports);
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/abis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,4CAAyB;AACzB,kDAA+B;AAC/B,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,yCAAsB;AACtB,uDAAoC;AACpC,2CAAwB;AACxB,+CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/abis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,4CAAyB;AACzB,kDAA+B;AAC/B,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,yCAAsB;AACtB,uDAAoC;AACpC,gDAA6B;AAC7B,2CAAwB;AACxB,+CAA4B"}
|
|
@@ -6,5 +6,35 @@ export declare const VIRTUAL_POOL_ABI: readonly [{
|
|
|
6
6
|
readonly outputs: readonly [{
|
|
7
7
|
readonly type: "uint256";
|
|
8
8
|
}];
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "getReserves";
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
readonly stateMutability: "view";
|
|
13
|
+
readonly inputs: readonly [];
|
|
14
|
+
readonly outputs: readonly [{
|
|
15
|
+
readonly type: "uint256";
|
|
16
|
+
}, {
|
|
17
|
+
readonly type: "uint256";
|
|
18
|
+
}, {
|
|
19
|
+
readonly type: "uint256";
|
|
20
|
+
}];
|
|
21
|
+
}, {
|
|
22
|
+
readonly name: "metadata";
|
|
23
|
+
readonly type: "function";
|
|
24
|
+
readonly stateMutability: "view";
|
|
25
|
+
readonly inputs: readonly [];
|
|
26
|
+
readonly outputs: readonly [{
|
|
27
|
+
readonly type: "uint256";
|
|
28
|
+
}, {
|
|
29
|
+
readonly type: "uint256";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "uint256";
|
|
32
|
+
}, {
|
|
33
|
+
readonly type: "uint256";
|
|
34
|
+
}, {
|
|
35
|
+
readonly type: "address";
|
|
36
|
+
}, {
|
|
37
|
+
readonly type: "address";
|
|
38
|
+
}];
|
|
9
39
|
}];
|
|
10
40
|
//# sourceMappingURL=virtualPool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualPool.d.ts","sourceRoot":"","sources":["../../../src/core/abis/virtualPool.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"virtualPool.d.ts","sourceRoot":"","sources":["../../../src/core/abis/virtualPool.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI3B,CAAA"}
|
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VIRTUAL_POOL_ABI = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
|
-
exports.VIRTUAL_POOL_ABI = (0, viem_1.parseAbi)([
|
|
5
|
+
exports.VIRTUAL_POOL_ABI = (0, viem_1.parseAbi)([
|
|
6
|
+
'function protocolFee() view returns (uint256)',
|
|
7
|
+
'function getReserves() view returns (uint256, uint256, uint256)',
|
|
8
|
+
'function metadata() view returns (uint256, uint256, uint256, uint256, address, address)',
|
|
9
|
+
]);
|
|
6
10
|
//# sourceMappingURL=virtualPool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualPool.js","sourceRoot":"","sources":["../../../src/core/abis/virtualPool.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAElB,QAAA,gBAAgB,GAAG,IAAA,eAAQ,EAAC
|
|
1
|
+
{"version":3,"file":"virtualPool.js","sourceRoot":"","sources":["../../../src/core/abis/virtualPool.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAElB,QAAA,gBAAgB,GAAG,IAAA,eAAQ,EAAC;IACvC,+CAA+C;IAC/C,iEAAiE;IACjE,yFAAyF;CAC1F,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../../src/core/constants/addresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEhE,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../../src/core/constants/addresses.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAEhE,eAAO,MAAM,SAAS,EAAE,kBA6DvB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,iBAAiB,CAAA;AAEhD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,GAAG,MAAM,CAYrF"}
|
|
@@ -32,6 +32,9 @@ exports.addresses = {
|
|
|
32
32
|
FPMMFactory: '0x65A67cb93a3e035C32f131e911A0d6b46a5f3Bd0',
|
|
33
33
|
VirtualPoolFactory: '0x6CE2dFC48b2688075A804835757a734e3316E0a2',
|
|
34
34
|
Router: '0xc04201c72A401373905A71DE3cE868b8583d0545',
|
|
35
|
+
// TODO: replace with deployed addresses
|
|
36
|
+
ReserveLiquidityStrategy: '0x0000000000000000000000000000000000000001',
|
|
37
|
+
CDPLiquidityStrategy: '0x0000000000000000000000000000000000000002',
|
|
35
38
|
},
|
|
36
39
|
[chainId_1.ChainId.CELO_SEPOLIA]: {
|
|
37
40
|
// Oracles & Breakers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/core/constants/addresses.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"addresses.js","sourceRoot":"","sources":["../../../src/core/constants/addresses.ts"],"names":[],"mappings":";;;AA2EA,gDAYC;AAvFD,uCAAmC;AAGtB,QAAA,SAAS,GAAuB;IAC3C,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE;QACd,qBAAqB;QACrB,UAAU,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3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IAGvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wBAAwB,CAAC,EAAE,MAAM,CAAA;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;KAC9B,GAAG,IAAI,OAAO,GAAG,iBAAiB;CACpC,CAAA"}
|
|
@@ -36,4 +36,110 @@ export interface Pool {
|
|
|
36
36
|
*/
|
|
37
37
|
exchangeId?: string;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Pricing and oracle data for an FPMM pool
|
|
41
|
+
*/
|
|
42
|
+
export interface FPMMPricing {
|
|
43
|
+
/** Raw oracle price numerator from contract */
|
|
44
|
+
oraclePriceNum: bigint;
|
|
45
|
+
/** Raw oracle price denominator from contract */
|
|
46
|
+
oraclePriceDen: bigint;
|
|
47
|
+
/** Oracle price as a decimal number (num / den) */
|
|
48
|
+
oraclePrice: number;
|
|
49
|
+
/** Raw reserve/pool price numerator from contract */
|
|
50
|
+
reservePriceNum: bigint;
|
|
51
|
+
/** Raw reserve/pool price denominator from contract */
|
|
52
|
+
reservePriceDen: bigint;
|
|
53
|
+
/** Reserve/pool price as a decimal number (num / den) */
|
|
54
|
+
reservePrice: number;
|
|
55
|
+
/** Price difference in basis points (raw from contract) */
|
|
56
|
+
priceDifferenceBps: bigint;
|
|
57
|
+
/** Price difference as a percentage (bps / 100, e.g. 12 bps → 0.12%) */
|
|
58
|
+
priceDifferencePercent: number;
|
|
59
|
+
/** Whether the reserve/pool price is above the oracle price */
|
|
60
|
+
reservePriceAboveOraclePrice: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Fee configuration for an FPMM pool
|
|
64
|
+
*/
|
|
65
|
+
export interface FPMMFees {
|
|
66
|
+
/** LP fee in basis points (raw) */
|
|
67
|
+
lpFeeBps: bigint;
|
|
68
|
+
/** LP fee as a percentage (e.g. 0.25 = 0.25%) */
|
|
69
|
+
lpFeePercent: number;
|
|
70
|
+
/** Protocol fee in basis points (raw) */
|
|
71
|
+
protocolFeeBps: bigint;
|
|
72
|
+
/** Protocol fee as a percentage */
|
|
73
|
+
protocolFeePercent: number;
|
|
74
|
+
/** Total fee (lpFee + protocolFee) as a percentage */
|
|
75
|
+
totalFeePercent: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Rebalancing state and configuration for an FPMM pool
|
|
79
|
+
*/
|
|
80
|
+
export interface FPMMRebalancing {
|
|
81
|
+
/** Rebalance incentive in basis points (raw) */
|
|
82
|
+
rebalanceIncentiveBps: bigint;
|
|
83
|
+
/** Rebalance incentive as a percentage */
|
|
84
|
+
rebalanceIncentivePercent: number;
|
|
85
|
+
/** Threshold above oracle price in basis points (raw) */
|
|
86
|
+
rebalanceThresholdAboveBps: bigint;
|
|
87
|
+
/** Threshold above as a percentage */
|
|
88
|
+
rebalanceThresholdAbovePercent: number;
|
|
89
|
+
/** Threshold below oracle price in basis points (raw) */
|
|
90
|
+
rebalanceThresholdBelowBps: bigint;
|
|
91
|
+
/** Threshold below as a percentage */
|
|
92
|
+
rebalanceThresholdBelowPercent: number;
|
|
93
|
+
/** Whether the current price is within rebalancing thresholds */
|
|
94
|
+
inBand: boolean;
|
|
95
|
+
/** The active liquidity strategy address for this pool, or null if none */
|
|
96
|
+
liquidityStrategy: string | null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Enriched details for an FPMM pool including pricing, fees, and rebalancing state
|
|
100
|
+
*/
|
|
101
|
+
export interface FPMMPoolDetails extends Pool {
|
|
102
|
+
poolType: 'FPMM';
|
|
103
|
+
/** Scaling factor for token0 (10^tokenDecimals) */
|
|
104
|
+
decimals0: bigint;
|
|
105
|
+
/** Scaling factor for token1 (10^tokenDecimals) */
|
|
106
|
+
decimals1: bigint;
|
|
107
|
+
/** Reserve of token0 (raw) */
|
|
108
|
+
reserve0: bigint;
|
|
109
|
+
/** Reserve of token1 (raw) */
|
|
110
|
+
reserve1: bigint;
|
|
111
|
+
/** Block timestamp of last reserve update */
|
|
112
|
+
blockTimestampLast: bigint;
|
|
113
|
+
/** Pricing and oracle data */
|
|
114
|
+
pricing: FPMMPricing;
|
|
115
|
+
/** Fee configuration */
|
|
116
|
+
fees: FPMMFees;
|
|
117
|
+
/** Rebalancing state */
|
|
118
|
+
rebalancing: FPMMRebalancing;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Enriched details for a Virtual pool including reserves and spread
|
|
122
|
+
*/
|
|
123
|
+
export interface VirtualPoolDetails extends Pool {
|
|
124
|
+
poolType: 'Virtual';
|
|
125
|
+
/** Scaling factor for token0 (10^tokenDecimals) */
|
|
126
|
+
decimals0: bigint;
|
|
127
|
+
/** Scaling factor for token1 (10^tokenDecimals) */
|
|
128
|
+
decimals1: bigint;
|
|
129
|
+
/** Reserve (bucket) of token0 (raw) */
|
|
130
|
+
reserve0: bigint;
|
|
131
|
+
/** Reserve (bucket) of token1 (raw) */
|
|
132
|
+
reserve1: bigint;
|
|
133
|
+
/** Block timestamp of last reserve update */
|
|
134
|
+
blockTimestampLast: bigint;
|
|
135
|
+
/** Spread/fee in basis points (raw) */
|
|
136
|
+
spreadBps: bigint;
|
|
137
|
+
/** Spread as a percentage (e.g. 0.5 = 0.5%) */
|
|
138
|
+
spreadPercent: number;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Discriminated union of enriched pool details.
|
|
142
|
+
* Use `poolType` to narrow the type.
|
|
143
|
+
*/
|
|
144
|
+
export type PoolDetails = FPMMPoolDetails | VirtualPoolDetails;
|
|
39
145
|
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/core/types/pool.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB,gEAAgE;IAChE,IAAI,SAAS;IACb,gEAAgE;IAChE,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAA;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/core/types/pool.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,QAAQ;IAClB,gEAAgE;IAChE,IAAI,SAAS;IACb,gEAAgE;IAChE,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAA;IAEvB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAA;IACtB,iDAAiD;IACjD,cAAc,EAAE,MAAM,CAAA;IACtB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAA;IAEnB,qDAAqD;IACrD,eAAe,EAAE,MAAM,CAAA;IACvB,uDAAuD;IACvD,eAAe,EAAE,MAAM,CAAA;IACvB,yDAAy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EAAE,WAAW,CAAA;IACpB,wBAAwB;IACxB,IAAI,EAAE,QAAQ,CAAA;IACd,wBAAwB;IACxB,WAAW,EAAE,eAAe,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,IAAI;IAC9C,QAAQ,EAAE,SAAS,CAAA;IACnB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,6CAA6C;IAC7C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,+CAA+C;IAC/C,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,kBAAkB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pool } from '../../core/types';
|
|
1
|
+
import { Pool, PoolDetails } from '../../core/types';
|
|
2
2
|
import { PublicClient } from 'viem';
|
|
3
3
|
/**
|
|
4
4
|
* Service for discovering liquidity pools in the Mento protocol.
|
|
@@ -24,14 +24,26 @@ export declare class PoolService {
|
|
|
24
24
|
*/
|
|
25
25
|
getPools(): Promise<Pool[]>;
|
|
26
26
|
/**
|
|
27
|
-
* Fetches
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
27
|
+
* Fetches enriched on-chain details for a specific pool by address.
|
|
28
|
+
* Resolves the pool type from the discovery cache, then fetches
|
|
29
|
+
* pool-type-specific data (pricing, fees, rebalancing for FPMM; reserves and spread for Virtual).
|
|
30
|
+
*
|
|
31
|
+
* @param poolAddr - The deployed pool contract address
|
|
32
|
+
* @returns Enriched pool details (FPMMPoolDetails or VirtualPoolDetails)
|
|
33
|
+
* @throws {Error} If the pool address is not found in any known factory
|
|
34
|
+
* @throws {Error} If on-chain calls fail
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const details = await poolService.getPoolDetails('0x...')
|
|
39
|
+
* if (details.poolType === 'FPMM') {
|
|
40
|
+
* console.log(details.pricing.oraclePrice)
|
|
41
|
+
* console.log(details.rebalancing.inBand)
|
|
42
|
+
* } else {
|
|
43
|
+
* console.log(details.spreadPercent)
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
34
46
|
*/
|
|
35
|
-
|
|
47
|
+
getPoolDetails(poolAddr: string): Promise<PoolDetails>;
|
|
36
48
|
}
|
|
37
49
|
//# sourceMappingURL=PoolService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolService.d.ts","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PoolService.d.ts","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAInC;;;GAGG;AACH,qBAAa,WAAW;IAGV,OAAO,CAAC,YAAY;IAAgB,OAAO,CAAC,OAAO;IAF/D,OAAO,CAAC,UAAU,CAAsB;gBAEpB,YAAY,EAAE,YAAY,EAAU,OAAO,EAAE,MAAM;IAEvE;;;;;;;;;;;;OAYG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAgCjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAc7D"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PoolService = void 0;
|
|
4
|
-
const constants_1 = require("../../core/constants");
|
|
5
4
|
const types_1 = require("../../core/types");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
// TODO: Update to enrich pools with more data as needed. Use optional flag to include more data.
|
|
5
|
+
const poolDiscovery_1 = require("./poolDiscovery");
|
|
6
|
+
const poolDetails_1 = require("./poolDetails");
|
|
9
7
|
/**
|
|
10
8
|
* Service for discovering liquidity pools in the Mento protocol.
|
|
11
9
|
* Aggregates pools from multiple factory contracts (FPMM and VirtualPool).
|
|
@@ -38,12 +36,12 @@ class PoolService {
|
|
|
38
36
|
// the hardcoded factory addresses for the chain for v1.
|
|
39
37
|
const pools = [];
|
|
40
38
|
try {
|
|
41
|
-
const fpmmPools = await
|
|
39
|
+
const fpmmPools = await (0, poolDiscovery_1.fetchFPMMPools)(this.publicClient, this.chainId);
|
|
42
40
|
pools.push(...fpmmPools);
|
|
43
41
|
}
|
|
44
42
|
catch { }
|
|
45
43
|
try {
|
|
46
|
-
const virtualPools = await
|
|
44
|
+
const virtualPools = await (0, poolDiscovery_1.fetchVirtualPools)(this.publicClient, this.chainId);
|
|
47
45
|
pools.push(...virtualPools);
|
|
48
46
|
}
|
|
49
47
|
catch { }
|
|
@@ -56,109 +54,37 @@ class PoolService {
|
|
|
56
54
|
return pools;
|
|
57
55
|
}
|
|
58
56
|
/**
|
|
59
|
-
* Fetches
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.publicClient.readContract({
|
|
79
|
-
address: poolAddress,
|
|
80
|
-
abi: abis_1.FPMM_ABI,
|
|
81
|
-
functionName: 'token0',
|
|
82
|
-
}),
|
|
83
|
-
this.publicClient.readContract({
|
|
84
|
-
address: poolAddress,
|
|
85
|
-
abi: abis_1.FPMM_ABI,
|
|
86
|
-
functionName: 'token1',
|
|
87
|
-
}),
|
|
88
|
-
]);
|
|
89
|
-
return {
|
|
90
|
-
factoryAddr: fpmmFactoryAddress,
|
|
91
|
-
poolAddr: poolAddress,
|
|
92
|
-
token0: token0,
|
|
93
|
-
token1: token1,
|
|
94
|
-
poolType: types_1.PoolType.FPMM,
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
return await Promise.all(poolDataPromises);
|
|
98
|
-
}
|
|
99
|
-
catch (error) {
|
|
100
|
-
throw new Error(`Failed to fetch FPMM pools: ${error.message}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
|
|
105
|
-
* VirtualPoolFactory doesn't have an enumeration method,
|
|
106
|
-
* so we have to derive pools from BiPoolManager.
|
|
57
|
+
* Fetches enriched on-chain details for a specific pool by address.
|
|
58
|
+
* Resolves the pool type from the discovery cache, then fetches
|
|
59
|
+
* pool-type-specific data (pricing, fees, rebalancing for FPMM; reserves and spread for Virtual).
|
|
60
|
+
*
|
|
61
|
+
* @param poolAddr - The deployed pool contract address
|
|
62
|
+
* @returns Enriched pool details (FPMMPoolDetails or VirtualPoolDetails)
|
|
63
|
+
* @throws {Error} If the pool address is not found in any known factory
|
|
64
|
+
* @throws {Error} If on-chain calls fail
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const details = await poolService.getPoolDetails('0x...')
|
|
69
|
+
* if (details.poolType === 'FPMM') {
|
|
70
|
+
* console.log(details.pricing.oraclePrice)
|
|
71
|
+
* console.log(details.rebalancing.inBand)
|
|
72
|
+
* } else {
|
|
73
|
+
* console.log(details.spreadPercent)
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
107
76
|
*/
|
|
108
|
-
async
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
112
|
-
|
|
77
|
+
async getPoolDetails(poolAddr) {
|
|
78
|
+
const pools = await this.getPools();
|
|
79
|
+
const pool = pools.find((p) => p.poolAddr.toLowerCase() === poolAddr.toLowerCase());
|
|
80
|
+
if (!pool) {
|
|
81
|
+
throw new Error(`Pool not found: ${poolAddr}. ` + 'Ensure the address is a valid pool discovered by getPools().');
|
|
113
82
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// we can simplify this by using VirtualPoolFactory.getAllPools() returns(address[])
|
|
117
|
-
// Get all exchanges from BiPoolManager
|
|
118
|
-
const exchangesData = (await this.publicClient.readContract({
|
|
119
|
-
address: biPoolManagerAddress,
|
|
120
|
-
abi: abis_1.BIPOOL_MANAGER_ABI,
|
|
121
|
-
functionName: 'getExchanges',
|
|
122
|
-
}));
|
|
123
|
-
if (exchangesData.length === 0) {
|
|
124
|
-
return [];
|
|
125
|
-
}
|
|
126
|
-
// For each exchange, check if a virtual pool exists, and if so, return the pool address.
|
|
127
|
-
const poolPromises = exchangesData.map(async (exchange) => {
|
|
128
|
-
if (exchange.assets.length !== 2) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const [token0, token1] = (0, sortUtils_1.sortTokenAddresses)(exchange.assets[0], exchange.assets[1]);
|
|
132
|
-
const poolAddress = (await this.publicClient.readContract({
|
|
133
|
-
address: virtualPoolFactoryAddress,
|
|
134
|
-
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
135
|
-
functionName: 'getOrPrecomputeProxyAddress',
|
|
136
|
-
args: [token0, token1],
|
|
137
|
-
}));
|
|
138
|
-
const isDeployed = (await this.publicClient.readContract({
|
|
139
|
-
address: virtualPoolFactoryAddress,
|
|
140
|
-
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
141
|
-
functionName: 'isPool',
|
|
142
|
-
args: [poolAddress],
|
|
143
|
-
}));
|
|
144
|
-
if (!isDeployed) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
const pool = {
|
|
148
|
-
factoryAddr: virtualPoolFactoryAddress,
|
|
149
|
-
poolAddr: poolAddress,
|
|
150
|
-
token0: token0,
|
|
151
|
-
token1: token1,
|
|
152
|
-
poolType: types_1.PoolType.Virtual,
|
|
153
|
-
exchangeId: exchange.exchangeId,
|
|
154
|
-
};
|
|
155
|
-
return pool;
|
|
156
|
-
});
|
|
157
|
-
const results = await Promise.all(poolPromises);
|
|
158
|
-
return results.filter((pool) => pool !== null);
|
|
83
|
+
if (pool.poolType === types_1.PoolType.FPMM) {
|
|
84
|
+
return (0, poolDetails_1.fetchFPMMPoolDetails)(this.publicClient, this.chainId, pool);
|
|
159
85
|
}
|
|
160
|
-
|
|
161
|
-
|
|
86
|
+
else {
|
|
87
|
+
return (0, poolDetails_1.fetchVirtualPoolDetails)(this.publicClient, pool);
|
|
162
88
|
}
|
|
163
89
|
}
|
|
164
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolService.js","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"PoolService.js","sourceRoot":"","sources":["../../../src/services/pools/PoolService.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAE9D,mDAAmE;AACnE,+CAA6E;AAE7E;;;GAGG;AACH,MAAa,WAAW;IAGtB,YAAoB,YAA0B,EAAU,OAAe;QAAnD,iBAAY,GAAZ,YAAY,CAAc;QAAU,YAAO,GAAP,OAAO,CAAQ;QAF/D,eAAU,GAAkB,IAAI,CAAA;IAEkC,CAAC;IAE3E;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,UAAU,CAAA;QACxB,CAAC;QAED,6DAA6D;QAC7D,2DAA2D;QAC3D,8DAA8D;QAC9D,MAAM,KAAK,GAAW,EAAE,CAAA;QAExB,IAAI,CA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ACpE,CAAC;aAAM,CAAC;YACN,OAAO,IAAA,qCAAuB,EAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;QACzD,CAAC;IACH,CAAC;CACF;AArFD,kCAqFC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Pool, FPMMPoolDetails, VirtualPoolDetails } from '../../core/types';
|
|
2
|
+
import { PublicClient } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Fetches enriched details for an FPMM pool
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchFPMMPoolDetails(publicClient: PublicClient, chainId: number, pool: Pool): Promise<FPMMPoolDetails>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetches enriched details for a Virtual pool
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchVirtualPoolDetails(publicClient: PublicClient, pool: Pool): Promise<VirtualPoolDetails>;
|
|
11
|
+
//# sourceMappingURL=poolDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDetails.d.ts","sourceRoot":"","sources":["../../../src/services/pools/poolDetails.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAW,MAAM,MAAM,CAAA;AAE5C;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,eAAe,CAAC,CAyG1B;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA4BjH"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchFPMMPoolDetails = fetchFPMMPoolDetails;
|
|
4
|
+
exports.fetchVirtualPoolDetails = fetchVirtualPoolDetails;
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
|
+
const abis_1 = require("../../core/abis");
|
|
7
|
+
/**
|
|
8
|
+
* Fetches enriched details for an FPMM pool
|
|
9
|
+
*/
|
|
10
|
+
async function fetchFPMMPoolDetails(publicClient, chainId, pool) {
|
|
11
|
+
const address = pool.poolAddr;
|
|
12
|
+
try {
|
|
13
|
+
// Known liquidity strategy addresses for this chain
|
|
14
|
+
const knownStrategies = getKnownLiquidityStrategies(chainId);
|
|
15
|
+
const [reservesResult, pricesResult, decimals0, decimals1, lpFee, protocolFee, rebalanceIncentive, rebalanceThresholdAbove, rebalanceThresholdBelow, ...strategyResults] = await Promise.all([
|
|
16
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'getReserves' }),
|
|
17
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'getPrices' }),
|
|
18
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals0' }),
|
|
19
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'decimals1' }),
|
|
20
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'lpFee' }),
|
|
21
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'protocolFee' }),
|
|
22
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceIncentive' }),
|
|
23
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdAbove' }),
|
|
24
|
+
publicClient.readContract({ address, abi: abis_1.FPMM_ABI, functionName: 'rebalanceThresholdBelow' }),
|
|
25
|
+
...knownStrategies.map((strategyAddr) => publicClient.readContract({
|
|
26
|
+
address,
|
|
27
|
+
abi: abis_1.FPMM_ABI,
|
|
28
|
+
functionName: 'liquidityStrategy',
|
|
29
|
+
args: [strategyAddr],
|
|
30
|
+
})),
|
|
31
|
+
]);
|
|
32
|
+
const [reserve0, reserve1, blockTimestampLast] = reservesResult;
|
|
33
|
+
const [oraclePriceNum, oraclePriceDen, reservePriceNum, reservePriceDen, priceDifference, reservePriceAboveOraclePrice,] = pricesResult;
|
|
34
|
+
const lpFeeBps = lpFee;
|
|
35
|
+
const protocolFeeBps = protocolFee;
|
|
36
|
+
const rebalanceIncentiveBps = rebalanceIncentive;
|
|
37
|
+
const thresholdAboveBps = rebalanceThresholdAbove;
|
|
38
|
+
const thresholdBelowBps = rebalanceThresholdBelow;
|
|
39
|
+
// Find the active liquidity strategy (first match wins)
|
|
40
|
+
// Note: this could break at some point in the future if we decide to use
|
|
41
|
+
// more than one stragegy for a pool. For now it is not an issue,
|
|
42
|
+
// if we do forget to change this the impact is low as this function
|
|
43
|
+
// is just for informational purposes.
|
|
44
|
+
const activeIndex = strategyResults.findIndex((result) => result === true);
|
|
45
|
+
const liquidityStrategy = activeIndex >= 0 ? knownStrategies[activeIndex] : null;
|
|
46
|
+
const applicableThreshold = reservePriceAboveOraclePrice ? thresholdAboveBps : thresholdBelowBps;
|
|
47
|
+
const inBand = priceDifference < applicableThreshold;
|
|
48
|
+
return {
|
|
49
|
+
...pool,
|
|
50
|
+
poolType: 'FPMM',
|
|
51
|
+
decimals0: decimals0,
|
|
52
|
+
decimals1: decimals1,
|
|
53
|
+
reserve0,
|
|
54
|
+
reserve1,
|
|
55
|
+
blockTimestampLast,
|
|
56
|
+
pricing: {
|
|
57
|
+
oraclePriceNum,
|
|
58
|
+
oraclePriceDen,
|
|
59
|
+
oraclePrice: Number(oraclePriceNum) / Number(oraclePriceDen),
|
|
60
|
+
reservePriceNum,
|
|
61
|
+
reservePriceDen,
|
|
62
|
+
reservePrice: Number(reservePriceNum) / Number(reservePriceDen),
|
|
63
|
+
priceDifferenceBps: priceDifference,
|
|
64
|
+
priceDifferencePercent: Number(priceDifference) / 100,
|
|
65
|
+
reservePriceAboveOraclePrice,
|
|
66
|
+
},
|
|
67
|
+
fees: {
|
|
68
|
+
lpFeeBps,
|
|
69
|
+
lpFeePercent: Number(lpFeeBps) / 100,
|
|
70
|
+
protocolFeeBps,
|
|
71
|
+
protocolFeePercent: Number(protocolFeeBps) / 100,
|
|
72
|
+
totalFeePercent: (Number(lpFeeBps) + Number(protocolFeeBps)) / 100,
|
|
73
|
+
},
|
|
74
|
+
rebalancing: {
|
|
75
|
+
rebalanceIncentiveBps,
|
|
76
|
+
rebalanceIncentivePercent: Number(rebalanceIncentiveBps) / 100,
|
|
77
|
+
rebalanceThresholdAboveBps: thresholdAboveBps,
|
|
78
|
+
rebalanceThresholdAbovePercent: Number(thresholdAboveBps) / 100,
|
|
79
|
+
rebalanceThresholdBelowBps: thresholdBelowBps,
|
|
80
|
+
rebalanceThresholdBelowPercent: Number(thresholdBelowBps) / 100,
|
|
81
|
+
inBand,
|
|
82
|
+
liquidityStrategy,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new Error(`Failed to fetch FPMM pool details for ${pool.poolAddr}: ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Fetches enriched details for a Virtual pool
|
|
92
|
+
*/
|
|
93
|
+
async function fetchVirtualPoolDetails(publicClient, pool) {
|
|
94
|
+
const address = pool.poolAddr;
|
|
95
|
+
try {
|
|
96
|
+
const [reservesResult, protocolFee, metadataResult] = await Promise.all([
|
|
97
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'getReserves' }),
|
|
98
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'protocolFee' }),
|
|
99
|
+
publicClient.readContract({ address, abi: abis_1.VIRTUAL_POOL_ABI, functionName: 'metadata' }),
|
|
100
|
+
]);
|
|
101
|
+
const [reserve0, reserve1, blockTimestampLast] = reservesResult;
|
|
102
|
+
const [dec0, dec1] = metadataResult;
|
|
103
|
+
const spreadBps = protocolFee;
|
|
104
|
+
return {
|
|
105
|
+
...pool,
|
|
106
|
+
poolType: 'Virtual',
|
|
107
|
+
decimals0: dec0,
|
|
108
|
+
decimals1: dec1,
|
|
109
|
+
reserve0,
|
|
110
|
+
reserve1,
|
|
111
|
+
blockTimestampLast,
|
|
112
|
+
spreadBps,
|
|
113
|
+
spreadPercent: Number(spreadBps) / 100,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
throw new Error(`Failed to fetch Virtual pool details for ${pool.poolAddr}: ${error.message}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the known liquidity strategy addresses for the given chain.
|
|
122
|
+
*/
|
|
123
|
+
function getKnownLiquidityStrategies(chainId) {
|
|
124
|
+
const strategies = [];
|
|
125
|
+
const chainAddresses = constants_1.addresses[chainId];
|
|
126
|
+
if (!chainAddresses)
|
|
127
|
+
return strategies;
|
|
128
|
+
if (chainAddresses.ReserveLiquidityStrategy) {
|
|
129
|
+
strategies.push(chainAddresses.ReserveLiquidityStrategy);
|
|
130
|
+
}
|
|
131
|
+
if (chainAddresses.CDPLiquidityStrategy) {
|
|
132
|
+
strategies.push(chainAddresses.CDPLiquidityStrategy);
|
|
133
|
+
}
|
|
134
|
+
return strategies;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=poolDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDetails.js","sourceRoot":"","sources":["../../../src/services/pools/poolDetails.ts"],"names":[],"mappings":";;AAQA,oDA6GC;AAKD,0DA4BC;AAtJD,oDAAyD;AAEzD,0CAA4D;AAG5D;;GAEG;AACI,KAAK,UAAU,oBAAoB,CACxC,YAA0B,EAC1B,OAAe,EACf,IAAU;IAEV,MAAM,OAAO,GAAG,IAAI,CAAC,QAAmB,CAAA;IAExC,IAAI,CAAC;QACH,oDAAoD;QACpD,MAAM,eAAe,GAAG,2B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Ac,CAAC,oBAAoB,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Pool } from '../../core/types';
|
|
2
|
+
import { PublicClient } from 'viem';
|
|
3
|
+
/**
|
|
4
|
+
* Fetches all FPMM pools from the FPMM Factory
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchFPMMPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
|
|
9
|
+
* VirtualPoolFactory doesn't have an enumeration method,
|
|
10
|
+
* so we have to derive pools from BiPoolManager.
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchVirtualPools(publicClient: PublicClient, chainId: number): Promise<Pool[]>;
|
|
13
|
+
//# sourceMappingURL=poolDiscovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDiscovery.d.ts","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAY,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,YAAY,EAAW,MAAM,MAAM,CAAA;AAG5C;;GAEG;AACH,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CA8CjG;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAiEpG"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchFPMMPools = fetchFPMMPools;
|
|
4
|
+
exports.fetchVirtualPools = fetchVirtualPools;
|
|
5
|
+
const constants_1 = require("../../core/constants");
|
|
6
|
+
const types_1 = require("../../core/types");
|
|
7
|
+
const abis_1 = require("../../core/abis");
|
|
8
|
+
const sortUtils_1 = require("../../utils/sortUtils");
|
|
9
|
+
/**
|
|
10
|
+
* Fetches all FPMM pools from the FPMM Factory
|
|
11
|
+
*/
|
|
12
|
+
async function fetchFPMMPools(publicClient, chainId) {
|
|
13
|
+
const fpmmFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'FPMMFactory');
|
|
14
|
+
if (!fpmmFactoryAddress) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
// Get all deployed FPMM pool addresses
|
|
19
|
+
const poolAddresses = (await publicClient.readContract({
|
|
20
|
+
address: fpmmFactoryAddress,
|
|
21
|
+
abi: abis_1.FPMM_FACTORY_ABI,
|
|
22
|
+
functionName: 'deployedFPMMAddresses',
|
|
23
|
+
}));
|
|
24
|
+
if (poolAddresses.length === 0) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const poolDataPromises = poolAddresses.map(async (poolAddress) => {
|
|
28
|
+
const [token0, token1] = await Promise.all([
|
|
29
|
+
publicClient.readContract({
|
|
30
|
+
address: poolAddress,
|
|
31
|
+
abi: abis_1.FPMM_ABI,
|
|
32
|
+
functionName: 'token0',
|
|
33
|
+
}),
|
|
34
|
+
publicClient.readContract({
|
|
35
|
+
address: poolAddress,
|
|
36
|
+
abi: abis_1.FPMM_ABI,
|
|
37
|
+
functionName: 'token1',
|
|
38
|
+
}),
|
|
39
|
+
]);
|
|
40
|
+
return {
|
|
41
|
+
factoryAddr: fpmmFactoryAddress,
|
|
42
|
+
poolAddr: poolAddress,
|
|
43
|
+
token0: token0,
|
|
44
|
+
token1: token1,
|
|
45
|
+
poolType: types_1.PoolType.FPMM,
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
return await Promise.all(poolDataPromises);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to fetch FPMM pools: ${error.message}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Fetches all Virtual pools by discovering them from BiPoolManager exchanges.
|
|
56
|
+
* VirtualPoolFactory doesn't have an enumeration method,
|
|
57
|
+
* so we have to derive pools from BiPoolManager.
|
|
58
|
+
*/
|
|
59
|
+
async function fetchVirtualPools(publicClient, chainId) {
|
|
60
|
+
const virtualPoolFactoryAddress = (0, constants_1.getContractAddress)(chainId, 'VirtualPoolFactory');
|
|
61
|
+
const biPoolManagerAddress = (0, constants_1.getContractAddress)(chainId, 'BiPoolManager');
|
|
62
|
+
if (!virtualPoolFactoryAddress || !biPoolManagerAddress) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
// TODO: When the latest virtual pool factory contract is deployed
|
|
67
|
+
// we can simplify this by using VirtualPoolFactory.getAllPools() returns(address[])
|
|
68
|
+
// Get all exchanges from BiPoolManager
|
|
69
|
+
const exchangesData = (await publicClient.readContract({
|
|
70
|
+
address: biPoolManagerAddress,
|
|
71
|
+
abi: abis_1.BIPOOL_MANAGER_ABI,
|
|
72
|
+
functionName: 'getExchanges',
|
|
73
|
+
}));
|
|
74
|
+
if (exchangesData.length === 0) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
// For each exchange, check if a virtual pool exists, and if so, return the pool address.
|
|
78
|
+
const poolPromises = exchangesData.map(async (exchange) => {
|
|
79
|
+
if (exchange.assets.length !== 2) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const [token0, token1] = (0, sortUtils_1.sortTokenAddresses)(exchange.assets[0], exchange.assets[1]);
|
|
83
|
+
const poolAddress = (await publicClient.readContract({
|
|
84
|
+
address: virtualPoolFactoryAddress,
|
|
85
|
+
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
86
|
+
functionName: 'getOrPrecomputeProxyAddress',
|
|
87
|
+
args: [token0, token1],
|
|
88
|
+
}));
|
|
89
|
+
const isDeployed = (await publicClient.readContract({
|
|
90
|
+
address: virtualPoolFactoryAddress,
|
|
91
|
+
abi: abis_1.VIRTUAL_POOL_FACTORY_ABI,
|
|
92
|
+
functionName: 'isPool',
|
|
93
|
+
args: [poolAddress],
|
|
94
|
+
}));
|
|
95
|
+
if (!isDeployed) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const pool = {
|
|
99
|
+
factoryAddr: virtualPoolFactoryAddress,
|
|
100
|
+
poolAddr: poolAddress,
|
|
101
|
+
token0: token0,
|
|
102
|
+
token1: token1,
|
|
103
|
+
poolType: types_1.PoolType.Virtual,
|
|
104
|
+
exchangeId: exchange.exchangeId,
|
|
105
|
+
};
|
|
106
|
+
return pool;
|
|
107
|
+
});
|
|
108
|
+
const results = await Promise.all(poolPromises);
|
|
109
|
+
return results.filter((pool) => pool !== null);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw new Error(`Failed to fetch Virtual pools: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=poolDiscovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"poolDiscovery.js","sourceRoot":"","sources":["../../../src/services/pools/poolDiscovery.ts"],"names":[],"mappings":";;AASA,wCA8CC;AAOD,8CAiEC;AA/HD,oDAAkE;AAClE,4CAAiD;AACjD,0CAA0G;AAE1G,qDAA0D;AAE1D;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,YAA0B,EAAE,OAAe;IAC9E,MAAM,kBAAkB,GAAG,IAAA,8BAAkB,EAAC,OAAkB,EAAE,aAAa,CAAC,CAAA;IAEhF,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,CAAC;QACH,uCAAuC;QACvC,MAAM,aAAa,GAAG,CAAC,MAAM,YAAY,CAAC,YAAY,CAAC;YACrD,OAAO,EAAE,kBAA6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