@andrewkimjoseph/celina-sdk 0.27.6 → 0.28.0
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/README.md +2 -2
- package/build/a2a/skills.js +1 -1
- package/build/a2a/skills.js.map +1 -1
- package/build/abis/uniswap-v3.d.ts +171 -0
- package/build/abis/uniswap-v3.js +120 -0
- package/build/abis/uniswap-v3.js.map +1 -0
- package/build/config/uniswap.d.ts +15 -0
- package/build/config/uniswap.js +9 -1
- package/build/config/uniswap.js.map +1 -1
- package/build/index.d.ts +3 -3
- package/build/services/swap-pairs.d.ts +18 -4
- package/build/services/swap-pairs.js +35 -2
- package/build/services/swap-pairs.js.map +1 -1
- package/build/services/uniswap-path-router.d.ts +11 -1
- package/build/services/uniswap-path-router.js +36 -10
- package/build/services/uniswap-path-router.js.map +1 -1
- package/build/services/uniswap-v3-path-router.d.ts +40 -0
- package/build/services/uniswap-v3-path-router.js +183 -0
- package/build/services/uniswap-v3-path-router.js.map +1 -0
- package/build/services/uniswap-v3-pool-discovery.d.ts +33 -0
- package/build/services/uniswap-v3-pool-discovery.js +141 -0
- package/build/services/uniswap-v3-pool-discovery.js.map +1 -0
- package/build/services/uniswap-venue-quote.d.ts +28 -0
- package/build/services/uniswap-venue-quote.js +114 -0
- package/build/services/uniswap-venue-quote.js.map +1 -0
- package/build/services/uniswap.service.d.ts +24 -9
- package/build/services/uniswap.service.js +86 -37
- package/build/services/uniswap.service.js.map +1 -1
- package/build/src/a2a/skills.js +1 -1
- package/build/src/a2a/skills.js.map +1 -1
- package/build/src/abis/uniswap-v3.d.ts +171 -0
- package/build/src/abis/uniswap-v3.js +120 -0
- package/build/src/abis/uniswap-v3.js.map +1 -0
- package/build/src/config/uniswap.d.ts +15 -0
- package/build/src/config/uniswap.js +9 -1
- package/build/src/config/uniswap.js.map +1 -1
- package/build/src/index.d.ts +3 -3
- package/build/src/services/swap-pairs.d.ts +18 -4
- package/build/src/services/swap-pairs.js +35 -2
- package/build/src/services/swap-pairs.js.map +1 -1
- package/build/src/services/uniswap-path-router.d.ts +11 -1
- package/build/src/services/uniswap-path-router.js +36 -10
- package/build/src/services/uniswap-path-router.js.map +1 -1
- package/build/src/services/uniswap-v3-path-router.d.ts +40 -0
- package/build/src/services/uniswap-v3-path-router.js +183 -0
- package/build/src/services/uniswap-v3-path-router.js.map +1 -0
- package/build/src/services/uniswap-v3-pool-discovery.d.ts +33 -0
- package/build/src/services/uniswap-v3-pool-discovery.js +141 -0
- package/build/src/services/uniswap-v3-pool-discovery.js.map +1 -0
- package/build/src/services/uniswap-venue-quote.d.ts +28 -0
- package/build/src/services/uniswap-venue-quote.js +114 -0
- package/build/src/services/uniswap-venue-quote.js.map +1 -0
- package/build/src/services/uniswap.service.d.ts +24 -9
- package/build/src/services/uniswap.service.js +86 -37
- package/build/src/services/uniswap.service.js.map +1 -1
- package/build/src/tools/domains/browser.js +5 -3
- package/build/src/tools/domains/browser.js.map +1 -1
- package/build/src/tools/domains/uniswap.js +5 -5
- package/build/src/tools/domains/uniswap.js.map +1 -1
- package/build/src/tools/swap-routing.d.ts +2 -2
- package/build/src/tools/swap-routing.js +21 -6
- package/build/src/tools/swap-routing.js.map +1 -1
- package/build/tests/catalog/domains/defi.js +8 -1
- package/build/tests/catalog/domains/defi.js.map +1 -1
- package/build/tools/domains/browser.js +5 -3
- package/build/tools/domains/browser.js.map +1 -1
- package/build/tools/domains/uniswap.js +5 -5
- package/build/tools/domains/uniswap.js.map +1 -1
- package/build/tools/swap-routing.d.ts +2 -2
- package/build/tools/swap-routing.js +21 -6
- package/build/tools/swap-routing.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -138,7 +138,7 @@ Identity whitelist reads, daily UBI entitlement, unsigned UBI claim, and **G$
|
|
|
138
138
|
|-------|---------|
|
|
139
139
|
| `getWhitelistingInfo`, `getUbiClaimEligibility`, `getReserveQuote` | `prepareClaimUbi`, `prepareReserveSwap` |
|
|
140
140
|
|
|
141
|
-
For **G$ ↔ USDm**, use `getReserveQuote` / `prepareReserveSwap` (or aggregated `getSwapQuoteWithFallback` from `@andrewkimjoseph/celina-sdk/tools`) — not Uniswap. For other G$ pairs (e.g. G$ → USDT), Uniswap v4
|
|
141
|
+
For **G$ ↔ USDm**, use `getReserveQuote` / `prepareReserveSwap` (or aggregated `getSwapQuoteWithFallback` from `@andrewkimjoseph/celina-sdk/tools`) — not Uniswap. For other G$ pairs (e.g. G$ → USDT), Uniswap v3 and v4 remain the AMM fallback. The quote keeps the higher output.
|
|
142
142
|
|
|
143
143
|
MCP: `get_gooddollar_whitelisting_info`, `get_gooddollar_ubi_entitlement`, `get_gooddollar_reserve_quote`, `estimate_gooddollar_reserve_swap`, `execute_gooddollar_reserve_swap` (stdio write with server key); `claim_daily_gooddollar_ubi` (stdio UBI write). Browser apps: `prepareClaimUbi`, `prepareReserveSwap`, or `prepare_swap` + wagmi.
|
|
144
144
|
|
|
@@ -153,7 +153,7 @@ MCP: `get_gooddollar_whitelisting_info`, `get_gooddollar_ubi_entitlement`, `get_
|
|
|
153
153
|
## Roadmap
|
|
154
154
|
|
|
155
155
|
- [x] Mento FX routing (`getFxQuote`, `estimateFx`, `prepareFx`)
|
|
156
|
-
- [x] Uniswap v4 swaps (`getSwapQuote`, `estimateSwap`, `prepareSwap`)
|
|
156
|
+
- [x] Uniswap v3 and v4 swaps (`getSwapQuote`, `estimateSwap`, `prepareSwap`)
|
|
157
157
|
- [x] GoodDollar reserve swaps (`getReserveQuote`, `prepareReserveSwap`) — G$ ↔ USDm via MentoBroker
|
|
158
158
|
- [x] Aave tools (`getBalances` / MCP `get_aave_balances`, `prepareSupply`, `prepareWithdraw`) — USDT, WETH, USDm, USDC, CELO, EURm
|
|
159
159
|
- [x] Self proof verification (`verifySelfAgent`, `verifySelfRequest`, ai.self.xyz)
|
package/build/a2a/skills.js
CHANGED
package/build/a2a/skills.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/a2a/skills.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,kCAAkC,CAAC;AAQnE,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAoD;IACpF,UAAU,EAAE;QACV,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC;KACxC;IACD,OAAO,EAAE;QACP,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC;KACtC;IACD,KAAK,EAAE;QACL,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC;KACpC;IACD,WAAW,EAAE;QACX,EAAE,EAAE,kBAAkB;QACtB,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;KAC9B;IACD,UAAU,EAAE;QACV,EAAE,EAAE,UAAU;QACd,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC;KACtC;IACD,OAAO,EAAE;QACP,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/a2a/skills.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,kCAAkC,CAAC;AAQnE,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAoD;IACpF,UAAU,EAAE;QACV,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC;KACxC;IACD,OAAO,EAAE;QACP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C;YACb,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9B,SAAS;QACX,CAAC;QACD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE;YACrB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,4BAA4B,QAAQ,GAAG;YAChE,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;YACpB,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,QAAQ,EAAE;gBACR,oBAAoB,gBAAgB,mBAAmB,QAAQ,uBAAuB;aACvF;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,WAAW,GAAG,GAAG,KAAK,CAAC,IAAI,oCAAoC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACjG,CAAC;IAED,OAAO,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/** Uniswap v3 factory, QuoterV2, and SwapRouter02 on Celo mainnet. */
|
|
2
|
+
export declare const uniswapV3FactoryAbi: readonly [{
|
|
3
|
+
readonly name: "getPool";
|
|
4
|
+
readonly type: "function";
|
|
5
|
+
readonly stateMutability: "view";
|
|
6
|
+
readonly inputs: readonly [{
|
|
7
|
+
readonly name: "tokenA";
|
|
8
|
+
readonly type: "address";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "tokenB";
|
|
11
|
+
readonly type: "address";
|
|
12
|
+
}, {
|
|
13
|
+
readonly name: "fee";
|
|
14
|
+
readonly type: "uint24";
|
|
15
|
+
}];
|
|
16
|
+
readonly outputs: readonly [{
|
|
17
|
+
readonly name: "pool";
|
|
18
|
+
readonly type: "address";
|
|
19
|
+
}];
|
|
20
|
+
}];
|
|
21
|
+
export declare const uniswapV3PoolAbi: readonly [{
|
|
22
|
+
readonly name: "liquidity";
|
|
23
|
+
readonly type: "function";
|
|
24
|
+
readonly stateMutability: "view";
|
|
25
|
+
readonly inputs: readonly [];
|
|
26
|
+
readonly outputs: readonly [{
|
|
27
|
+
readonly name: "liquidity";
|
|
28
|
+
readonly type: "uint128";
|
|
29
|
+
}];
|
|
30
|
+
}];
|
|
31
|
+
export declare const v3QuoterAbi: readonly [{
|
|
32
|
+
readonly name: "quoteExactInputSingle";
|
|
33
|
+
readonly type: "function";
|
|
34
|
+
readonly stateMutability: "nonpayable";
|
|
35
|
+
readonly inputs: readonly [{
|
|
36
|
+
readonly name: "params";
|
|
37
|
+
readonly type: "tuple";
|
|
38
|
+
readonly components: readonly [{
|
|
39
|
+
readonly name: "tokenIn";
|
|
40
|
+
readonly type: "address";
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "tokenOut";
|
|
43
|
+
readonly type: "address";
|
|
44
|
+
}, {
|
|
45
|
+
readonly name: "amountIn";
|
|
46
|
+
readonly type: "uint256";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "fee";
|
|
49
|
+
readonly type: "uint24";
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: "sqrtPriceLimitX96";
|
|
52
|
+
readonly type: "uint160";
|
|
53
|
+
}];
|
|
54
|
+
}];
|
|
55
|
+
readonly outputs: readonly [{
|
|
56
|
+
readonly name: "amountOut";
|
|
57
|
+
readonly type: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "sqrtPriceX96After";
|
|
60
|
+
readonly type: "uint160";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "initializedTicksCrossed";
|
|
63
|
+
readonly type: "uint32";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "gasEstimate";
|
|
66
|
+
readonly type: "uint256";
|
|
67
|
+
}];
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: "quoteExactInput";
|
|
70
|
+
readonly type: "function";
|
|
71
|
+
readonly stateMutability: "nonpayable";
|
|
72
|
+
readonly inputs: readonly [{
|
|
73
|
+
readonly name: "path";
|
|
74
|
+
readonly type: "bytes";
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "amountIn";
|
|
77
|
+
readonly type: "uint256";
|
|
78
|
+
}];
|
|
79
|
+
readonly outputs: readonly [{
|
|
80
|
+
readonly name: "amountOut";
|
|
81
|
+
readonly type: "uint256";
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "sqrtPriceX96AfterList";
|
|
84
|
+
readonly type: "uint160[]";
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "initializedTicksCrossedList";
|
|
87
|
+
readonly type: "uint32[]";
|
|
88
|
+
}, {
|
|
89
|
+
readonly name: "gasEstimate";
|
|
90
|
+
readonly type: "uint256";
|
|
91
|
+
}];
|
|
92
|
+
}];
|
|
93
|
+
/**
|
|
94
|
+
* SwapRouter02 execution surface used by Celina.
|
|
95
|
+
* `exactInputSingle` / `exactInput` have no deadline; `multicall(uint256,bytes[])` applies one.
|
|
96
|
+
*/
|
|
97
|
+
export declare const swapRouter02Abi: readonly [{
|
|
98
|
+
readonly name: "exactInputSingle";
|
|
99
|
+
readonly type: "function";
|
|
100
|
+
readonly stateMutability: "payable";
|
|
101
|
+
readonly inputs: readonly [{
|
|
102
|
+
readonly name: "params";
|
|
103
|
+
readonly type: "tuple";
|
|
104
|
+
readonly components: readonly [{
|
|
105
|
+
readonly name: "tokenIn";
|
|
106
|
+
readonly type: "address";
|
|
107
|
+
}, {
|
|
108
|
+
readonly name: "tokenOut";
|
|
109
|
+
readonly type: "address";
|
|
110
|
+
}, {
|
|
111
|
+
readonly name: "fee";
|
|
112
|
+
readonly type: "uint24";
|
|
113
|
+
}, {
|
|
114
|
+
readonly name: "recipient";
|
|
115
|
+
readonly type: "address";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "amountIn";
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
}, {
|
|
120
|
+
readonly name: "amountOutMinimum";
|
|
121
|
+
readonly type: "uint256";
|
|
122
|
+
}, {
|
|
123
|
+
readonly name: "sqrtPriceLimitX96";
|
|
124
|
+
readonly type: "uint160";
|
|
125
|
+
}];
|
|
126
|
+
}];
|
|
127
|
+
readonly outputs: readonly [{
|
|
128
|
+
readonly name: "amountOut";
|
|
129
|
+
readonly type: "uint256";
|
|
130
|
+
}];
|
|
131
|
+
}, {
|
|
132
|
+
readonly name: "exactInput";
|
|
133
|
+
readonly type: "function";
|
|
134
|
+
readonly stateMutability: "payable";
|
|
135
|
+
readonly inputs: readonly [{
|
|
136
|
+
readonly name: "params";
|
|
137
|
+
readonly type: "tuple";
|
|
138
|
+
readonly components: readonly [{
|
|
139
|
+
readonly name: "path";
|
|
140
|
+
readonly type: "bytes";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "recipient";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
}, {
|
|
145
|
+
readonly name: "amountIn";
|
|
146
|
+
readonly type: "uint256";
|
|
147
|
+
}, {
|
|
148
|
+
readonly name: "amountOutMinimum";
|
|
149
|
+
readonly type: "uint256";
|
|
150
|
+
}];
|
|
151
|
+
}];
|
|
152
|
+
readonly outputs: readonly [{
|
|
153
|
+
readonly name: "amountOut";
|
|
154
|
+
readonly type: "uint256";
|
|
155
|
+
}];
|
|
156
|
+
}, {
|
|
157
|
+
readonly name: "multicall";
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly stateMutability: "payable";
|
|
160
|
+
readonly inputs: readonly [{
|
|
161
|
+
readonly name: "deadline";
|
|
162
|
+
readonly type: "uint256";
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "data";
|
|
165
|
+
readonly type: "bytes[]";
|
|
166
|
+
}];
|
|
167
|
+
readonly outputs: readonly [{
|
|
168
|
+
readonly name: "results";
|
|
169
|
+
readonly type: "bytes[]";
|
|
170
|
+
}];
|
|
171
|
+
}];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/** Uniswap v3 factory, QuoterV2, and SwapRouter02 on Celo mainnet. */
|
|
2
|
+
export const uniswapV3FactoryAbi = [
|
|
3
|
+
{
|
|
4
|
+
name: "getPool",
|
|
5
|
+
type: "function",
|
|
6
|
+
stateMutability: "view",
|
|
7
|
+
inputs: [
|
|
8
|
+
{ name: "tokenA", type: "address" },
|
|
9
|
+
{ name: "tokenB", type: "address" },
|
|
10
|
+
{ name: "fee", type: "uint24" },
|
|
11
|
+
],
|
|
12
|
+
outputs: [{ name: "pool", type: "address" }],
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
export const uniswapV3PoolAbi = [
|
|
16
|
+
{
|
|
17
|
+
name: "liquidity",
|
|
18
|
+
type: "function",
|
|
19
|
+
stateMutability: "view",
|
|
20
|
+
inputs: [],
|
|
21
|
+
outputs: [{ name: "liquidity", type: "uint128" }],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
export const v3QuoterAbi = [
|
|
25
|
+
{
|
|
26
|
+
name: "quoteExactInputSingle",
|
|
27
|
+
type: "function",
|
|
28
|
+
stateMutability: "nonpayable",
|
|
29
|
+
inputs: [
|
|
30
|
+
{
|
|
31
|
+
name: "params",
|
|
32
|
+
type: "tuple",
|
|
33
|
+
components: [
|
|
34
|
+
{ name: "tokenIn", type: "address" },
|
|
35
|
+
{ name: "tokenOut", type: "address" },
|
|
36
|
+
{ name: "amountIn", type: "uint256" },
|
|
37
|
+
{ name: "fee", type: "uint24" },
|
|
38
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
outputs: [
|
|
43
|
+
{ name: "amountOut", type: "uint256" },
|
|
44
|
+
{ name: "sqrtPriceX96After", type: "uint160" },
|
|
45
|
+
{ name: "initializedTicksCrossed", type: "uint32" },
|
|
46
|
+
{ name: "gasEstimate", type: "uint256" },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "quoteExactInput",
|
|
51
|
+
type: "function",
|
|
52
|
+
stateMutability: "nonpayable",
|
|
53
|
+
inputs: [
|
|
54
|
+
{ name: "path", type: "bytes" },
|
|
55
|
+
{ name: "amountIn", type: "uint256" },
|
|
56
|
+
],
|
|
57
|
+
outputs: [
|
|
58
|
+
{ name: "amountOut", type: "uint256" },
|
|
59
|
+
{ name: "sqrtPriceX96AfterList", type: "uint160[]" },
|
|
60
|
+
{ name: "initializedTicksCrossedList", type: "uint32[]" },
|
|
61
|
+
{ name: "gasEstimate", type: "uint256" },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
/**
|
|
66
|
+
* SwapRouter02 execution surface used by Celina.
|
|
67
|
+
* `exactInputSingle` / `exactInput` have no deadline; `multicall(uint256,bytes[])` applies one.
|
|
68
|
+
*/
|
|
69
|
+
export const swapRouter02Abi = [
|
|
70
|
+
{
|
|
71
|
+
name: "exactInputSingle",
|
|
72
|
+
type: "function",
|
|
73
|
+
stateMutability: "payable",
|
|
74
|
+
inputs: [
|
|
75
|
+
{
|
|
76
|
+
name: "params",
|
|
77
|
+
type: "tuple",
|
|
78
|
+
components: [
|
|
79
|
+
{ name: "tokenIn", type: "address" },
|
|
80
|
+
{ name: "tokenOut", type: "address" },
|
|
81
|
+
{ name: "fee", type: "uint24" },
|
|
82
|
+
{ name: "recipient", type: "address" },
|
|
83
|
+
{ name: "amountIn", type: "uint256" },
|
|
84
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
85
|
+
{ name: "sqrtPriceLimitX96", type: "uint160" },
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "exactInput",
|
|
93
|
+
type: "function",
|
|
94
|
+
stateMutability: "payable",
|
|
95
|
+
inputs: [
|
|
96
|
+
{
|
|
97
|
+
name: "params",
|
|
98
|
+
type: "tuple",
|
|
99
|
+
components: [
|
|
100
|
+
{ name: "path", type: "bytes" },
|
|
101
|
+
{ name: "recipient", type: "address" },
|
|
102
|
+
{ name: "amountIn", type: "uint256" },
|
|
103
|
+
{ name: "amountOutMinimum", type: "uint256" },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
outputs: [{ name: "amountOut", type: "uint256" }],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "multicall",
|
|
111
|
+
type: "function",
|
|
112
|
+
stateMutability: "payable",
|
|
113
|
+
inputs: [
|
|
114
|
+
{ name: "deadline", type: "uint256" },
|
|
115
|
+
{ name: "data", type: "bytes[]" },
|
|
116
|
+
],
|
|
117
|
+
outputs: [{ name: "results", type: "bytes[]" }],
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
//# sourceMappingURL=uniswap-v3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswap-v3.js","sourceRoot":"","sources":["../../src/abis/uniswap-v3.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE;SAChC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAA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AE,QAAQ;gBACd,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;oBAC/B,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;oBACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;oBACrC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE;iBAC9C;aACF;SACF;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAClD;IACD;QACE,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;SAClC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAChD;CACO,CAAC"}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/** Uniswap v3 on Celo mainnet — https://docs.celo.org/tooling/contracts/uniswap-contracts */
|
|
2
|
+
export declare const UNISWAP_V3: {
|
|
3
|
+
readonly factory: "0xAfE208a311B21f13EF87E33A90049fC17A7acDEc";
|
|
4
|
+
readonly quoterV2: "0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8";
|
|
5
|
+
readonly swapRouter02: "0x5615CDAb10dc425a742d643d949a7F474C01abc4";
|
|
6
|
+
};
|
|
7
|
+
/** Standard v3 fee tiers probed on the Celo factory. */
|
|
8
|
+
export declare const UNISWAP_V3_FEE_TIERS: readonly [100, 500, 3000, 10000];
|
|
9
|
+
/** Canonical v3 pool (token0 sorts before token1). */
|
|
10
|
+
export type UniswapV3Pool = {
|
|
11
|
+
token0: `0x${string}`;
|
|
12
|
+
token1: `0x${string}`;
|
|
13
|
+
fee: number;
|
|
14
|
+
};
|
|
15
|
+
export type UniswapProtocol = "uniswap_v3" | "uniswap_v4";
|
|
1
16
|
/** Uniswap v4 on Celo mainnet — https://docs.celo.org/tooling/contracts/uniswap-contracts */
|
|
2
17
|
export declare const UNISWAP_V4: {
|
|
3
18
|
readonly poolManager: "0x288dc841A52FCA2707c6947B3A777c5E56cd87BC";
|
package/build/config/uniswap.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Uniswap v4 contract addresses and routing helpers for Celo mainnet.
|
|
2
|
+
* Uniswap v3 and v4 contract addresses and routing helpers for Celo mainnet.
|
|
3
3
|
* @see https://docs.celo.org/tooling/contracts/uniswap-contracts
|
|
4
4
|
*/
|
|
5
5
|
import { MENTO_CELO_ADDRESS } from "./chains.js";
|
|
6
|
+
/** Uniswap v3 on Celo mainnet — https://docs.celo.org/tooling/contracts/uniswap-contracts */
|
|
7
|
+
export const UNISWAP_V3 = {
|
|
8
|
+
factory: "0xAfE208a311B21f13EF87E33A90049fC17A7acDEc",
|
|
9
|
+
quoterV2: "0x82825d0554fA07f7FC52Ab63c961F330fdEFa8E8",
|
|
10
|
+
swapRouter02: "0x5615CDAb10dc425a742d643d949a7F474C01abc4",
|
|
11
|
+
};
|
|
12
|
+
/** Standard v3 fee tiers probed on the Celo factory. */
|
|
13
|
+
export const UNISWAP_V3_FEE_TIERS = [100, 500, 3000, 10000];
|
|
6
14
|
/** Uniswap v4 on Celo mainnet — https://docs.celo.org/tooling/contracts/uniswap-contracts */
|
|
7
15
|
export const UNISWAP_V4 = {
|
|
8
16
|
poolManager: "0x288dc841A52FCA2707c6947B3A777c5E56cd87BC",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswap.js","sourceRoot":"","sources":["../../src/config/uniswap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE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CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,uBAAuB,CAAC,OAAuB;IAC7D,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,GAAG,qBAAqB,CAClD,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,SAAS,CAClB,CAAC;IACF,OAAO,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC9C,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAC/B,OAAiC;IAEjC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,UAAU,CAAC,cAAc,CAAC;IACnC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAiC;IAEjC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,wBAAwB,CACtC,OAAiC;IAEjC,IAAI,OAAO,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO,kBAAkB,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,QAAuB;IAC7D,OAAO,QAAQ,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,cAAc,CAAC;AAC9D,CAAC"}
|
package/build/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface CelinaClient {
|
|
|
35
35
|
transaction: TransactionService;
|
|
36
36
|
/** Mento FX quotes, estimates, and `prepareFx` flows. */
|
|
37
37
|
mentoFx: MentoFxService;
|
|
38
|
-
/** Uniswap v4 quotes, estimates, and `prepareSwap` flows. */
|
|
38
|
+
/** Uniswap v3 and v4 quotes, estimates, and `prepareSwap` flows. */
|
|
39
39
|
uniswap: UniswapService;
|
|
40
40
|
/** Aave V3 `getBalances`, `prepareSupply`, and `prepareWithdraw` on Celo. */
|
|
41
41
|
aave: AaveService;
|
|
@@ -89,9 +89,9 @@ export type { SdkConfig } from "./config/sdk-config.js";
|
|
|
89
89
|
export type { ResolvedToken } from "./services/token.service.js";
|
|
90
90
|
/** Slippage, deadline, and recipient options for Mento FX swaps. */
|
|
91
91
|
export type { MentoFxParams } from "./services/mento-fx.service.js";
|
|
92
|
-
/** Unordered registry-token pair listing for Mento FX / Uniswap
|
|
92
|
+
/** Unordered registry-token pair listing for Mento FX / Uniswap. */
|
|
93
93
|
export type { SwapPair, SwapPairsResult } from "./services/swap-pairs.js";
|
|
94
|
-
/** Slippage, deadline, and
|
|
94
|
+
/** Slippage, deadline, recipient, and optional venue pin for Uniswap swaps. */
|
|
95
95
|
export type { UniswapSwapParams } from "./services/uniswap.service.js";
|
|
96
96
|
/** Pagination and metadata options for governance proposal lists. */
|
|
97
97
|
export type { GovernanceProposalsOptions } from "./services/governance.service.js";
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/** Graph fields shared by the v3 and v4 pool indexes. */
|
|
2
|
+
type UniswapPairGraph = {
|
|
3
|
+
poolsByPair: Iterable<readonly [string, unknown]>;
|
|
4
|
+
adjacency: Map<string, Set<string>>;
|
|
5
|
+
};
|
|
6
|
+
/** Uniswap venue that currently has a pool or multi-hop path for a pair. */
|
|
7
|
+
export type UniswapVenue = "uniswap_v3" | "uniswap_v4";
|
|
2
8
|
/** One unordered registry-token pair with hop count. */
|
|
3
9
|
export type SwapPair = {
|
|
4
10
|
token_a: string;
|
|
5
11
|
token_b: string;
|
|
6
12
|
hops: number;
|
|
13
|
+
/** Set on Uniswap listings. Omitted for Mento pairs. */
|
|
14
|
+
venues?: UniswapVenue[];
|
|
7
15
|
};
|
|
8
|
-
/** Mento FX or Uniswap
|
|
16
|
+
/** Mento FX or Uniswap pair listing returned to tools and SDK callers. */
|
|
9
17
|
export type SwapPairsResult = {
|
|
10
18
|
network: "mainnet";
|
|
11
19
|
protocol: "mento_fx" | "uniswap_v4";
|
|
@@ -35,9 +43,15 @@ export declare function filterPairsByToken(pairs: SwapPair[], symbol: string): {
|
|
|
35
43
|
export declare function withTokenFilter(result: SwapPairsResult, symbol?: string): SwapPairsResult;
|
|
36
44
|
/** Build unordered registry pairs from Mento `routes.getRoutes()` results. */
|
|
37
45
|
export declare function buildPairsFromMentoRoutes(routes: readonly MentoRouteLike[]): SwapPair[];
|
|
46
|
+
/** Tag every pair with a single Uniswap venue. */
|
|
47
|
+
export declare function withVenue(pairs: SwapPair[], venue: UniswapVenue): SwapPair[];
|
|
48
|
+
/**
|
|
49
|
+
* Merge pair listings. Hop count is the shortest path. Venues are the union.
|
|
50
|
+
*/
|
|
51
|
+
export declare function mergeSwapPairs(lists: SwapPair[][]): SwapPair[];
|
|
38
52
|
/**
|
|
39
|
-
* Build unordered registry pairs from a Uniswap
|
|
53
|
+
* Build unordered registry pairs from a Uniswap pool index.
|
|
40
54
|
* Direct pools are hops: 1; two-hop adjacency among registry tokens is hops: 2.
|
|
41
55
|
*/
|
|
42
|
-
export declare function buildPairsFromUniswapIndex(index:
|
|
56
|
+
export declare function buildPairsFromUniswapIndex(index: UniswapPairGraph): SwapPair[];
|
|
43
57
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared swap-pair listing helpers for Mento FX and Uniswap v4.
|
|
2
|
+
* Shared swap-pair listing helpers for Mento FX and Uniswap v3/v4.
|
|
3
3
|
* Pair existence only — no quotes.
|
|
4
4
|
*/
|
|
5
5
|
import { findKnownToken, KNOWN_TOKENS, MENTO_CELO_ADDRESS } from "../config/chains.js";
|
|
@@ -83,8 +83,41 @@ export function buildPairsFromMentoRoutes(routes) {
|
|
|
83
83
|
}
|
|
84
84
|
return sortedPairs(map);
|
|
85
85
|
}
|
|
86
|
+
/** Tag every pair with a single Uniswap venue. */
|
|
87
|
+
export function withVenue(pairs, venue) {
|
|
88
|
+
return pairs.map((pair) => ({ ...pair, venues: [venue] }));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Merge pair listings. Hop count is the shortest path. Venues are the union.
|
|
92
|
+
*/
|
|
93
|
+
export function mergeSwapPairs(lists) {
|
|
94
|
+
const map = new Map();
|
|
95
|
+
for (const list of lists) {
|
|
96
|
+
for (const pair of list) {
|
|
97
|
+
const key = pairKey(pair.token_a, pair.token_b);
|
|
98
|
+
const existing = map.get(key);
|
|
99
|
+
if (!existing) {
|
|
100
|
+
map.set(key, {
|
|
101
|
+
...pair,
|
|
102
|
+
venues: pair.venues ? [...pair.venues] : undefined,
|
|
103
|
+
});
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const venues = [
|
|
107
|
+
...new Set([...(existing.venues ?? []), ...(pair.venues ?? [])]),
|
|
108
|
+
].sort();
|
|
109
|
+
map.set(key, {
|
|
110
|
+
token_a: existing.token_a,
|
|
111
|
+
token_b: existing.token_b,
|
|
112
|
+
hops: Math.min(existing.hops, pair.hops),
|
|
113
|
+
...(venues.length > 0 ? { venues } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return sortedPairs(map);
|
|
118
|
+
}
|
|
86
119
|
/**
|
|
87
|
-
* Build unordered registry pairs from a Uniswap
|
|
120
|
+
* Build unordered registry pairs from a Uniswap pool index.
|
|
88
121
|
* Direct pools are hops: 1; two-hop adjacency among registry tokens is hops: 2.
|
|
89
122
|
*/
|
|
90
123
|
export function buildPairsFromUniswapIndex(index) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap-pairs.js","sourceRoot":"","sources":["../../src/services/swap-pairs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,M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EAAE,SAAS,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QAChD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,SAAS;QACX,CAAC;QACD,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;YAC5B,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,SAAS;YACX,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE,CAAC;gBAChC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,SAAS;gBACX,CAAC;gBACD,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { PublicClient } from "viem";
|
|
5
5
|
import { type UniswapPoolKey } from "../config/uniswap.js";
|
|
6
|
+
import { type UniswapPoolIndex } from "./uniswap-pool-discovery.js";
|
|
6
7
|
/** Single hop descriptor in a Uniswap v4 multi-hop path. */
|
|
7
8
|
export type UniswapPathKey = {
|
|
8
9
|
intermediateCurrency: `0x${string}`;
|
|
@@ -28,6 +29,15 @@ export type UniswapSwapRoute = {
|
|
|
28
29
|
* prepare steps that follow it in the same chat turn.
|
|
29
30
|
*/
|
|
30
31
|
export declare const MAX_QUOTE_PATHS = 16;
|
|
32
|
+
/**
|
|
33
|
+
* Split a shared simulateContract budget across two venues.
|
|
34
|
+
* Each venue gets up to half, then leftover calls go to the venue with more candidates.
|
|
35
|
+
*/
|
|
36
|
+
export declare function splitQuoteBudget(firstCount: number, secondCount: number, total?: number): {
|
|
37
|
+
first: number;
|
|
38
|
+
second: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function countV4CandidatePaths(index: UniswapPoolIndex, currencyIn: `0x${string}`, currencyOut: `0x${string}`): number;
|
|
31
41
|
/**
|
|
32
42
|
* Quote all candidate paths and return the highest-output Uniswap v4 route.
|
|
33
43
|
* @param client - Celo public client for quoter simulation
|
|
@@ -36,7 +46,7 @@ export declare const MAX_QUOTE_PATHS = 16;
|
|
|
36
46
|
* @param amountIn - Input amount in base units
|
|
37
47
|
* @returns Best route and quoter output, or `null` when no path quotes successfully
|
|
38
48
|
*/
|
|
39
|
-
export declare function findBestUniswapRoute(client: PublicClient, currencyIn: `0x${string}`, currencyOut: `0x${string}`, amountIn: bigint): Promise<{
|
|
49
|
+
export declare function findBestUniswapRoute(client: PublicClient, currencyIn: `0x${string}`, currencyOut: `0x${string}`, amountIn: bigint, maxPaths?: number, index?: UniswapPoolIndex): Promise<{
|
|
40
50
|
route: UniswapSwapRoute;
|
|
41
51
|
amountOut: bigint;
|
|
42
52
|
indexSource: string;
|
|
@@ -39,6 +39,35 @@ function buildPathKeys(pools, currencyIn) {
|
|
|
39
39
|
}
|
|
40
40
|
return pathKeys;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Split a shared simulateContract budget across two venues.
|
|
44
|
+
* Each venue gets up to half, then leftover calls go to the venue with more candidates.
|
|
45
|
+
*/
|
|
46
|
+
export function splitQuoteBudget(firstCount, secondCount, total = MAX_QUOTE_PATHS) {
|
|
47
|
+
const budget = Math.max(0, total);
|
|
48
|
+
const firstNeeded = Math.max(0, firstCount);
|
|
49
|
+
const secondNeeded = Math.max(0, secondCount);
|
|
50
|
+
if (firstNeeded + secondNeeded <= budget) {
|
|
51
|
+
return { first: firstNeeded, second: secondNeeded };
|
|
52
|
+
}
|
|
53
|
+
const half = Math.floor(budget / 2);
|
|
54
|
+
let first = Math.min(firstNeeded, half);
|
|
55
|
+
let second = Math.min(secondNeeded, budget - first);
|
|
56
|
+
let leftover = budget - first - second;
|
|
57
|
+
if (firstNeeded > first && leftover > 0) {
|
|
58
|
+
const give = Math.min(leftover, firstNeeded - first);
|
|
59
|
+
first += give;
|
|
60
|
+
leftover -= give;
|
|
61
|
+
}
|
|
62
|
+
if (secondNeeded > second && leftover > 0) {
|
|
63
|
+
const give = Math.min(leftover, secondNeeded - second);
|
|
64
|
+
second += give;
|
|
65
|
+
}
|
|
66
|
+
return { first, second };
|
|
67
|
+
}
|
|
68
|
+
export function countV4CandidatePaths(index, currencyIn, currencyOut) {
|
|
69
|
+
return enumeratePaths(index, currencyIn, currencyOut).length;
|
|
70
|
+
}
|
|
42
71
|
function enumeratePaths(index, currencyIn, currencyOut) {
|
|
43
72
|
const start = currencyIn.toLowerCase();
|
|
44
73
|
const goal = currencyOut.toLowerCase();
|
|
@@ -125,16 +154,13 @@ async function quotePath(client, currencyIn, pools, amountIn) {
|
|
|
125
154
|
* @param amountIn - Input amount in base units
|
|
126
155
|
* @returns Best route and quoter output, or `null` when no path quotes successfully
|
|
127
156
|
*/
|
|
128
|
-
export async function findBestUniswapRoute(client, currencyIn, currencyOut, amountIn) {
|
|
129
|
-
const
|
|
130
|
-
// Sort shortest-first so 1-hop direct pools are always preferred, then cap
|
|
131
|
-
//
|
|
132
|
-
|
|
133
|
-
// unbounded walk over a dense pool graph can exhaust the per-invocation
|
|
134
|
-
// budget before the subsequent balance-check and prepare steps can run.
|
|
135
|
-
const candidatePaths = enumeratePaths(index, currencyIn, currencyOut)
|
|
157
|
+
export async function findBestUniswapRoute(client, currencyIn, currencyOut, amountIn, maxPaths = MAX_QUOTE_PATHS, index) {
|
|
158
|
+
const poolIndex = index ?? (await getUniswapPoolIndex(client));
|
|
159
|
+
// Sort shortest-first so 1-hop direct pools are always preferred, then cap
|
|
160
|
+
// simulateContract calls. Each call is one Cloudflare Workers subrequest.
|
|
161
|
+
const candidatePaths = enumeratePaths(poolIndex, currencyIn, currencyOut)
|
|
136
162
|
.sort((a, b) => a.length - b.length)
|
|
137
|
-
.slice(0,
|
|
163
|
+
.slice(0, Math.max(0, maxPaths));
|
|
138
164
|
// Quote every candidate path concurrently; failed quotes (e.g. uninitialized
|
|
139
165
|
// pools or insufficient liquidity) are dropped rather than aborting the rest.
|
|
140
166
|
const quotes = await Promise.allSettled(candidatePaths.map(async (pools) => ({
|
|
@@ -169,7 +195,7 @@ export async function findBestUniswapRoute(client, currencyIn, currencyOut, amou
|
|
|
169
195
|
return {
|
|
170
196
|
route: best.route,
|
|
171
197
|
amountOut: best.amountOut,
|
|
172
|
-
indexSource:
|
|
198
|
+
indexSource: poolIndex.source,
|
|
173
199
|
};
|
|
174
200
|
}
|
|
175
201
|
/**
|