Skip to content

Commit 31e338e

Browse files
committed
docs(withdraw-cli): scrub internal references from README + comments
Removes internal-only references from the public withdraw-cli release: private module cross-references in source comments, internal audit-round tags (R48 / R49 / R55, one in a user-facing console line), and predecessor build-version comparisons (V9.x / V10). Rewritten to describe the invariants and the V1 contract surface directly. Documentation and comments only; no behaviour change.
1 parent 8715946 commit 31e338e

4 files changed

Lines changed: 23 additions & 27 deletions

File tree

withdraw-cli/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ V1 command-line self-serve withdrawal + Layer 3 dead-man-switch trigger. Runs en
44

55
Currently supports **Preprod** (V1 launch-candidate ceremony). Mainnet placeholder ships unfilled — pass `--config <path>` once V1 mainnet ceremony lands.
66

7-
## What V1 adds vs the V9.x / V10 `withdraw-cli`
7+
## V1 contract surface
88

9-
V1 ships a different on-chain contract surface from V9.x / V10:
9+
This CLI targets the V1 on-chain contract surface:
1010

11-
- **29-field VaultDatum** (vs 25 in V9). Adds `liqwid_positions`, `non_deposit_value`, `last_realloc_time`, `last_fee_update_time`, `last_ada_swap_time`, `keeper_fee_bps`, `gov_fee_bps`, `max_slippage_bps`, `min_swap_peg_bps`, and the new operational flag `community_sunset_triggered`.
12-
- **R55 compile-time vault NFT anchor**: `vault_nft_policy` is no longer a datum field — it's baked into `vault_proxy` / `vusdcx` / `order` at compile time. The CLI locates the vault UTXO by NFT scan at the proxy address.
13-
- **Withdraw redeemer signature**: `Constr(1, [shares, receiver, receiver_output_idx])` (V9 was `Constr(1, [shares, receiver])`). The third field defends against R48 M-1 anti-double-satisfaction.
14-
- **Withdraw-Zero routes through `vault_user`** (V9 used `vault_core`; V1 split the user-flow validators).
11+
- **29-field VaultDatum**, including `liqwid_positions`, `non_deposit_value`, `last_realloc_time`, `last_fee_update_time`, `last_ada_swap_time`, `keeper_fee_bps`, `gov_fee_bps`, `max_slippage_bps`, `min_swap_peg_bps`, and the operational flag `community_sunset_triggered`.
12+
- **Compile-time vault NFT anchor**: `vault_nft_policy` is not a datum field — it's baked into `vault_proxy` / `vusdcx` / `order` at compile time. The CLI locates the vault UTXO by NFT scan at the proxy address.
13+
- **Withdraw redeemer signature**: `Constr(1, [shares, receiver, receiver_output_idx])`. The third field pins which output index the receiver payout must land at, closing an output double-satisfaction gap.
14+
- **Withdraw-Zero routes through `vault_user`**: the user-flow validators are split, so Withdraw touches `vault_user` only.
1515
- **Layer 3 CommunitySunset**: a permissionless redeemer any vUSDCx holder can call after ≥90 days of operational inactivity. Sets `frozen=1 + community_sunset_triggered=1`, opening the permissionless `vault_recall.RecallFromLiqwid` + `vault_protocol.DeployToProtocol` Layer 2 paths. The CLI exposes this as `sunset-status` (read) + `sunset-trigger` (write).
1616

1717
## Quick start
@@ -49,7 +49,7 @@ optivaults-v1-withdraw balance \
4949

5050
### `quote` — estimate output
5151

52-
Pure-math preview of a Withdraw, including R49 M-4 deferred-yield (subtract NET not BASE from `total_deposited`) and the 7-day keeper-inactive fee waiver.
52+
Pure-math preview of a Withdraw, including deferred-yield accounting (subtract NET not BASE from `total_deposited`) and the 7-day keeper-inactive fee waiver.
5353

