bridge

package
v0.179.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2024 License: MPL-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncreaseEstimatedGasFactor = 1.1

	EthSymbol = "ETH"
	SntSymbol = "SNT"
	SttSymbol = "STT"

	TransferName        = "Transfer"
	HopName             = "Hop"
	CBridgeName         = "CBridge"
	SwapParaswapName    = "Paraswap"
	ERC721TransferName  = "ERC721Transfer"
	ERC1155TransferName = "ERC1155Transfer"
	ENSRegisterName     = "ENSRegister"
	ENSReleaseName      = "ENSRelease"
)
View Source
const (
	SevenDaysInSeconds = 604800
)

Variables

View Source
var (
	ZeroAddress     = common.Address{}
	ZeroBigIntValue = big.NewInt(0)
)

Functions

This section is empty.

Types

type BonderFee added in v0.179.22

type BonderFee struct {
	AmountIn                *bigint.BigInt `json:"amountIn"`
	Slippage                float32        `json:"slippage"`
	AmountOutMin            *bigint.BigInt `json:"amountOutMin"`
	DestinationAmountOutMin *bigint.BigInt `json:"destinationAmountOutMin"`
	BonderFee               *bigint.BigInt `json:"bonderFee"`
	EstimatedRecieved       *bigint.BigInt `json:"estimatedRecieved"`
	Deadline                int64          `json:"deadline"`
	DestinationDeadline     int64          `json:"destinationDeadline"`
}

func (*BonderFee) UnmarshalJSON added in v0.179.22

func (bf *BonderFee) UnmarshalJSON(data []byte) error

type Bridge

type Bridge interface {
	// returns the name of the bridge
	Name() string
	// checks if the bridge is available for the given networks/tokens
	AvailableFor(params BridgeParams) (bool, error)
	// calculates the fees for the bridge and returns the amount BonderFee and TokenFee (used for bridges)
	CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)
	// Pack the method for sending tx and method call's data
	PackTxInputData(params BridgeParams, contractType string) ([]byte, error)
	EstimateGas(params BridgeParams) (uint64, error)
	CalculateAmountOut(params BridgeParams) (*big.Int, error)
	Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)
	GetContractAddress(params BridgeParams) (common.Address, error)
	BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)
	BuildTx(params BridgeParams) (*ethTypes.Transaction, error)
}

type BridgeParams added in v0.179.28

type BridgeParams struct {
	FromChain *params.Network
	ToChain   *params.Network
	FromAddr  common.Address
	ToAddr    common.Address
	FromToken *token.Token
	ToToken   *token.Token
	AmountIn  *big.Int

	// extra params
	BonderFee *big.Int
	Username  string
	PublicKey string
}

type CBridge added in v0.117.3

type CBridge struct {
	// contains filtered or unexported fields
}

func NewCbridge added in v0.117.3

func NewCbridge(rpcClient *rpc.Client, transactor transactions.TransactorIface, tokenManager *token.Manager) *CBridge

func (*CBridge) AvailableFor added in v0.179.22

func (s *CBridge) AvailableFor(params BridgeParams) (bool, error)

func (*CBridge) BuildTransaction added in v0.171.1

func (s *CBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*CBridge) BuildTx added in v0.178.0

func (s *CBridge) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*CBridge) CalculateAmountOut added in v0.117.3

func (s *CBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*CBridge) CalculateFees added in v0.117.3

func (s *CBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*CBridge) EstimateGas added in v0.117.3

func (s *CBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*CBridge) GetContractAddress added in v0.125.0

func (s *CBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*CBridge) Name added in v0.117.3

func (s *CBridge) Name() string

func (*CBridge) PackTxInputData added in v0.179.24

func (c *CBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*CBridge) Send added in v0.117.3

func (s *CBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)

type CBridgeTxArgs added in v0.117.3

