From 5471f6ff99a3c4b2812d60d2ca293efafc83a1a5 Mon Sep 17 00:00:00 2001 From: 0xpeluche <0xpeluche@proton.me> Date: Wed, 25 Sep 2024 14:39:35 +0200 Subject: [PATCH] feat:Adapter, Limitless-Exchange (prediction markets) --- projects/limitless-exchange/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 projects/limitless-exchange/index.js diff --git a/projects/limitless-exchange/index.js b/projects/limitless-exchange/index.js new file mode 100644 index 000000000000..005357f54872 --- /dev/null +++ b/projects/limitless-exchange/index.js @@ -0,0 +1,22 @@ +const eventAbi = "event FixedProductMarketMakerCreation(address indexed creator, address fixedProductMarketMaker, address indexed conditionalTokens, address indexed collateralToken, bytes32[] conditionIds, uint256 fee)"; +const config = [ + { factory: "0x8E50578ACa3C5E2Ef5ed2aA4bd66429B5e44C16E", resolver: "0x15A61459d65D89A25a9e91e0dc9FC69598791505", fromBlock: "13547870" }, + { factory: "0xc397D5d70cb3B56B26dd5C2824d49a96c4dabF50", resolver: "0xc9c98965297bc527861c898329ee280632b76e18", fromBlock: "13547845" }, +]; + +const getMarkets = async ({ factory, resolver, fromBlock }, api) => { + const logs = await api.getLogs({ target: factory, eventAbi, fromBlock, toTimestamp: api.timestamp }); + const tokens = [...new Set(logs.map((log) => log.args[3]))]; + return api.sumTokens({ owner: resolver, tokens }); +}; + +const tvl = async (api) => { + for (const marketConfig of config) { + await getMarkets(marketConfig, api); + } +}; + +module.exports = { + methodology: "The TVL represents the total amount of tokens deposited in the prediction markets", + base: { tvl } +};