@bananapus/nana-sdk-core 1.5.0 → 1.6.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/cashOut.d.ts +187 -0
- package/dist/cjs/v6/cashOut.d.ts.map +1 -1
- package/dist/cjs/v6/cashOut.js +251 -0
- package/dist/cjs/v6/cashOut.js.map +1 -1
- package/dist/cjs/v6/currency.d.ts +9 -9
- package/dist/cjs/v6/currency.d.ts.map +1 -1
- package/dist/cjs/v6/currency.js +9 -9
- package/dist/cjs/v6/currency.js.map +1 -1
- package/dist/cjs/v6/launch.d.ts +7 -5
- package/dist/cjs/v6/launch.d.ts.map +1 -1
- package/dist/cjs/v6/launch.js +8 -6
- package/dist/cjs/v6/launch.js.map +1 -1
- package/dist/cjs/v6/revnets.d.ts +2 -2
- package/dist/esm/v6/cashOut.d.ts +187 -0
- package/dist/esm/v6/cashOut.d.ts.map +1 -1
- package/dist/esm/v6/cashOut.js +245 -1
- package/dist/esm/v6/cashOut.js.map +1 -1
- package/dist/esm/v6/currency.d.ts +9 -9
- package/dist/esm/v6/currency.d.ts.map +1 -1
- package/dist/esm/v6/currency.js +9 -9
- package/dist/esm/v6/currency.js.map +1 -1
- package/dist/esm/v6/launch.d.ts +7 -5
- package/dist/esm/v6/launch.d.ts.map +1 -1
- package/dist/esm/v6/launch.js +8 -6
- package/dist/esm/v6/launch.js.map +1 -1
- package/dist/esm/v6/revnets.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/v6/launch.js
CHANGED
|
@@ -30,17 +30,19 @@ async function getProjectCreationFee(client, chainId) {
|
|
|
30
30
|
/**
|
|
31
31
|
* Build a `JBAccountingContext` for a token.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
* (native token → 61166).
|
|
35
|
-
*
|
|
36
|
-
*
|
|
33
|
+
* By default the context currency is token-keyed: `uint32(uint160(token))`
|
|
34
|
+
* (native token → 61166). Pass an explicit shared currency such as ETH=1 or
|
|
35
|
+
* USD=2 when the terminal should convert this token through a protocol price
|
|
36
|
+
* feed. A ruleset's `baseCurrency` is the denomination used to interpret its
|
|
37
|
+
* issuance weight.
|
|
37
38
|
*
|
|
38
39
|
* @param token The token address. Defaults to the native token sentinel
|
|
39
40
|
* (`0x…EEEe`).
|
|
40
41
|
* @param decimals The token's decimals. Defaults to 18 for the native token;
|
|
41
42
|
* REQUIRED for any other token (there is no safe default).
|
|
43
|
+
* @param currency The context's currency id. Defaults to the token-keyed id.
|
|
42
44
|
*/
|
|
43
|
-
function buildAccountingContext(token = constants_js_1.NATIVE_TOKEN, decimals) {
|
|
45
|
+
function buildAccountingContext(token = constants_js_1.NATIVE_TOKEN, decimals, currency = (0, currency_js_1.tokenCurrencyId)(token)) {
|
|
44
46
|
const isNative = token.toLowerCase() === constants_js_1.NATIVE_TOKEN.toLowerCase();
|
|
45
47
|
if (decimals === undefined && !isNative) {
|
|
46
48
|
throw new Error(`decimals is required for non-native token ${token} (there is no safe default)`);
|
|
@@ -48,7 +50,7 @@ function buildAccountingContext(token = constants_js_1.NATIVE_TOKEN, decimals) {
|
|
|
48
50
|
return {
|
|
49
51
|
token,
|
|
50
52
|
decimals: decimals ?? constants_js_1.NATIVE_TOKEN_DECIMALS,
|
|
51
|
-
currency
|
|
53
|
+
currency,
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../src/v6/launch.ts"],"names":[],"mappings":";;AA2CA,sDASC;
|
|
1
|
+
{"version":3,"file":"launch.js","sourceRoot":"","sources":["../../../src/v6/launch.ts"],"names":[],"mappings":";;AA2CA,sDASC;AAiBD,wDAgBC;AAcD,kEAsBC;AAYD,oDAyBC;AAsBD,8DAoBC;AAoBD,oDAuBC;AAgBD,sDAsBC;AAGD,0DASC;AArSD,+BAQc;AACd,kDAAsE;AACtE,0DAA0E;AAE1E,+CAAmE;AAGn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CAAC;IAC3C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/cjs/v6/revnets.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ type RevDeployArgs4 = Extract<RevDeployArgs, readonly [unknown, unknown, unknown
|
|
|
8
8
|
/**
|
|
9
9
|
* A revnet's full configuration: its token description (name/ticker/uri and
|
|
10
10
|
* the salt that fixes the ERC-20's deterministic address), base currency
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
11
|
+
* (either a token-keyed currency or a well-known `JBCurrencyIds` id such as
|
|
12
|
+
* ETH=1 or USD=2), operator, and stage configurations.
|
|
13
13
|
*/
|
|
14
14
|
export type REVConfig = RevDeployArgs4[1];
|
|
15
15
|
/**
|
package/dist/esm/v6/cashOut.d.ts
CHANGED
|
@@ -108,4 +108,191 @@ export declare function getCashOutQuote(client: PublicClient, { chainId, project
|
|
|
108
108
|
decimals?: bigint;
|
|
109
109
|
currency?: bigint;
|
|
110
110
|
}): Promise<CashOutQuote>;
|
|
111
|
+
/**
|
|
112
|
+
* The default cash-out slippage tolerance, in basis points (1%).
|
|
113
|
+
*
|
|
114
|
+
* Quotes from {@link getHookAwareCashOutQuote} are exact against current state;
|
|
115
|
+
* this tolerance only absorbs quote-to-inclusion drift (payments, other cash
|
|
116
|
+
* outs, sucker snapshot syncs, or pool moves that land first).
|
|
117
|
+
*/
|
|
118
|
+
export declare const DEFAULT_CASH_OUT_SLIPPAGE_BPS = 100n;
|
|
119
|
+
/**
|
|
120
|
+
* Apply a slippage tolerance to a quoted output, flooring toward zero but
|
|
121
|
+
* never below 1 for a positive quote (a zero minimum disables protection).
|
|
122
|
+
*
|
|
123
|
+
* @param quoted The quoted output amount.
|
|
124
|
+
* @param slippageBps The tolerance in basis points. Defaults to
|
|
125
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
126
|
+
* @returns The minimum acceptable output.
|
|
127
|
+
*/
|
|
128
|
+
export declare function slippageFloor(quoted: bigint, slippageBps?: bigint): bigint;
|
|
129
|
+
/**
|
|
130
|
+
* The exact protocol fee `JBMultiTerminal` deducts from a cash-out reclaim:
|
|
131
|
+
* `reclaimAmount / 40` (2.5%, floor division — NOT `× 975 / 1000`, which can
|
|
132
|
+
* differ by 1 wei and break an exact minimum).
|
|
133
|
+
*
|
|
134
|
+
* With a non-zero cash-out tax rate the fee applies to the full reclaim. With
|
|
135
|
+
* a zero tax rate it applies only up to the project's fee-free surplus
|
|
136
|
+
* (round-trip prevention). Feeless beneficiaries pay no fee.
|
|
137
|
+
*
|
|
138
|
+
* @param args.reclaimAmount The gross reclaim amount, before the terminal fee.
|
|
139
|
+
* @param args.cashOutTaxRate The ruleset's cash-out tax rate.
|
|
140
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
141
|
+
* @param args.feeFreeSurplus The project's `feeFreeSurplusOf` counter for the
|
|
142
|
+
* reclaimed token. Only consulted when the tax rate is zero.
|
|
143
|
+
* @returns The fee amount the terminal will deduct.
|
|
144
|
+
*/
|
|
145
|
+
export declare function cashOutProtocolFee({ reclaimAmount, cashOutTaxRate, beneficiaryIsFeeless, feeFreeSurplus, }: {
|
|
146
|
+
reclaimAmount: bigint;
|
|
147
|
+
cashOutTaxRate: bigint;
|
|
148
|
+
beneficiaryIsFeeless?: boolean;
|
|
149
|
+
feeFreeSurplus?: bigint;
|
|
150
|
+
}): bigint;
|
|
151
|
+
/**
|
|
152
|
+
* The diagnostic payload the buyback hook packs into its cash-out hook
|
|
153
|
+
* specification — the protocol's public preview API for the sell-side routing
|
|
154
|
+
* decision (returned by `previewCashOutFrom` whether or not the pool route
|
|
155
|
+
* wins).
|
|
156
|
+
*/
|
|
157
|
+
export interface BuybackCashOutSpec {
|
|
158
|
+
minimumSwapAmountOut: bigint;
|
|
159
|
+
cashOutCountToSell: bigint;
|
|
160
|
+
netDirectCashOutAmount: bigint;
|
|
161
|
+
twapTick: number;
|
|
162
|
+
twapLiquidity: bigint;
|
|
163
|
+
poolId: Hex;
|
|
164
|
+
rawSwapQuote: bigint;
|
|
165
|
+
hasUserSpecifiedMinimumSwapAmountOut: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Decode the buyback hook's cash-out specification metadata (see
|
|
169
|
+
* {@link BuybackCashOutSpec}).
|
|
170
|
+
*/
|
|
171
|
+
export declare function decodeBuybackCashOutSpec(metadata: Hex): BuybackCashOutSpec;
|
|
172
|
+
/**
|
|
173
|
+
* Build the buyback hook's `cashOut` metadata entry:
|
|
174
|
+
* `(uint256 minimumSwapAmountOut, bool skip)`.
|
|
175
|
+
*
|
|
176
|
+
* `minimumSwapAmountOut` is a hard floor on the net terminal-token output,
|
|
177
|
+
* enforced by the hook on BOTH the pool route and the direct bonding-curve
|
|
178
|
+
* fallback. Note an explicit non-zero minimum skips the hook's TWAP lookup:
|
|
179
|
+
* a minimum at or below the direct net keeps execution on the terminal path,
|
|
180
|
+
* a minimum above it routes through the pool. `skip: true` forces the
|
|
181
|
+
* terminal path outright (the floor still applies).
|
|
182
|
+
*
|
|
183
|
+
* @param args.hook The hook address the terminal consults (from the preview's
|
|
184
|
+
* hook specification).
|
|
185
|
+
* @param args.minimumSwapAmountOut The net-output floor.
|
|
186
|
+
* @param args.skip Force the direct terminal path. Defaults to false.
|
|
187
|
+
* @returns The metadata to pass as `cashOutTokensOf`'s `metadata` argument.
|
|
188
|
+
*/
|
|
189
|
+
export declare function buildBuybackCashOutMetadata({ hook, minimumSwapAmountOut, skip, }: {
|
|
190
|
+
hook: Address;
|
|
191
|
+
minimumSwapAmountOut: bigint;
|
|
192
|
+
skip?: boolean;
|
|
193
|
+
}): Hex;
|
|
194
|
+
/** A hook specification tuple as returned by the terminal preview functions. */
|
|
195
|
+
export interface CashOutHookSpecification {
|
|
196
|
+
hook: Address;
|
|
197
|
+
noop: boolean;
|
|
198
|
+
amount: bigint;
|
|
199
|
+
metadata: Hex;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* A slippage-protected cash-out route: which venue the transaction should
|
|
203
|
+
* expect, and the exact `minTokensReclaimed`/`metadata` pair to submit.
|
|
204
|
+
*/
|
|
205
|
+
export interface CashOutRoute {
|
|
206
|
+
/** "treasury" = direct bonding-curve reclaim; "amm" = buyback pool sell. */
|
|
207
|
+
route: "treasury" | "amm";
|
|
208
|
+
/** The quoted net output on the chosen route. */
|
|
209
|
+
expectedReturn: bigint;
|
|
210
|
+
/** The slippage-floored minimum net output. */
|
|
211
|
+
minimumReturn: bigint;
|
|
212
|
+
/**
|
|
213
|
+
* The `minTokensReclaimed` to pass to `cashOutTokensOf`. Non-zero only on
|
|
214
|
+
* the treasury route — on the pool route the terminal itself reclaims
|
|
215
|
+
* nothing (the hook pays the beneficiary), so the floor lives in
|
|
216
|
+
* {@link CashOutRoute.metadata} instead.
|
|
217
|
+
*/
|
|
218
|
+
terminalMinimum: bigint;
|
|
219
|
+
/** The `metadata` to pass to `cashOutTokensOf`. */
|
|
220
|
+
metadata: Hex;
|
|
221
|
+
/** The gross direct reclaim, before the terminal fee. */
|
|
222
|
+
treasuryGross: bigint;
|
|
223
|
+
/** The terminal fee on the direct reclaim. */
|
|
224
|
+
treasuryProtocolFee: bigint;
|
|
225
|
+
/** The net direct reclaim after the terminal fee. */
|
|
226
|
+
treasuryNet: bigint;
|
|
227
|
+
/** The decoded buyback diagnostics, when the hook was consulted. */
|
|
228
|
+
buyback: (BuybackCashOutSpec & {
|
|
229
|
+
hook: Address;
|
|
230
|
+
}) | null;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Interpret a hook-aware `previewCashOutFrom` result and prepare a
|
|
234
|
+
* slippage-protected route.
|
|
235
|
+
*
|
|
236
|
+
* On the treasury route the floor is enforced via `minTokensReclaimed`; if the
|
|
237
|
+
* routing flips to the pool between quote and inclusion, the transaction
|
|
238
|
+
* reverts rather than executing a stale path — re-quote and retry. On the pool
|
|
239
|
+
* route the floor is moved into the hook's `cashOut` metadata (the terminal
|
|
240
|
+
* minimum must be zero there), and if the floored pool quote no longer beats
|
|
241
|
+
* the direct net, the route falls back to the treasury path.
|
|
242
|
+
*
|
|
243
|
+
* @param args.reclaimAmount `previewCashOutFrom`'s gross reclaim amount.
|
|
244
|
+
* @param args.cashOutTaxRate `previewCashOutFrom`'s cash-out tax rate.
|
|
245
|
+
* @param args.hookSpecifications `previewCashOutFrom`'s hook specifications.
|
|
246
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
247
|
+
* Defaults to false (conservative: assumes the fee applies).
|
|
248
|
+
* @param args.feeFreeSurplus The terminal's `feeFreeSurplusOf` for the token.
|
|
249
|
+
* Only consulted when the tax rate is zero. Defaults to 0.
|
|
250
|
+
* @param args.slippageBps Tolerance for quote-to-inclusion drift. Defaults to
|
|
251
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
252
|
+
* @returns The protected route.
|
|
253
|
+
*/
|
|
254
|
+
export declare function resolveCashOutRoute({ reclaimAmount, cashOutTaxRate, hookSpecifications, beneficiaryIsFeeless, feeFreeSurplus, slippageBps, }: {
|
|
255
|
+
reclaimAmount: bigint;
|
|
256
|
+
cashOutTaxRate: bigint;
|
|
257
|
+
hookSpecifications: readonly CashOutHookSpecification[];
|
|
258
|
+
beneficiaryIsFeeless?: boolean;
|
|
259
|
+
feeFreeSurplus?: bigint;
|
|
260
|
+
slippageBps?: bigint;
|
|
261
|
+
}): CashOutRoute;
|
|
262
|
+
/**
|
|
263
|
+
* Quote a cash out through `JBMultiTerminal.previewCashOutFrom` — the
|
|
264
|
+
* hook-aware simulation of the REAL cash-out path (data hook, buyback
|
|
265
|
+
* routing, cross-chain terms) — and prepare a slippage-protected route.
|
|
266
|
+
*
|
|
267
|
+
* Prefer this over {@link getCashOutQuote} for building transactions:
|
|
268
|
+
* `currentReclaimableSurplusOf` skips the data hook entirely, so its result
|
|
269
|
+
* can diverge from what `cashOutTokensOf` pays and is unsafe to use as a
|
|
270
|
+
* minimum.
|
|
271
|
+
*
|
|
272
|
+
* @param client A viem public client on the given chain.
|
|
273
|
+
* @param args.chainId The chain to quote on.
|
|
274
|
+
* @param args.projectId The project's id.
|
|
275
|
+
* @param args.holder The address whose tokens would be cashed out.
|
|
276
|
+
* @param args.cashOutCount The number of project tokens to cash out.
|
|
277
|
+
* @param args.tokenToReclaim The terminal token to reclaim.
|
|
278
|
+
* @param args.beneficiary The reclaim beneficiary. Defaults to the holder.
|
|
279
|
+
* @param args.terminal The terminal to quote against. Defaults to the chain's
|
|
280
|
+
* canonical `JBMultiTerminal`.
|
|
281
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
282
|
+
* Defaults to false.
|
|
283
|
+
* @param args.slippageBps Tolerance for quote-to-inclusion drift. Defaults to
|
|
284
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
285
|
+
* @returns The protected route (see {@link CashOutRoute}).
|
|
286
|
+
*/
|
|
287
|
+
export declare function getHookAwareCashOutQuote(client: PublicClient, { chainId, projectId, holder, cashOutCount, tokenToReclaim, beneficiary, terminal, beneficiaryIsFeeless, slippageBps, }: {
|
|
288
|
+
chainId: JBChainId;
|
|
289
|
+
projectId: bigint;
|
|
290
|
+
holder: Address;
|
|
291
|
+
cashOutCount: bigint;
|
|
292
|
+
tokenToReclaim: Address;
|
|
293
|
+
beneficiary?: Address;
|
|
294
|
+
terminal?: Address;
|
|
295
|
+
beneficiaryIsFeeless?: boolean;
|
|
296
|
+
slippageBps?: bigint;
|
|
297
|
+
}): Promise<CashOutRoute>;
|
|
111
298
|
//# sourceMappingURL=cashOut.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cashOut.d.ts","sourceRoot":"","sources":["../../../src/v6/cashOut.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cashOut.d.ts","sourceRoot":"","sources":["../../../src/v6/cashOut.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,E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AAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,YAAY,CAiEf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,YAAY,EACpB,EACE,OAAO,EACP,SAAS,EACT,MAAM,EACN,YAAY,EACZ,cAAc,EACd,WAAW,EACX,QAAQ,EACR,oBAA4B,EAC5B,WAA2C,GAC5C,EAAE;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GACA,OAAO,CAAC,YAAY,CAAC,CAoCvB"}
|
package/dist/esm/v6/cashOut.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeAbiParameters } from "viem";
|
|
1
|
+
import { decodeAbiParameters, encodeAbiParameters, } from "viem";
|
|
2
2
|
import { jbMultiTerminalAbi, jbTerminalStoreAbi, } from "../generated/juicebox.js";
|
|
3
3
|
import { applyJbDaoCashOutFee } from "../utils/fee.js";
|
|
4
4
|
import { createHookMetadata, hookMetadataId } from "../utils/hook.js";
|
|
@@ -104,4 +104,248 @@ export async function getCashOutQuote(client, { chainId, projectId, cashOutCount
|
|
|
104
104
|
reclaimAmountAfterFee: applyJbDaoCashOutFee(reclaimAmount),
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The default cash-out slippage tolerance, in basis points (1%).
|
|
109
|
+
*
|
|
110
|
+
* Quotes from {@link getHookAwareCashOutQuote} are exact against current state;
|
|
111
|
+
* this tolerance only absorbs quote-to-inclusion drift (payments, other cash
|
|
112
|
+
* outs, sucker snapshot syncs, or pool moves that land first).
|
|
113
|
+
*/
|
|
114
|
+
export const DEFAULT_CASH_OUT_SLIPPAGE_BPS = 100n;
|
|
115
|
+
const MAX_BPS = 10000n;
|
|
116
|
+
function requireBps(slippageBps) {
|
|
117
|
+
if (slippageBps < 0n || slippageBps >= MAX_BPS) {
|
|
118
|
+
throw new Error("Slippage basis points must be in [0, 10000)");
|
|
119
|
+
}
|
|
120
|
+
return slippageBps;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Apply a slippage tolerance to a quoted output, flooring toward zero but
|
|
124
|
+
* never below 1 for a positive quote (a zero minimum disables protection).
|
|
125
|
+
*
|
|
126
|
+
* @param quoted The quoted output amount.
|
|
127
|
+
* @param slippageBps The tolerance in basis points. Defaults to
|
|
128
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
129
|
+
* @returns The minimum acceptable output.
|
|
130
|
+
*/
|
|
131
|
+
export function slippageFloor(quoted, slippageBps = DEFAULT_CASH_OUT_SLIPPAGE_BPS) {
|
|
132
|
+
requireBps(slippageBps);
|
|
133
|
+
if (quoted <= 0n)
|
|
134
|
+
return 0n;
|
|
135
|
+
const floor = (quoted * (MAX_BPS - slippageBps)) / MAX_BPS;
|
|
136
|
+
return floor > 0n ? floor : 1n;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* The exact protocol fee `JBMultiTerminal` deducts from a cash-out reclaim:
|
|
140
|
+
* `reclaimAmount / 40` (2.5%, floor division — NOT `× 975 / 1000`, which can
|
|
141
|
+
* differ by 1 wei and break an exact minimum).
|
|
142
|
+
*
|
|
143
|
+
* With a non-zero cash-out tax rate the fee applies to the full reclaim. With
|
|
144
|
+
* a zero tax rate it applies only up to the project's fee-free surplus
|
|
145
|
+
* (round-trip prevention). Feeless beneficiaries pay no fee.
|
|
146
|
+
*
|
|
147
|
+
* @param args.reclaimAmount The gross reclaim amount, before the terminal fee.
|
|
148
|
+
* @param args.cashOutTaxRate The ruleset's cash-out tax rate.
|
|
149
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
150
|
+
* @param args.feeFreeSurplus The project's `feeFreeSurplusOf` counter for the
|
|
151
|
+
* reclaimed token. Only consulted when the tax rate is zero.
|
|
152
|
+
* @returns The fee amount the terminal will deduct.
|
|
153
|
+
*/
|
|
154
|
+
export function cashOutProtocolFee({ reclaimAmount, cashOutTaxRate, beneficiaryIsFeeless = false, feeFreeSurplus = 0n, }) {
|
|
155
|
+
if (reclaimAmount <= 0n || beneficiaryIsFeeless)
|
|
156
|
+
return 0n;
|
|
157
|
+
if (cashOutTaxRate > 0n)
|
|
158
|
+
return reclaimAmount / 40n;
|
|
159
|
+
const feeable = reclaimAmount < feeFreeSurplus ? reclaimAmount : feeFreeSurplus;
|
|
160
|
+
return feeable / 40n;
|
|
161
|
+
}
|
|
162
|
+
const BUYBACK_CASH_OUT_SPEC_ABI = [
|
|
163
|
+
{ name: "minimumSwapAmountOut", type: "uint256" },
|
|
164
|
+
{ name: "cashOutCountToSell", type: "uint256" },
|
|
165
|
+
{ name: "netDirectCashOutAmount", type: "uint256" },
|
|
166
|
+
{ name: "twapTick", type: "int24" },
|
|
167
|
+
{ name: "twapLiquidity", type: "uint128" },
|
|
168
|
+
{ name: "poolId", type: "bytes32" },
|
|
169
|
+
{ name: "rawSwapQuote", type: "uint256" },
|
|
170
|
+
{ name: "hasUserSpecifiedMinimumSwapAmountOut", type: "bool" },
|
|
171
|
+
];
|
|
172
|
+
/**
|
|
173
|
+
* Decode the buyback hook's cash-out specification metadata (see
|
|
174
|
+
* {@link BuybackCashOutSpec}).
|
|
175
|
+
*/
|
|
176
|
+
export function decodeBuybackCashOutSpec(metadata) {
|
|
177
|
+
const [minimumSwapAmountOut, cashOutCountToSell, netDirectCashOutAmount, twapTick, twapLiquidity, poolId, rawSwapQuote, hasUserSpecifiedMinimumSwapAmountOut,] = decodeAbiParameters(BUYBACK_CASH_OUT_SPEC_ABI, metadata);
|
|
178
|
+
return {
|
|
179
|
+
minimumSwapAmountOut,
|
|
180
|
+
cashOutCountToSell,
|
|
181
|
+
netDirectCashOutAmount,
|
|
182
|
+
twapTick,
|
|
183
|
+
twapLiquidity,
|
|
184
|
+
poolId,
|
|
185
|
+
rawSwapQuote,
|
|
186
|
+
hasUserSpecifiedMinimumSwapAmountOut,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Build the buyback hook's `cashOut` metadata entry:
|
|
191
|
+
* `(uint256 minimumSwapAmountOut, bool skip)`.
|
|
192
|
+
*
|
|
193
|
+
* `minimumSwapAmountOut` is a hard floor on the net terminal-token output,
|
|
194
|
+
* enforced by the hook on BOTH the pool route and the direct bonding-curve
|
|
195
|
+
* fallback. Note an explicit non-zero minimum skips the hook's TWAP lookup:
|
|
196
|
+
* a minimum at or below the direct net keeps execution on the terminal path,
|
|
197
|
+
* a minimum above it routes through the pool. `skip: true` forces the
|
|
198
|
+
* terminal path outright (the floor still applies).
|
|
199
|
+
*
|
|
200
|
+
* @param args.hook The hook address the terminal consults (from the preview's
|
|
201
|
+
* hook specification).
|
|
202
|
+
* @param args.minimumSwapAmountOut The net-output floor.
|
|
203
|
+
* @param args.skip Force the direct terminal path. Defaults to false.
|
|
204
|
+
* @returns The metadata to pass as `cashOutTokensOf`'s `metadata` argument.
|
|
205
|
+
*/
|
|
206
|
+
export function buildBuybackCashOutMetadata({ hook, minimumSwapAmountOut, skip = false, }) {
|
|
207
|
+
if (minimumSwapAmountOut < 0n) {
|
|
208
|
+
throw new Error("Cash out minimum cannot be negative");
|
|
209
|
+
}
|
|
210
|
+
const payload = encodeAbiParameters([{ type: "uint256" }, { type: "bool" }], [minimumSwapAmountOut, skip]);
|
|
211
|
+
return createHookMetadata([hookMetadataId(hook, "cashOut")], [payload]);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Interpret a hook-aware `previewCashOutFrom` result and prepare a
|
|
215
|
+
* slippage-protected route.
|
|
216
|
+
*
|
|
217
|
+
* On the treasury route the floor is enforced via `minTokensReclaimed`; if the
|
|
218
|
+
* routing flips to the pool between quote and inclusion, the transaction
|
|
219
|
+
* reverts rather than executing a stale path — re-quote and retry. On the pool
|
|
220
|
+
* route the floor is moved into the hook's `cashOut` metadata (the terminal
|
|
221
|
+
* minimum must be zero there), and if the floored pool quote no longer beats
|
|
222
|
+
* the direct net, the route falls back to the treasury path.
|
|
223
|
+
*
|
|
224
|
+
* @param args.reclaimAmount `previewCashOutFrom`'s gross reclaim amount.
|
|
225
|
+
* @param args.cashOutTaxRate `previewCashOutFrom`'s cash-out tax rate.
|
|
226
|
+
* @param args.hookSpecifications `previewCashOutFrom`'s hook specifications.
|
|
227
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
228
|
+
* Defaults to false (conservative: assumes the fee applies).
|
|
229
|
+
* @param args.feeFreeSurplus The terminal's `feeFreeSurplusOf` for the token.
|
|
230
|
+
* Only consulted when the tax rate is zero. Defaults to 0.
|
|
231
|
+
* @param args.slippageBps Tolerance for quote-to-inclusion drift. Defaults to
|
|
232
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
233
|
+
* @returns The protected route.
|
|
234
|
+
*/
|
|
235
|
+
export function resolveCashOutRoute({ reclaimAmount, cashOutTaxRate, hookSpecifications, beneficiaryIsFeeless = false, feeFreeSurplus = 0n, slippageBps = DEFAULT_CASH_OUT_SLIPPAGE_BPS, }) {
|
|
236
|
+
requireBps(slippageBps);
|
|
237
|
+
const treasuryProtocolFee = cashOutProtocolFee({
|
|
238
|
+
reclaimAmount,
|
|
239
|
+
cashOutTaxRate,
|
|
240
|
+
beneficiaryIsFeeless,
|
|
241
|
+
feeFreeSurplus,
|
|
242
|
+
});
|
|
243
|
+
const treasuryNet = reclaimAmount - treasuryProtocolFee;
|
|
244
|
+
const specification = hookSpecifications.find((spec) => spec.metadata !== "0x") ?? null;
|
|
245
|
+
const buyback = specification
|
|
246
|
+
? {
|
|
247
|
+
hook: specification.hook,
|
|
248
|
+
...decodeBuybackCashOutSpec(specification.metadata),
|
|
249
|
+
}
|
|
250
|
+
: null;
|
|
251
|
+
const treasuryRoute = {
|
|
252
|
+
route: "treasury",
|
|
253
|
+
expectedReturn: treasuryNet,
|
|
254
|
+
minimumReturn: slippageFloor(treasuryNet, slippageBps),
|
|
255
|
+
terminalMinimum: slippageFloor(treasuryNet, slippageBps),
|
|
256
|
+
metadata: "0x",
|
|
257
|
+
treasuryGross: reclaimAmount,
|
|
258
|
+
treasuryProtocolFee,
|
|
259
|
+
treasuryNet,
|
|
260
|
+
buyback,
|
|
261
|
+
};
|
|
262
|
+
if (!specification || specification.noop || !buyback)
|
|
263
|
+
return treasuryRoute;
|
|
264
|
+
// The pool route won the preview. Re-previews with an explicit metadata
|
|
265
|
+
// minimum report that already-protected floor and no raw quote — preserve
|
|
266
|
+
// it instead of discounting a second time.
|
|
267
|
+
const quote = buyback.rawSwapQuote > 0n
|
|
268
|
+
? buyback.rawSwapQuote
|
|
269
|
+
: buyback.minimumSwapAmountOut;
|
|
270
|
+
const minimumReturn = buyback.rawSwapQuote > 0n && !buyback.hasUserSpecifiedMinimumSwapAmountOut
|
|
271
|
+
? slippageFloor(quote, slippageBps)
|
|
272
|
+
: buyback.minimumSwapAmountOut;
|
|
273
|
+
// An explicit metadata minimum at or below the direct net routes execution
|
|
274
|
+
// back to the terminal path anyway; take the deterministic treasury route.
|
|
275
|
+
if (quote <= 0n || minimumReturn <= buyback.netDirectCashOutAmount) {
|
|
276
|
+
return treasuryRoute;
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
route: "amm",
|
|
280
|
+
expectedReturn: quote,
|
|
281
|
+
minimumReturn,
|
|
282
|
+
terminalMinimum: 0n,
|
|
283
|
+
metadata: buildBuybackCashOutMetadata({
|
|
284
|
+
hook: specification.hook,
|
|
285
|
+
minimumSwapAmountOut: minimumReturn,
|
|
286
|
+
}),
|
|
287
|
+
treasuryGross: reclaimAmount,
|
|
288
|
+
treasuryProtocolFee,
|
|
289
|
+
treasuryNet,
|
|
290
|
+
buyback,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Quote a cash out through `JBMultiTerminal.previewCashOutFrom` — the
|
|
295
|
+
* hook-aware simulation of the REAL cash-out path (data hook, buyback
|
|
296
|
+
* routing, cross-chain terms) — and prepare a slippage-protected route.
|
|
297
|
+
*
|
|
298
|
+
* Prefer this over {@link getCashOutQuote} for building transactions:
|
|
299
|
+
* `currentReclaimableSurplusOf` skips the data hook entirely, so its result
|
|
300
|
+
* can diverge from what `cashOutTokensOf` pays and is unsafe to use as a
|
|
301
|
+
* minimum.
|
|
302
|
+
*
|
|
303
|
+
* @param client A viem public client on the given chain.
|
|
304
|
+
* @param args.chainId The chain to quote on.
|
|
305
|
+
* @param args.projectId The project's id.
|
|
306
|
+
* @param args.holder The address whose tokens would be cashed out.
|
|
307
|
+
* @param args.cashOutCount The number of project tokens to cash out.
|
|
308
|
+
* @param args.tokenToReclaim The terminal token to reclaim.
|
|
309
|
+
* @param args.beneficiary The reclaim beneficiary. Defaults to the holder.
|
|
310
|
+
* @param args.terminal The terminal to quote against. Defaults to the chain's
|
|
311
|
+
* canonical `JBMultiTerminal`.
|
|
312
|
+
* @param args.beneficiaryIsFeeless Whether the beneficiary is feeless.
|
|
313
|
+
* Defaults to false.
|
|
314
|
+
* @param args.slippageBps Tolerance for quote-to-inclusion drift. Defaults to
|
|
315
|
+
* {@link DEFAULT_CASH_OUT_SLIPPAGE_BPS}.
|
|
316
|
+
* @returns The protected route (see {@link CashOutRoute}).
|
|
317
|
+
*/
|
|
318
|
+
export async function getHookAwareCashOutQuote(client, { chainId, projectId, holder, cashOutCount, tokenToReclaim, beneficiary, terminal, beneficiaryIsFeeless = false, slippageBps = DEFAULT_CASH_OUT_SLIPPAGE_BPS, }) {
|
|
319
|
+
const terminalAddress = terminal ?? v6Address("JBMultiTerminal", chainId);
|
|
320
|
+
const [, reclaimAmount, cashOutTaxRate, hookSpecifications] = await client.readContract({
|
|
321
|
+
address: terminalAddress,
|
|
322
|
+
abi: jbMultiTerminalAbi,
|
|
323
|
+
functionName: "previewCashOutFrom",
|
|
324
|
+
args: [
|
|
325
|
+
holder,
|
|
326
|
+
projectId,
|
|
327
|
+
cashOutCount,
|
|
328
|
+
tokenToReclaim,
|
|
329
|
+
beneficiary ?? holder,
|
|
330
|
+
"0x",
|
|
331
|
+
],
|
|
332
|
+
});
|
|
333
|
+
// The fee-free surplus counter only matters on zero-tax rulesets.
|
|
334
|
+
const feeFreeSurplus = cashOutTaxRate === 0n
|
|
335
|
+
? await client.readContract({
|
|
336
|
+
address: terminalAddress,
|
|
337
|
+
abi: jbMultiTerminalAbi,
|
|
338
|
+
functionName: "feeFreeSurplusOf",
|
|
339
|
+
args: [projectId, tokenToReclaim],
|
|
340
|
+
})
|
|
341
|
+
: 0n;
|
|
342
|
+
return resolveCashOutRoute({
|
|
343
|
+
reclaimAmount,
|
|
344
|
+
cashOutTaxRate,
|
|
345
|
+
hookSpecifications,
|
|
346
|
+
beneficiaryIsFeeless,
|
|
347
|
+
feeFreeSurplus,
|
|
348
|
+
slippageBps,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
107
351
|
//# sourceMappingURL=cashOut.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cashOut.js","sourceRoot":"","sources":["../../../src/v6/cashOut.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"cashOut.js","sourceRoot":"","sources":["../../../src/v6/cashOut.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,MAAM,CAAC;AACd,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,O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
/**
|
|
3
3
|
* The v6 base currency id for ETH (JBCurrencyIds.ETH).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* ruleset's `baseCurrency`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* native token) as a ruleset `baseCurrency` to "skip the price feed" — base currency
|
|
10
|
-
* must be 1 or 2.
|
|
5
|
+
* ETH = 1 and USD = 2 are well-known shared denominations used by protocol price
|
|
6
|
+
* feeds. A ruleset's `baseCurrency` may instead be a token-keyed currency from
|
|
7
|
+
* {@link tokenCurrencyId} when its issuance weight is denominated directly in that
|
|
8
|
+
* token.
|
|
11
9
|
*
|
|
12
10
|
* @link https://github.com/Bananapus/nana-core-v6/blob/main/src/libraries/JBCurrencyIds.sol
|
|
13
11
|
*/
|
|
@@ -32,9 +30,11 @@ export declare const NATIVE_TOKEN_CURRENCY_ID = 61166;
|
|
|
32
30
|
* The v6 accounting-context currency id for a token: `uint32(uint160(tokenAddress))`,
|
|
33
31
|
* i.e. the lowest 4 bytes of the token's address.
|
|
34
32
|
*
|
|
35
|
-
* Use this for terminal accounting contexts (`{ token, decimals, currency }`)
|
|
36
|
-
* a ruleset's `baseCurrency
|
|
37
|
-
*
|
|
33
|
+
* Use this for terminal accounting contexts (`{ token, decimals, currency }`). It may
|
|
34
|
+
* also be used as a ruleset's `baseCurrency` when issuance is denominated directly in
|
|
35
|
+
* that token. Use a shared denomination such as {@link BASE_CURRENCY_ETH} or
|
|
36
|
+
* {@link BASE_CURRENCY_USD} when multiple accepted tokens must be converted through
|
|
37
|
+
* price feeds.
|
|
38
38
|
*
|
|
39
39
|
* @param token The token address to derive a currency id from.
|
|
40
40
|
* @returns The token's accounting-context currency id (fits in a uint32).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/v6/currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/v6/currency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEtD"}
|
package/dist/esm/v6/currency.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The v6 base currency id for ETH (JBCurrencyIds.ETH).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* ruleset's `baseCurrency`
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* native token) as a ruleset `baseCurrency` to "skip the price feed" — base currency
|
|
9
|
-
* must be 1 or 2.
|
|
4
|
+
* ETH = 1 and USD = 2 are well-known shared denominations used by protocol price
|
|
5
|
+
* feeds. A ruleset's `baseCurrency` may instead be a token-keyed currency from
|
|
6
|
+
* {@link tokenCurrencyId} when its issuance weight is denominated directly in that
|
|
7
|
+
* token.
|
|
10
8
|
*
|
|
11
9
|
* @link https://github.com/Bananapus/nana-core-v6/blob/main/src/libraries/JBCurrencyIds.sol
|
|
12
10
|
*/
|
|
@@ -31,9 +29,11 @@ export const NATIVE_TOKEN_CURRENCY_ID = 61166;
|
|
|
31
29
|
* The v6 accounting-context currency id for a token: `uint32(uint160(tokenAddress))`,
|
|
32
30
|
* i.e. the lowest 4 bytes of the token's address.
|
|
33
31
|
*
|
|
34
|
-
* Use this for terminal accounting contexts (`{ token, decimals, currency }`)
|
|
35
|
-
* a ruleset's `baseCurrency
|
|
36
|
-
*
|
|
32
|
+
* Use this for terminal accounting contexts (`{ token, decimals, currency }`). It may
|
|
33
|
+
* also be used as a ruleset's `baseCurrency` when issuance is denominated directly in
|
|
34
|
+
* that token. Use a shared denomination such as {@link BASE_CURRENCY_ETH} or
|
|
35
|
+
* {@link BASE_CURRENCY_USD} when multiple accepted tokens must be converted through
|
|
36
|
+
* price feeds.
|
|
37
37
|
*
|
|
38
38
|
* @param token The token address to derive a currency id from.
|
|
39
39
|
* @returns The token's accounting-context currency id (fits in a uint32).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/v6/currency.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/v6/currency.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/esm/v6/launch.d.ts
CHANGED
|
@@ -25,17 +25,19 @@ export declare function getProjectCreationFee(client: PublicClient, chainId: JBC
|
|
|
25
25
|
/**
|
|
26
26
|
* Build a `JBAccountingContext` for a token.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
* (native token → 61166).
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* By default the context currency is token-keyed: `uint32(uint160(token))`
|
|
29
|
+
* (native token → 61166). Pass an explicit shared currency such as ETH=1 or
|
|
30
|
+
* USD=2 when the terminal should convert this token through a protocol price
|
|
31
|
+
* feed. A ruleset's `baseCurrency` is the denomination used to interpret its
|
|
32
|
+
* issuance weight.
|
|
32
33
|
*
|
|
33
34
|
* @param token The token address. Defaults to the native token sentinel
|
|
34
35
|
* (`0x…EEEe`).
|
|
35
36
|
* @param decimals The token's decimals. Defaults to 18 for the native token;
|
|
36
37
|
* REQUIRED for any other token (there is no safe default).
|
|
38
|
+
* @param currency The context's currency id. Defaults to the token-keyed id.
|
|
37
39
|
*/
|
|
38
|
-
export declare function buildAccountingContext(token?: Address, decimals?: number): JBAccountingContext;
|
|
40
|
+
export declare function buildAccountingContext(token?: Address, decimals?: number, currency?: number): JBAccountingContext;
|
|
39
41
|
/**
|
|
40
42
|
* Build the standard terminal configurations for a launch:
|
|
41
43
|
*
|