Skip to content

Commit

Permalink
Add rune support
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Nov 3, 2023
1 parent e9b88de commit f86761e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/swap/defi/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down

0 comments on commit f86761e

Please sign in to comment.