@bananapus/nana-sdk-core 2.41.3 → 3.0.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/review/decode.js +1 -1
- package/dist/cjs/review/decode.js.map +1 -1
- package/dist/cjs/v6/index.d.ts +0 -1
- package/dist/cjs/v6/index.d.ts.map +1 -1
- package/dist/cjs/v6/index.js +0 -1
- package/dist/cjs/v6/index.js.map +1 -1
- package/dist/cjs/v6/pay.d.ts +89 -35
- package/dist/cjs/v6/pay.d.ts.map +1 -1
- package/dist/cjs/v6/pay.js +285 -41
- package/dist/cjs/v6/pay.js.map +1 -1
- package/dist/esm/review/decode.js +1 -1
- package/dist/esm/review/decode.js.map +1 -1
- package/dist/esm/v6/index.d.ts +0 -1
- package/dist/esm/v6/index.d.ts.map +1 -1
- package/dist/esm/v6/index.js +0 -1
- package/dist/esm/v6/index.js.map +1 -1
- package/dist/esm/v6/pay.d.ts +89 -35
- package/dist/esm/v6/pay.d.ts.map +1 -1
- package/dist/esm/v6/pay.js +285 -43
- package/dist/esm/v6/pay.js.map +1 -1
- package/package.json +1 -6
- package/dist/cjs/v6/directPay.d.ts +0 -69
- package/dist/cjs/v6/directPay.d.ts.map +0 -1
- package/dist/cjs/v6/directPay.js +0 -391
- package/dist/cjs/v6/directPay.js.map +0 -1
- package/dist/esm/v6/directPay.d.ts +0 -69
- package/dist/esm/v6/directPay.d.ts.map +0 -1
- package/dist/esm/v6/directPay.js +0 -385
- package/dist/esm/v6/directPay.js.map +0 -1
package/dist/esm/v6/pay.d.ts
CHANGED
|
@@ -59,39 +59,16 @@ export interface PayPreview {
|
|
|
59
59
|
*/
|
|
60
60
|
reservedTokenCount: bigint;
|
|
61
61
|
}
|
|
62
|
-
export type PaySettlement = "issuance" | "swap";
|
|
63
|
-
export interface PayRouteCandidate extends PayPreview {
|
|
64
|
-
kind: "pay";
|
|
65
|
-
settlement: PaySettlement;
|
|
66
|
-
}
|
|
67
|
-
export interface DirectSwapRouteCandidate extends PayPreview {
|
|
68
|
-
kind: "direct-swap";
|
|
69
|
-
settlement: "swap";
|
|
70
|
-
quotedTokenCount: bigint;
|
|
71
|
-
}
|
|
72
|
-
export type BestPayRoute = PayRouteCandidate | DirectSwapRouteCandidate;
|
|
73
|
-
/**
|
|
74
|
-
* Pick the executable route which guarantees the beneficiary the most tokens.
|
|
75
|
-
*
|
|
76
|
-
* A direct pool swap bypasses the terminal, so its reserved token count is always
|
|
77
|
-
* zero. Its quote is reduced by `slippageBps` before comparison: a route is only
|
|
78
|
-
* selected when its on-chain minimum beats the terminal preview, not merely when
|
|
79
|
-
* its optimistic quote does.
|
|
80
|
-
*/
|
|
81
|
-
export declare function chooseBestPayRoute({ pay, paySettlement, directSwapQuote, slippageBps, }: {
|
|
82
|
-
pay: PayPreview;
|
|
83
|
-
paySettlement: PaySettlement;
|
|
84
|
-
directSwapQuote?: bigint | null;
|
|
85
|
-
slippageBps?: bigint;
|
|
86
|
-
}): BestPayRoute;
|
|
87
62
|
/**
|
|
88
|
-
* Preview the project tokens
|
|
89
|
-
* `previewPayFor(projectId, token, amount, beneficiary, metadata)`.
|
|
63
|
+
* Preview the project tokens a payment puts in the beneficiary's hands, via the
|
|
64
|
+
* terminal's `previewPayFor(projectId, token, amount, beneficiary, metadata)`.
|
|
90
65
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
66
|
+
* When the buyback hook wins the route, the terminal mints nothing itself and
|
|
67
|
+
* reports zero; the hook's pay specification carries the swap quote. This folds
|
|
68
|
+
* it in with the router terminal's scoring rule (see
|
|
69
|
+
* {@link effectivePayPreview}), for the hook the buyback registry resolves for
|
|
70
|
+
* the project, 1.4 or 1.1.1. The swap figure ignores pool fees and price
|
|
71
|
+
* impact, so use {@link prepareUserPay} for a payment's minimum.
|
|
95
72
|
*
|
|
96
73
|
* @param client A viem public client on the given chain.
|
|
97
74
|
* @param args.chainId The chain to preview on.
|
|
@@ -100,19 +77,71 @@ export declare function chooseBestPayRoute({ pay, paySettlement, directSwapQuote
|
|
|
100
77
|
* @param args.token The token being paid.
|
|
101
78
|
* @param args.amount The amount being paid, as a fixed point number with the token's
|
|
102
79
|
* decimals.
|
|
103
|
-
* @param args.beneficiary The address that would receive the
|
|
80
|
+
* @param args.beneficiary The address that would receive the project tokens.
|
|
104
81
|
* @param args.metadata Hook metadata. Defaults to "0x".
|
|
105
82
|
* @returns The previewed token counts.
|
|
106
83
|
*/
|
|
107
|
-
export declare function previewPay(client: PublicClient,
|
|
84
|
+
export declare function previewPay(client: PublicClient, args: PayArgs & {
|
|
85
|
+
metadata?: Hex;
|
|
86
|
+
}): Promise<PayPreview>;
|
|
87
|
+
interface PayArgs {
|
|
108
88
|
chainId: JBChainId;
|
|
109
89
|
terminal: Address;
|
|
110
90
|
projectId: bigint;
|
|
111
91
|
token: Address;
|
|
112
92
|
amount: bigint;
|
|
113
93
|
beneficiary: Address;
|
|
114
|
-
|
|
115
|
-
|
|
94
|
+
}
|
|
95
|
+
type PayHookSpecification = {
|
|
96
|
+
hook: Address;
|
|
97
|
+
noop: boolean;
|
|
98
|
+
metadata: Hex;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Fold the buyback hook's pay specification into a terminal preview, with the
|
|
102
|
+
* rule `JBPayRouteResolver._effectivePreviewPayTokenCounts` scores routes by.
|
|
103
|
+
* The swap leg uses the hook's raw quote: the TWAP price times the amount, with
|
|
104
|
+
* no pool fee or price impact. It is a ranking figure, not a minimum.
|
|
105
|
+
*/
|
|
106
|
+
export declare function effectivePayPreview({ buybackHook, beneficiaryTokenCount, reservedTokenCount, weight, reservedPercent, hookSpecifications, }: {
|
|
107
|
+
buybackHook: Address | null;
|
|
108
|
+
beneficiaryTokenCount: bigint;
|
|
109
|
+
reservedTokenCount: bigint;
|
|
110
|
+
weight: bigint;
|
|
111
|
+
/** The ruleset's reserved percent, for 1.1.1 specs. */
|
|
112
|
+
reservedPercent?: bigint;
|
|
113
|
+
hookSpecifications: readonly PayHookSpecification[];
|
|
114
|
+
}): PayPreview;
|
|
115
|
+
/** A pay card's whole payment: what to send, what to show, what to require. */
|
|
116
|
+
export interface PreparedUserPay {
|
|
117
|
+
metadata: Hex;
|
|
118
|
+
preview: PayPreview;
|
|
119
|
+
minReturnedTokens: bigint;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Prepare a person's payment with {@link buildUserPayMetadata}: preview it,
|
|
123
|
+
* and set the minimum the terminal enforces on the beneficiary's balance.
|
|
124
|
+
*
|
|
125
|
+
* When the project's buyback hook honors `skipSplits` and its pool is in the
|
|
126
|
+
* paid token, this quotes that pool (fee and price impact included) and sends
|
|
127
|
+
* the slippage-floored quote as an explicit minimum. The hook then swaps
|
|
128
|
+
* whenever the pool beats the payer's share of a mint, and reverts below the
|
|
129
|
+
* floor. Without it the hook routes by its TWAP floor, which reaches zero on
|
|
130
|
+
* large buys against a thin pool and sends them to minting even when the pool
|
|
131
|
+
* pays far more.
|
|
132
|
+
*
|
|
133
|
+
* Otherwise (no pool, hook 1.1.1, a router converting the token first, or a
|
|
134
|
+
* failed quote) the hook routes by TWAP. The minimum is then the payer's mint
|
|
135
|
+
* entitlement when the hook would swap, since the hook never settles below it,
|
|
136
|
+
* and the terminal's own issuance when it would not.
|
|
137
|
+
*
|
|
138
|
+
* @param args.slippageBps Tolerance on the pool quote and on the fallback
|
|
139
|
+
* minimum. Defaults to 100 (1%).
|
|
140
|
+
*/
|
|
141
|
+
export declare function prepareUserPay(client: PublicClient, { tiers, slippageBps, ...args }: PayArgs & {
|
|
142
|
+
tiers?: UserPayTiers;
|
|
143
|
+
slippageBps?: bigint;
|
|
144
|
+
}): Promise<PreparedUserPay>;
|
|
116
145
|
/**
|
|
117
146
|
* Build pay metadata instructing a project's JB721 tiers hook to mint specific tiers.
|
|
118
147
|
*
|
|
@@ -152,4 +181,29 @@ export declare function buildBuybackPayMetadata({ hook, amountToSwapWith, minimu
|
|
|
152
181
|
minimumSwapAmountOut: bigint;
|
|
153
182
|
skipSplits?: boolean;
|
|
154
183
|
}): Hex;
|
|
184
|
+
/** The 721 tiers a payment buys. */
|
|
185
|
+
export interface UserPayTiers {
|
|
186
|
+
metadataIdTarget: Address;
|
|
187
|
+
tierIdsToMint: bigint[];
|
|
188
|
+
allowOverspending?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The pay metadata a person's pay card sends: the buyback registry's quote
|
|
192
|
+
* `(0, minimumSwapAmountOut, skipSplits=true)`, plus the 721 tiers when the
|
|
193
|
+
* payment buys NFTs. Prefer {@link prepareUserPay}, which picks the minimum.
|
|
194
|
+
*
|
|
195
|
+
* The registry rekeys its quote to the project's resolved hook. On buyback 1.4
|
|
196
|
+
* the hook buys from the pool only when that gives the payer more than their
|
|
197
|
+
* share of a mint, and hands the swapped tokens over without the reserved
|
|
198
|
+
* split. Minting still goes through the split. A zero swap amount swaps the
|
|
199
|
+
* whole payment. A zero minimum routes by the hook's TWAP floor; a nonzero one
|
|
200
|
+
* replaces it and reverts below it. The terminal's `minReturnedTokens` checks
|
|
201
|
+
* the beneficiary's balance change, which counts the swapped tokens.
|
|
202
|
+
*/
|
|
203
|
+
export declare function buildUserPayMetadata({ chainId, tiers, minimumSwapAmountOut, }: {
|
|
204
|
+
chainId: JBChainId;
|
|
205
|
+
tiers?: UserPayTiers;
|
|
206
|
+
minimumSwapAmountOut?: bigint;
|
|
207
|
+
}): Hex;
|
|
208
|
+
export {};
|
|
155
209
|
//# sourceMappingURL=pay.d.ts.map
|
package/dist/esm/v6/pay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/v6/pay.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"pay.d.ts","sourceRoot":"","sources":["../../../src/v6/pay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,G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BAAmB,CAAC,EAClC,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,iBAA8C,GAC/C,EAAE;IACD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,GAAG,GAAG,CAeN;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,IAAI,EACJ,gBAAgB,EAChB,oBAAoB,EACpB,UAAkB,GACnB,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,GAAG,CAUN;AAED,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,KAAK,EACL,oBAAyB,GAC1B,EAAE;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,GAAG,CA0BN"}
|
package/dist/esm/v6/pay.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { encodeAbiParameters } from "viem";
|
|
2
|
-
import { DEFAULT_ALLOW_OVERSPENDING, NATIVE_TOKEN } from "../constants.js";
|
|
3
|
-
import { jbMultiTerminalAbi } from "../generated/juicebox.js";
|
|
1
|
+
import { encodeAbiParameters, zeroAddress, } from "viem";
|
|
2
|
+
import { DEFAULT_ALLOW_OVERSPENDING, MAX_RESERVED_PERCENT, NATIVE_TOKEN, } from "../constants.js";
|
|
3
|
+
import { jbBuybackHookRegistryAbi, jbMultiTerminalAbi, } from "../generated/juicebox.js";
|
|
4
|
+
import { getJBContractAddress } from "../utils/contracts.js";
|
|
4
5
|
import { createHookMetadata, hookMetadataId } from "../utils/hook.js";
|
|
6
|
+
import { slippageFloor } from "./cashOut.js";
|
|
7
|
+
import { quoteUniswapV4ExactInputSingle, uniswapV4PoolId, } from "./uniswapV4.js";
|
|
5
8
|
/**
|
|
6
9
|
* Build a `pay(projectId, token, amount, beneficiary, minReturnedTokens, memo,
|
|
7
10
|
* metadata)` transaction request for a v6 terminal.
|
|
@@ -44,43 +47,15 @@ export function buildPayTx({ chainId, terminal, projectId, token, amount, benefi
|
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
|
-
*
|
|
50
|
+
* Preview the project tokens a payment puts in the beneficiary's hands, via the
|
|
51
|
+
* terminal's `previewPayFor(projectId, token, amount, beneficiary, metadata)`.
|
|
48
52
|
*
|
|
49
|
-
*
|
|
50
|
-
* zero
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (slippageBps < 0n || slippageBps >= 10000n) {
|
|
56
|
-
throw new Error("slippageBps must be between 0 and 9,999.");
|
|
57
|
-
}
|
|
58
|
-
const payRoute = {
|
|
59
|
-
kind: "pay",
|
|
60
|
-
settlement: paySettlement,
|
|
61
|
-
...pay,
|
|
62
|
-
};
|
|
63
|
-
if (!directSwapQuote || directSwapQuote <= 0n)
|
|
64
|
-
return payRoute;
|
|
65
|
-
const minimum = (directSwapQuote * (10000n - slippageBps)) / 10000n;
|
|
66
|
-
if (minimum <= pay.beneficiaryTokenCount)
|
|
67
|
-
return payRoute;
|
|
68
|
-
return {
|
|
69
|
-
kind: "direct-swap",
|
|
70
|
-
settlement: "swap",
|
|
71
|
-
quotedTokenCount: directSwapQuote,
|
|
72
|
-
beneficiaryTokenCount: minimum,
|
|
73
|
-
reservedTokenCount: 0n,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Preview the project tokens minted by a payment, via the terminal's
|
|
78
|
-
* `previewPayFor(projectId, token, amount, beneficiary, metadata)`.
|
|
79
|
-
*
|
|
80
|
-
* The terminal's `previewPayFor` is used (rather than
|
|
81
|
-
* `JBTerminalStore.previewPayFrom`) because it takes exactly the data a `pay` caller
|
|
82
|
-
* already has — the store variant additionally requires a full `JBTokenAmount` tuple
|
|
83
|
-
* (token, decimals, currency, value), forcing an extra accounting-context lookup.
|
|
53
|
+
* When the buyback hook wins the route, the terminal mints nothing itself and
|
|
54
|
+
* reports zero; the hook's pay specification carries the swap quote. This folds
|
|
55
|
+
* it in with the router terminal's scoring rule (see
|
|
56
|
+
* {@link effectivePayPreview}), for the hook the buyback registry resolves for
|
|
57
|
+
* the project, 1.4 or 1.1.1. The swap figure ignores pool fees and price
|
|
58
|
+
* impact, so use {@link prepareUserPay} for a payment's minimum.
|
|
84
59
|
*
|
|
85
60
|
* @param client A viem public client on the given chain.
|
|
86
61
|
* @param args.chainId The chain to preview on.
|
|
@@ -89,18 +64,256 @@ export function chooseBestPayRoute({ pay, paySettlement, directSwapQuote, slippa
|
|
|
89
64
|
* @param args.token The token being paid.
|
|
90
65
|
* @param args.amount The amount being paid, as a fixed point number with the token's
|
|
91
66
|
* decimals.
|
|
92
|
-
* @param args.beneficiary The address that would receive the
|
|
67
|
+
* @param args.beneficiary The address that would receive the project tokens.
|
|
93
68
|
* @param args.metadata Hook metadata. Defaults to "0x".
|
|
94
69
|
* @returns The previewed token counts.
|
|
95
70
|
*/
|
|
96
|
-
export async function previewPay(client,
|
|
97
|
-
|
|
71
|
+
export async function previewPay(client, args) {
|
|
72
|
+
return (await readPay(client, args)).preview;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Decode a buyback pay specification: 17 words on 1.4, 15 on 1.1.1, which
|
|
76
|
+
* share the first 15. 1.1.1 has no `skipSplits` and reports no reserved
|
|
77
|
+
* percent, so the ruleset's is used.
|
|
78
|
+
*/
|
|
79
|
+
function decodeBuybackPaySpec(spec, rulesetReservedPercent) {
|
|
80
|
+
const words = (spec.metadata.length - 2) / 64;
|
|
81
|
+
if (words !== 15 && words < 17)
|
|
82
|
+
return null;
|
|
83
|
+
const word = (i) => `0x${spec.metadata.slice(2 + i * 64, 2 + (i + 1) * 64)}`;
|
|
84
|
+
const uint = (i) => BigInt(word(i));
|
|
85
|
+
return {
|
|
86
|
+
hook: spec.hook,
|
|
87
|
+
noop: spec.noop,
|
|
88
|
+
projectTokenIs0: uint(0) !== 0n,
|
|
89
|
+
amountToMintWith: uint(1),
|
|
90
|
+
minimumSwapAmountOut: uint(2),
|
|
91
|
+
tokenCountWithoutHook: uint(5),
|
|
92
|
+
weightRatio: uint(6),
|
|
93
|
+
amountToSwapWith: uint(7),
|
|
94
|
+
poolId: word(10),
|
|
95
|
+
rawSwapQuote: uint(13),
|
|
96
|
+
oracleUnseeded: uint(14) !== 0n,
|
|
97
|
+
skipSplits: words >= 17 && uint(15) !== 0n,
|
|
98
|
+
reservedPercent: words >= 17 ? uint(16) : rulesetReservedPercent,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** The controller's beneficiary share of a split mint, rounded the same way. */
|
|
102
|
+
function splitOf(tokenCount, reservedPercent) {
|
|
103
|
+
const max = BigInt(MAX_RESERVED_PERCENT);
|
|
104
|
+
const beneficiaryTokenCount = (tokenCount * (max - reservedPercent)) / max;
|
|
105
|
+
return {
|
|
106
|
+
beneficiaryTokenCount,
|
|
107
|
+
reservedTokenCount: tokenCount - beneficiaryTokenCount,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Tokens the hook's direct-mint leg issues, as the hook computes them. */
|
|
111
|
+
function directMintOf(spec, weight) {
|
|
112
|
+
return spec.amountToMintWith !== 0n && spec.weightRatio !== 0n
|
|
113
|
+
? (spec.amountToMintWith * weight) / spec.weightRatio
|
|
114
|
+
: 0n;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Fold the buyback hook's pay specification into a terminal preview, with the
|
|
118
|
+
* rule `JBPayRouteResolver._effectivePreviewPayTokenCounts` scores routes by.
|
|
119
|
+
* The swap leg uses the hook's raw quote: the TWAP price times the amount, with
|
|
120
|
+
* no pool fee or price impact. It is a ranking figure, not a minimum.
|
|
121
|
+
*/
|
|
122
|
+
export function effectivePayPreview({ buybackHook, beneficiaryTokenCount, reservedTokenCount, weight, reservedPercent = 0n, hookSpecifications, }) {
|
|
123
|
+
let best = { beneficiaryTokenCount, reservedTokenCount };
|
|
124
|
+
if (!buybackHook ||
|
|
125
|
+
beneficiaryTokenCount !== 0n ||
|
|
126
|
+
reservedTokenCount !== 0n) {
|
|
127
|
+
return best;
|
|
128
|
+
}
|
|
129
|
+
for (const spec of hookSpecifications) {
|
|
130
|
+
if (spec.noop || spec.hook.toLowerCase() !== buybackHook.toLowerCase()) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const decoded = decodeBuybackPaySpec(spec, reservedPercent);
|
|
134
|
+
if (!decoded)
|
|
135
|
+
continue;
|
|
136
|
+
const directMintTokenCount = directMintOf(decoded, weight);
|
|
137
|
+
const swapTokenCount = !decoded.oracleUnseeded &&
|
|
138
|
+
decoded.rawSwapQuote > decoded.minimumSwapAmountOut
|
|
139
|
+
? decoded.rawSwapQuote
|
|
140
|
+
: decoded.minimumSwapAmountOut;
|
|
141
|
+
const candidate = splitOf(decoded.skipSplits
|
|
142
|
+
? directMintTokenCount
|
|
143
|
+
: swapTokenCount + directMintTokenCount, decoded.reservedPercent);
|
|
144
|
+
if (decoded.skipSplits)
|
|
145
|
+
candidate.beneficiaryTokenCount += swapTokenCount;
|
|
146
|
+
if (candidate.beneficiaryTokenCount > best.beneficiaryTokenCount ||
|
|
147
|
+
(candidate.beneficiaryTokenCount === best.beneficiaryTokenCount &&
|
|
148
|
+
candidate.reservedTokenCount > best.reservedTokenCount)) {
|
|
149
|
+
best = candidate;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return best;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* What the payer receives if the hook mints instead of swapping. The hook
|
|
156
|
+
* swaps only while the pool beats this rate, and unwinds to it when a swap
|
|
157
|
+
* underfills, so every honest settlement clears it.
|
|
158
|
+
*/
|
|
159
|
+
function mintEntitlementOf(spec, weight) {
|
|
160
|
+
const swapLeg = spec.skipSplits
|
|
161
|
+
? spec.tokenCountWithoutHook
|
|
162
|
+
: splitOf(spec.tokenCountWithoutHook, spec.reservedPercent)
|
|
163
|
+
.beneficiaryTokenCount;
|
|
164
|
+
return (swapLeg +
|
|
165
|
+
splitOf(directMintOf(spec, weight), spec.reservedPercent)
|
|
166
|
+
.beneficiaryTokenCount);
|
|
167
|
+
}
|
|
168
|
+
/** One terminal preview, with the project's buyback spec decoded. */
|
|
169
|
+
async function readPay(client, { chainId, terminal, projectId, token, amount, beneficiary, metadata = "0x", }) {
|
|
170
|
+
const [ruleset, beneficiaryTokenCount, reservedTokenCount, hookSpecifications,] = await client.readContract({
|
|
98
171
|
address: terminal,
|
|
99
172
|
abi: jbMultiTerminalAbi,
|
|
100
173
|
functionName: "previewPayFor",
|
|
101
174
|
args: [projectId, token, amount, beneficiary, metadata],
|
|
102
175
|
});
|
|
103
|
-
|
|
176
|
+
// Only a payment with hook specs needs to know which one is the buyback hook.
|
|
177
|
+
const buybackHook = hookSpecifications.length > 0
|
|
178
|
+
? await resolvedBuybackHookOf(client, chainId, projectId)
|
|
179
|
+
: null;
|
|
180
|
+
const reservedPercent = (ruleset.metadata >> 4n) & 0xffffn;
|
|
181
|
+
const spec = buybackHook
|
|
182
|
+
? hookSpecifications.find((s) => s.hook.toLowerCase() === buybackHook.toLowerCase())
|
|
183
|
+
: undefined;
|
|
184
|
+
return {
|
|
185
|
+
preview: effectivePayPreview({
|
|
186
|
+
buybackHook,
|
|
187
|
+
beneficiaryTokenCount,
|
|
188
|
+
reservedTokenCount,
|
|
189
|
+
weight: ruleset.weight,
|
|
190
|
+
reservedPercent,
|
|
191
|
+
hookSpecifications,
|
|
192
|
+
}),
|
|
193
|
+
terminalBeneficiaryTokenCount: beneficiaryTokenCount,
|
|
194
|
+
weight: ruleset.weight,
|
|
195
|
+
buyback: spec ? decodeBuybackPaySpec(spec, reservedPercent) : null,
|
|
196
|
+
unreadableSwap: !!spec && !spec.noop && !decodeBuybackPaySpec(spec, reservedPercent),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** The buyback hook the registry resolves for a project, or null. */
|
|
200
|
+
async function resolvedBuybackHookOf(client, chainId, projectId) {
|
|
201
|
+
let registry;
|
|
202
|
+
try {
|
|
203
|
+
registry = getJBContractAddress("JBBuybackHookRegistry", 6, chainId);
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
// A failed read throws: guessing "no hook" would drop the payment's minimum.
|
|
209
|
+
const hook = await client.readContract({
|
|
210
|
+
address: registry,
|
|
211
|
+
abi: jbBuybackHookRegistryAbi,
|
|
212
|
+
functionName: "hookOf",
|
|
213
|
+
args: [projectId],
|
|
214
|
+
});
|
|
215
|
+
return hook === zeroAddress ? null : hook;
|
|
216
|
+
}
|
|
217
|
+
const maxBigInt = (a, b) => (a > b ? a : b);
|
|
218
|
+
const poolKeyOfAbi = [
|
|
219
|
+
{
|
|
220
|
+
type: "function",
|
|
221
|
+
name: "poolKeyOf",
|
|
222
|
+
stateMutability: "view",
|
|
223
|
+
inputs: [
|
|
224
|
+
{ name: "projectId", type: "uint256" },
|
|
225
|
+
{ name: "terminalToken", type: "address" },
|
|
226
|
+
],
|
|
227
|
+
outputs: [
|
|
228
|
+
{
|
|
229
|
+
name: "key",
|
|
230
|
+
type: "tuple",
|
|
231
|
+
components: [
|
|
232
|
+
{ name: "currency0", type: "address" },
|
|
233
|
+
{ name: "currency1", type: "address" },
|
|
234
|
+
{ name: "fee", type: "uint24" },
|
|
235
|
+
{ name: "tickSpacing", type: "int24" },
|
|
236
|
+
{ name: "hooks", type: "address" },
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
];
|
|
242
|
+
/**
|
|
243
|
+
* Prepare a person's payment with {@link buildUserPayMetadata}: preview it,
|
|
244
|
+
* and set the minimum the terminal enforces on the beneficiary's balance.
|
|
245
|
+
*
|
|
246
|
+
* When the project's buyback hook honors `skipSplits` and its pool is in the
|
|
247
|
+
* paid token, this quotes that pool (fee and price impact included) and sends
|
|
248
|
+
* the slippage-floored quote as an explicit minimum. The hook then swaps
|
|
249
|
+
* whenever the pool beats the payer's share of a mint, and reverts below the
|
|
250
|
+
* floor. Without it the hook routes by its TWAP floor, which reaches zero on
|
|
251
|
+
* large buys against a thin pool and sends them to minting even when the pool
|
|
252
|
+
* pays far more.
|
|
253
|
+
*
|
|
254
|
+
* Otherwise (no pool, hook 1.1.1, a router converting the token first, or a
|
|
255
|
+
* failed quote) the hook routes by TWAP. The minimum is then the payer's mint
|
|
256
|
+
* entitlement when the hook would swap, since the hook never settles below it,
|
|
257
|
+
* and the terminal's own issuance when it would not.
|
|
258
|
+
*
|
|
259
|
+
* @param args.slippageBps Tolerance on the pool quote and on the fallback
|
|
260
|
+
* minimum. Defaults to 100 (1%).
|
|
261
|
+
*/
|
|
262
|
+
export async function prepareUserPay(client, { tiers, slippageBps = 100n, ...args }) {
|
|
263
|
+
const { chainId, projectId, token } = args;
|
|
264
|
+
const metadata = buildUserPayMetadata({ chainId, tiers });
|
|
265
|
+
const { preview, terminalBeneficiaryTokenCount, weight, buyback, unreadableSwap, } = await readPay(client, { ...args, metadata });
|
|
266
|
+
if (unreadableSwap) {
|
|
267
|
+
throw new Error("The project's buyback hook swaps with an unknown specification, so no safe minimum can be set.");
|
|
268
|
+
}
|
|
269
|
+
const fallback = {
|
|
270
|
+
metadata,
|
|
271
|
+
preview,
|
|
272
|
+
minReturnedTokens: slippageFloor(buyback && !buyback.noop
|
|
273
|
+
? // The swap and the leftover mint each round down once.
|
|
274
|
+
maxBigInt(mintEntitlementOf(buyback, weight) - 2n, 0n)
|
|
275
|
+
: terminalBeneficiaryTokenCount, slippageBps),
|
|
276
|
+
};
|
|
277
|
+
if (!buyback?.skipSplits || buyback.amountToSwapWith === 0n)
|
|
278
|
+
return fallback;
|
|
279
|
+
try {
|
|
280
|
+
const poolKey = await client.readContract({
|
|
281
|
+
address: buyback.hook,
|
|
282
|
+
abi: poolKeyOfAbi,
|
|
283
|
+
functionName: "poolKeyOf",
|
|
284
|
+
args: [
|
|
285
|
+
projectId,
|
|
286
|
+
token.toLowerCase() === NATIVE_TOKEN.toLowerCase()
|
|
287
|
+
? zeroAddress
|
|
288
|
+
: token,
|
|
289
|
+
],
|
|
290
|
+
});
|
|
291
|
+
// A router converts the paid token first, so its pool is a different one.
|
|
292
|
+
if (uniswapV4PoolId(poolKey) !== buyback.poolId)
|
|
293
|
+
return fallback;
|
|
294
|
+
const quote = await quoteUniswapV4ExactInputSingle(client, {
|
|
295
|
+
chainId,
|
|
296
|
+
poolKey,
|
|
297
|
+
zeroForOne: !buyback.projectTokenIs0,
|
|
298
|
+
amountIn: buyback.amountToSwapWith,
|
|
299
|
+
});
|
|
300
|
+
const minimumSwapAmountOut = slippageFloor(quote, slippageBps);
|
|
301
|
+
// The pool loses to minting: leave the payment on the mint path.
|
|
302
|
+
if (minimumSwapAmountOut <= buyback.tokenCountWithoutHook)
|
|
303
|
+
return fallback;
|
|
304
|
+
const directMint = splitOf(directMintOf(buyback, weight), buyback.reservedPercent);
|
|
305
|
+
return {
|
|
306
|
+
metadata: buildUserPayMetadata({ chainId, tiers, minimumSwapAmountOut }),
|
|
307
|
+
preview: {
|
|
308
|
+
beneficiaryTokenCount: quote + directMint.beneficiaryTokenCount,
|
|
309
|
+
reservedTokenCount: directMint.reservedTokenCount,
|
|
310
|
+
},
|
|
311
|
+
minReturnedTokens: minimumSwapAmountOut,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
return fallback;
|
|
316
|
+
}
|
|
104
317
|
}
|
|
105
318
|
/**
|
|
106
319
|
* Build pay metadata instructing a project's JB721 tiers hook to mint specific tiers.
|
|
@@ -141,4 +354,33 @@ export function buildBuybackPayMetadata({ hook, amountToSwapWith, minimumSwapAmo
|
|
|
141
354
|
encodeAbiParameters([{ type: "uint256" }, { type: "uint256" }, { type: "bool" }], [amountToSwapWith, minimumSwapAmountOut, skipSplits]),
|
|
142
355
|
]);
|
|
143
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* The pay metadata a person's pay card sends: the buyback registry's quote
|
|
359
|
+
* `(0, minimumSwapAmountOut, skipSplits=true)`, plus the 721 tiers when the
|
|
360
|
+
* payment buys NFTs. Prefer {@link prepareUserPay}, which picks the minimum.
|
|
361
|
+
*
|
|
362
|
+
* The registry rekeys its quote to the project's resolved hook. On buyback 1.4
|
|
363
|
+
* the hook buys from the pool only when that gives the payer more than their
|
|
364
|
+
* share of a mint, and hands the swapped tokens over without the reserved
|
|
365
|
+
* split. Minting still goes through the split. A zero swap amount swaps the
|
|
366
|
+
* whole payment. A zero minimum routes by the hook's TWAP floor; a nonzero one
|
|
367
|
+
* replaces it and reverts below it. The terminal's `minReturnedTokens` checks
|
|
368
|
+
* the beneficiary's balance change, which counts the swapped tokens.
|
|
369
|
+
*/
|
|
370
|
+
export function buildUserPayMetadata({ chainId, tiers, minimumSwapAmountOut = 0n, }) {
|
|
371
|
+
const ids = [
|
|
372
|
+
hookMetadataId(getJBContractAddress("JBBuybackHookRegistry", 6, chainId), "pay"),
|
|
373
|
+
];
|
|
374
|
+
const data = [
|
|
375
|
+
encodeAbiParameters([{ type: "uint256" }, { type: "uint256" }, { type: "bool" }], [0n, minimumSwapAmountOut, true]),
|
|
376
|
+
];
|
|
377
|
+
if (tiers && tiers.tierIdsToMint.length > 0) {
|
|
378
|
+
ids.push(hookMetadataId(tiers.metadataIdTarget, "pay"));
|
|
379
|
+
data.push(encodeAbiParameters([{ type: "bool" }, { type: "uint16[]" }], [
|
|
380
|
+
tiers.allowOverspending ?? DEFAULT_ALLOW_OVERSPENDING,
|
|
381
|
+
tiers.tierIdsToMint.map(Number),
|
|
382
|
+
]));
|
|
383
|
+
}
|
|
384
|
+
return createHookMetadata(ids, data);
|
|
385
|
+
}
|
|
144
386
|
//# sourceMappingURL=pay.js.map
|
package/dist/esm/v6/pay.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pay.js","sourceRoot":"","sources":["../../../src/v6/pay.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,mBAAmB,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAetE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,OAAO,EACP,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,EACN,WAAW,EACX,iBAAiB,GAAG,EAAE,EACtB,IAAI,GAAG,EAAE,EACT,QAAQ,GAAG,IAAI,GAWhB;IACC,MAAM,QAAQ,GAAG,KAAK,CAAC,WAAW,EAAE,KAAK,YAAY,CAAC,WAAW,EAAE,CAAC;IAEpE,OAAO;QACL,OAAO;QACP,OAAO,EAAE,QAAQ;QACjB,GAAG,EAAE,kBAAkB;QACvB,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE;YACJ,SAAS;YACT,KAAK;YACL,MAAM;YACN,WAAW;YACX,iBAAiB;YACjB,IAAI;YACJ,QAAQ;SACT;QACD,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;KAC9B,CAAC;AACJ,CAAC;AA+BD;;;;;;;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C,CACjC;KACF,CAAC;IACF,IAAI,KAAK,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,CACP,mBAAmB,CACjB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EACxC;YACE,KAAK,CAAC,iBAAiB,IAAI,0BAA0B;YACrD,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC;SAChC,CACF,CACF,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bananapus/nana-sdk-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": {
|
|
@@ -71,11 +71,6 @@
|
|
|
71
71
|
"import": "./dist/esm/v6/index.js",
|
|
72
72
|
"require": "./dist/cjs/v6/index.js"
|
|
73
73
|
},
|
|
74
|
-
"./v6/direct-pay": {
|
|
75
|
-
"types": "./dist/esm/v6/directPay.d.ts",
|
|
76
|
-
"import": "./dist/esm/v6/directPay.js",
|
|
77
|
-
"require": "./dist/cjs/v6/directPay.js"
|
|
78
|
-
},
|
|
79
74
|
"./v6/permit2": {
|
|
80
75
|
"types": "./dist/esm/v6/permit2.d.ts",
|
|
81
76
|
"import": "./dist/esm/v6/permit2.js",
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex, PublicClient } from "viem";
|
|
2
|
-
import type { JBChainId } from "../types.js";
|
|
3
|
-
import { type PayPreview, type PaySettlement } from "./pay.js";
|
|
4
|
-
import type { Permit2SignatureAuthorization } from "./permit2.js";
|
|
5
|
-
import { type UniswapV4PoolKey } from "./uniswapV4.js";
|
|
6
|
-
export interface NativeSwapConfig {
|
|
7
|
-
wrappedNative: Address;
|
|
8
|
-
bridgeToken: Address;
|
|
9
|
-
v3Quoter: Address;
|
|
10
|
-
}
|
|
11
|
-
/** Canonical WETH/USDC V3 bridge used by direct-pay swaps on all v6 mainnets. */
|
|
12
|
-
export declare const NATIVE_SWAP_BY_CHAIN: Readonly<Partial<Record<JBChainId, NativeSwapConfig>>>;
|
|
13
|
-
export type DirectPayInputRoute = {
|
|
14
|
-
kind: "single-v4";
|
|
15
|
-
} | {
|
|
16
|
-
kind: "native-v3-v4";
|
|
17
|
-
wrappedNative: Address;
|
|
18
|
-
bridgeToken: Address;
|
|
19
|
-
bridgeTokenSymbol: "USDC";
|
|
20
|
-
bridgeTokenDecimals: 6;
|
|
21
|
-
v3Fee: number;
|
|
22
|
-
quotedBridgeAmount: bigint;
|
|
23
|
-
} | {
|
|
24
|
-
kind: "erc20-v3-native-v4";
|
|
25
|
-
inputToken: Address;
|
|
26
|
-
wrappedNative: Address;
|
|
27
|
-
bridgeTokenSymbol: "ETH";
|
|
28
|
-
bridgeTokenDecimals: 18;
|
|
29
|
-
v3Fee: number;
|
|
30
|
-
quotedBridgeAmount: bigint;
|
|
31
|
-
};
|
|
32
|
-
export interface DirectPaySwapQuote {
|
|
33
|
-
kind: "direct-swap";
|
|
34
|
-
poolKey: UniswapV4PoolKey;
|
|
35
|
-
zeroForOne: boolean;
|
|
36
|
-
quotedTokenCount: bigint;
|
|
37
|
-
/** Protected minimum and the beneficiary's direct-swap token count. */
|
|
38
|
-
minimumTokenCount: bigint;
|
|
39
|
-
beneficiaryTokenCount: bigint;
|
|
40
|
-
reservedTokenCount: 0n;
|
|
41
|
-
inputRoute: DirectPayInputRoute;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Quote the best direct pool purchase, including the atomic ETH/USDC V3 bridge
|
|
45
|
-
* when the user's payment currency differs from the hooked V4 pool currency.
|
|
46
|
-
* Returns null unless its slippage-protected minimum beats terminal payment.
|
|
47
|
-
*/
|
|
48
|
-
export declare function quoteDirectPaySwap({ client, chainId, poolKey, pairIsCurrency0, paymentToken, amount, payPreview, paySettlement, slippageBps, }: {
|
|
49
|
-
client: PublicClient;
|
|
50
|
-
chainId: JBChainId;
|
|
51
|
-
poolKey: UniswapV4PoolKey;
|
|
52
|
-
pairIsCurrency0: boolean;
|
|
53
|
-
paymentToken: Address;
|
|
54
|
-
amount: bigint;
|
|
55
|
-
payPreview: PayPreview;
|
|
56
|
-
paySettlement?: PaySettlement;
|
|
57
|
-
slippageBps?: bigint;
|
|
58
|
-
}): Promise<DirectPaySwapQuote | null>;
|
|
59
|
-
/** Build the atomic Universal Router transaction for a direct-pay quote. */
|
|
60
|
-
export declare function buildDirectPaySwapTx({ chainId, quote, amount, recipient, deadline, }: {
|
|
61
|
-
chainId: JBChainId;
|
|
62
|
-
quote: DirectPaySwapQuote;
|
|
63
|
-
amount: bigint;
|
|
64
|
-
recipient: Address;
|
|
65
|
-
deadline: bigint;
|
|
66
|
-
}): import("./uniswapV4.js").UniswapV4SwapTxRequest;
|
|
67
|
-
/** Prepend Universal Router's PERMIT2_PERMIT command to a reviewed swap. */
|
|
68
|
-
export declare function addPermit2SignatureToDirectPaySwap(request: ReturnType<typeof buildDirectPaySwapTx>, authorization: Permit2SignatureAuthorization, signature: Hex): ReturnType<typeof buildDirectPaySwapTx>;
|
|
69
|
-
//# sourceMappingURL=directPay.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"directPay.d.ts","sourceRoot":"","sources":["../../../src/v6/directPay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OA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