From c84e51ffb6ffdd826a755ebc27e63ae6af6a56e7 Mon Sep 17 00:00:00 2001 From: Samuel Holmes Date: Fri, 11 Aug 2023 17:11:25 -0700 Subject: [PATCH] Use the `value` from the LI.FI quote response data directly The mainnet value must be sent as it is calculated by the LI.FI API because it includes mainnet amount needed to pay for bridge fees within the smart contract. --- src/swap/defi/lifi.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/swap/defi/lifi.ts b/src/swap/defi/lifi.ts index 969fd553..675b5422 100644 --- a/src/swap/defi/lifi.ts +++ b/src/swap/defi/lifi.ts @@ -291,10 +291,10 @@ export function makeLifiPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin { const quoteJson = await quoteResponse.json() const quote = asV1Quote(quoteJson) - const { estimate, includedSteps } = quote + const { estimate, includedSteps, transactionRequest } = quote const { approvalAddress, toAmountMin } = estimate - const { data, gasLimit, gasPrice } = quote.transactionRequest + const { data, gasLimit, gasPrice } = transactionRequest const gasPriceDecimal = hexToDecimal(gasPrice) const gasPriceGwei = div18(gasPriceDecimal, '1000000000') const providers = includedSteps.map(s => s.toolDetails.name) @@ -333,7 +333,7 @@ export function makeLifiPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin { spendTargets: [ { memo: data, - nativeAmount: nativeAmount, + nativeAmount: mul(transactionRequest.value, '1'), publicAddress: approvalAddress } ],