Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exchange broker #2

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Exchange broker #2

wants to merge 16 commits into from

Conversation

jfrazier-eth
Copy link
Collaborator

@jfrazier-eth jfrazier-eth commented Nov 2, 2022

Exchange Broker

Requirements:

  • Support brokering orders between multiple exchanges
    • Minimum requirement: A listing on another exchange should be able to be purchased, a valid Infinity listing should be constructed (passed via function arguments) and matched with an existing listing on Infinity.
    • Ideally this is abstract enough to support arbitrage between two or more non-Infinity exchanges
  • It would be ideal if the requirements could be met without altering InfinityExchange.sol to prevent additional approvals
  • Infinity exchange should be fully reimbursed for any gas used

Features Supported

  • Fulfill a listing on another exchange => using a valid Infinity offer automatically fulfill an Infinity listing
  • Ability to call matchOneToOneOrders, matchOneToManyOrders and matchOrders in a single transaction - this may slightly decrease gas costs vs calling these each separately
  • Ability to take out a flash loan to execute trades
  • TokenBroker is able to execute arbitrary transactions such as setting approvals, withdrawing ETH from WETH, and fulfilling an order on another exchange.
  • Infinity exchange is fully reimbursed for gas used

Questions:

What is the best way to pay for gas fees?

  1. User's pay for all gas fees (current implementation)
  • Pros

    • Assuming users set their gas fee limit high enough, this allows Infinity to realize its maximum volume
  • Cons

    • Requires us to redeploy the InfinityExchange contract (user's will need to reapprove)
    • Does not support arbitrage between two (or more) non-Infinity exchanges
    • Users may wonder why there are large discrepancies in gas usage, or be put off by the gas they end up paying
      • What is the price a user would pay for multi-exchange automatic order execution over manually using an aggregator?
    • Requires users's gas fee limit to be set high
  1. User's pay for their order being matched on Infinity, TokenBroker is responsible for paying for fees like purchasing from other marketplaces and taking out flash loans
  • Pros
    • No need to redeploy the InfinityExchange contract (user's will NOT need to reapprove)
    • Supports arbitrage between non-Infinity exchanges
    • User gas paid remains the same, so the details of purchasing from another exchange are fully abstracted
    • Assuming there is significant arbitrage in bundles of orders, this allows also allows Infinity to realize its maximum volume
  • Cons
    • Requires there to be enough arbitrage in a full bundle of orders to be able to pay for gas fees

@jfrazier-eth jfrazier-eth marked this pull request as ready for review November 8, 2022 16:39
@jfrazier-eth jfrazier-eth mentioned this pull request Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant