Skip to content

Releases: chainhop-dex/chainhop-contracts

v1.0.0-dev.2 Refund Feature

17 Mar 11:05
Compare
Choose a tag to compare
Pre-release

Change Log

Refund Via Liquidity Bridge

  • allows user to withdraw refund in one tx through the TransferSwapper contract

Steps to refund

  1. Query SGN Gateway's QueryTransferStatus to know whether the transfer has gone through or has entered a refund state.
  2. If the transfer is in refund state, query SGN node to get the refund call params through /sgn/v1/message/execution_context_by_src_transfer. Continue polling until response.has_enough_sigs is true. Note: The only thing frontend needs to change in this request is "src_transfer_id", keep others as is in the example.
  • Example SGN request url
// fetch refund call params
https://cbridge-v2-test.celer.network/sgn/v1/message/execution_context_by_src_transfer?src_transfer_id=0x0160e46d34b3617e5a821d5a24bc9bbd5b2d4e2fb25b3daf6da42b9635faecfd&src_bridge_type=1&message_id_only=false&check_sigs=true

// fetch withdraw call params
https://cbridge-v2-test.celer.network/sgn/cbridge/v1/withdraw/status?seq_num=<seq_num>&usr_addr=<TransferSwap_Address>
  • Side note: SGN's endpoint is listed here
  1. Call TransferSwapper.refundViaLiquidityBridge on source chain using both withdraw call params and refund call params
  2. funds should be returned to the receiver specified in the original TransferDescription on source chain

1.0.0-dev.1 Initial Dev Release

15 Mar 07:55
Compare
Choose a tag to compare
Pre-release

Change Log

Param TransferDescription

  • Added allowPartialFill option. In case of multi route swapping, turning on this param allows some swap routes to fail and refund the failed amount in to user as bridge token while also sending the amount gained from success swaps to user. (NOTE: this parameter should always be set to false for the initial release)

  • Added nativeIn option. Set this param to true if swapping with native token (e.g. ETH, BNB) as the token in.

Event RequestDone

  • Added refundAmount field. In case of allowPartialFill == true or normal swap failure on the destination chain, the refunded amount (as bridge token) is recorded in this field (originally it reuses the dstAmount field in the RequestDone event).

Event RequestSent

  • Added transferId field.

Fee's Sign Data Encoding

  • Sign data is changed to include srcChainId, amountIn and tokenIn to prevent user from using signed fee of small swaps (low gas cost) for huge swaps.
keccak256(abi.encodePacked("executor fee", srcChainId, dstChainId, amountIn, tokenIn, feeDeadline, fee))