Axis-Fi / axis-core

Axis Protocol
https://axis.finance
Other
6 stars 1 forks source link

Auction House: Purchases for Atomic Auctions #6

Closed Oighty closed 7 months ago

Oighty commented 9 months ago

Atomic auctions allow users to instantly purchase tokens from them. They are settled in the same transaction. As such, the interface is similar to an AMM. A user specifies the lotId (in place of a pool address), amount in, and minAmountOut (which is a slippage check) in the same way as when executing a swap on an AMM pool. The user can also specify a recipient that is different than the address which is providing the funds and a referrer (which is often the interface submitting the transaction). It could be useful to allow for Permit-style approvals for the quote token so the user doesn't have to submit an approval transaction before a purchase.

Continuing the analogy, the AuctionHouse should also have functionality to route purchases through multiple atomic auctions within a single purchase. This allows solvers or front-ends to save gas on transactions where multiple hops through different auctions give the best price. For a route, you specify a list of lotIds that the purchase should go through, the amount in is in quote tokens of the first auction in the list and the minAmountOut is in payout tokens for the last auction in the list. We can treat the interim as a black box since we only care about what is received at the end.

Additionally, it may make sense to allow multiple purchases to be batched in the same transaction. There are two cases:

  1. There are multiple markets with the same payout token. A user can get the best price by splitting their purchase amounts to different markets instead of all of them going to the same one.
  2. The user wants to batch multiple separate purchases (with different payouts) into the same transaction to save gas.

A first pass at the function interfaces are defined on the Router abstract in src/design/ARCHITECTURE.md