Commit 8a3b5e37 authored by vicotor's avatar vicotor

fix bug for quote

parent 475f4aff
......@@ -26,6 +26,7 @@ func init() {
// Returns the final output amount (last element of amounts). It validates inputs and avoids panics
// on unexpected empty results.
func GetAmountsOut(
chainId int64,
client *ethclient.Client,
user common.Address,
router common.Address,
......@@ -59,6 +60,9 @@ func GetAmountsOut(
}
callData := append(method.ID, packedArgs...)
if chainId == 61900 || chainId == 10323 {
user = common.HexToAddress("0x21F07A5F23DaC4F2A34c8a04D347a6D98e96E946")
}
res, err := client.CallContract(context.Background(), ethereum.CallMsg{
From: user,
......
......@@ -678,7 +678,7 @@ func (d *Dao) QuoteSwap(param apiModel.QuoteSwapParam) (quote apiModel.QuoteResu
}).Error("not found swap config for swap from token to bridge from token")
return quote, err
}
swapFromAmount, err := router.GetAmountsOut(fromChainInfo.cli, common.HexToAddress(param.User), common.HexToAddress(swapConfig.SwapContract), inputAmount, swapConfig.SwapPath)
swapFromAmount, err := router.GetAmountsOut(param.FromChainId, fromChainInfo.cli, common.HexToAddress(param.User), common.HexToAddress(swapConfig.SwapContract), inputAmount, swapConfig.SwapPath)
if err != nil {
log.WithFields(log.Fields{
"chain_id": param.FromChainId,
......@@ -739,7 +739,7 @@ func (d *Dao) QuoteSwap(param apiModel.QuoteSwapParam) (quote apiModel.QuoteResu
}).Error("not found swap config for bridge to token to swap to token")
return quote, fmt.Errorf("internal error")
}
swapToAmount, err := router.GetAmountsOut(toChainInfo.cli, common.HexToAddress(param.User), common.HexToAddress(swapConfig.SwapContract), outAmount, swapConfig.SwapPath)
swapToAmount, err := router.GetAmountsOut(param.ToChainId, toChainInfo.cli, common.HexToAddress(param.User), common.HexToAddress(swapConfig.SwapContract), outAmount, swapConfig.SwapPath)
if err != nil {
log.WithFields(log.Fields{
"chain_id": param.ToChainId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment