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

index search #106

Open
Zergity opened this issue Dec 15, 2023 · 1 comment
Open

index search #106

Zergity opened this issue Dec 15, 2023 · 1 comment
Assignees

Comments

@Zergity
Copy link
Contributor

Zergity commented Dec 15, 2023

Initial load of the dapp page only load the following pools:

  1. whitelisted pools in public configs
  2. all pools with pool token (1155) in user wallet
  3. cached pools of the same index with above pools

Search:

  1. first search in the pools above (for base symbol and name)
  2. if there's result, show them and a link button [more] at the end (clicking it willl go to step 4)
  3. if there's no result, continue with step 4
  4. query the scan API for topic events, and show the result

Whitelist pools config: configs/<network>/pools.json

{
  pools: {
    "0x.. pool addess": {
      baseSymbol: "MAGIC",
      ... more data can be put here to save loading time like pool configs and search keys, etc.
    }
  }
}

Data Flows

Flow 1: pools are whitelisted by pool address, and grouped by index = base+quote+reserve (configs and staticcall)
Flow 2: pools that user has balance, grouped by index = base+quote+reserve (scan API and staticcall)
Flow 3: pools are searched by keywords (topics), and grouped by index = base+quote+reserve (scan API and staticcall)
Flow 4: pool is specified in URL query, load it and display any cached pools with the same index

In all 3 flows, there will be pools of the same index that doesn't show in the UI on the first load, there will be a Load More Pools button (next to the leverage slide), that scan all log with topic0 == baseToken, grouped by index, store to localstorage and show to UI.

Topics

Pools now are created with 4 topics for base token search:

  • topic0: baseToken address (instead of event signature), this topic is used to search for all pool with the same base token address that user pasted in the search box
  • topics1: baseSymbol
  • topics2 & 3: part of baseSymbol, or other kind of search keywords that pool creator can pass for their users to find their pool easier

To search for pool with keyword MA, the filter should be:

{
  address: configs.derivable.poolDeployer,
  topics: [
        [null, null, null, null],
        [null, "MA", null, null],
        [null, null, "MA", null],
        [null, null, null, "MA"],
  ],
}

The first 2 arbitrum pools:

TOKEN_R WETH
INDEX √PENDLE/WETH x16
TOPICS 0x0c880f6761F1af8d9Aa9C466984b80DAb9a8c9e8 PENDLE PEND PEN
WINDOW 2 min(s)
MARK 0.00055474
INTEREST_HL 36.10 day(s)
PREMIUM_HL 0.36 day(s)
MATURITY 1.00 hr(s)
VESTING 2.00 min(s)
CLOSE_FEE 1 %
OPEN_FEE 0 %
New Pool Address: 0xBb8b02f3a4C3598e6830FC6740F57af3a03e2c96
TOKEN_R WETH
INDEX √MAGIC/WETH x16
TOPICS 0x539bdE0d7Dbd336b79148AA742883198BBF60342 MAGIC MAG MA
WINDOW 2 min(s)
MARK 0.0003498
INTEREST_HL 36.10 day(s)
PREMIUM_HL 0.36 day(s)
MATURITY 1.00 hr(s)
VESTING 2.00 min(s)
CLOSE_FEE 1 %
OPEN_FEE 0 %
New Pool Address: 0x482c5d7B45B7fEEF78B255cc5b7AcA9e2Fea6F7a
@Zergity
Copy link
Contributor Author

Zergity commented Dec 15, 2023

1: using this wallet 0xE61383556642AF1Bd7c5756b13f19A63Dc8601df will have this issue and crash the UI:

react-dom.development.js:12056 Uncaught TypeError: Cannot read properties of undefined (reading 'topics')
    at history.ts:152:1
    at Array.map (<anonymous>)
    at History.formatSwapHistory (history.ts:151:1)
    at useSwapHistory.ts:52:1
    at commitHookEffectListMount (react-dom.development.js:23150:1)
    at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
    at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
    at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
    at commitPassiveMountEffects (react-dom.development.js:24866:1)
    at flushPassiveEffectsImpl (react-dom.development.js:27039:1)

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

3 participants