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

Proposal: integrate Symmetric finance DEX #6

Closed
diwu1989 opened this issue Dec 15, 2021 · 8 comments
Closed

Proposal: integrate Symmetric finance DEX #6

diwu1989 opened this issue Dec 15, 2021 · 8 comments

Comments

@diwu1989
Copy link
Contributor

Their exchange interface:
https://github.com/centfinance/Symmetric.Core/blob/develop/contracts/proxies/ExchangeProxy.sol#L20-L28

There's about anywhere between 100 to 300 celo daily of uncontested arb profit on Symmetric right now.
Would like to implement Symmetric Pair and add it as a DEX liquidity source.

@zviadm
Copy link
Collaborator

zviadm commented Dec 16, 2021

Integrating Symmetric would be fantastic. I have just been too lazy to parse out all their contract intricacies to implement it.
One hint: To add multi-token pools (i.e. pools with 3 or more tokens), you need to create every single possible Pair, but use same 'PairKey' for all of them. This is the way the system is designed to support multi-token pools.

Example: Pool has tokens: A, B, C, you will create Pairs of A/B, A/C, B/C but all of them with the same PairKey which is generally address of the pool itself.

@diwu1989
Copy link
Contributor Author

I think will start with a simple version that only deal with dual-token pool, just to get the arbs started.

The multi-token pool is more complicated, that same pool can be re-used in the swap path entering and exiting as different pairs though right?

@diwu1989
Copy link
Contributor Author

okay i think i know what you mean, will take a stab at it

@diwu1989
Copy link
Contributor Author

They have decent offline javascript calculations already:
https://github.com/centfinance/Symmetric.Core/blob/develop/lib/calc_comparisons.js

@diwu1989
Copy link
Contributor Author

They dont have on-chain registry yet, their UI uses a static json i think:
https://storageapi.fleek.co/switch1983-team-bucket/cent-exchange-celo/pools

@diwu1989
Copy link
Contributor Author

GraphQL to get all their pools:

{
  pools {
    id
    tokens {
      id
      name
      symbol
      balance
      denormWeight
    }
    swapFee
    controller
    publicSwap
    finalized
  }
}

https://thegraph.com/hosted-service/subgraph/centfinance/cent-swap-celo

@diwu1989
Copy link
Contributor Author

@diwu1989
Copy link
Contributor Author

This is a pretty good GraphQL to run:

curl 'https://api.thegraph.com/subgraphs/name/centfinance/cent-swap-celo' \
  -H 'authority: api.thegraph.com' \
  -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'content-type: application/json' \
  -H 'accept: */*' \
  -H 'origin: https://thegraph.com' \
  -H 'sec-fetch-site: same-site' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'referer: https://thegraph.com/' \
  -H 'accept-language: en-US,en;q=0.9' \
  --data-raw '{"query":"{\n  pools(orderBy: createTime, orderDirection: desc, where: { active: true, liquidity_gt: 0, finalized: true}) {\n    id\n    active\n    liquidity\n    tokensCount\n    tokens {\n      id\n      name\n      symbol\n      balance\n      denormWeight\n    }\n    createTime\n    swapFee\n    controller\n    publicSwap\n    finalized\n  }\n}","variables":null}' \
  --compressed
{
  pools(
    orderBy: createTime
    orderDirection: desc
    where: { active: true, liquidity_gt: 0, finalized: true }
  ) {
    id
    active
    liquidity
    tokensCount
    createTime
    swapFee
    controller
    publicSwap
    finalized
    tokens {
      id
      name
      symbol
      balance
      denormWeight
    }
  }
}

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

No branches or pull requests

2 participants