bridge

package
v0.179.11 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MPL-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const HopCanonicalTokenIndex = 0
View Source
const HopLpFeeBps = 4
View Source
const HopMinBonderFeeUsd = 0.25
View Source
const HophTokenIndex = 1
View Source
const IncreaseEstimatedGasFactor = 1.1

Variables

View Source
var HopBondTransferGasLimit = map[uint64]int64{
	1:      165000,
	5:      165000,
	10:     100000000,
	42161:  2500000,
	420:    100000000,
	421613: 2500000,
}
View Source
var HopBonderFeeBps = map[string]map[uint64]int64{
	"USDC": {
		1:      14,
		5:      14,
		10:     14,
		42161:  14,
		420:    14,
		421613: 14,
	},
	"USDT": {
		1:      26,
		10:     26,
		421613: 26,
	},
	"DAI": {
		1:     26,
		10:    26,
		42161: 26,
	},
	"ETH": {
		1:      5,
		5:      5,
		10:     5,
		42161:  5,
		420:    5,
		421613: 5,
	},
	"WBTC": {
		1:     23,
		10:    23,
		42161: 23,
	},
}
View Source
var HopSettlementGasLimitPerTx = map[uint64]int64{
	1:      5141,
	5:      5141,
	10:     8545,
	42161:  19843,
	420:    8545,
	421613: 19843,
}
View Source
var ZeroAddress = common.Address{}

Functions

This section is empty.

Types

type Bridge

type Bridge interface {
	Name() string
	Can(from *params.Network, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)
	CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)
	EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)
	CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)
	Send(sendArgs *TransactionBridge, verifiedAccount *account.SelectedExtKey) (types.Hash, error)
	GetContractAddress(network *params.Network, token *token.Token) *common.Address
	BuildTransaction(sendArgs *TransactionBridge) (*ethTypes.Transaction, error)
	BuildTx(fromNetwork, toNetwork *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error)
}

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.Transactor, tokenManager *token.Manager) *CBridge

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(fromNetwork, toNetwork *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error)

func (*CBridge) CalculateAmountOut added in v0.117.3

func (s *CBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*CBridge) CalculateFees added in v0.117.3

func (s *CBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*CBridge) Can added in v0.117.3

func (s *CBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)

func (*CBridge) EstimateGas added in v0.117.3

func (s *CBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*CBridge) GetContractAddress added in v0.125.0

func (s *CBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*CBridge) Name added in v0.117.3

func (s *CBridge) Name() string

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 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.Transactor) *ERC1155TransferBridge

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 (s *ERC1155TransferBridge) BuildTx(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, _ *big.Int) (*ethTypes.Transaction, error)

func (*ERC1155TransferBridge) CalculateAmountOut added in v0.174.1

func (s *ERC1155TransferBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*ERC1155TransferBridge) CalculateFees added in v0.174.1

func (s *ERC1155TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*ERC1155TransferBridge) Can added in v0.174.1

func (s *ERC1155TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)

func (*ERC1155TransferBridge) EstimateGas added in v0.174.1

func (s *ERC1155TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*ERC1155TransferBridge) GetContractAddress added in v0.174.1

func (s *ERC1155TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*ERC1155TransferBridge) Name added in v0.174.1

func (s *ERC1155TransferBridge) Name() string

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.Transactor) *ERC721TransferBridge

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 (s *ERC721TransferBridge) BuildTx(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, _ *big.Int) (*ethTypes.Transaction, error)

func (*ERC721TransferBridge) CalculateAmountOut added in v0.166.9

func (s *ERC721TransferBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*ERC721TransferBridge) CalculateFees added in v0.166.9

func (s *ERC721TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*ERC721TransferBridge) Can added in v0.166.9

func (s *ERC721TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)

func (*ERC721TransferBridge) EstimateGas added in v0.166.9

func (s *ERC721TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*ERC721TransferBridge) GetContractAddress added in v0.166.9

func (s *ERC721TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*ERC721TransferBridge) Name added in v0.166.9

func (s *ERC721TransferBridge) Name() string

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.Transactor, tokenManager *token.Manager) *HopBridge

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(fromNetwork, toNetwork *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error)

func (*HopBridge) CalculateAmountOut

func (h *HopBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*HopBridge) CalculateBonderFees

func (h *HopBridge) CalculateBonderFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, error)

CalculateBonderFees logics come from: https://docs.hop.exchange/fee-calculation

func (*HopBridge) CalculateFees

func (h *HopBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*HopBridge) Can

func (h *HopBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)

func (*HopBridge) EstimateGas

func (h *HopBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*HopBridge) GetContractAddress added in v0.125.0

func (h *HopBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*HopBridge) Name

func (h *HopBridge) Name() string

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.Transactor, tokenManager *walletToken.Manager) *SwapParaswap

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(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, _ *big.Int) (*ethTypes.Transaction, error)

func (*SwapParaswap) CalculateAmountOut added in v0.179.1

func (s *SwapParaswap) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*SwapParaswap) CalculateFees added in v0.179.1

func (s *SwapParaswap) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*SwapParaswap) Can added in v0.179.1

func (s *SwapParaswap) Can(from, to *params.Network, token *walletToken.Token, toToken *walletToken.Token, balance *big.Int) (bool, error)

func (*SwapParaswap) EstimateGas added in v0.179.1

func (s *SwapParaswap) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*SwapParaswap) GetContractAddress added in v0.179.1

func (s *SwapParaswap) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*SwapParaswap) Name added in v0.179.1

func (s *SwapParaswap) Name() string

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.Transactor) *TransferBridge

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(network, _ *params.Network, fromAddress common.Address, toAddress common.Address, token *token.Token, amountIn *big.Int, bonderFee *big.Int) (*ethTypes.Transaction, error)

func (*TransferBridge) CalculateAmountOut added in v0.166.9

func (s *TransferBridge) CalculateAmountOut(from, to *params.Network, amountIn *big.Int, symbol string) (*big.Int, error)

func (*TransferBridge) CalculateFees added in v0.166.9

func (s *TransferBridge) CalculateFees(from, to *params.Network, token *token.Token, amountIn *big.Int, nativeTokenPrice, tokenPrice float64, gasPrice *big.Float) (*big.Int, *big.Int, error)

func (*TransferBridge) Can added in v0.166.9

func (s *TransferBridge) Can(from, to *params.Network, token *token.Token, toToken *token.Token, balance *big.Int) (bool, error)

func (*TransferBridge) EstimateGas added in v0.166.9

func (s *TransferBridge) EstimateGas(fromNetwork *params.Network, toNetwork *params.Network, from common.Address, to common.Address, token *token.Token, toToken *token.Token, amountIn *big.Int) (uint64, error)

func (*TransferBridge) GetContractAddress added in v0.166.9

func (s *TransferBridge) GetContractAddress(network *params.Network, token *token.Token) *common.Address

func (*TransferBridge) Name added in v0.166.9

func (s *TransferBridge) Name() string

func (*TransferBridge) Send added in v0.166.9

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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