From 6f930b618fadbcc606878685c4d05e1dc0e9c01d Mon Sep 17 00:00:00 2001 From: g1nt0ki <99907941+g1nt0ki@users.noreply.github.com> Date: Thu, 15 Feb 2024 23:46:21 +0100 Subject: [PATCH] Bitflow (#8977) * feat: add BitFlow adapter * code refactor --------- Co-authored-by: Rodrigo Eduardo --- projects/bitflow/index.js | 17 +++++++++++++++++ projects/helper/chain/stacks.js | 4 +++- projects/helper/tokenMapping.js | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 projects/bitflow/index.js diff --git a/projects/bitflow/index.js b/projects/bitflow/index.js new file mode 100644 index 0000000000..ffd2235fb2 --- /dev/null +++ b/projects/bitflow/index.js @@ -0,0 +1,17 @@ +const { sumTokensExport } = require("../helper/sumTokens"); + +const BITFLOW_ADDRESS = "SPQC38PW542EQJ5M11CR25P7BS1CA6QT4TBXGB3M"; + +const PAIRS = [ + `${BITFLOW_ADDRESS}.stableswap-stx-ststx-v-1-1`, + `${BITFLOW_ADDRESS}.stableswap-stx-ststx-v-1-2`, + `${BITFLOW_ADDRESS}.stableswap-usda-susdt-v-1-2`, + `${BITFLOW_ADDRESS}.stableswap-abtc-xbtc-v-1-2`, +] + +module.exports = { + stacks: { + tvl: sumTokensExport({ owners: PAIRS }), + }, + methodology: "Total Liquidity Added to DEX Trading Pools", +}; diff --git a/projects/helper/chain/stacks.js b/projects/helper/chain/stacks.js index 04989fd2cf..579e39dbe7 100644 --- a/projects/helper/chain/stacks.js +++ b/projects/helper/chain/stacks.js @@ -1,5 +1,6 @@ const { get, } = require('../http') const { nullAddress } = require('../tokenMapping') +const { getFixBalancesSync } = require('../portedTokens') const sdk = require('@defillama/sdk') const chain = 'stacks' @@ -41,7 +42,8 @@ async function sumTokens({ owner, owners = [], tokens = [], balances = {}, black if (owner) owners = [owner] await Promise.all(owners.map(i => addTokens(i, { balances, tokens, blacklistedTokens, }))) - return balances + const transform = getFixBalancesSync(chain) + return transform(balances) } module.exports = { diff --git a/projects/helper/tokenMapping.js b/projects/helper/tokenMapping.js index 2523386241..c88302a7b9 100644 --- a/projects/helper/tokenMapping.js +++ b/projects/helper/tokenMapping.js @@ -66,6 +66,11 @@ const fixBalancesTokens = { moonbeam: { '0xffffffff99dabe1a8de0ea22baa6fd48fde96f6c': { coingeckoId: 'voucher-glmr', decimals: 18 }, '0xffffffffcd0ad0ea6576b7b285295c85e94cf4c1': { coingeckoId: 'filecoin', decimals: 18 }, + }, + stacks: { + 'SP4SZE494VC2YC5JYG7AYFQ44F5Q4PYV7DVMDPBG.ststx-token::ststx': { coingeckoId: 'blockstack', decimals: 6 }, + 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-susdt::bridged-usdt': { coingeckoId: 'tether', decimals: 8 }, + 'SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-abtc::bridged-btc': { coingeckoId: 'bitcoin', decimals: 8 }, } }