type CBridgeTxArgs struct {
	transactions.SendTxArgs
	ChainID   uint64         `json:"chainId"`
	Symbol    string         `json:"symbol"`
	Recipient common.Address `json:"recipient"`
	Amount    *hexutil.Big   `json:"amount"`
}

type ENSRegisterBridge added in v0.179.28

type ENSRegisterBridge struct {
	// contains filtered or unexported fields
}

func NewENSRegisterBridge added in v0.179.28

func NewENSRegisterBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface, ensService *ens.Service) *ENSRegisterBridge

func (*ENSRegisterBridge) AvailableFor added in v0.179.28

func (s *ENSRegisterBridge) AvailableFor(params BridgeParams) (bool, error)

func (*ENSRegisterBridge) BuildTransaction added in v0.179.28

func (s *ENSRegisterBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*ENSRegisterBridge) BuildTx added in v0.179.28

func (s *ENSRegisterBridge) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*ENSRegisterBridge) CalculateAmountOut added in v0.179.28

func (s *ENSRegisterBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*ENSRegisterBridge) CalculateFees added in v0.179.28

func (s *ENSRegisterBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*ENSRegisterBridge) EstimateGas added in v0.179.28

func (s *ENSRegisterBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*ENSRegisterBridge) GetContractAddress added in v0.179.28

func (s *ENSRegisterBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*ENSRegisterBridge) GetPriceForRegisteringEnsName added in v0.179.28

func (s *ENSRegisterBridge) GetPriceForRegisteringEnsName(chainID uint64) (*big.Int, error)

func (*ENSRegisterBridge) Name added in v0.179.28

func (s *ENSRegisterBridge) Name() string

func (*ENSRegisterBridge) PackTxInputData added in v0.179.28

func (s *ENSRegisterBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*ENSRegisterBridge) Send added in v0.179.28

func (s *ENSRegisterBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

type ENSReleaseBridge added in v0.179.28

type ENSReleaseBridge struct {
	// contains filtered or unexported fields
}

func NewENSReleaseBridge added in v0.179.28

func NewENSReleaseBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface, ensService *ens.Service) *ENSReleaseBridge

func (*ENSReleaseBridge) AvailableFor added in v0.179.28

func (s *ENSReleaseBridge) AvailableFor(params BridgeParams) (bool, error)

func (*ENSReleaseBridge) BuildTransaction added in v0.179.28

func (s *ENSReleaseBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*ENSReleaseBridge) BuildTx added in v0.179.28

func (s *ENSReleaseBridge) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*ENSReleaseBridge) CalculateAmountOut added in v0.179.28

func (s *ENSReleaseBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*ENSReleaseBridge) CalculateFees added in v0.179.28

func (s *ENSReleaseBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*ENSReleaseBridge) EstimateGas added in v0.179.28

func (s *ENSReleaseBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*ENSReleaseBridge) GetContractAddress added in v0.179.28

func (s *ENSReleaseBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*ENSReleaseBridge) Name added in v0.179.28

func (s *ENSReleaseBridge) Name() string

func (*ENSReleaseBridge) PackTxInputData added in v0.179.28

func (s *ENSReleaseBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*ENSReleaseBridge) Send added in v0.179.28

func (s *ENSReleaseBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

type ERC1155TransferBridge added in v0.174.1

type ERC1155TransferBridge struct {
	// contains filtered or unexported fields
}

func NewERC1155TransferBridge added in v0.174.1

func NewERC1155TransferBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface) *ERC1155TransferBridge

func (*ERC1155TransferBridge) AvailableFor added in v0.179.22

func (s *ERC1155TransferBridge) AvailableFor(params BridgeParams) (bool, error)

func (*ERC1155TransferBridge) BuildTransaction added in v0.174.1

func (s *ERC1155TransferBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*ERC1155TransferBridge) BuildTx added in v0.178.0

func (*ERC1155TransferBridge) CalculateAmountOut added in v0.174.1

func (s *ERC1155TransferBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*ERC1155TransferBridge) CalculateFees added in v0.174.1