5454
```bash
5555
optivaults-v1-withdraw quote \
@@ -126,7 +126,7 @@ The CLI builds V1 transactions with:
126126
- **Proxy spend** — vault UTXO at proxy address with `ProxyRedeemer::UseUser = Constr(0,[])`
127127
- **User staking withdrawal**`withdraw(user_reward_addr, 0, Constr(1, [shares, receiver, receiver_output_idx]))`
128128
- **vUSDCx burn**`mintAssets({vusdcx: -shares}, Constr(1, []))`
129-
- **Reference scripts**`readFrom([vaultProxy, vaultUser, vusdcx])` (3 entries, identical to V9.x — the additional V1 staking validators are not needed for Withdraw)
129+
- **Reference scripts**`readFrom([vaultProxy, vaultUser, vusdcx])` (3 entries — the additional V1 staking validators are not needed for Withdraw)
130130

131131
CommunitySunset replaces the `withdraw` redeemer with `Constr(3, [])` and skips the burn + payout outputs (datum-only mutation, vault assets unchanged).
132132

withdraw-cli/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ program
188188
const shares = BigInt(opts.shares)
189189
const q = computeWithdrawQuote(vault, shares)
190190

191-
console.log('── Withdraw Quote (V1, R49 M-4 deferred-yield) ──')
191+
console.log('── Withdraw Quote (V1, deferred-yield accounting) ──')
192192
console.log(` Shares to burn: ${q.shares.toString()}`)
193193
console.log(` Gross withdraw: ${fmtMicro(q.baseWithdraw)} (deposit-token units)`)
194194
console.log(` Early fee: ${fmtMicro(q.earlyFee)} (${q.keeperInactive ? 'WAIVED — keeper inactive 7d+' : 'active'})`)

withdraw-cli/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export interface V1Config {
7575

7676
/// Bech32 address of the vault UTXO (lives at proxy script address).
7777
proxyAddr: string
78-
/// Hex28 — vault NFT minting policy (R55 compile-time anchor).
78+
/// Hex28 — vault NFT minting policy (compile-time anchor).
7979
vaultNftPolicy: string
8080
/// Hex — vault NFT asset name (typically "OptiVault" hex).
8181
vaultNftName: string

withdraw-cli/src/vault.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22
* V1 vault state query + Withdraw-Zero TX builder + CommunitySunset
33
* (Layer 3 90-day dead-man-switch) TX builder.
44
*
5-
* V1 differs from V9.x / V10:
6-
* - 29-field VaultDatum (added: liqwid_positions, non_deposit_value,
5+
* V1 contract surface:
6+
* - 29-field VaultDatum (liqwid_positions, non_deposit_value,
77
* last_realloc_time, last_fee_update_time, last_ada_swap_time,
88
* keeper_fee_bps, gov_fee_bps, max_slippage_bps, min_swap_peg_bps,
99
* community_sunset_triggered)
10-
* - Withdraw redeemer: Constr(1, [shares, receiver, receiver_output_idx])
11-
* (V9 was Constr(1, [shares, receiver]) — 2 fields; V1 added
12-
* receiver_output_idx to defend against R48 M-1 anti-double-satisfaction)
13-
* - Withdraw routes through `vault_user` staking validator (V9 used
14-
* `vault_core`; V1 split user-flow into `vault_user` + `vault_keeper_hot`)
15-
* - vault_proxy.UseUser = Constr(0, []) (was UseCore)
16-
* - vault_nft_policy is a compile-time anchor (R55), not a datum field;
10+
* - Withdraw redeemer: Constr(1, [shares, receiver, receiver_output_idx])
11+
* receiver_output_idx pins the payout output index, defending against
12+
* output double-satisfaction
13+
* - Withdraw routes through the `vault_user` staking validator (the
14+
* user-flow validators are split into `vault_user` + `vault_keeper_hot`)
15+
* - vault_proxy.UseUser = Constr(0, [])
16+
* - vault_nft_policy is a compile-time anchor, not a datum field;
1717
* vault is identified via NFT scan at proxy address
1818
* - CommunitySunset = Constr(3, []) — permissionless redeemer; sets
1919
* frozen=1 + community_sunset_triggered=1 after ≥90d operational inactivity
2020
*
21-
* V1 Withdraw TX structure (Withdraw-Zero pattern, identical 3 ref scripts
22-
* to V9):
21+
* V1 Withdraw TX structure (Withdraw-Zero pattern, 3 ref scripts):
2322
* - Spend vault UTXO at proxy address with ProxyRedeemer::UseUser
2423
* - Withdraw 0 lovelace from `vault_user` reward address with
2524
* VaultRedeemer::Withdraw(shares, receiver, receiver_output_idx)
@@ -200,9 +199,6 @@ function hexToUint8Array(hex: string): Uint8Array {
200199
* letting Lucid send hex text.
201200
* 3. Return `{redeemer_tag, redeemer_index, ex_units}` shape that
202201
* Lucid's downstream effect-ts switch expects.
203-
*
204-
* Mirrors `v1/reference/frontend/src/lib/lucidClient.ts::patchBlockfrostEvaluate`
205-
* + `deploy/lib/blockfrostProvider.ts::patchEval`.
206202
*/
207203
function patchBlockfrostEvaluate(bf: any, baseUrl: string, key: string): void {
208204
bf.evaluateTx = async (tx: string, _additionalUTxOs?: unknown) => {
@@ -264,7 +260,7 @@ function patchBlockfrostEvaluate(bf: any, baseUrl: string, key: string): void {
264260
* missing `drep_deposit` / `gov_action_deposit` fields). Replace its
265261
* `getProtocolParameters` with a Conway-safe implementation that reads
266262
* Blockfrost REST directly + applies fallbacks. Cached per provider
267-
* instance. Mirrors `v1/keeper/src/agent/utils/blockfrostProtocolParamsPatch.ts`.
263+
* instance.
268264
*/
269265
function patchProtocolParamsConwaySafe(bf: any, url: string, key: string): void {
270266
let cached: any = null
@@ -353,7 +349,7 @@ export function hydrateRewardAddrs(cfg: V1Config): void {
353349

354350
/**
355351
* Locate the unique vault UTXO at proxy.address by scanning for the
356-
* one-shot vault NFT (R55 compile-time anchor). The deploy ceremony
352+
* one-shot vault NFT (compile-time anchor). The deploy ceremony
357353
* mints exactly one such NFT and burns the mint window deadline, so
358354
* there is provably one vault UTxO per proxy address.
359355
*/
@@ -589,7 +585,7 @@ export async function buildWithdrawTx(
589585
// Build new datum — copy all 29 fields, mutate only accounting deltas.
590586
const oldDatum = Data.from(state.rawDatum) as any
591587
const newFields = [...(oldDatum.fields as unknown[])]
592-
newFields[VF.total_deposited] = state.totalDeposited - quote.netWithdraw // R49 M-4 deferred-yield: subtract NET, not BASE
588+
newFields[VF.total_deposited] = state.totalDeposited - quote.netWithdraw // deferred-yield: subtract NET, not BASE
593589
newFields[VF.total_shares] = state.totalShares - shares
594590
newFields[VF.idle_buffer] = state.idleBuffer - quote.netWithdraw
595591
const newDatumCbor = Data.to(new Constr(0, newFields as any) as any)

0 commit comments

Comments
 (0)