JIT-funded TWAP from EOA via ComposableCowPoller#14
Open
anxolin wants to merge 3 commits into
Open
Conversation
Follow-up to the TWAP-from-EOA PoC. Instead of moving the full TWAP sell amount into cow-shed up front, each part is pulled just-in-time from the EOA via the ComposableCowPoller contract, so capital stays in the user's wallet between parts. - New postTwapForEOAWithJitFunds script: a 1-wei sell=buy order carries a gasless post-hook that approves the Vault Relayer and creates the TWAP on cow-shed; the EOA approves the poller for the full sell amount and registers the JIT funding schedule. The watch-tower then pulls each part on demand. - Add a minimal ComposableCowPoller contract helper and its Gnosis address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #12 (TWAP from EOA), adding just-in-time funding of funds.
In #12 the full TWAP sell amount had to flow into cow-shed up front, which is capital-inefficient for TWAPs/DCA that span long periods. Here the capital stays in the user's EOA and each part is pulled just before it settles via the
ComposableCowPollercontract (see cowprotocol/composable-cow#116).How it works
createWithContext, sot0is anchored to the settlement block). The TWAP is owned by cow-shed; proceeds go back to the EOA. Now that sell==buy is supported, no extra intermediate token is needed.ComposableCowPollerfor the full TWAP sell amount and registers the funding schedule (register(ctx, {handler, funder: EOA, owner: cow-shed, staticInput})).poller.topUp(ctx), which pulls exactly that part's sell amount from the EOA into cow-shed.This removes both drawbacks noted in #12: it is capital-efficient, and it no longer depends on a distinct sell/buy token for the setup order.
Notes
topUpis left to the watch-tower (it cannot live in the TWAP's own appData: the hook embedsctx, butctxderives from the appData hash — a cycle).yarn installto patch the SDK.Test
Requirements: set
PRIVATE_KEYandRPC_URL_100in.env; the EOA needs ≥ ~0.21 sDAI on Gnosis (0.2 TWAP + dust for the sell=buy order fee).Then watch the cow-shed orders in the explorer (printed by the script) as each part is funded and settled.