func (s *ERC1155TransferBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*ERC1155TransferBridge) EstimateGas added in v0.174.1

func (s *ERC1155TransferBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*ERC1155TransferBridge) GetContractAddress added in v0.174.1

func (s *ERC1155TransferBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*ERC1155TransferBridge) Name added in v0.174.1

func (s *ERC1155TransferBridge) Name() string

func (*ERC1155TransferBridge) PackTxInputData added in v0.179.24

func (s *ERC1155TransferBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*ERC1155TransferBridge) Send added in v0.174.1

func (s *ERC1155TransferBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

type ERC1155TransferTxArgs added in v0.174.1

type ERC1155TransferTxArgs struct {
	transactions.SendTxArgs
	TokenID   *hexutil.Big   `json:"tokenId"`
	Recipient common.Address `json:"recipient"`
	Amount    *hexutil.Big   `json:"amount"`
}

type ERC721TransferBridge added in v0.166.9

type ERC721TransferBridge struct {
	// contains filtered or unexported fields
}

func NewERC721TransferBridge added in v0.166.9

func NewERC721TransferBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface) *ERC721TransferBridge

func (*ERC721TransferBridge) AvailableFor added in v0.179.22

func (s *ERC721TransferBridge) AvailableFor(params BridgeParams) (bool, error)

func (*ERC721TransferBridge) BuildTransaction added in v0.171.1

func (s *ERC721TransferBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*ERC721TransferBridge) BuildTx added in v0.178.0

func (*ERC721TransferBridge) CalculateAmountOut added in v0.166.9

func (s *ERC721TransferBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*ERC721TransferBridge) CalculateFees added in v0.166.9

func (s *ERC721TransferBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*ERC721TransferBridge) EstimateGas added in v0.166.9

func (s *ERC721TransferBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*ERC721TransferBridge) GetContractAddress added in v0.166.9

func (s *ERC721TransferBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*ERC721TransferBridge) Name added in v0.166.9

func (s *ERC721TransferBridge) Name() string

func (*ERC721TransferBridge) PackTxInputData added in v0.179.24

func (s *ERC721TransferBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*ERC721TransferBridge) Send added in v0.166.9

func (s *ERC721TransferBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

type ERC721TransferTxArgs added in v0.166.9

type ERC721TransferTxArgs struct {
	transactions.SendTxArgs
	TokenID   *hexutil.Big   `json:"tokenId"`
	Recipient common.Address `json:"recipient"`
}

type HopBridge

type HopBridge struct {
	// contains filtered or unexported fields
}

func NewHopBridge

func NewHopBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface, tokenManager *token.Manager) *HopBridge

func (*HopBridge) AvailableFor added in v0.179.22

func (h *HopBridge) AvailableFor(params BridgeParams) (bool, error)

func (*HopBridge) BuildTransaction added in v0.171.1

func (h *HopBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*HopBridge) BuildTx added in v0.178.0

func (h *HopBridge) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*HopBridge) CalculateAmountOut

func (h *HopBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*HopBridge) CalculateFees

func (h *HopBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*HopBridge) EstimateGas

func (h *HopBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*HopBridge) GetContractAddress added in v0.125.0

func (h *HopBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*HopBridge) Name

func (h *HopBridge) Name() string

func (*HopBridge) PackTxInputData added in v0.179.24

func (h *HopBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*HopBridge) Send

func (h *HopBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (hash types.Hash, err error)

type HopTxArgs

type HopTxArgs struct {
	transactions.SendTxArgs
	ChainID   uint64         `json:"chainId"`
	Symbol    string         `json:"symbol"`
	Recipient common.Address `json:"recipient"`
	Amount    *hexutil.Big   `json:"amount"`
	BonderFee *hexutil.Big   `json:"bonderFee"`
}

type SwapParaswap added in v0.179.1

type SwapParaswap struct {
	// contains filtered or unexported fields
}

func NewSwapParaswap added in v0.179.1

func NewSwapParaswap(rpcClient *rpc.Client, transactor transactions.TransactorIface, tokenManager *walletToken.Manager) *SwapParaswap

func (*SwapParaswap) AvailableFor added in v0.179.22

func (s *SwapParaswap) AvailableFor(params BridgeParams) (bool, error)

func (*SwapParaswap) BuildTransaction added in v0.179.1

func (s *SwapParaswap) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*SwapParaswap) BuildTx added in v0.179.1

