WIP: Add cow CLI settle command#52
Conversation
no need to distinguish when resolving token information
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
need to clean up the code a bit tomorrow
Description
Adds a command
settleto the existing settlement CLI which, given a list of order UIDs/PDAs, attemptsSummary
The settle command completes all the required operations to complete a settlement. This generally breaks down to:
BeginSettleto pull in the required funds from the user into the solver's token ATAFinalizeSettleto push the resulting funds to the user, including surplus based on the available fundsIt can serve as an example of what is needed in order to complete a settlement.
Other design considerations:
buyorders have not yet been tested and should be considered unsupportod for this initial releaseNOTE: this branch assumes that #26 is merged already in its changes, which is why it appears there are many more changes than actually happening. Please disregard any changes already in that PR for now.
Out of Scope
orca_swap()insettle.rsis stubbed out and will error if a settlement requires a swap (i.e. non-CoW case where no counterpart order exists for a given token pair). Since the priority is to demonstrate the most basic settlement the extra step of swapping as a interaction is currently not included.Run a test settlement on DevNet!
Prerequisites:
trader-usdc.json: the trader that has USDC and wants to buy SOL; use https://faucet.circle.com/ to get USDC for the trade on devnet. Needs a bit of SOL for gas.trader-sol.json: the trader that has SOL and wants to buy USDC; needs SOL for both the order (0.1 SOL in the example below) and some gas.solver.json: the solver for the order, needs a bit of SOL for gas.Expected output:
The
[+N surplus]annotation confirms that proportional surplus was distributed back to each order beyond their minimum requested amount.If the supplied order is expired (defaults to 5 minutes), you may see an error like
...Program MooohhPEAAHwAwEozL7JPEmnDvaahuUpccYN4Yb8ccK failed: custom program error: 0xf(0xf corresponds to 15, the settlement contract's error for expired order). If this happens, recreate the orders and try again.Example settle generated by the CLI: https://solscan.io/tx/4YuY3MGV1w4GKRFnL8oDjmqz79ALNTC8c7i1t9UMifWuFhVCSRaA2t2ECweG9GfWttv9nz3Xu15dx5sDbw9GZsCS?cluster=devnet
🤖 Generated with Claude Code