feat: withdraw via treasury InstantWithdrawCw20 (replace TransferFrom allowance) #20
Labels
No labels
enhancement
governance
QA
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/ust1-window#20
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Change
ust1-windowredeem path from CW20TransferFrom+ treasury allowance to calling the CMM Treasury’s registered CW20 InstantWithdraw API (Option 3). Deposits keep forwarding vFDUSD tocmm_treasury; withdraws ask treasury toTransfervFDUSD to the user.Depends on: PlasticDigits2/ustr-cmm#6 (treasury
SetCw20Spender+InstantWithdrawCw20).Parent deploy track: #19 Phase 5 (withdraw smoke currently blocked).
Current codebase
contracts/ust1-window/src/contract.rs→withdrawv_out; thenBurnUST1 +TransferFrom { owner: cmm_treasury, recipient: user, amount: v_out }.contract.rs→query_cw20_allowanceInsufficientTreasuryAllowance.contracts/ust1-window/src/error.rsInsufficientVfdusd,InsufficientTreasuryAllowance.state.rs/msg.rscmm_treasuryset at instantiate only (defaultust1_cmm::CMM_TREASURY_MAINNET); noSetTreasury.contracts/ust1-window/src/multitest.rsAddrtreasury that canIncreaseAllowance(setup_with_treasury_allowance).smartcontracts-terraclassic/tests/src/integration_tests.rsdocs/DEPLOYMENT.mdPhase 5 §2,README.mdterra1zxwpzpzpleatqn39r00grau4yt29sld8pw78s7ktvjafnj5nsaxq0h3rh2(code 11550)terra16j5u6….Problem: Default
cmm_treasuryis ustr-cmm Treasury (contract). It cannot signincrease_allowance. Option 2 (treasury emits allowance) was rejected in favor of Option 3 (treasury InstantWithdraw for registered spender).Why this is needed
terra16j5u6…(no re-pointing window to a hot wallet) once ustr-cmm#6 lands and spender is registered.Constraints / guardrails
Transfer→cmm_treasuryunchanged.INV-SWAP-*), per-tx / rolling limits, pause,min_vfdusd_out.Burn+ treasuryInstantWithdrawCw20must be in the same tx response (ordered submessages); failure of either must fail the tx.cmm_treasuryremains instantiate-only unless a separate governance issue addsSetTreasury(out of scope unless migrate forces it).terra1zxwp…(admin = governance) or re-instantiate only if migrate insufficient — prefer migrate to keep address if integrators already wired it.SetCw20Spender { token: TERRA_VFDUSD, spender: WINDOW }after both contracts are live — document inDEPLOYMENT.md.cmm-native-wrapin this issue (native wrap is ustr-cmm wrap-mapper per #19 decisions).Relevant files
contracts/ust1-window/src/contract.rs— withdraw messages + remove allowance gatecontracts/ust1-window/src/error.rs— replace/repurposeInsufficientTreasuryAllowancecontracts/ust1-window/src/state.rs— doc comments oncmm_treasurycontracts/ust1-window/src/msg.rs—MigrateMsgif neededcontracts/ust1-window/src/multitest.rs— mock treasury that accepts InstantWithdrawCw20smartcontracts-terraclassic/tests/src/integration_tests.rs— end-to-end without IncreaseAllowancesmartcontracts-terraclassic/packages/ust1-cmm/— keep mainnet treasury constant; optional shared msg types if usefuldocs/DEPLOYMENT.mdPhase 5 — replace allowance steps with SetCw20Spender + migrate windowREADME.md— withdraw model blurbRecommended direction
Define a minimal treasury execute client in-window (or tiny helper module), matching ustr-cmm#6:
In
withdraw:InsufficientVfdusd).InsufficientTreasuryAllowance.BurnUST1, thenWasmMsg::Execute→cfg.cmm_treasurywithInstantWithdrawCw20 { recipient: user, token: cfg.vfdusd_token, amount: v_out }.Multitest: replace mock EOA allowance with a stub treasury contract (or cw-multi-test app contract) implementing InstantWithdrawCw20 + holding CW20.
Optimize + store new
ust1_windowcode; migrate mainnet window; treasury gov registers window as vFDUSD spender; run withdraw smoke.Update Phase 5 docs: delete EOA
increase_allowanceinstructions; add dependency on ustr-cmm#6 +SetCw20Spender.Out of scope: Implementing treasury CW20 API (ustr-cmm#6); oracle service; bridge; changing fee/limit params.
Acceptance criteria
TransferFromor requires CW20 allowance.InstantWithdrawCw20(or final agreed msg name from ustr-cmm#6) with correct recipient/token/amount.docs/DEPLOYMENT.md+ README describe Option 3 wiring; Phase 5 checklist updated.SetCw20Spender→ smoke).Test plan — functional paths
v_outmin_vfdusd_outInsufficientVfdusdor treasury error)Test plan — attack / abuse / hack vectors
ExecuteMsgtrying to pull treasurysender(user), not attacker-controlled fieldCMM_TREASURY_MAINNETv_out; no second transfer; fail-closed on treasury errorVerification criteria
cargo testforust1-window+ integration suite green.IncreaseAllowance.SetCw20Spender: small withdraw smoke tx succeeds; finder shows treasury CW20Transfer(notTransferFromfrom an EOA).allowance(treasury, window)remains 0 / unused.Dependencies / sequencing
SetCw20Spenderon treasury.mentioned in issue PlasticDigits2/ustr-cmm#6
Companion treasury issue: https://gitlab.com/PlasticDigits2/ustr-cmm/-/work_items/6
Blocked on ustr-cmm#6 msg schema / migrate before mainnet withdraw smoke on #19.
mentioned in issue #19
mentioned in merge request PlasticDigits2/ustr-cmm!38
mentioned in issue PlasticDigits2/ustr-cmm#7
mentioned in merge request PlasticDigits2/ustr-cmm!39
mentioned in issue PlasticDigits2/ustr-cmm#5
mentioned in commit
41c203273cmentioned in merge request !34
Implementation MR: https://gitlab.com/PlasticDigits/ust1-window/-/merge_requests/1
Done in MR (code + docs + tests):
InstantWithdrawCw20(noTransferFrom/ allowance)INV-WITHDRAW-*Not done here (ops / #19):
terra1zxwp…SetCw20Spender+limit_24h(ustr-cmm#7 fail-closed)marked the checklist item Withdraw no longer calls TransferFrom or requires CW20 allowance. as completed
marked the checklist item Withdraw emits treasury InstantWithdrawCw20
or final agreed msg name from ustr\-cmm\#6with correct recipient/token/amount. as completedmarked the checklist item Deposit path unchanged (forward vFDUSD to treasury). as completed
marked the checklist item Multitest + integration tests updated; allowance-based setup removed or marked obsolete. as completed
marked the checklist item Errors: clear failure when treasury rejects (unregistered / paused / insufficient balance). as completed
marked the checklist item docs/DEPLOYMENT.md + README describe Option 3 wiring; Phase 5 checklist updated. as completed
marked the checklist item Mainnet migrate plan documented (code id → migrate tx → SetCw20Spender → smoke). as completed
marked the checklist item Linked to ustr-cmm#6; #19 Phase 5 withdraw AC unblocked after ops steps. as completed
mentioned in commit
5b1e719622mentioned in issue #21