func (s *SwapParaswap) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*SwapParaswap) CalculateAmountOut added in v0.179.1

func (s *SwapParaswap) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*SwapParaswap) CalculateFees added in v0.179.1

func (s *SwapParaswap) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*SwapParaswap) EstimateGas added in v0.179.1

func (s *SwapParaswap) EstimateGas(params BridgeParams) (uint64, error)

func (*SwapParaswap) GetContractAddress added in v0.179.1

func (s *SwapParaswap) GetContractAddress(params BridgeParams) (address common.Address, err error)

func (*SwapParaswap) Name added in v0.179.1

func (s *SwapParaswap) Name() string

func (*SwapParaswap) PackTxInputData added in v0.179.24

func (s *SwapParaswap) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*SwapParaswap) Send added in v0.179.1

func (s *SwapParaswap) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)

type SwapTxArgs added in v0.179.1

type SwapTxArgs struct {
	transactions.SendTxArgs
	ChainID uint64 `json:"chainId"`
}

type TransactionBridge

type TransactionBridge struct {
	BridgeName        string
	ChainID           uint64
	TransferTx        *transactions.SendTxArgs
	HopTx             *HopTxArgs
	CbridgeTx         *CBridgeTxArgs
	ERC721TransferTx  *ERC721TransferTxArgs
	ERC1155TransferTx *ERC1155TransferTxArgs
	SwapTx            *SwapTxArgs
}

func (*TransactionBridge) Data

func (t *TransactionBridge) Data() types.HexBytes

func (*TransactionBridge) From

func (t *TransactionBridge) From() types.Address

func (*TransactionBridge) To

func (*TransactionBridge) Value

func (t *TransactionBridge) Value() *big.Int

type TransferBridge added in v0.166.9

type TransferBridge struct {
	// contains filtered or unexported fields
}

func NewTransferBridge added in v0.166.9

func NewTransferBridge(rpcClient *rpc.Client, transactor transactions.TransactorIface) *TransferBridge

func (*TransferBridge) AvailableFor added in v0.179.22

func (s *TransferBridge) AvailableFor(params BridgeParams) (bool, error)

func (*TransferBridge) BuildTransaction added in v0.171.1

func (s *TransferBridge) BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)

func (*TransferBridge) BuildTx added in v0.178.0

func (s *TransferBridge) BuildTx(params BridgeParams) (*ethTypes.Transaction, error)

func (*TransferBridge) CalculateAmountOut added in v0.166.9

func (s *TransferBridge) CalculateAmountOut(params BridgeParams) (*big.Int, error)

func (*TransferBridge) CalculateFees added in v0.166.9

func (s *TransferBridge) CalculateFees(params BridgeParams) (*big.Int, *big.Int, error)

func (*TransferBridge) EstimateGas added in v0.166.9

func (s *TransferBridge) EstimateGas(params BridgeParams) (uint64, error)

func (*TransferBridge) GetContractAddress added in v0.166.9

func (s *TransferBridge) GetContractAddress(params BridgeParams) (common.Address, error)

func (*TransferBridge) Name added in v0.166.9

func (s *TransferBridge) Name() string

func (*TransferBridge) PackTxInputData added in v0.179.24

func (s *TransferBridge) PackTxInputData(params BridgeParams, contractType string) ([]byte, error)

func (*TransferBridge) Send added in v0.166.9

func (s *TransferBridge) Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)

Directories

Path Synopsis
Package mock_bridge is a generated GoMock package.
Package mock_bridge is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL