@bananapus/nana-sdk-core 1.10.1 → 1.11.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/dist/cjs/v6/index.d.ts +1 -0
- package/dist/cjs/v6/index.d.ts.map +1 -1
- package/dist/cjs/v6/index.js +1 -0
- package/dist/cjs/v6/index.js.map +1 -1
- package/dist/cjs/v6/uniswapV4Deployments.d.ts +7 -0
- package/dist/cjs/v6/uniswapV4Deployments.d.ts.map +1 -1
- package/dist/cjs/v6/uniswapV4Deployments.js +16 -1
- package/dist/cjs/v6/uniswapV4Deployments.js.map +1 -1
- package/dist/cjs/v6/uniswapV4Fees.d.ts +76 -0
- package/dist/cjs/v6/uniswapV4Fees.d.ts.map +1 -0
- package/dist/cjs/v6/uniswapV4Fees.js +167 -0
- package/dist/cjs/v6/uniswapV4Fees.js.map +1 -0
- package/dist/esm/v6/index.d.ts +1 -0
- package/dist/esm/v6/index.d.ts.map +1 -1
- package/dist/esm/v6/index.js +1 -0
- package/dist/esm/v6/index.js.map +1 -1
- package/dist/esm/v6/uniswapV4Deployments.d.ts +7 -0
- package/dist/esm/v6/uniswapV4Deployments.d.ts.map +1 -1
- package/dist/esm/v6/uniswapV4Deployments.js +15 -0
- package/dist/esm/v6/uniswapV4Deployments.js.map +1 -1
- package/dist/esm/v6/uniswapV4Fees.d.ts +76 -0
- package/dist/esm/v6/uniswapV4Fees.d.ts.map +1 -0
- package/dist/esm/v6/uniswapV4Fees.js +161 -0
- package/dist/esm/v6/uniswapV4Fees.js.map +1 -0
- package/package.json +1 -1
package/dist/cjs/v6/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./cashOut.js";
|
|
|
15
15
|
export * from "./nft.js";
|
|
16
16
|
export * from "./tokens.js";
|
|
17
17
|
export * from "./uniswapV4.js";
|
|
18
|
+
export * from "./uniswapV4Fees.js";
|
|
18
19
|
export * from "./permissions.js";
|
|
19
20
|
export * from "./suckers.js";
|
|
20
21
|
export * from "./loans.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/cjs/v6/index.js
CHANGED
|
@@ -31,6 +31,7 @@ __exportStar(require("./cashOut.js"), exports);
|
|
|
31
31
|
__exportStar(require("./nft.js"), exports);
|
|
32
32
|
__exportStar(require("./tokens.js"), exports);
|
|
33
33
|
__exportStar(require("./uniswapV4.js"), exports);
|
|
34
|
+
__exportStar(require("./uniswapV4Fees.js"), exports);
|
|
34
35
|
__exportStar(require("./permissions.js"), exports);
|
|
35
36
|
__exportStar(require("./suckers.js"), exports);
|
|
36
37
|
__exportStar(require("./loans.js"), exports);
|
package/dist/cjs/v6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,8CAA4B;AAC5B,+CAA6B;AAC7B,iDAA+B;AAC/B,2CAAyB;AACzB,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,mDAAiC;AACjC,+CAA6B;AAC7B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B;AAC9B,4CAA0B;AAC1B,8CAA4B;AAC5B,iDAA+B;AAC/B,gDAA8B;AAC9B,8CAA4B;AAC5B,+CAA6B;AAC7B,iDAA+B;AAC/B,2CAAyB;AACzB,iDAA+B;AAC/B,+CAA6B;AAC7B,qDAAmC;AACnC,+CAA6B;AAC7B,2CAAyB;AACzB,8CAA4B;AAC5B,iDAA+B;AAC/B,qDAAmC;AACnC,mDAAiC;AACjC,+CAA6B;AAC7B,6CAA2B"}
|
|
@@ -8,6 +8,12 @@ export declare const UNISWAP_V4_POSITION_MANAGER_ADDRESSES: Readonly<Partial<Rec
|
|
|
8
8
|
export declare const UNISWAP_V4_QUOTER_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
9
9
|
/** Canonical Universal Router deployments which support V4 swaps. */
|
|
10
10
|
export declare const UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
11
|
+
/**
|
|
12
|
+
* Canonical StateView deployments — the periphery lens over PoolManager's
|
|
13
|
+
* `extsload` storage. Each address was verified by calling `poolManager()` and
|
|
14
|
+
* matching it against {@link UNISWAP_V4_POOL_MANAGER_ADDRESSES} for the chain.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UNISWAP_V4_STATE_VIEW_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
11
17
|
/** Permit2 is deployed at the same address on supported EVM chains. */
|
|
12
18
|
export declare const UNISWAP_PERMIT2_ADDRESS: Address;
|
|
13
19
|
/** Resolve the supported V4 surface for a chain without guessing addresses. */
|
|
@@ -16,6 +22,7 @@ export declare function uniswapV4Deployment(chainId: number): {
|
|
|
16
22
|
positionManager: Address | null;
|
|
17
23
|
quoter: Address | null;
|
|
18
24
|
universalRouter: Address | null;
|
|
25
|
+
stateView: Address | null;
|
|
19
26
|
permit2: Address;
|
|
20
27
|
} | null;
|
|
21
28
|
//# sourceMappingURL=uniswapV4Deployments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswapV4Deployments.d.ts","sourceRoot":"","sources":["../../../src/v6/uniswapV4Deployments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,6DAA6D;AAC7D,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CACtD,OAAO,CAAC,MA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AAEF,uEAAuE;AACvE,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAChD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAC1D,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,EAAE,OACQ,CAAC;AAE/C,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,IAAI,CAmCP"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UNISWAP_PERMIT2_ADDRESS = exports.UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES = exports.UNISWAP_V4_QUOTER_ADDRESSES = exports.UNISWAP_V4_POSITION_MANAGER_ADDRESSES = exports.UNISWAP_V4_POOL_MANAGER_ADDRESSES = void 0;
|
|
3
|
+
exports.UNISWAP_PERMIT2_ADDRESS = exports.UNISWAP_V4_STATE_VIEW_ADDRESSES = exports.UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES = exports.UNISWAP_V4_QUOTER_ADDRESSES = exports.UNISWAP_V4_POSITION_MANAGER_ADDRESSES = exports.UNISWAP_V4_POOL_MANAGER_ADDRESSES = void 0;
|
|
4
4
|
exports.uniswapV4Deployment = uniswapV4Deployment;
|
|
5
5
|
/** Canonical PoolManager deployments used by Juicebox v6. */
|
|
6
6
|
exports.UNISWAP_V4_POOL_MANAGER_ADDRESSES = {
|
|
@@ -42,6 +42,20 @@ exports.UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES = {
|
|
|
42
42
|
421614: "0xefd1d4bd4cf1e86da286bb4cb1b8bced9c10ba47",
|
|
43
43
|
11155111: "0x3A9D48AB9751398BbFa63ad67599Bb04e4BdF98b",
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Canonical StateView deployments — the periphery lens over PoolManager's
|
|
47
|
+
* `extsload` storage. Each address was verified by calling `poolManager()` and
|
|
48
|
+
* matching it against {@link UNISWAP_V4_POOL_MANAGER_ADDRESSES} for the chain.
|
|
49
|
+
*/
|
|
50
|
+
exports.UNISWAP_V4_STATE_VIEW_ADDRESSES = {
|
|
51
|
+
1: "0x7ffe42c4a5deea5b0fec41c94c136cf115597227",
|
|
52
|
+
10: "0xc18a3169788f4f75a170290584eca6395c75ecdb",
|
|
53
|
+
8453: "0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",
|
|
54
|
+
42161: "0x76fd297e2d437cd7f76d50f01afe6160f86e9990",
|
|
55
|
+
84532: "0x571291b572ed32ce6751a2cb2486ebee8defb9b4",
|
|
56
|
+
421614: "0x9d467fa9062b6e9b1a46e26007ad82db116c67cb",
|
|
57
|
+
11155111: "0xe1dd9c3fa50edb962e442f60dfbc432e24537e4c",
|
|
58
|
+
};
|
|
45
59
|
/** Permit2 is deployed at the same address on supported EVM chains. */
|
|
46
60
|
exports.UNISWAP_PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
47
61
|
/** Resolve the supported V4 surface for a chain without guessing addresses. */
|
|
@@ -54,6 +68,7 @@ function uniswapV4Deployment(chainId) {
|
|
|
54
68
|
positionManager: exports.UNISWAP_V4_POSITION_MANAGER_ADDRESSES[chainId] ?? null,
|
|
55
69
|
quoter: exports.UNISWAP_V4_QUOTER_ADDRESSES[chainId] ?? null,
|
|
56
70
|
universalRouter: exports.UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES[chainId] ?? null,
|
|
71
|
+
stateView: exports.UNISWAP_V4_STATE_VIEW_ADDRESSES[chainId] ?? null,
|
|
57
72
|
permit2: exports.UNISWAP_PERMIT2_ADDRESS,
|
|
58
73
|
};
|
|
59
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswapV4Deployments.js","sourceRoot":"","sources":["../../../src/v6/uniswapV4Deployments.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"uniswapV4Deployments.js","sourceRoot":"","sources":["../../../src/v6/uniswapV4Deployments.ts"],"names":[],"mappings":";;;AA6EA,kDA0CC;AApHD,6DAA6D;AAChD,QAAA,iCAAiC,GAE1C;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF,iEAAiE;AACpD,QAAA,qCAAqC,GAE9C;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF,uEAAuE;AAC1D,QAAA,2BAA2B,GAEpC;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF,qEAAqE;AACxD,QAAA,qCAAqC,GAE9C;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF;;;;GAIG;AACU,QAAA,+BAA+B,GAExC;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF,uEAAuE;AAC1D,QAAA,uBAAuB,GAClC,4CAA4C,CAAC;AAE/C,+EAA+E;AAC/E,SAAgB,mBAAmB,CAAC,OAAe;IAQjD,MAAM,WAAW,GACf,yCAGD,CAAC,OAAO,CAAC,CAAC;IACX,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IAC9B,OAAO;QACL,WAAW;QACX,eAAe,EAEX,6CAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,MAAM,EAEF,mCAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,eAAe,EAEX,6CAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,SAAS,EAEL,uCAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,OAAO,EAAE,+BAAuB;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from "viem";
|
|
2
|
+
import type { JBChainId } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The PoolManager position key: `keccak256(abi.encodePacked(owner, tickLower,
|
|
5
|
+
* tickUpper, salt))`. For a PositionManager-held position the owner is the
|
|
6
|
+
* PositionManager and the salt is the position's token id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function uniswapV4PositionId({ owner, tickLower, tickUpper, salt, }: {
|
|
9
|
+
owner: Address;
|
|
10
|
+
tickLower: number;
|
|
11
|
+
tickUpper: number;
|
|
12
|
+
salt: bigint;
|
|
13
|
+
}): Hex;
|
|
14
|
+
/**
|
|
15
|
+
* Fees a position has accrued since its last checkpoint, from the pool's fee
|
|
16
|
+
* growth accumulators.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Fee growth accumulators are unchecked `uint256` in the pool and are
|
|
19
|
+
* expected to wrap; the difference is therefore taken modulo 2^256, exactly as
|
|
20
|
+
* Solidity computes it. A checked subtraction would read a wrapped accumulator
|
|
21
|
+
* as a negative (or enormous) balance.
|
|
22
|
+
*/
|
|
23
|
+
export declare function uniswapV4FeesOwed({ liquidity, feeGrowthInsideLastX128, feeGrowthInsideX128, }: {
|
|
24
|
+
liquidity: bigint;
|
|
25
|
+
feeGrowthInsideLastX128: bigint;
|
|
26
|
+
feeGrowthInsideX128: bigint;
|
|
27
|
+
}): bigint;
|
|
28
|
+
export interface UniswapV4PositionFees {
|
|
29
|
+
/** Unclaimed currency0 fees, in currency0's own decimals. */
|
|
30
|
+
amount0: bigint;
|
|
31
|
+
/** Unclaimed currency1 fees, in currency1's own decimals. */
|
|
32
|
+
amount1: bigint;
|
|
33
|
+
/** The position's live liquidity, as the pool records it. */
|
|
34
|
+
liquidity: bigint;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read a position's unclaimed fees through StateView.
|
|
38
|
+
*
|
|
39
|
+
* This is the fees CLAIMABLE NOW, not the position's lifetime earnings: the
|
|
40
|
+
* pool rewrites `feeGrowthInsideLast` on every collect, so anything already
|
|
41
|
+
* taken is no longer visible here. Reconstructing lifetime earnings means
|
|
42
|
+
* replaying the position's `ModifyLiquidity` events against archive state.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readUniswapV4PositionFees(client: Pick<PublicClient, "readContract">, { chainId, stateView, poolId, positionManager, tokenId, tickLower, tickUpper, }: {
|
|
45
|
+
chainId?: JBChainId;
|
|
46
|
+
/** Overrides the chain's canonical StateView deployment. */
|
|
47
|
+
stateView?: Address;
|
|
48
|
+
poolId: Hex;
|
|
49
|
+
positionManager: Address;
|
|
50
|
+
tokenId: bigint;
|
|
51
|
+
tickLower: number;
|
|
52
|
+
tickUpper: number;
|
|
53
|
+
}): Promise<UniswapV4PositionFees>;
|
|
54
|
+
export interface UniswapV4CollectFeesTxRequest {
|
|
55
|
+
to: Address;
|
|
56
|
+
data: Hex;
|
|
57
|
+
value: bigint;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Collect a position's fees without touching its liquidity.
|
|
61
|
+
*
|
|
62
|
+
* A V4 "collect" is a zero-liquidity decrease: the pool settles the accrued
|
|
63
|
+
* fees into the position's delta, and TAKE_PAIR pays both currencies out. The
|
|
64
|
+
* minimum-out parameters are 0 because nothing is swapped — the amounts are
|
|
65
|
+
* whatever the pool has already accrued, so a floor could only make a valid
|
|
66
|
+
* claim revert.
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildCollectUniswapV4FeesTx({ positionManager, tokenId, currency0, currency1, recipient, deadline, }: {
|
|
69
|
+
positionManager: Address;
|
|
70
|
+
tokenId: bigint;
|
|
71
|
+
currency0: Address;
|
|
72
|
+
currency1: Address;
|
|
73
|
+
recipient: Address;
|
|
74
|
+
deadline: bigint;
|
|
75
|
+
}): UniswapV4CollectFeesTxRequest;
|
|
76
|
+
//# sourceMappingURL=uniswapV4Fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswapV4Fees.d.ts","sourceRoot":"","sources":["../../../src/v6/uniswapV4Fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,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E,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,6BAA6B,CAiChC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniswapV4PositionId = uniswapV4PositionId;
|
|
4
|
+
exports.uniswapV4FeesOwed = uniswapV4FeesOwed;
|
|
5
|
+
exports.readUniswapV4PositionFees = readUniswapV4PositionFees;
|
|
6
|
+
exports.buildCollectUniswapV4FeesTx = buildCollectUniswapV4FeesTx;
|
|
7
|
+
const viem_1 = require("viem");
|
|
8
|
+
const uniswapV4Deployments_js_1 = require("./uniswapV4Deployments.js");
|
|
9
|
+
const UINT256_MAX = (1n << 256n) - 1n;
|
|
10
|
+
const Q128 = 1n << 128n;
|
|
11
|
+
const STATE_VIEW_ABI = [
|
|
12
|
+
{
|
|
13
|
+
type: "function",
|
|
14
|
+
name: "getFeeGrowthInside",
|
|
15
|
+
stateMutability: "view",
|
|
16
|
+
inputs: [
|
|
17
|
+
{ name: "poolId", type: "bytes32" },
|
|
18
|
+
{ name: "tickLower", type: "int24" },
|
|
19
|
+
{ name: "tickUpper", type: "int24" },
|
|
20
|
+
],
|
|
21
|
+
outputs: [
|
|
22
|
+
{ name: "feeGrowthInside0X128", type: "uint256" },
|
|
23
|
+
{ name: "feeGrowthInside1X128", type: "uint256" },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "function",
|
|
28
|
+
name: "getPositionInfo",
|
|
29
|
+
stateMutability: "view",
|
|
30
|
+
inputs: [
|
|
31
|
+
{ name: "poolId", type: "bytes32" },
|
|
32
|
+
{ name: "positionId", type: "bytes32" },
|
|
33
|
+
],
|
|
34
|
+
outputs: [
|
|
35
|
+
{ name: "liquidity", type: "uint128" },
|
|
36
|
+
{ name: "feeGrowthInside0LastX128", type: "uint256" },
|
|
37
|
+
{ name: "feeGrowthInside1LastX128", type: "uint256" },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
const POSITION_MANAGER_ABI = [
|
|
42
|
+
{
|
|
43
|
+
type: "function",
|
|
44
|
+
name: "modifyLiquidities",
|
|
45
|
+
stateMutability: "payable",
|
|
46
|
+
inputs: [
|
|
47
|
+
{ name: "unlockData", type: "bytes" },
|
|
48
|
+
{ name: "deadline", type: "uint256" },
|
|
49
|
+
],
|
|
50
|
+
outputs: [],
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
/** v4-periphery `Actions.DECREASE_LIQUIDITY`. */
|
|
54
|
+
const ACTION_DECREASE_LIQUIDITY = 0x01;
|
|
55
|
+
/** v4-periphery `Actions.TAKE_PAIR`. */
|
|
56
|
+
const ACTION_TAKE_PAIR = 0x11;
|
|
57
|
+
/**
|
|
58
|
+
* The PoolManager position key: `keccak256(abi.encodePacked(owner, tickLower,
|
|
59
|
+
* tickUpper, salt))`. For a PositionManager-held position the owner is the
|
|
60
|
+
* PositionManager and the salt is the position's token id.
|
|
61
|
+
*/
|
|
62
|
+
function uniswapV4PositionId({ owner, tickLower, tickUpper, salt, }) {
|
|
63
|
+
return (0, viem_1.keccak256)((0, viem_1.encodePacked)(["address", "int24", "int24", "bytes32"], [
|
|
64
|
+
owner,
|
|
65
|
+
tickLower,
|
|
66
|
+
tickUpper,
|
|
67
|
+
`0x${salt.toString(16).padStart(64, "0")}`,
|
|
68
|
+
]));
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Fees a position has accrued since its last checkpoint, from the pool's fee
|
|
72
|
+
* growth accumulators.
|
|
73
|
+
*
|
|
74
|
+
* @remarks Fee growth accumulators are unchecked `uint256` in the pool and are
|
|
75
|
+
* expected to wrap; the difference is therefore taken modulo 2^256, exactly as
|
|
76
|
+
* Solidity computes it. A checked subtraction would read a wrapped accumulator
|
|
77
|
+
* as a negative (or enormous) balance.
|
|
78
|
+
*/
|
|
79
|
+
function uniswapV4FeesOwed({ liquidity, feeGrowthInsideLastX128, feeGrowthInsideX128, }) {
|
|
80
|
+
if (liquidity <= 0n)
|
|
81
|
+
return 0n;
|
|
82
|
+
const delta = (feeGrowthInsideX128 - feeGrowthInsideLastX128) & UINT256_MAX;
|
|
83
|
+
return (delta * liquidity) / Q128;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read a position's unclaimed fees through StateView.
|
|
87
|
+
*
|
|
88
|
+
* This is the fees CLAIMABLE NOW, not the position's lifetime earnings: the
|
|
89
|
+
* pool rewrites `feeGrowthInsideLast` on every collect, so anything already
|
|
90
|
+
* taken is no longer visible here. Reconstructing lifetime earnings means
|
|
91
|
+
* replaying the position's `ModifyLiquidity` events against archive state.
|
|
92
|
+
*/
|
|
93
|
+
async function readUniswapV4PositionFees(client, { chainId, stateView, poolId, positionManager, tokenId, tickLower, tickUpper, }) {
|
|
94
|
+
const lens = stateView ??
|
|
95
|
+
(chainId
|
|
96
|
+
? uniswapV4Deployments_js_1.UNISWAP_V4_STATE_VIEW_ADDRESSES[chainId]
|
|
97
|
+
: undefined);
|
|
98
|
+
if (!lens) {
|
|
99
|
+
throw new Error(`No Uniswap V4 StateView deployment for chain ${chainId ?? "unknown"}.`);
|
|
100
|
+
}
|
|
101
|
+
const positionId = uniswapV4PositionId({
|
|
102
|
+
owner: positionManager,
|
|
103
|
+
tickLower,
|
|
104
|
+
tickUpper,
|
|
105
|
+
salt: tokenId,
|
|
106
|
+
});
|
|
107
|
+
const [position, inside] = await Promise.all([
|
|
108
|
+
client.readContract({
|
|
109
|
+
address: lens,
|
|
110
|
+
abi: STATE_VIEW_ABI,
|
|
111
|
+
functionName: "getPositionInfo",
|
|
112
|
+
args: [poolId, positionId],
|
|
113
|
+
}),
|
|
114
|
+
client.readContract({
|
|
115
|
+
address: lens,
|
|
116
|
+
abi: STATE_VIEW_ABI,
|
|
117
|
+
functionName: "getFeeGrowthInside",
|
|
118
|
+
args: [poolId, tickLower, tickUpper],
|
|
119
|
+
}),
|
|
120
|
+
]);
|
|
121
|
+
const [liquidity, feeGrowthInside0Last, feeGrowthInside1Last] = position;
|
|
122
|
+
const [feeGrowthInside0, feeGrowthInside1] = inside;
|
|
123
|
+
return {
|
|
124
|
+
liquidity,
|
|
125
|
+
amount0: uniswapV4FeesOwed({
|
|
126
|
+
liquidity,
|
|
127
|
+
feeGrowthInsideLastX128: feeGrowthInside0Last,
|
|
128
|
+
feeGrowthInsideX128: feeGrowthInside0,
|
|
129
|
+
}),
|
|
130
|
+
amount1: uniswapV4FeesOwed({
|
|
131
|
+
liquidity,
|
|
132
|
+
feeGrowthInsideLastX128: feeGrowthInside1Last,
|
|
133
|
+
feeGrowthInsideX128: feeGrowthInside1,
|
|
134
|
+
}),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Collect a position's fees without touching its liquidity.
|
|
139
|
+
*
|
|
140
|
+
* A V4 "collect" is a zero-liquidity decrease: the pool settles the accrued
|
|
141
|
+
* fees into the position's delta, and TAKE_PAIR pays both currencies out. The
|
|
142
|
+
* minimum-out parameters are 0 because nothing is swapped — the amounts are
|
|
143
|
+
* whatever the pool has already accrued, so a floor could only make a valid
|
|
144
|
+
* claim revert.
|
|
145
|
+
*/
|
|
146
|
+
function buildCollectUniswapV4FeesTx({ positionManager, tokenId, currency0, currency1, recipient, deadline, }) {
|
|
147
|
+
const decreaseParams = (0, viem_1.encodeAbiParameters)([
|
|
148
|
+
{ type: "uint256" },
|
|
149
|
+
{ type: "uint128" },
|
|
150
|
+
{ type: "uint128" },
|
|
151
|
+
{ type: "uint128" },
|
|
152
|
+
{ type: "bytes" },
|
|
153
|
+
], [tokenId, 0n, 0n, 0n, "0x"]);
|
|
154
|
+
const takeParams = (0, viem_1.encodeAbiParameters)([{ type: "address" }, { type: "address" }, { type: "address" }], [currency0, currency1, recipient]);
|
|
155
|
+
const actions = (0, viem_1.encodePacked)(["uint8", "uint8"], [ACTION_DECREASE_LIQUIDITY, ACTION_TAKE_PAIR]);
|
|
156
|
+
const unlockData = (0, viem_1.encodeAbiParameters)([{ type: "bytes" }, { type: "bytes[]" }], [actions, [decreaseParams, takeParams]]);
|
|
157
|
+
return {
|
|
158
|
+
to: positionManager,
|
|
159
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
160
|
+
abi: POSITION_MANAGER_ABI,
|
|
161
|
+
functionName: "modifyLiquidities",
|
|
162
|
+
args: [unlockData, deadline],
|
|
163
|
+
}),
|
|
164
|
+
value: 0n,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=uniswapV4Fees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswapV4Fees.js","sourceRoot":"","sources":["../../../src/v6/uniswapV4Fees.ts"],"names":[],"mappings":";;AAqEA,kDAsBC;AAWD,8CAYC;AAmBD,8DA0EC;AAiBD,kEA+CC;AA/QD,+BAQc;AACd,uEAA4E;AAG5E,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACtC,MAAM,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC;AAExB,MAAM,cAAc,GAAG;IACrB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,oBAAoB;QAC1B,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,WAAW,EAAE,I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,CAAC,EAC/D,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAClC,CAAC;IACF,MAAM,OAAO,GAAG,IAAA,mBAAY,EAC1B,CAAC,OAAO,EAAE,OAAO,CAAC,EAClB,CAAC,yBAAyB,EAAE,gBAAgB,CAAC,CAC9C,CAAC;IACF,MAAM,UAAU,GAAG,IAAA,0BAAmB,EACpC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EACxC,CAAC,OAAO,EAAE,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CACxC,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,eAAe;QACnB,IAAI,EAAE,IAAA,yBAAkB,EAAC;YACvB,GAAG,EAAE,oBAAoB;YACzB,YAAY,EAAE,mBAAmB;YACjC,IAAI,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;SAC7B,CAAC;QACF,KAAK,EAAE,EAAE;KACV,CAAC;AACJ,CAAC"}
|
package/dist/esm/v6/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./cashOut.js";
|
|
|
15
15
|
export * from "./nft.js";
|
|
16
16
|
export * from "./tokens.js";
|
|
17
17
|
export * from "./uniswapV4.js";
|
|
18
|
+
export * from "./uniswapV4Fees.js";
|
|
18
19
|
export * from "./permissions.js";
|
|
19
20
|
export * from "./suckers.js";
|
|
20
21
|
export * from "./loans.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
package/dist/esm/v6/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./cashOut.js";
|
|
|
15
15
|
export * from "./nft.js";
|
|
16
16
|
export * from "./tokens.js";
|
|
17
17
|
export * from "./uniswapV4.js";
|
|
18
|
+
export * from "./uniswapV4Fees.js";
|
|
18
19
|
export * from "./permissions.js";
|
|
19
20
|
export * from "./suckers.js";
|
|
20
21
|
export * from "./loans.js";
|
package/dist/esm/v6/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v6/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
|
@@ -8,6 +8,12 @@ export declare const UNISWAP_V4_POSITION_MANAGER_ADDRESSES: Readonly<Partial<Rec
|
|
|
8
8
|
export declare const UNISWAP_V4_QUOTER_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
9
9
|
/** Canonical Universal Router deployments which support V4 swaps. */
|
|
10
10
|
export declare const UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
11
|
+
/**
|
|
12
|
+
* Canonical StateView deployments — the periphery lens over PoolManager's
|
|
13
|
+
* `extsload` storage. Each address was verified by calling `poolManager()` and
|
|
14
|
+
* matching it against {@link UNISWAP_V4_POOL_MANAGER_ADDRESSES} for the chain.
|
|
15
|
+
*/
|
|
16
|
+
export declare const UNISWAP_V4_STATE_VIEW_ADDRESSES: Readonly<Partial<Record<JBChainId, Address>>>;
|
|
11
17
|
/** Permit2 is deployed at the same address on supported EVM chains. */
|
|
12
18
|
export declare const UNISWAP_PERMIT2_ADDRESS: Address;
|
|
13
19
|
/** Resolve the supported V4 surface for a chain without guessing addresses. */
|
|
@@ -16,6 +22,7 @@ export declare function uniswapV4Deployment(chainId: number): {
|
|
|
16
22
|
positionManager: Address | null;
|
|
17
23
|
quoter: Address | null;
|
|
18
24
|
universalRouter: Address | null;
|
|
25
|
+
stateView: Address | null;
|
|
19
26
|
permit2: Address;
|
|
20
27
|
} | null;
|
|
21
28
|
//# sourceMappingURL=uniswapV4Deployments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswapV4Deployments.d.ts","sourceRoot":"","sources":["../../../src/v6/uniswapV4Deployments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,6DAA6D;AAC7D,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CACtD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC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Q,CAChD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,qCAAqC,EAAE,QAAQ,CAC1D,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAE,QAAQ,CACpD,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CASpC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,EAAE,OACQ,CAAC;AAE/C,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,eAAe,EAAE,OAAO,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB,GAAG,IAAI,CAmCP"}
|
|
@@ -38,6 +38,20 @@ export const UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES = {
|
|
|
38
38
|
421614: "0xefd1d4bd4cf1e86da286bb4cb1b8bced9c10ba47",
|
|
39
39
|
11155111: "0x3A9D48AB9751398BbFa63ad67599Bb04e4BdF98b",
|
|
40
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Canonical StateView deployments — the periphery lens over PoolManager's
|
|
43
|
+
* `extsload` storage. Each address was verified by calling `poolManager()` and
|
|
44
|
+
* matching it against {@link UNISWAP_V4_POOL_MANAGER_ADDRESSES} for the chain.
|
|
45
|
+
*/
|
|
46
|
+
export const UNISWAP_V4_STATE_VIEW_ADDRESSES = {
|
|
47
|
+
1: "0x7ffe42c4a5deea5b0fec41c94c136cf115597227",
|
|
48
|
+
10: "0xc18a3169788f4f75a170290584eca6395c75ecdb",
|
|
49
|
+
8453: "0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",
|
|
50
|
+
42161: "0x76fd297e2d437cd7f76d50f01afe6160f86e9990",
|
|
51
|
+
84532: "0x571291b572ed32ce6751a2cb2486ebee8defb9b4",
|
|
52
|
+
421614: "0x9d467fa9062b6e9b1a46e26007ad82db116c67cb",
|
|
53
|
+
11155111: "0xe1dd9c3fa50edb962e442f60dfbc432e24537e4c",
|
|
54
|
+
};
|
|
41
55
|
/** Permit2 is deployed at the same address on supported EVM chains. */
|
|
42
56
|
export const UNISWAP_PERMIT2_ADDRESS = "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
43
57
|
/** Resolve the supported V4 surface for a chain without guessing addresses. */
|
|
@@ -50,6 +64,7 @@ export function uniswapV4Deployment(chainId) {
|
|
|
50
64
|
positionManager: UNISWAP_V4_POSITION_MANAGER_ADDRESSES[chainId] ?? null,
|
|
51
65
|
quoter: UNISWAP_V4_QUOTER_ADDRESSES[chainId] ?? null,
|
|
52
66
|
universalRouter: UNISWAP_V4_UNIVERSAL_ROUTER_ADDRESSES[chainId] ?? null,
|
|
67
|
+
stateView: UNISWAP_V4_STATE_VIEW_ADDRESSES[chainId] ?? null,
|
|
53
68
|
permit2: UNISWAP_PERMIT2_ADDRESS,
|
|
54
69
|
};
|
|
55
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniswapV4Deployments.js","sourceRoot":"","sources":["../../../src/v6/uniswapV4Deployments.ts"],"names":[],"mappings":"AAGA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iCAAiC,GAE1C;IACF,CAAC,EAAE,4CAA4C;IAC/C,EAAE,EAAE,4CAA4C;IAChD,IAAI,EAAE,4CAA4C;IAClD,KAAK,EAAE,4CAA4C;IACnD,KAAK,EAAE,4CAA4C;IACnD,MAAM,EAAE,4CAA4C;IACpD,QAAQ,EAAE,4CAA4C;CACvD,CAAC;AAEF,iEAAiE;A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QACL,WAAW;QACX,eAAe,EAEX,qCAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,MAAM,EAEF,2BAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,eAAe,EAEX,qCAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,SAAS,EAEL,+BAGD,CAAC,OAAO,CAAC,IAAI,IAAI;QACpB,OAAO,EAAE,uBAAuB;KACjC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type Address, type Hex, type PublicClient } from "viem";
|
|
2
|
+
import type { JBChainId } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The PoolManager position key: `keccak256(abi.encodePacked(owner, tickLower,
|
|
5
|
+
* tickUpper, salt))`. For a PositionManager-held position the owner is the
|
|
6
|
+
* PositionManager and the salt is the position's token id.
|
|
7
|
+
*/
|
|
8
|
+
export declare function uniswapV4PositionId({ owner, tickLower, tickUpper, salt, }: {
|
|
9
|
+
owner: Address;
|
|
10
|
+
tickLower: number;
|
|
11
|
+
tickUpper: number;
|
|
12
|
+
salt: bigint;
|
|
13
|
+
}): Hex;
|
|
14
|
+
/**
|
|
15
|
+
* Fees a position has accrued since its last checkpoint, from the pool's fee
|
|
16
|
+
* growth accumulators.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Fee growth accumulators are unchecked `uint256` in the pool and are
|
|
19
|
+
* expected to wrap; the difference is therefore taken modulo 2^256, exactly as
|
|
20
|
+
* Solidity computes it. A checked subtraction would read a wrapped accumulator
|
|
21
|
+
* as a negative (or enormous) balance.
|
|
22
|
+
*/
|
|
23
|
+
export declare function uniswapV4FeesOwed({ liquidity, feeGrowthInsideLastX128, feeGrowthInsideX128, }: {
|
|
24
|
+
liquidity: bigint;
|
|
25
|
+
feeGrowthInsideLastX128: bigint;
|
|
26
|
+
feeGrowthInsideX128: bigint;
|
|
27
|
+
}): bigint;
|
|
28
|
+
export interface UniswapV4PositionFees {
|
|
29
|
+
/** Unclaimed currency0 fees, in currency0's own decimals. */
|
|
30
|
+
amount0: bigint;
|
|
31
|
+
/** Unclaimed currency1 fees, in currency1's own decimals. */
|
|
32
|
+
amount1: bigint;
|
|
33
|
+
/** The position's live liquidity, as the pool records it. */
|
|
34
|
+
liquidity: bigint;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Read a position's unclaimed fees through StateView.
|
|
38
|
+
*
|
|
39
|
+
* This is the fees CLAIMABLE NOW, not the position's lifetime earnings: the
|
|
40
|
+
* pool rewrites `feeGrowthInsideLast` on every collect, so anything already
|
|
41
|
+
* taken is no longer visible here. Reconstructing lifetime earnings means
|
|
42
|
+
* replaying the position's `ModifyLiquidity` events against archive state.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readUniswapV4PositionFees(client: Pick<PublicClient, "readContract">, { chainId, stateView, poolId, positionManager, tokenId, tickLower, tickUpper, }: {
|
|
45
|
+
chainId?: JBChainId;
|
|
46
|
+
/** Overrides the chain's canonical StateView deployment. */
|
|
47
|
+
stateView?: Address;
|
|
48
|
+
poolId: Hex;
|
|
49
|
+
positionManager: Address;
|
|
50
|
+
tokenId: bigint;
|
|
51
|
+
tickLower: number;
|
|
52
|
+
tickUpper: number;
|
|
53
|
+
}): Promise<UniswapV4PositionFees>;
|
|
54
|
+
export interface UniswapV4CollectFeesTxRequest {
|
|
55
|
+
to: Address;
|
|
56
|
+
data: Hex;
|
|
57
|
+
value: bigint;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Collect a position's fees without touching its liquidity.
|
|
61
|
+
*
|
|
62
|
+
* A V4 "collect" is a zero-liquidity decrease: the pool settles the accrued
|
|
63
|
+
* fees into the position's delta, and TAKE_PAIR pays both currencies out. The
|
|
64
|
+
* minimum-out parameters are 0 because nothing is swapped — the amounts are
|
|
65
|
+
* whatever the pool has already accrued, so a floor could only make a valid
|
|
66
|
+
* claim revert.
|
|
67
|
+
*/
|
|
68
|
+
export declare function buildCollectUniswapV4FeesTx({ positionManager, tokenId, currency0, currency1, recipient, deadline, }: {
|
|
69
|
+
positionManager: Address;
|
|
70
|
+
tokenId: bigint;
|
|
71
|
+
currency0: Address;
|
|
72
|
+
currency1: Address;
|
|
73
|
+
recipient: Address;
|
|
74
|
+
deadline: bigint;
|
|
75
|
+
}): UniswapV4CollectFeesTxRequest;
|
|
76
|
+
//# sourceMappingURL=uniswapV4Fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswapV4Fees.d.ts","sourceRoot":"","sources":["../../../src/v6/uniswapV4Fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAsD7C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,SAAS,EACT,SAAS,EACT,IAAI,GACL,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,GAAG,CAYN;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,uBAAuB,EACvB,mBAAmB,GACpB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB,EAAE,MAAM,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;CAC7B,GAAG,MAAM,CAIT;AAED,MAAM,WAAW,qBAAqB;IACpC,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EAC1C,EACE,OAAO,EACP,SAAS,EACT,MAAM,EACN,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,GACV,EAAE;IACD,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GACA,OAAO,CAAC,qBAAqB,CAAC,CAsDhC;AAED,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,GACT,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,6BAA6B,CAiChC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { encodeAbiParameters, encodeFunctionData, encodePacked, keccak256, } from "viem";
|
|
2
|
+
import { UNISWAP_V4_STATE_VIEW_ADDRESSES } from "./uniswapV4Deployments.js";
|
|
3
|
+
const UINT256_MAX = (1n << 256n) - 1n;
|
|
4
|
+
const Q128 = 1n << 128n;
|
|
5
|
+
const STATE_VIEW_ABI = [
|
|
6
|
+
{
|
|
7
|
+
type: "function",
|
|
8
|
+
name: "getFeeGrowthInside",
|
|
9
|
+
stateMutability: "view",
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: "poolId", type: "bytes32" },
|
|
12
|
+
{ name: "tickLower", type: "int24" },
|
|
13
|
+
{ name: "tickUpper", type: "int24" },
|
|
14
|
+
],
|
|
15
|
+
outputs: [
|
|
16
|
+
{ name: "feeGrowthInside0X128", type: "uint256" },
|
|
17
|
+
{ name: "feeGrowthInside1X128", type: "uint256" },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "function",
|
|
22
|
+
name: "getPositionInfo",
|
|
23
|
+
stateMutability: "view",
|
|
24
|
+
inputs: [
|
|
25
|
+
{ name: "poolId", type: "bytes32" },
|
|
26
|
+
{ name: "positionId", type: "bytes32" },
|
|
27
|
+
],
|
|
28
|
+
outputs: [
|
|
29
|
+
{ name: "liquidity", type: "uint128" },
|
|
30
|
+
{ name: "feeGrowthInside0LastX128", type: "uint256" },
|
|
31
|
+
{ name: "feeGrowthInside1LastX128", type: "uint256" },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
const POSITION_MANAGER_ABI = [
|
|
36
|
+
{
|
|
37
|
+
type: "function",
|
|
38
|
+
name: "modifyLiquidities",
|
|
39
|
+
stateMutability: "payable",
|
|
40
|
+
inputs: [
|
|
41
|
+
{ name: "unlockData", type: "bytes" },
|
|
42
|
+
{ name: "deadline", type: "uint256" },
|
|
43
|
+
],
|
|
44
|
+
outputs: [],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
/** v4-periphery `Actions.DECREASE_LIQUIDITY`. */
|
|
48
|
+
const ACTION_DECREASE_LIQUIDITY = 0x01;
|
|
49
|
+
/** v4-periphery `Actions.TAKE_PAIR`. */
|
|
50
|
+
const ACTION_TAKE_PAIR = 0x11;
|
|
51
|
+
/**
|
|
52
|
+
* The PoolManager position key: `keccak256(abi.encodePacked(owner, tickLower,
|
|
53
|
+
* tickUpper, salt))`. For a PositionManager-held position the owner is the
|
|
54
|
+
* PositionManager and the salt is the position's token id.
|
|
55
|
+
*/
|
|
56
|
+
export function uniswapV4PositionId({ owner, tickLower, tickUpper, salt, }) {
|
|
57
|
+
return keccak256(encodePacked(["address", "int24", "int24", "bytes32"], [
|
|
58
|
+
owner,
|
|
59
|
+
tickLower,
|
|
60
|
+
tickUpper,
|
|
61
|
+
`0x${salt.toString(16).padStart(64, "0")}`,
|
|
62
|
+
]));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Fees a position has accrued since its last checkpoint, from the pool's fee
|
|
66
|
+
* growth accumulators.
|
|
67
|
+
*
|
|
68
|
+
* @remarks Fee growth accumulators are unchecked `uint256` in the pool and are
|
|
69
|
+
* expected to wrap; the difference is therefore taken modulo 2^256, exactly as
|
|
70
|
+
* Solidity computes it. A checked subtraction would read a wrapped accumulator
|
|
71
|
+
* as a negative (or enormous) balance.
|
|
72
|
+
*/
|
|
73
|
+
export function uniswapV4FeesOwed({ liquidity, feeGrowthInsideLastX128, feeGrowthInsideX128, }) {
|
|
74
|
+
if (liquidity <= 0n)
|
|
75
|
+
return 0n;
|
|
76
|
+
const delta = (feeGrowthInsideX128 - feeGrowthInsideLastX128) & UINT256_MAX;
|
|
77
|
+
return (delta * liquidity) / Q128;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Read a position's unclaimed fees through StateView.
|
|
81
|
+
*
|
|
82
|
+
* This is the fees CLAIMABLE NOW, not the position's lifetime earnings: the
|
|
83
|
+
* pool rewrites `feeGrowthInsideLast` on every collect, so anything already
|
|
84
|
+
* taken is no longer visible here. Reconstructing lifetime earnings means
|
|
85
|
+
* replaying the position's `ModifyLiquidity` events against archive state.
|
|
86
|
+
*/
|
|
87
|
+
export async function readUniswapV4PositionFees(client, { chainId, stateView, poolId, positionManager, tokenId, tickLower, tickUpper, }) {
|
|
88
|
+
const lens = stateView ??
|
|
89
|
+
(chainId
|
|
90
|
+
? UNISWAP_V4_STATE_VIEW_ADDRESSES[chainId]
|
|
91
|
+
: undefined);
|
|
92
|
+
if (!lens) {
|
|
93
|
+
throw new Error(`No Uniswap V4 StateView deployment for chain ${chainId ?? "unknown"}.`);
|
|
94
|
+
}
|
|
95
|
+
const positionId = uniswapV4PositionId({
|
|
96
|
+
owner: positionManager,
|
|
97
|
+
tickLower,
|
|
98
|
+
tickUpper,
|
|
99
|
+
salt: tokenId,
|
|
100
|
+
});
|
|
101
|
+
const [position, inside] = await Promise.all([
|
|
102
|
+
client.readContract({
|
|
103
|
+
address: lens,
|
|
104
|
+
abi: STATE_VIEW_ABI,
|
|
105
|
+
functionName: "getPositionInfo",
|
|
106
|
+
args: [poolId, positionId],
|
|
107
|
+
}),
|
|
108
|
+
client.readContract({
|
|
109
|
+
address: lens,
|
|
110
|
+
abi: STATE_VIEW_ABI,
|
|
111
|
+
functionName: "getFeeGrowthInside",
|
|
112
|
+
args: [poolId, tickLower, tickUpper],
|
|
113
|
+
}),
|
|
114
|
+
]);
|
|
115
|
+
const [liquidity, feeGrowthInside0Last, feeGrowthInside1Last] = position;
|
|
116
|
+
const [feeGrowthInside0, feeGrowthInside1] = inside;
|
|
117
|
+
return {
|
|
118
|
+
liquidity,
|
|
119
|
+
amount0: uniswapV4FeesOwed({
|
|
120
|
+
liquidity,
|
|
121
|
+
feeGrowthInsideLastX128: feeGrowthInside0Last,
|
|
122
|
+
feeGrowthInsideX128: feeGrowthInside0,
|
|
123
|
+
}),
|
|
124
|
+
amount1: uniswapV4FeesOwed({
|
|
125
|
+
liquidity,
|
|
126
|
+
feeGrowthInsideLastX128: feeGrowthInside1Last,
|
|
127
|
+
feeGrowthInsideX128: feeGrowthInside1,
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Collect a position's fees without touching its liquidity.
|
|
133
|
+
*
|
|
134
|
+
* A V4 "collect" is a zero-liquidity decrease: the pool settles the accrued
|
|
135
|
+
* fees into the position's delta, and TAKE_PAIR pays both currencies out. The
|
|
136
|
+
* minimum-out parameters are 0 because nothing is swapped — the amounts are
|
|
137
|
+
* whatever the pool has already accrued, so a floor could only make a valid
|
|
138
|
+
* claim revert.
|
|
139
|
+
*/
|
|
140
|
+
export function buildCollectUniswapV4FeesTx({ positionManager, tokenId, currency0, currency1, recipient, deadline, }) {
|
|
141
|
+
const decreaseParams = encodeAbiParameters([
|
|
142
|
+
{ type: "uint256" },
|
|
143
|
+
{ type: "uint128" },
|
|
144
|
+
{ type: "uint128" },
|
|
145
|
+
{ type: "uint128" },
|
|
146
|
+
{ type: "bytes" },
|
|
147
|
+
], [tokenId, 0n, 0n, 0n, "0x"]);
|
|
148
|
+
const takeParams = encodeAbiParameters([{ type: "address" }, { type: "address" }, { type: "address" }], [currency0, currency1, recipient]);
|
|
149
|
+
const actions = encodePacked(["uint8", "uint8"], [ACTION_DECREASE_LIQUIDITY, ACTION_TAKE_PAIR]);
|
|
150
|
+
const unlockData = encodeAbiParameters([{ type: "bytes" }, { type: "bytes[]" }], [actions, [decreaseParams, takeParams]]);
|
|
151
|
+
return {
|
|
152
|
+
to: positionManager,
|
|
153
|
+
data: encodeFunctionData({
|
|
154
|
+
abi: POSITION_MANAGER_ABI,
|
|
155
|
+
functionName: "modifyLiquidities",
|
|
156
|
+
args: [unlockData, deadline],
|
|
157
|
+
}),
|
|
158
|
+
value: 0n,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=uniswapV4Fees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniswapV4Fees.js","sourceRoot":"","sources":["../../../src/v6/uniswapV4Fees.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EACZ,SAAS,GAIV,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAG5E,MAAM,WAAW,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACtC,MAAM,IAAI,GAAG,EAAE,IAAI,IAAI,CAAC;AAExB,MA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