From f35f4b96a3de837419ad221dd8e770357c4047a8 Mon Sep 17 00:00:00 2001 From: Efrain9502 <137243819+Efrain9502@users.noreply.github.com> Date: Wed, 8 Jan 2025 05:45:12 +0800 Subject: [PATCH] Add Haedal AMM Adapter (#12977) --- projects/haedal-amm/index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 projects/haedal-amm/index.js diff --git a/projects/haedal-amm/index.js b/projects/haedal-amm/index.js new file mode 100644 index 0000000000..570a986902 --- /dev/null +++ b/projects/haedal-amm/index.js @@ -0,0 +1,19 @@ +const sui = require('../helper/chain/sui') + +async function suiTVL(api) { + const poolObjectID = '0x3b822ea230e2f63860b05d4166ddce7133c0d04838d8f93ce02a88098fe0c609' + const {fields:{pools:{fields: {contents:listPool}}}} = await sui.getObject(poolObjectID) + for( const pool of listPool){ + const {fields:{value: pool_id}} = pool + const {type,fields:{coins:{fields:{base_coin, quote_coin}}}} = await sui.getObject(pool_id) + const [coinA, coinB] = type.replace('>', '').split('<')[1].split(', ') + api.add(coinA, base_coin) + api.add(coinB, quote_coin) + } +} + +module.exports = { + sui: { + tvl: suiTVL, + } +} \ No newline at end of file