@logswap/sdk 0.5.79 → 0.5.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -14
- package/dist/admin.d.ts +697 -75
- package/dist/admin.js +54 -65
- package/dist/client.d.ts +2 -2
- package/dist/client.js +13 -2
- package/dist/fpool.d.ts +309 -339
- package/dist/fpool.js +225 -210
- package/dist/generated.d.ts +1542 -1182
- package/dist/generated.js +938 -847
- package/dist/history.d.ts +1 -2
- package/dist/history.js +3 -5
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.js +4 -2
- package/dist/keys.d.ts +23 -1
- package/dist/keys.js +18 -0
- package/dist/liquidity.d.ts +0 -5
- package/dist/liquidity.js +1 -2
- package/dist/pools.d.ts +8 -11
- package/dist/pools.js +9 -8
- package/dist/positions.d.ts +4 -5
- package/dist/positions.js +6 -7
- package/dist/views.d.ts +6 -10
- package/dist/views.js +6 -6
- package/package.json +1 -1
- package/src/admin.ts +62 -74
- package/src/client.ts +13 -2
- package/src/fpool.ts +315 -289
- package/src/generated.ts +938 -847
- package/src/history.ts +3 -4
- package/src/indexer.ts +5 -3
- package/src/keys.ts +34 -1
- package/src/liquidity.ts +1 -7
- package/src/pools.ts +14 -15
- package/src/positions.ts +6 -7
- package/src/views.ts +12 -16
package/dist/history.d.ts
CHANGED
|
@@ -63,8 +63,7 @@ export declare function getEventLogs<A = Record<string, unknown>>(c: LogswapClie
|
|
|
63
63
|
source: "indexer" | "chain";
|
|
64
64
|
}>;
|
|
65
65
|
/**
|
|
66
|
-
* A policy's name in the indexer for one of its events: `Policy
|
|
67
|
-
* two-signature `Listed`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
66
|
+
* A policy's name in the indexer for one of its events: `Policy`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
68
67
|
*/
|
|
69
68
|
export declare function indexedContractOf(kind: FPoolKind, event: string): string;
|
|
70
69
|
export declare function tableFor(c: LogswapClient, address: Address, event: string, contract?: string): {
|
package/dist/history.js
CHANGED
|
@@ -64,17 +64,15 @@ function contractName(c, address, event) {
|
|
|
64
64
|
return null;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* A policy's name in the indexer for one of its events: `Policy
|
|
68
|
-
* two-signature `Listed`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
67
|
+
* A policy's name in the indexer for one of its events: `Policy`. Pass it as {@link EventLogsQuery.contract} for a policy outside the artifact.
|
|
69
68
|
*/
|
|
70
69
|
export function indexedContractOf(kind, event) {
|
|
71
|
-
|
|
72
|
-
return kind === "private" ? "PrivatePolicy" : "PublicPolicy";
|
|
70
|
+
void kind; // `Listed` was the public and the private policy's since 064; the public policy dropped its asset list in F 33 (073), so it is unshared
|
|
73
71
|
return "Policy";
|
|
74
72
|
}
|
|
75
73
|
/** Events whose name two indexed contracts share: postgraphile prefixes their tables. */
|
|
76
74
|
// `CollectorProposed` / `CollectorAccepted` are C 7 / F 26 and older; `TreasuryProposed` / `TreasuryAccepted` replace them (066).
|
|
77
|
-
const SHARED = new Set(["Swap", "Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved"
|
|
75
|
+
const SHARED = new Set(["Swap", "Transfer", "Approval", "OperatorSet", "CollectorProposed", "CollectorAccepted", "TreasuryProposed", "TreasuryAccepted", "Approved"]);
|
|
78
76
|
const plural = (n) => (/(s|x|ch|sh)$/.test(n) ? `${n}es` : `${n}s`);
|
|
79
77
|
/** A column's GraphQL name: postgraphile camelCases the snake_case rindexer writes (`F` → `f`). */
|
|
80
78
|
const column = (name) => name[0].toLowerCase() + name.slice(1);
|
package/dist/indexer.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare function indexerHealthy(url: string, signal?: AbortSignal): Promi
|
|
|
82
82
|
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
83
83
|
* scan as the fallback for when it is not.
|
|
84
84
|
*
|
|
85
|
-
* `MarketCreated` carries every field of the `PoolKey
|
|
85
|
+
* `MarketCreated` carries every field of the `PoolKey` (`mintFee` included since C 12), so the key is rebuilt exactly and `poolId` is
|
|
86
86
|
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
87
87
|
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
88
88
|
*/
|
package/dist/indexer.js
CHANGED
|
@@ -133,18 +133,20 @@ export async function indexerHealthy(url, signal) {
|
|
|
133
133
|
* the more durable path and should be preferred wherever an indexer is configured, with the log
|
|
134
134
|
* scan as the fallback for when it is not.
|
|
135
135
|
*
|
|
136
|
-
* `MarketCreated` carries every field of the `PoolKey
|
|
136
|
+
* `MarketCreated` carries every field of the `PoolKey` (`mintFee` included since C 12), so the key is rebuilt exactly and `poolId` is
|
|
137
137
|
* recomputed locally rather than trusted from the row — the same offline derivation the SDK uses
|
|
138
138
|
* everywhere else, so a wrong id fails loudly instead of addressing the wrong pool.
|
|
139
139
|
*/
|
|
140
140
|
export async function discoverMarketsIndexed(url, signal) {
|
|
141
|
-
const nodes = await gqlAll(url, "allMarketCreateds", "poolId base quote tickSpacing swapFee x0 blockNumber txHash contractAddress", { signal });
|
|
141
|
+
const nodes = await gqlAll(url, "allMarketCreateds", "poolId base quote tickSpacing swapFee mintFee policy x0 blockNumber txHash contractAddress", { signal });
|
|
142
142
|
return nodes.map((n) => {
|
|
143
143
|
const key = {
|
|
144
144
|
base: n.base,
|
|
145
145
|
quote: n.quote,
|
|
146
146
|
tickSpacing: BigInt(n.tickSpacing),
|
|
147
|
+
policy: n.policy,
|
|
147
148
|
swapFee: BigInt(n.swapFee), // rindexer names the column after the event's field: `swapFee` since C version 6 (logswap-be #40)
|
|
149
|
+
mintFee: BigInt(n.mintFee), // a key field since C 12 (078): the event carries it
|
|
148
150
|
};
|
|
149
151
|
return {
|
|
150
152
|
key,
|
package/dist/keys.d.ts
CHANGED
|
@@ -22,15 +22,31 @@ import { type Address, type Hex } from "viem";
|
|
|
22
22
|
*/
|
|
23
23
|
export declare const FEE_MIN: bigint;
|
|
24
24
|
export declare const FEE_MAX: bigint;
|
|
25
|
+
/**
|
|
26
|
+
* The most a pool's creator-selected mint fee may be, WAD (2%): `2 * swapFee <= mintFee <= MINT_FEE_MAX`
|
|
27
|
+
* (C 12 / F 38, decision 078). Both managers check it at `initialize` and revert `BadParam`; the mint fee is a
|
|
28
|
+
* key field, fixed for the life of the pool.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MINT_FEE_MAX: bigint;
|
|
31
|
+
/** The least a pool's mint fee may be for this swap fee: twice it. */
|
|
32
|
+
export declare function minMintFee(swapFee: bigint): bigint;
|
|
33
|
+
/** Is `mintFee` inside the domain for this `swapFee`? Pure; the managers enforce the same bound. */
|
|
34
|
+
export declare function isValidMintFee(swapFee: bigint, mintFee: bigint): boolean;
|
|
25
35
|
/**
|
|
26
36
|
* The economic tuple that IS the market. Field order is load-bearing: it is the ABI encoding order,
|
|
27
|
-
* so it must match `src/types/
|
|
37
|
+
* so it must match `src/types/CPoolKey.sol` exactly.
|
|
28
38
|
*/
|
|
29
39
|
export interface PoolKey {
|
|
30
40
|
base: Address;
|
|
31
41
|
quote: Address;
|
|
32
42
|
/** Log-tick spacing, WAD. The LP-boundary ladder — position floors and caps. */
|
|
33
43
|
tickSpacing: bigint;
|
|
44
|
+
/**
|
|
45
|
+
* The C policy that admits this market (C version 10, decision 073): `PoolKey.policy`, a registry-approved
|
|
46
|
+
* policy, fixed for the market's life. Part of the id: the same pair under two policies is two markets.
|
|
47
|
+
* `address(0)` is a bare deployment with no registry.
|
|
48
|
+
*/
|
|
49
|
+
policy: Address;
|
|
34
50
|
/**
|
|
35
51
|
* The swap fee, WAD, fixed for the life of the market: {@link FEE_MIN} (1 bp) ≤ φ ≤ {@link FEE_MAX} (1%),
|
|
36
52
|
* or `0n`, which since C version 7 is NO fee (decisions 065; `DEFAULT_FEE` is gone). The gate
|
|
@@ -40,6 +56,12 @@ export interface PoolKey {
|
|
|
40
56
|
* is not part of the encoding: no pool id changed with it.
|
|
41
57
|
*/
|
|
42
58
|
swapFee: bigint;
|
|
59
|
+
/**
|
|
60
|
+
* The mint fee, WAD, selected by the creator and fixed for the life of the market (C version 12, decision
|
|
61
|
+
* 078): `2 * swapFee <= mintFee <= {@link MINT_FEE_MAX}`. The fee on newly earning `L`; part of the id, so the
|
|
62
|
+
* same pair and swap fee at two mint fees is two markets. `initialize` takes no separate mint-fee argument.
|
|
63
|
+
*/
|
|
64
|
+
mintFee: bigint;
|
|
43
65
|
}
|
|
44
66
|
/**
|
|
45
67
|
* `poolId = keccak256(abi.encode(key))` — the primary key of the entire read model.
|
package/dist/keys.js
CHANGED
|
@@ -22,6 +22,20 @@ import { encodeAbiParameters, keccak256 } from "viem";
|
|
|
22
22
|
*/
|
|
23
23
|
export const FEE_MIN = 10n ** 14n;
|
|
24
24
|
export const FEE_MAX = 10n ** 16n;
|
|
25
|
+
/**
|
|
26
|
+
* The most a pool's creator-selected mint fee may be, WAD (2%): `2 * swapFee <= mintFee <= MINT_FEE_MAX`
|
|
27
|
+
* (C 12 / F 38, decision 078). Both managers check it at `initialize` and revert `BadParam`; the mint fee is a
|
|
28
|
+
* key field, fixed for the life of the pool.
|
|
29
|
+
*/
|
|
30
|
+
export const MINT_FEE_MAX = 2n * 10n ** 16n;
|
|
31
|
+
/** The least a pool's mint fee may be for this swap fee: twice it. */
|
|
32
|
+
export function minMintFee(swapFee) {
|
|
33
|
+
return 2n * swapFee;
|
|
34
|
+
}
|
|
35
|
+
/** Is `mintFee` inside the domain for this `swapFee`? Pure; the managers enforce the same bound. */
|
|
36
|
+
export function isValidMintFee(swapFee, mintFee) {
|
|
37
|
+
return mintFee <= MINT_FEE_MAX && swapFee <= mintFee / 2n;
|
|
38
|
+
}
|
|
25
39
|
const POOL_KEY_ABI = [
|
|
26
40
|
{
|
|
27
41
|
type: "tuple",
|
|
@@ -29,7 +43,9 @@ const POOL_KEY_ABI = [
|
|
|
29
43
|
{ name: "base", type: "address" },
|
|
30
44
|
{ name: "quote", type: "address" },
|
|
31
45
|
{ name: "tickSpacing", type: "int256" },
|
|
46
|
+
{ name: "policy", type: "address" },
|
|
32
47
|
{ name: "swapFee", type: "uint256" },
|
|
48
|
+
{ name: "mintFee", type: "uint256" },
|
|
33
49
|
],
|
|
34
50
|
},
|
|
35
51
|
];
|
|
@@ -46,7 +62,9 @@ export function poolId(key) {
|
|
|
46
62
|
base: key.base,
|
|
47
63
|
quote: key.quote,
|
|
48
64
|
tickSpacing: key.tickSpacing,
|
|
65
|
+
policy: key.policy,
|
|
49
66
|
swapFee: key.swapFee,
|
|
67
|
+
mintFee: key.mintFee,
|
|
50
68
|
},
|
|
51
69
|
]));
|
|
52
70
|
}
|
package/dist/liquidity.d.ts
CHANGED
|
@@ -61,11 +61,6 @@ export interface CreateMarketArgs extends WriteOptions {
|
|
|
61
61
|
targetFloor: bigint;
|
|
62
62
|
/** The founding exposure; must exceed the manager's `minBackstopL` lock. */
|
|
63
63
|
L: bigint;
|
|
64
|
-
/**
|
|
65
|
-
* The market's mint fee, WAD of newly-earning L — the creator's pick from the gate's menu
|
|
66
|
-
* (decisions 065). Defaults to {@link presetMintFee}: twice the swap fee, capped at `FEE_MAX`.
|
|
67
|
-
*/
|
|
68
|
-
mintFee?: bigint;
|
|
69
64
|
/** Required, as on {@link mint}. Creation is atomic at `x0`, so the flows are fixed by the arguments; {@link UNBOUNDED} is safe here only for that reason. */
|
|
70
65
|
maxBaseIn: bigint;
|
|
71
66
|
maxQuoteIn: bigint;
|
package/dist/liquidity.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { logswapLensAbi, logswapRouterAbi } from "./generated.js";
|
|
25
25
|
import { NO_CAP } from "./ids.js";
|
|
26
|
-
import { describeId, getPositionClass
|
|
26
|
+
import { describeId, getPositionClass } from "./positions.js";
|
|
27
27
|
import { execute, OPEN_DELTA, settleInKind, settleOnly, swapExactInAction, swapExactOutAction, updateAction, } from "./actions.js";
|
|
28
28
|
import { requireWallet, resolveDeadline, resolveRecipient, sendRouterWrite, sendRouterWriteWithPermits, withSlippage, } from "./write.js";
|
|
29
29
|
import { quoteExactIn, quoteExactOut } from "./swap.js";
|
|
@@ -70,7 +70,6 @@ export async function createMarket(c, a) {
|
|
|
70
70
|
args: [
|
|
71
71
|
a.key,
|
|
72
72
|
a.x0,
|
|
73
|
-
a.mintFee ?? presetMintFee(a.key.swapFee),
|
|
74
73
|
a.targetFloor,
|
|
75
74
|
a.L,
|
|
76
75
|
a.maxBaseIn,
|
package/dist/pools.d.ts
CHANGED
|
@@ -30,13 +30,11 @@ export interface PoolState {
|
|
|
30
30
|
/** Fee-per-unit-L accumulator: $\phi \cdot \mathrm{TV}(\log p)$. */
|
|
31
31
|
F: bigint;
|
|
32
32
|
/** Quadratic variation of log-price, $\Sigma = \sum_{\text{swaps}} (\Delta x_{\text{swap}})^2$ — one term per swap. */
|
|
33
|
-
|
|
33
|
+
realizedVariance: bigint;
|
|
34
34
|
currentK: bigint;
|
|
35
35
|
protocolOwed: bigint;
|
|
36
36
|
minBackstopL: bigint;
|
|
37
37
|
backstopFloor: bigint;
|
|
38
|
-
/** The market's mint fee, WAD of newly-earning L: proposed at birth, the gate's answer (065). */
|
|
39
|
-
mintFee: bigint;
|
|
40
38
|
/** The market's swap-fee tax, WAD of every fee paid out: the gate's answer at birth, fixed for life (066). */
|
|
41
39
|
swapFeeTax: bigint;
|
|
42
40
|
}
|
|
@@ -98,7 +96,7 @@ export declare function cListable(price: number, baseDecimals: number, quoteDeci
|
|
|
98
96
|
*
|
|
99
97
|
* Signed: negative means variation has outrun fee income over the pool's life.
|
|
100
98
|
*/
|
|
101
|
-
export declare function lpEdge(state: Pick<PoolState, "F" | "
|
|
99
|
+
export declare function lpEdge(state: Pick<PoolState, "F" | "realizedVariance">): bigint;
|
|
102
100
|
/** A market discovered from a `MarketCreated` log — the full key, plus where it was created. */
|
|
103
101
|
export interface DiscoveredMarket {
|
|
104
102
|
key: PoolKey;
|
|
@@ -180,7 +178,7 @@ export declare function formatQuote(amount: bigint, quoteDecimals: number): stri
|
|
|
180
178
|
/** Fees the pool has accrued over its life, in QUOTE units: $F \cdot L$. */
|
|
181
179
|
export declare function feesQuote(state: Pick<PoolState, "F" | "lActive">): bigint;
|
|
182
180
|
/** The LP edge in QUOTE units: $(F - \tfrac12\Sigma) \cdot L$. Signed. */
|
|
183
|
-
export declare function edgeQuote(state: Pick<PoolState, "F" | "
|
|
181
|
+
export declare function edgeQuote(state: Pick<PoolState, "F" | "realizedVariance" | "lActive">): bigint;
|
|
184
182
|
/** The pool floor as a price. **Lossy** — display only, like {@link priceOf}. */
|
|
185
183
|
export declare function floorPrice(state: Pick<PoolState, "backstopFloor">, scale?: number): number;
|
|
186
184
|
/** $\log(p / p_{\text{floor}}) = x - \xi$ — how far spot sits above the floor, in log units (WAD). */
|
|
@@ -211,15 +209,14 @@ export declare function annualise(perUnitL: bigint, elapsedSeconds: bigint): num
|
|
|
211
209
|
/** When a market was created, as a unix timestamp — the denominator for {@link annualise}. */
|
|
212
210
|
export declare function marketOpenedAt(c: LogswapClient, m: DiscoveredMarket): Promise<bigint>;
|
|
213
211
|
/**
|
|
214
|
-
* Create a C market: `initialize(key, x0
|
|
215
|
-
*
|
|
216
|
-
* swap fee
|
|
217
|
-
* canonical path is the router's {@link createMarket}, which forwards its
|
|
218
|
-
* mints the backstop in the same transaction (064).
|
|
212
|
+
* Create a C market: `initialize(key, x0)` on the manager — a call, not a deployment, and no funds move. The
|
|
213
|
+
* creator-selected mint fee is part of the key (C 12, decision 078: `2 * swapFee <= mintFee <= MINT_FEE_MAX`,
|
|
214
|
+
* preset at twice the swap fee by {@link presetMintFee}); there is no separate argument. Under a curated gate the
|
|
215
|
+
* CALLER must be a listed creator; the canonical path is the router's {@link createMarket}, which forwards its
|
|
216
|
+
* user to the gate and mints the backstop in the same transaction (064).
|
|
219
217
|
*/
|
|
220
218
|
export declare function initializeMarket(c: LogswapClient, a: {
|
|
221
219
|
key: PoolKey;
|
|
222
220
|
x0: bigint;
|
|
223
|
-
mintFee?: bigint;
|
|
224
221
|
account: Address;
|
|
225
222
|
}): Promise<`0x${string}`>;
|
package/dist/pools.js
CHANGED
|
@@ -17,7 +17,6 @@ import { clientChainId } from "./client.js";
|
|
|
17
17
|
import { signerFor } from "./write.js";
|
|
18
18
|
import { readCachedToken, registerCacheClear, writeCachedToken } from "./tokencache.js";
|
|
19
19
|
import { poolId } from "./keys.js";
|
|
20
|
-
import { presetMintFee } from "./positions.js";
|
|
21
20
|
import { getEventLogs } from "./history.js";
|
|
22
21
|
/** Read a market's full state by key, through the lens (`getPools`; C version 7). All zero, `initialized` false, for a market nobody opened. */
|
|
23
22
|
export async function getPool(c, key) {
|
|
@@ -100,7 +99,7 @@ export function cListable(price, baseDecimals, quoteDecimals) {
|
|
|
100
99
|
* Signed: negative means variation has outrun fee income over the pool's life.
|
|
101
100
|
*/
|
|
102
101
|
export function lpEdge(state) {
|
|
103
|
-
return state.F - state.
|
|
102
|
+
return state.F - state.realizedVariance / 2n;
|
|
104
103
|
}
|
|
105
104
|
/**
|
|
106
105
|
* Enumerate markets from `MarketCreated` logs.
|
|
@@ -132,7 +131,9 @@ export async function discoverMarkets(c, opts = {}) {
|
|
|
132
131
|
base: a.base,
|
|
133
132
|
quote: a.quote,
|
|
134
133
|
tickSpacing: a.tickSpacing,
|
|
134
|
+
policy: a.policy,
|
|
135
135
|
swapFee: a.swapFee,
|
|
136
|
+
mintFee: a.mintFee,
|
|
136
137
|
};
|
|
137
138
|
return {
|
|
138
139
|
key,
|
|
@@ -339,18 +340,18 @@ export async function marketOpenedAt(c, m) {
|
|
|
339
340
|
return b.timestamp;
|
|
340
341
|
}
|
|
341
342
|
/**
|
|
342
|
-
* Create a C market: `initialize(key, x0
|
|
343
|
-
*
|
|
344
|
-
* swap fee
|
|
345
|
-
* canonical path is the router's {@link createMarket}, which forwards its
|
|
346
|
-
* mints the backstop in the same transaction (064).
|
|
343
|
+
* Create a C market: `initialize(key, x0)` on the manager — a call, not a deployment, and no funds move. The
|
|
344
|
+
* creator-selected mint fee is part of the key (C 12, decision 078: `2 * swapFee <= mintFee <= MINT_FEE_MAX`,
|
|
345
|
+
* preset at twice the swap fee by {@link presetMintFee}); there is no separate argument. Under a curated gate the
|
|
346
|
+
* CALLER must be a listed creator; the canonical path is the router's {@link createMarket}, which forwards its
|
|
347
|
+
* user to the gate and mints the backstop in the same transaction (064).
|
|
347
348
|
*/
|
|
348
349
|
export async function initializeMarket(c, a) {
|
|
349
350
|
const { request } = await c.public.simulateContract({
|
|
350
351
|
address: c.addresses.cPoolManager,
|
|
351
352
|
abi: cPoolManagerAbi,
|
|
352
353
|
functionName: "initialize",
|
|
353
|
-
args: [a.key, a.x0
|
|
354
|
+
args: [a.key, a.x0],
|
|
354
355
|
account: signerFor(c, a.account),
|
|
355
356
|
});
|
|
356
357
|
return c.wallet.writeContract(request);
|
package/dist/positions.d.ts
CHANGED
|
@@ -110,16 +110,15 @@ export declare function positionQuote(p: {
|
|
|
110
110
|
capped: boolean;
|
|
111
111
|
}, x: bigint): bigint;
|
|
112
112
|
/**
|
|
113
|
-
* The mint fee a create form presets: twice the swap fee
|
|
114
|
-
*
|
|
115
|
-
* (065); a listed entry is what the chain accepts — read it with `policyMintFeeMenu`.
|
|
113
|
+
* The mint fee a create form presets: the least the managers accept, twice the swap fee (C 12 / F 38, decision
|
|
114
|
+
* 078: `2 * swapFee <= mintFee <= {@link MINT_FEE_MAX}`). The creator selects it in the key; there is no menu.
|
|
116
115
|
*/
|
|
117
116
|
export declare function presetMintFee(swapFee: bigint): bigint;
|
|
118
117
|
/**
|
|
119
118
|
* The one-time mint fee at log-price `x`, in quote units — the amount `_mintCore` pulls ON TOP of
|
|
120
119
|
* the position's own legs, so a mint's total quote pull is `positionQuote(p, x) + mintFee(p, x, rate)`.
|
|
121
|
-
* `rate` is the MARKET's mint fee (`
|
|
122
|
-
*
|
|
120
|
+
* `rate` is the MARKET's mint fee (`key.mintFee`, WAD of L): the creator-selected key field since C 12 (078),
|
|
121
|
+
* fixed for life; there is no global `MINT_FEE`.
|
|
123
122
|
*
|
|
124
123
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
125
124
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
package/dist/positions.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { encodeAbiParameters, keccak256, parseAbiItem } from "viem";
|
|
9
9
|
import { logswapLensAbi, cPoolManagerAbi } from "./generated.js";
|
|
10
|
-
import {
|
|
10
|
+
import { MINT_FEE_MAX, poolId } from "./keys.js";
|
|
11
11
|
/** `CPoolState.POSITIONS_SLOT`: the manager's `positions` mapping (`forge inspect CPoolManager storageLayout`). */
|
|
12
12
|
const C_POSITIONS_SLOT = 4n;
|
|
13
13
|
const U128 = (1n << 128n) - 1n;
|
|
@@ -144,19 +144,18 @@ export function positionQuote(p, x) {
|
|
|
144
144
|
return (p.L * (upper - p.floor)) / 10n ** 18n;
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
|
-
* The mint fee a create form presets: twice the swap fee
|
|
148
|
-
*
|
|
149
|
-
* (065); a listed entry is what the chain accepts — read it with `policyMintFeeMenu`.
|
|
147
|
+
* The mint fee a create form presets: the least the managers accept, twice the swap fee (C 12 / F 38, decision
|
|
148
|
+
* 078: `2 * swapFee <= mintFee <= {@link MINT_FEE_MAX}`). The creator selects it in the key; there is no menu.
|
|
150
149
|
*/
|
|
151
150
|
export function presetMintFee(swapFee) {
|
|
152
151
|
const m = 2n * swapFee;
|
|
153
|
-
return m >
|
|
152
|
+
return m > MINT_FEE_MAX ? MINT_FEE_MAX : m;
|
|
154
153
|
}
|
|
155
154
|
/**
|
|
156
155
|
* The one-time mint fee at log-price `x`, in quote units — the amount `_mintCore` pulls ON TOP of
|
|
157
156
|
* the position's own legs, so a mint's total quote pull is `positionQuote(p, x) + mintFee(p, x, rate)`.
|
|
158
|
-
* `rate` is the MARKET's mint fee (`
|
|
159
|
-
*
|
|
157
|
+
* `rate` is the MARKET's mint fee (`key.mintFee`, WAD of L): the creator-selected key field since C 12 (078),
|
|
158
|
+
* fixed for life; there is no global `MINT_FEE`.
|
|
160
159
|
*
|
|
161
160
|
* Mirrors the manager's exemption cases: a DORMANT mint pays nothing — floor above spot, or a
|
|
162
161
|
* capped class spot has already passed (`cap <= x`). Anything earning pays `rate · L`, all of it
|
package/dist/views.d.ts
CHANGED
|
@@ -220,17 +220,15 @@ export interface PoolSummaryRow {
|
|
|
220
220
|
apy7d: number | null;
|
|
221
221
|
}
|
|
222
222
|
export declare function poolSummaries(url: string, q?: ViewQuery): Promise<PoolSummaryRow[]>;
|
|
223
|
-
/** A `regenerate`
|
|
223
|
+
/** A generation step (`regenerate` or a live-pool `deployLiquidity`): the income released and its split (the payee, the rest deepening the bid); a pad's `rung` from `Graduated`. */
|
|
224
224
|
export interface GenerationStepRow {
|
|
225
225
|
kind: string | null;
|
|
226
226
|
poolId: Hex;
|
|
227
227
|
/** The pool's generation after this step. */
|
|
228
228
|
genAfter: number;
|
|
229
|
-
|
|
229
|
+
income: bigint;
|
|
230
230
|
payee: Address;
|
|
231
231
|
toPayee: bigint;
|
|
232
|
-
cut: bigint;
|
|
233
|
-
burnt: bigint;
|
|
234
232
|
deepened: bigint;
|
|
235
233
|
rung: number | null;
|
|
236
234
|
txHash: Hex;
|
|
@@ -238,7 +236,7 @@ export interface GenerationStepRow {
|
|
|
238
236
|
blockTimestamp: number;
|
|
239
237
|
}
|
|
240
238
|
export declare function generationSteps(url: string, q?: ViewQuery): Promise<GenerationStepRow[]>;
|
|
241
|
-
/** Every pad and POL now: the latest snapshot's state, the next graduation's threshold (pads) and the
|
|
239
|
+
/** Every pad and POL now: the latest snapshot's state, the next graduation's threshold (pads) and the income's progress to it, and the steps so far. */
|
|
242
240
|
export interface PadStatusRow {
|
|
243
241
|
kind: string;
|
|
244
242
|
poolId: Hex;
|
|
@@ -247,20 +245,18 @@ export interface PadStatusRow {
|
|
|
247
245
|
creator: Address | null;
|
|
248
246
|
birthTime: number;
|
|
249
247
|
gen: number | null;
|
|
250
|
-
|
|
248
|
+
income: bigint | null;
|
|
251
249
|
unharvested: bigint | null;
|
|
252
250
|
l: bigint | null;
|
|
253
251
|
q: bigint | null;
|
|
254
252
|
tvlQuote: bigint | null;
|
|
255
253
|
shareValue: bigint | null;
|
|
256
254
|
threshold: bigint | null;
|
|
257
|
-
/**
|
|
255
|
+
/** income / threshold, a fraction; null without a threshold. */
|
|
258
256
|
progress: number | null;
|
|
259
257
|
stateBlock: bigint | null;
|
|
260
258
|
stateTime: number | null;
|
|
261
259
|
steps: number;
|
|
262
|
-
burntTotal: bigint;
|
|
263
|
-
cutTotal: bigint;
|
|
264
260
|
paidTotal: bigint;
|
|
265
261
|
deepenedTotal: bigint;
|
|
266
262
|
lastStep: number | null;
|
|
@@ -268,7 +264,7 @@ export interface PadStatusRow {
|
|
|
268
264
|
export declare function padStatuses(url: string, q?: ViewQuery): Promise<PadStatusRow[]>;
|
|
269
265
|
/**
|
|
270
266
|
* Protocol revenue per UTC day, side, source and token. Sources: F `mint_fee` (shares minted to the
|
|
271
|
-
* treasury, valued at the share value) and `
|
|
267
|
+
* treasury, valued at the share value) and `income_tax` (the income tax taken at harvest); C `accrued` (the swap-fee tax and the mint fee
|
|
272
268
|
* together, from the snapshots) and `collected` — basis `collected`, cash moved, not revenue on top
|
|
273
269
|
* of `accrued`.
|
|
274
270
|
*/
|
package/dist/views.js
CHANGED
|
@@ -163,20 +163,20 @@ export async function poolSummaries(url, q = {}) {
|
|
|
163
163
|
}));
|
|
164
164
|
}
|
|
165
165
|
export async function generationSteps(url, q = {}) {
|
|
166
|
-
const rows = await viewRows(url, "allGenerationSteps", "GenerationStep", "kind poolId genAfter
|
|
166
|
+
const rows = await viewRows(url, "allGenerationSteps", "GenerationStep", "kind poolId genAfter income payee toPayee deepened rung txHash blockNumber blockTimestamp", q);
|
|
167
167
|
return rows.map((r) => ({
|
|
168
|
-
kind: r.kind == null ? null : String(r.kind), poolId: hex(r.poolId), genAfter: num(r.genAfter),
|
|
169
|
-
toPayee: big(r.toPayee),
|
|
168
|
+
kind: r.kind == null ? null : String(r.kind), poolId: hex(r.poolId), genAfter: num(r.genAfter), income: big(r.income), payee: addr(r.payee),
|
|
169
|
+
toPayee: big(r.toPayee), deepened: big(r.deepened), rung: intOr(r.rung),
|
|
170
170
|
txHash: hex(r.txHash), blockNumber: big(r.blockNumber), blockTimestamp: secs(r.blockTimestamp),
|
|
171
171
|
}));
|
|
172
172
|
}
|
|
173
173
|
export async function padStatuses(url, q = {}) {
|
|
174
|
-
const rows = await viewRows(url, "allPadStatuses", "PadStatus", "kind poolId quote bases creator birthTime gen
|
|
174
|
+
const rows = await viewRows(url, "allPadStatuses", "PadStatus", "kind poolId quote bases creator birthTime gen income unharvested l q tvlQuote shareValue threshold progress stateBlock stateTime steps paidTotal deepenedTotal lastStep", q);
|
|
175
175
|
return rows.map((r) => ({
|
|
176
176
|
kind: String(r.kind), poolId: hex(r.poolId), quote: addr(r.quote), bases: addrs(r.bases), creator: addrOr(r.creator), birthTime: secs(r.birthTime),
|
|
177
|
-
gen: intOr(r.gen),
|
|
177
|
+
gen: intOr(r.gen), income: bigOr(r.income), unharvested: bigOr(r.unharvested), l: bigOr(r.l), q: bigOr(r.q), tvlQuote: bigOr(r.tvlQuote),
|
|
178
178
|
shareValue: bigOr(r.shareValue), threshold: bigOr(r.threshold), progress: numOr(r.progress), stateBlock: bigOr(r.stateBlock), stateTime: secsOr(r.stateTime),
|
|
179
|
-
steps: num(r.steps),
|
|
179
|
+
steps: num(r.steps), paidTotal: big(r.paidTotal), deepenedTotal: big(r.deepenedTotal), lastStep: secsOr(r.lastStep),
|
|
180
180
|
}));
|
|
181
181
|
}
|
|
182
182
|
export async function protocolRevenueDays(url, q = {}) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logswap/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.81",
|
|
4
4
|
"description": "TypeScript SDK for Logswap, the liquidity primitive introducing the logarithmic invariant — typed wrappers over the CPoolManager / FPoolManager / Router / Lens surface.",
|
|
5
5
|
"license": "GPL-2.0-or-later",
|
|
6
6
|
"type": "module",
|