|
|
|
@ -27,8 +27,6 @@ const getBaseApi = function (type) { |
|
|
|
|
return `https://api.metaswap.codefi.network/featureFlag` |
|
|
|
|
case 'aggregatorMetadata': |
|
|
|
|
return `https://api.metaswap.codefi.network/aggregatorMetadata` |
|
|
|
|
case 'feeAmount': |
|
|
|
|
return `https://api.metaswap.codefi.network/fee` |
|
|
|
|
default: |
|
|
|
|
throw new Error('getBaseApi requires an api call type') |
|
|
|
|
} |
|
|
|
@ -247,11 +245,6 @@ export async function fetchSwapsFeatureLiveness () { |
|
|
|
|
return status?.active |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function fetchMetaMaskFeeAmount () { |
|
|
|
|
const response = await fetchWithCache(getBaseApi('feeAmount'), { method: 'GET' }, { cacheRefreshTime: 600000 }) |
|
|
|
|
return response?.fee |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export async function fetchTokenPrice (address) { |
|
|
|
|
const query = `contract_addresses=${address}&vs_currencies=eth` |
|
|
|
|
|
|
|
|
@ -294,7 +287,18 @@ export function getRenderableGasFeesForQuote (tradeGas, approveGas, gasPrice, cu |
|
|
|
|
|
|
|
|
|
export function quotesToRenderableData (quotes, gasPrice, conversionRate, currentCurrency, approveGas, tokenConversionRates) { |
|
|
|
|
return Object.values(quotes).map((quote) => { |
|
|
|
|
const { destinationAmount = 0, sourceAmount = 0, sourceTokenInfo, destinationTokenInfo, slippage, aggType, aggregator, gasEstimateWithRefund, averageGas } = quote |
|
|
|
|
const { |
|
|
|
|
destinationAmount = 0, |
|
|
|
|
sourceAmount = 0, |
|
|
|
|
sourceTokenInfo, |
|
|
|
|
destinationTokenInfo, |
|
|
|
|
slippage, |
|
|
|
|
aggType, |
|
|
|
|
aggregator, |
|
|
|
|
gasEstimateWithRefund, |
|
|
|
|
averageGas, |
|
|
|
|
fee, |
|
|
|
|
} = quote |
|
|
|
|
const sourceValue = calcTokenAmount(sourceAmount, sourceTokenInfo.decimals || 18).toString(10) |
|
|
|
|
const destinationValue = calcTokenAmount(destinationAmount, destinationTokenInfo.decimals || 18).toPrecision(8) |
|
|
|
|
|
|
|
|
@ -357,6 +361,7 @@ export function quotesToRenderableData (quotes, gasPrice, conversionRate, curren |
|
|
|
|
sourceTokenValue: sourceValue, |
|
|
|
|
ethValueOfTrade, |
|
|
|
|
minimumAmountReceived, |
|
|
|
|
metaMaskFee: fee, |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|