Skip to content

feat(wind-down): price cohort USD->BTC self-conversions at mid rate - #733

Open
littledino2112 wants to merge 1 commit into
mainfrom
hn/wind-down-mid-price-conversion
Open

feat(wind-down): price cohort USD->BTC self-conversions at mid rate#733
littledino2112 wants to merge 1 commit into
mainfrom
hn/wind-down-mid-price-conversion

Conversation

@littledino2112

@littledino2112 littledino2112 commented Jul 29, 2026

Copy link
Copy Markdown

For the custodial wind-down, cohort accounts convert their USD balance to BTC before migrating out. There is no swap-fee line item in core to waive — the cost of a conversion is the dealer spread baked into stablesats' immediate-sell quote — so behind windDown.convertUsdToBtcAtMidPrice, a self-trade from a cohort account's USD wallet to its own BTC wallet fills the payment builder's hedgeSellUsd slot with the mid-price fns instead of the dealer quote fns. The builder, ledger entries, and trade limits are untouched.

Cohort accounts converting USD to their own BTC wallet get the exchange
mid rate instead of the dealer immediate-sell spread, behind
windDown.convertUsdToBtcAtMidPrice (default false). Pricing-slot swap at
the intraledger call site only; builder, ledger, limits untouched.

@esaugomez31 esaugomez31 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just minor comment.. also e2e (bats) tests are missing for this change, the cohort setup already exists in bats/core/api/migration.bats

Comment on lines 21 to +22
import { checkReceiveAllowed } from "@/app/wind-down/check-receive-allowed"
import { isAccountInWindDownCohort } from "@/app/wind-down/is-account-in-wind-down-cohort"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker but both can use the barrel

Suggested change
import { checkReceiveAllowed } from "@/app/wind-down/check-receive-allowed"
import { isAccountInWindDownCohort } from "@/app/wind-down/is-account-in-wind-down-cohort"
import { checkReceiveAllowed, isAccountInWindDownCohort } from "@/app/wind-down"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants