From f86761e339855a8dc524e78d637058fd70397448 Mon Sep 17 00:00:00 2001 From: Paul V Puey Date: Thu, 2 Nov 2023 16:53:33 -0700 Subject: [PATCH] Add rune support --- src/swap/defi/thorchain.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/swap/defi/thorchain.ts b/src/swap/defi/thorchain.ts index a51cb17b..8d7e816f 100644 --- a/src/swap/defi/thorchain.ts +++ b/src/swap/defi/thorchain.ts @@ -668,6 +668,22 @@ const getPool = ( tokenCode: string, pools: Pool[] ): Pool => { + if (mainnetCode === 'THOR' && tokenCode === 'RUNE') { + // Create a fake pool for rune. Use BTC pool to find rune USD price + const btcPool = pools.find(pool => pool.asset === 'BTC.BTC') + + if (btcPool == null) { + throw new SwapCurrencyError(swapInfo, request) + } + const { assetPrice, assetPriceUSD } = btcPool + const pool: Pool = { + asset: 'THOR.RUNE', + assetPrice: '1', + assetPriceUSD: div(assetPriceUSD, assetPrice, 16) + } + return pool + } + const pool = pools.find(pool => { const [asset] = pool.asset.split('-') return asset === `${mainnetCode}.${tokenCode}`