Skip to main content

transwap

Abstract

This document specifies the x/transwap module, which allows coin exchanges for Guru station.

This module has been designed to receive the MsgExchange transactions from other chains through IBC and perform the exchanges.

Compared to other ibc-related modules, the transwap module is a standalone solution where all functionalities are overwritten. The transwap module reads the state from x/bex module and relies on the registered exchanges for its transactions.

Contents

  1. Concepts
  2. State
  3. Keeper
  4. Events

Concepts

IBC

The x/transwap module relies on IBC protocol for exchanging messages between other chains. The module consumes MsgTransfer, and MsgExchange transaction packets through its exchange port.

  • MsgTransfer: behaves just like the ibc-transfer module. The coins are received to receiver address with ibc denomination. THis msg is mainly used for maintaining the luqidity on the reserve_address.
  • MsgExchange: performs the swap operation based on the request and transfers the converted amount to the destination address through registered port and channel.

Features

Ratemeter

The opt-in feature that defines the possibility of limiting users from over-using the coin exchanges to avoid scams and attacks. The ratemeter defines the maximum limit per user for a day and the maximum amount that can be exchanged per request.

Fees

The transwap module allows the organizations of providers to manually distribute the coin exchange added fees.

Note. The default transaction fee is not effected by the added fees. The added fees are the ones added on top of basic transaction signing fees.

Refunds

The x/transwap module allows a full refund at any point the transaction fails.

  • Fail on source chain. The tranbsaction does not reach the transwap module
  • Fail on Guru chain. The transwap module executes the default refund procedure
  • Fail on destination chain. The transwap module maps each acknowledgement with the original request where the refund procedure can be invoked manually.

State

The x/transwap module keeps in the state variables:

DescriptionKeyValueStore
Paramsmodule parameters[]byte{1}[]byte{Params}KV
DenomTracesdenom traces for keeping track of ibc-transferred coins[]byte{2}[]DenomTraceKV

Keeper

The x/transwap module provides this exported keeper that can be passed to other modules, which require access to transfer methods.

type Keeper interface {
Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error)
}

Events

The x/bex module emits the following events:

OnRecvTransfer

TypeAttribute KeyAttribute Value
transfersender{senderAddress}
transferreceiver{receiverAddress}
transferamount{amount}
transferchannel{channel}
transferport{port}

OnRecvExchange

TypeAttribute KeyAttribute Value
exchangesender{senderAddress}
exchangereceiver{receiverAddress}
exchangeamount{amount}
exchangechannel{channel}
exchangeport{port}