@logswap/sdk 0.5.80 → 0.5.82
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 +18 -47
- package/dist/admin.js +13 -31
- package/dist/client.d.ts +2 -2
- package/dist/client.js +13 -2
- package/dist/fpool.d.ts +174 -270
- package/dist/fpool.js +191 -175
- package/dist/generated.d.ts +484 -734
- package/dist/generated.js +251 -476
- package/dist/history.js +14 -3
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.js +3 -2
- package/dist/keys.d.ts +17 -1
- package/dist/keys.js +16 -0
- package/dist/liquidity.d.ts +0 -5
- package/dist/liquidity.js +1 -2
- package/dist/pools.d.ts +5 -8
- package/dist/pools.js +7 -7
- 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 +14 -36
- package/src/client.ts +13 -2
- package/src/fpool.ts +267 -245
- package/src/generated.ts +251 -476
- package/src/history.ts +17 -3
- package/src/indexer.ts +4 -3
- package/src/keys.ts +26 -1
- package/src/liquidity.ts +1 -7
- package/src/pools.ts +9 -11
- package/src/positions.ts +6 -7
- package/src/views.ts +12 -16
package/dist/history.js
CHANGED
|
@@ -84,11 +84,22 @@ export function tableFor(c, address, event, contract) {
|
|
|
84
84
|
return { field: `all${plural(type)}`, type };
|
|
85
85
|
}
|
|
86
86
|
const emitters = (q) => (Array.isArray(q.address) ? [...q.address] : [q.address]);
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* A column as the indexer serves it, typed by the ABI: numbers are strings, addresses lowercase, an
|
|
89
|
+
* array a JSON array, and a tuple a JSON object keyed by component name with the same conventions
|
|
90
|
+
* inside (`LiquidityDeployed.baseAssets`, F 38: `{base, amount, priceX36}[]` with string amounts).
|
|
91
|
+
* Decoding recurses into the components, so a tuple's numbers come out as bigints like the node's.
|
|
92
|
+
*/
|
|
93
|
+
function decode(p, v) {
|
|
88
94
|
if (v === null || v === undefined)
|
|
89
95
|
return v;
|
|
96
|
+
const { type } = p;
|
|
90
97
|
if (type.endsWith("[]"))
|
|
91
|
-
return v.map((x) => decode(type.slice(0, -2), x));
|
|
98
|
+
return v.map((x) => decode({ ...p, type: type.slice(0, -2) }, x));
|
|
99
|
+
if (type === "tuple") {
|
|
100
|
+
const o = v;
|
|
101
|
+
return Object.fromEntries((p.components ?? []).map((c) => [c.name, decode(c, o[c.name])]));
|
|
102
|
+
}
|
|
92
103
|
if (type.startsWith("uint") || type.startsWith("int"))
|
|
93
104
|
return BigInt(v);
|
|
94
105
|
if (type === "address")
|
|
@@ -171,7 +182,7 @@ async function fromIndexer(c, q) {
|
|
|
171
182
|
.filter((r) => want.has(String(r.contractAddress).toLowerCase()))
|
|
172
183
|
.map((r) => ({
|
|
173
184
|
address: want.get(String(r.contractAddress).toLowerCase()),
|
|
174
|
-
args: Object.fromEntries(inputs.map((i) => [i.name, decode(i
|
|
185
|
+
args: Object.fromEntries(inputs.map((i) => [i.name, decode(i, r[column(i.name)])])),
|
|
175
186
|
blockNumber: BigInt(r.blockNumber),
|
|
176
187
|
blockTimestamp: Math.floor(Date.parse(r.blockTimestamp) / 1000),
|
|
177
188
|
transactionHash: r.txHash,
|
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,12 +133,12 @@ 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 policy 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,
|
|
@@ -146,6 +146,7 @@ export async function discoverMarketsIndexed(url, signal) {
|
|
|
146
146
|
tickSpacing: BigInt(n.tickSpacing),
|
|
147
147
|
policy: n.policy,
|
|
148
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
|
|
149
150
|
};
|
|
150
151
|
return {
|
|
151
152
|
key,
|
package/dist/keys.d.ts
CHANGED
|
@@ -22,9 +22,19 @@ 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;
|
|
@@ -46,6 +56,12 @@ export interface PoolKey {
|
|
|
46
56
|
* is not part of the encoding: no pool id changed with it.
|
|
47
57
|
*/
|
|
48
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;
|
|
49
65
|
}
|
|
50
66
|
/**
|
|
51
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",
|
|
@@ -31,6 +45,7 @@ const POOL_KEY_ABI = [
|
|
|
31
45
|
{ name: "tickSpacing", type: "int256" },
|
|
32
46
|
{ name: "policy", type: "address" },
|
|
33
47
|
{ name: "swapFee", type: "uint256" },
|
|
48
|
+
{ name: "mintFee", type: "uint256" },
|
|
34
49
|
],
|
|
35
50
|
},
|
|
36
51
|
];
|
|
@@ -49,6 +64,7 @@ export function poolId(key) {
|
|
|
49
64
|
tickSpacing: key.tickSpacing,
|
|
50
65
|
policy: key.policy,
|
|
51
66
|
swapFee: key.swapFee,
|
|
67
|
+
mintFee: key.mintFee,
|
|
52
68
|
},
|
|
53
69
|
]));
|
|
54
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
|
@@ -35,8 +35,6 @@ export interface PoolState {
|
|
|
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
|
}
|
|
@@ -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) {
|
|
@@ -134,6 +133,7 @@ export async function discoverMarkets(c, opts = {}) {
|
|
|
134
133
|
tickSpacing: a.tickSpacing,
|
|
135
134
|
policy: a.policy,
|
|
136
135
|
swapFee: a.swapFee,
|
|
136
|
+
mintFee: a.mintFee,
|
|
137
137
|
};
|
|
138
138
|
return {
|
|
139
139
|
key,
|
|
@@ -340,18 +340,18 @@ export async function marketOpenedAt(c, m) {
|
|
|
340
340
|
return b.timestamp;
|
|
341
341
|
}
|
|
342
342
|
/**
|
|
343
|
-
* Create a C market: `initialize(key, x0
|
|
344
|
-
*
|
|
345
|
-
* swap fee
|
|
346
|
-
* canonical path is the router's {@link createMarket}, which forwards its
|
|
347
|
-
* 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).
|
|
348
348
|
*/
|
|
349
349
|
export async function initializeMarket(c, a) {
|
|
350
350
|
const { request } = await c.public.simulateContract({
|
|
351
351
|
address: c.addresses.cPoolManager,
|
|
352
352
|
abi: cPoolManagerAbi,
|
|
353
353
|
functionName: "initialize",
|
|
354
|
-
args: [a.key, a.x0
|
|
354
|
+
args: [a.key, a.x0],
|
|
355
355
|
account: signerFor(c, a.account),
|
|
356
356
|
});
|
|
357
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.82",
|
|
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",
|
package/src/admin.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* registry and the policies; no router.
|
|
8
8
|
*
|
|
9
9
|
* The mint fee has no cut to set since C version 6 / F version 24 (decisions 058): the whole fee
|
|
10
|
-
* is the protocol's on both managers. A harvest has no cut (056); a pad's protocol share of the
|
|
10
|
+
* is the protocol's on both managers. A harvest has no cut (056); a pad's protocol share of the income
|
|
11
11
|
* is the policy's (`PadPolicy.setSchedule`), capped by the manager at `POT_CUT_MAX`.
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -214,10 +214,10 @@ export async function registryKindOf(c: LogswapClient, policy: Address): Promise
|
|
|
214
214
|
// ─── the policies' numbers (the LOG Authority's; each bounded where it reaches the manager) ─────
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
* `PadPolicy.setSchedule` (decisions 056, 067, 070, 073): the rung's growth and the RANGE a creator chooses
|
|
218
|
-
*
|
|
219
|
-
* burnt since F version 28, and the protocol takes no cut of the
|
|
220
|
-
* {@link
|
|
217
|
+
* `PadPolicy.setSchedule` (decisions 056, 067, 070, 073): the rung's growth and the RANGE inside which a creator chooses their cut of the income
|
|
218
|
+
* at creation (its top ≤ the F manager's `PAYEE_CUT_MAX`). The rest of the income deepens the bid — nothing is bought or
|
|
219
|
+
* burnt since F version 28, and the protocol takes no cut of the income since F version 33 (its revenue is the income tax,
|
|
220
|
+
* {@link padSetIncomeTaxRate}). A change to the range applies to pads born after it; the growth moves every pad at its
|
|
221
221
|
* next rung. The rung is the pool's generation. `T(0)` is per quote since decision 070: {@link padSetThresholdBase}.
|
|
222
222
|
*/
|
|
223
223
|
export async function padSetSchedule(c: LogswapClient, policy: Address, s: PadSchedule): Promise<Hash> {
|
|
@@ -254,12 +254,12 @@ export async function padThresholdBases(c: LogswapClient, policy: Address, quote
|
|
|
254
254
|
);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
/** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the
|
|
257
|
+
/** `PadPolicy.thresholdOf(quote, rung)` (decision 070): the income a pad quoted in `quote` must bank to climb `rung` (0 reads `T(0)`). */
|
|
258
258
|
export async function padThresholdOf(c: LogswapClient, policy: Address, quote: Address, rung: bigint | number = 0n): Promise<bigint> {
|
|
259
259
|
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "thresholdOf", args: [quote, BigInt(rung)] } as never)) as bigint;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
/** `PadPolicy.threshold(poolId, rung)` (decision 070): the
|
|
262
|
+
/** `PadPolicy.threshold(poolId, rung)` (decision 070): the income pad `poolId` must bank to climb `rung`, in its own quote. */
|
|
263
263
|
export async function padThreshold(c: LogswapClient, policy: Address, poolId: Hex, rung: bigint | number): Promise<bigint> {
|
|
264
264
|
return (await c.public.readContract({ address: policy, abi: padPolicyAbi, functionName: "threshold", args: [poolId, BigInt(rung)] } as never)) as bigint;
|
|
265
265
|
}
|
|
@@ -283,14 +283,14 @@ export async function polSetMinQuoteRatio(c: LogswapClient, policy: Address, rat
|
|
|
283
283
|
return write(c, policy, polPolicyAbi, "setMinQuoteRatio", [ratio]);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
/** `PadPolicy.
|
|
287
|
-
export async function
|
|
288
|
-
return write(c, policy, padPolicyAbi, "
|
|
286
|
+
/** `PadPolicy.setIncomeTaxRate` (decision 073): the share of its new income dividend the dead shares pay LOG Treasury as income tax, WAD, at most 50%. The policy sponsor's. */
|
|
287
|
+
export async function padSetIncomeTaxRate(c: LogswapClient, policy: Address, rate: bigint): Promise<Hash> {
|
|
288
|
+
return write(c, policy, padPolicyAbi, "setIncomeTaxRate", [rate]);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
/** `PolPolicy.
|
|
292
|
-
export async function
|
|
293
|
-
return write(c, policy, polPolicyAbi, "
|
|
291
|
+
/** `PolPolicy.setIncomeTaxRate` (decision 073): the share of its new income dividend the pool's authority pays LOG Treasury, WAD, at most 50%. Paid on the authority's own shares only: an authority that holds through another address pays nothing. The policy sponsor's. */
|
|
292
|
+
export async function polSetIncomeTaxRate(c: LogswapClient, policy: Address, rate: bigint): Promise<Hash> {
|
|
293
|
+
return write(c, policy, polPolicyAbi, "setIncomeTaxRate", [rate]);
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/** `setQuoteListed` on any protocol policy: a quote a pool of that kind may be born against while it curates quotes. The LOG Authority's. */
|
|
@@ -335,28 +335,6 @@ export async function policyFeeAllowed(c: LogswapClient, policy: Address, fee: b
|
|
|
335
335
|
return { curated, listed, allowed: !curated || listed };
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
/** `setMintFeeListed` on any protocol policy (065): an entry of its mint-fee menu. The LOG Authority's. */
|
|
339
|
-
export async function policySetMintFeeListed(c: LogswapClient, policy: Address, mintFee: bigint, listed: boolean): Promise<Hash> {
|
|
340
|
-
return write(c, policy, fPolicyBaseAbi, "setMintFeeListed", [mintFee, listed]);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/** `setMintFeeCurated` on any protocol policy: on, a birth proposing an unlisted mint fee is refused (`MintFeeNotListed`). */
|
|
344
|
-
export async function policySetMintFeeCurated(c: LogswapClient, policy: Address, curated: boolean): Promise<Hash> {
|
|
345
|
-
return write(c, policy, fPolicyBaseAbi, "setMintFeeCurated", [curated]);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* A policy's mint-fee menu, for a create form (065): which of `candidates` it lists, and whether it
|
|
350
|
-
* curates at all (uncurated, any fee in the domain is accepted — the desk's policy never curates).
|
|
351
|
-
* The candidates are the app's — typically {@link presetMintFee} of each listed swap tier.
|
|
352
|
-
*/
|
|
353
|
-
export async function policyMintFeeMenu(c: LogswapClient, policy: Address, candidates: readonly bigint[]): Promise<{ curated: boolean; listed: bigint[] }> {
|
|
354
|
-
const rd = (functionName: string, args: readonly unknown[] = []) =>
|
|
355
|
-
c.public.readContract({ address: policy, abi: fPolicyBaseAbi, functionName, args } as never) as Promise<boolean>;
|
|
356
|
-
const [curated, ...flags] = await Promise.all([rd("mintFeeCurated"), ...candidates.map((m) => rd("mintFeeListed", [m]))]);
|
|
357
|
-
return { curated, listed: candidates.filter((_, i) => flags[i]) };
|
|
358
|
-
}
|
|
359
|
-
|
|
360
338
|
/** `PolicyRegistry.CreationMode` (decision 073): who may create under a policy. Open = 0, Restricted = 1 (the initializer list), SponsorOnly = 2 (bound to a sponsor, permanent). */
|
|
361
339
|
export type CreationMode = "open" | "restricted" | "sponsorOnly";
|
|
362
340
|
const CREATION_MODES: readonly CreationMode[] = ["open", "restricted", "sponsorOnly"];
|
|
@@ -418,7 +396,7 @@ export interface CGateRules {
|
|
|
418
396
|
exists: boolean;
|
|
419
397
|
/** Whether `router` is a trusted forwarder on the registry — `createMarket` through it is then checked against `creator`. */
|
|
420
398
|
routerTrusted: boolean;
|
|
421
|
-
/** Every check passes: the policy would admit this market from this creator (the mint fee
|
|
399
|
+
/** Every check passes: the policy would admit this market from this creator (the mint fee is a key field, checked by the manager). */
|
|
422
400
|
admitted: boolean;
|
|
423
401
|
}
|
|
424
402
|
|
package/src/client.ts
CHANGED
|
@@ -180,7 +180,11 @@ function guardChain(wallet: WalletClient, pub: PublicClient): WalletClient {
|
|
|
180
180
|
* takes `SwapParams` (the router's ABI does not move), object-word event names (`MarketCreated`,
|
|
181
181
|
* `PositionMinted`, ...), `MarketCreated` carries creator, mintFee and swapFeeTax. No pool id moved.
|
|
182
182
|
*/
|
|
183
|
-
|
|
183
|
+
// 11 (decision 078): `mintFee` is a key field (the creator's pick, `2 * swapFee <= mintFee <= 2%`); `initialize(key, x0)`
|
|
184
|
+
// takes no separate mint fee, `createMarket` neither; `getPool` drops `mintFee` and the gates' mint-fee menus are gone.
|
|
185
|
+
// Every C pool id moved.
|
|
186
|
+
// 12 (decisions 079-081): `Action` ordinals, the key is `CPoolKey` (names only). No pool id moved.
|
|
187
|
+
export const EXPECTED_VERSION = 12n;
|
|
184
188
|
/**
|
|
185
189
|
* The F manager's own tag (5 — the key's salt, pool names, the sponsor registry;
|
|
186
190
|
* 4 was the income-only harvest cut).
|
|
@@ -274,8 +278,15 @@ export const EXPECTED_VERSION = 10n;
|
|
|
274
278
|
// No pool id moved.
|
|
275
279
|
// 31 (decision 072): `DividendClaimed` names the generation (`gen`, indexed, after `poolId`); `lock` / `unlock` emit
|
|
276
280
|
// `LienLocked` / `LienUnlocked`. No selector, storage layout or pool id moved.
|
|
281
|
+
// 33 (decisions 073, 074): sponsor-bound policies, the income fee, registry admission.
|
|
282
|
+
// 34-38 (decisions 075-085): one liquidity routine. `FPoolKey` holds no weights and no cap and gains `mintFee` (every pool
|
|
283
|
+
// id moved); `initialize(key)`; `seed` / `retire` / `setLegs` are gone for `deployLiquidity(poolId, baseAssets,
|
|
284
|
+
// quoteAmount, lnCapOverSeed, to)` (it SETS THE BOOK on an unfunded or a live pool), `close(poolId, to)` and
|
|
285
|
+
// `regenerate(poolId, to)`; asset membership is fixed by the key; `LiquidityDeployed` echoes the input,
|
|
286
|
+
// `GenerationSeeded` / `LegsSet` are gone; the lens `fPool` field is `baseLegs`, the cap `lnCapOverSeed`; the pot and the
|
|
287
|
+
// income fee are the income and the income tax (`IncomeReleased`, `incomeHeld`, `incomeTax`); a pad is uncapped.
|
|
277
288
|
// A breaking bump: raised in the same change.
|
|
278
|
-
export const EXPECTED_F_VERSION =
|
|
289
|
+
export const EXPECTED_F_VERSION = 38n;
|
|
279
290
|
|
|
280
291
|
export async function assertVersion(c: LogswapClient, expected = EXPECTED_VERSION): Promise<void> {
|
|
281
292
|
const { cPoolManagerAbi, fPoolManagerAbi } = await import("./generated.js");
|