bridge

package
v0.0.0-...-2cf1f94 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NativeTokenAddress = "0x0000000000000000000000000000000000000000"
)

Variables

View Source
var DEFAULT_GAS_LIMIT_PERCENT_INCREASE = big.NewInt(100)

Source: https://github.com/OffchainLabs/arbitrum-sdk/blob/0da65020438fc3e46728ea182f1b4dcf04e3cb7f/src/lib/assetBridger/l1l3Bridger.ts#L284

View Source
var DEFAULT_GAS_PRICE_PERCENT_INCREASE = big.NewInt(500)

Source: https://github.com/OffchainLabs/arbitrum-sdk/blob/0da65020438fc3e46728ea182f1b4dcf04e3cb7f/src/lib/assetBridger/l1l3Bridger.ts#L282

View Source
var DEFAULT_SUBMISSION_FEE_PERCENT_INCREASE = big.NewInt(300)

Source: https://github.com/OffchainLabs/arbitrum-sdk/blob/0da65020438fc3e46728ea182f1b4dcf04e3cb7f/src/lib/message/L1ToL2MessageGasEstimator.ts#L27

View Source
var L2_FORWARDER_FACTORY_DEFAULT_GAS_LIMIT = uint64(1_000_000)

Source: https://github.com/OffchainLabs/arbitrum-sdk/blob/ha/teleporter-custom-fee-2/src/lib/assetBridger/l1l3Bridger.ts#L390

View Source
var NODE_INTERFACE_ADDRESS = common.HexToAddress("0x00000000000000000000000000000000000000C8")
View Source
var ONE_ETHER = big.NewInt(1_000_000_000_000_000_000)

Source: https://github.com/OffchainLabs/arbitrum-sdk/blob/0da65020438fc3e46728ea182f1b4dcf04e3cb7f/src/lib/message/L1ToL2MessageGasEstimator.ts#L154

Functions

func CalculateRequiredEth

func CalculateRequiredEth(gasParams RetryableGasParams, teleportationType TeleportationType) (*big.Int, *big.Int)

func CalculateRetryableGasLimit

func CalculateRetryableGasLimit(client *ethclient.Client, sender common.Address, deposit *big.Int, to common.Address, l2CallValue *big.Int, excessFeeRefundAddress common.Address, callValueRefundAddress common.Address, calldata []byte) (uint64, error)

Source: https://github.com/OffchainLabs/nitro-contracts/blob/main/src/node-interface/NodeInterface.sol#L25

func CalculateSafeTxHash

func CalculateSafeTxHash(safeAddress common.Address, txData SafeTransactionData, chainID *big.Int) (common.Hash, error)

func CreateBridgeCommand

func CreateBridgeCommand() *cobra.Command

func CreateBridgeERC20Command

func CreateBridgeERC20Command() *cobra.Command

func CreateBridgeERC20L1ToL2Command

func CreateBridgeERC20L1ToL2Command() *cobra.Command

func CreateBridgeNativeTokenCommand

func CreateBridgeNativeTokenCommand() *cobra.Command

func CreateBridgeNativeTokenL1ToL2Command

func CreateBridgeNativeTokenL1ToL2Command() *cobra.Command

func CreateBridgeNativeTokenL1ToL3Command

func CreateBridgeNativeTokenL1ToL3Command() *cobra.Command

func CreateSafeProposal

func CreateSafeProposal(client *ethclient.Client, key *keystore.Key, safeAddress common.Address, to common.Address, data []byte, value *big.Int, safeApi string, safeOperation OperationType, safeNonce *big.Int) error

func ERC20BridgeCall

func ERC20BridgeCall(routerAddress common.Address, keyFile string, password string, l1Rpc string, l2Rpc string, tokenAddress common.Address, to common.Address, amount *big.Int) (*types.Transaction, error)

func ERC20BridgePropose

func ERC20BridgePropose(routerAddress common.Address, keyFile string, password string, l1Rpc string, l2Rpc string, tokenAddress common.Address, to common.Address, amount *big.Int, safeAddress common.Address, safeApi string, safeOperation uint8, safeNonce *big.Int) error

func GetERC20BridgeCalldataAndValue

func GetERC20BridgeCalldataAndValue(routerAddress common.Address, keyFile string, password string, l1Rpc string, l2Rpc string, tokenAddress common.Address, to common.Address, amount *big.Int) ([]byte, *big.Int, error)

func GetForwarderAddress

func GetForwarderAddress(client *ethclient.Client, teleporterAddress common.Address, key *keystore.Key, l2l3RouterOrInbox common.Address, to common.Address) (common.Address, error)

func GetL1l2FeeTokenBridgeGasParams

func GetL1l2FeeTokenBridgeGasParams(l1Client *ethclient.Client, l2Client *ethclient.Client, l1BaseFee *big.Int, key *keystore.Key, teleportParams *TeleportParams, l1l2RouterAddress *common.Address, teleporterAddress common.Address, l2ForwarderAddress common.Address) (uint64, *big.Int, error)

func GetL1l2TokenBridgeGasParams

func GetL1l2TokenBridgeGasParams(l1Client *ethclient.Client, l2Client *ethclient.Client, l1BaseFee *big.Int, key *keystore.Key, teleportParams *TeleportParams, teleporterAddress common.Address, l2ForwarderAddress common.Address) (uint64, *big.Int, error)

func GetL2ForwaderGasParams

func GetL2ForwaderGasParams(client *ethclient.Client, key *keystore.Key, teleportParams *TeleportParams, l2ForwarderAddress common.Address) (uint64, *big.Int, error)

func GetL2L3TokenBridgeGasParams

func GetL2L3TokenBridgeGasParams(l2Client *ethclient.Client, l3Client *ethclient.Client, l2BaseFee *big.Int, key *keystore.Key, teleportParams *TeleportParams, l2ForwarderAddress common.Address, teleportationType TeleportationType) (uint64, *big.Int, error)

func GetNativeTokenBridgeCalldata

func GetNativeTokenBridgeCalldata(key *keystore.Key, l1Client *ethclient.Client, l2Client *ethclient.Client, to common.Address, l2CallValue *big.Int, l2Calldata []byte) ([]byte, error)

func NativeTokenBridgeCall

func NativeTokenBridgeCall(inboxAddress common.Address, keyFile string, password string, l1Rpc string, l2Rpc string, to common.Address, l2CallValue *big.Int, l2Calldata []byte) (*types.Transaction, error)

func NativeTokenBridgePropose

func NativeTokenBridgePropose(inboxAddress common.Address, keyFile string, password string, l1Rpc string, l2Rpc string, to common.Address, l2CallValue *big.Int, l2Calldata []byte, safeAddress common.Address, safeApi string, safeOperation uint8, safeNonce *big.Int) error

func PercentIncrease

func PercentIncrease(value *big.Int, percentage *big.Int) *big.Int

func SendTransaction

func SendTransaction(client *ethclient.Client, key *keystore.Key, password string, calldata []byte, to string, value *big.Int) (*types.Transaction, error)

Function to send a transaction

func Teleport

func Teleport(teleporter common.Address, teleportParams *TeleportParams, keyFile string, password string, l1Rpc string, l2Rpc string, l3Rpc string) (*types.Transaction, error)

Types

type L2ForwarderParams

type L2ForwarderParams struct {
	Owner             common.Address
	L2Token           common.Address
	L3FeeTokenL2Addr  common.Address
	RouterOrInbox     common.Address
	To                common.Address
	GasLimit          *big.Int
	GasPriceBid       *big.Int
	MaxSubmissionCost *big.Int
	L3CallData        []byte
}

type OperationType

type OperationType uint8

OperationType represents the type of operation for a Safe transaction

const (
	Call         OperationType = 0
	DelegateCall OperationType = 1
)

func (OperationType) String

func (o OperationType) String() string

String returns the string representation of the OperationType

type RetryableGasParams

type RetryableGasParams struct {
	L2GasPriceBid                       *big.Int
	L3GasPriceBid                       *big.Int
	L2ForwarderFactoryGasLimit          uint64
	L1l2FeeTokenBridgeGasLimit          uint64
	L1l2TokenBridgeGasLimit             uint64
	L2l3TokenBridgeGasLimit             uint64
	L2ForwarderFactoryMaxSubmissionCost *big.Int
	L1l2FeeTokenBridgeMaxSubmissionCost *big.Int
	L1l2TokenBridgeMaxSubmissionCost    *big.Int
	L2l3TokenBridgeMaxSubmissionCost    *big.Int
}

type SafeTransactionData

type SafeTransactionData struct {
	To             string        `json:"to"`
	Value          string        `json:"value"`
	Data           string        `json:"data"`
	Operation      OperationType `json:"operation"`
	SafeTxGas      uint64        `json:"safeTxGas"`
	BaseGas        uint64        `json:"baseGas"`
	GasPrice       string        `json:"gasPrice"`
	GasToken       string        `json:"gasToken"`
	RefundReceiver string        `json:"refundReceiver"`
	Nonce          *big.Int      `json:"nonce"`
	SafeTxHash     string        `json:"safeTxHash"`
	Sender         string        `json:"sender"`
	Signature      string        `json:"signature"`
	Origin         string        `json:"origin"`
}

SafeTransactionData represents the data for a Safe transaction

type TeleportParams

type TeleportParams struct {
	L1Token           common.Address
	L3FeeTokenL1Addr  common.Address
	L1l2Router        common.Address
	L2l3RouterOrInbox common.Address
	To                common.Address
	Amount            *big.Int
	GasParams         RetryableGasParams
	L3CallData        []byte
}

func SetTeleporterGasParams

func SetTeleporterGasParams(teleportParams *TeleportParams, teleporterAddress common.Address, l1Client *ethclient.Client, l2Client *ethclient.Client, l3Client *ethclient.Client, key *keystore.Key, teleportationType TeleportationType) (*TeleportParams, error)

type TeleportationType

type TeleportationType int
const (
	Standard               TeleportationType = 0 // Teleporting a token to an ETH fee L3
	OnlyCustomFee          TeleportationType = 1 // Teleporting a L3's custom fee token to a custom (non-eth) fee L3
	NonFeeTokenToCustomFee TeleportationType = 2 // Teleporting a non-fee token to a custom (non-eth) fee L3
)

Jump to

Keyboard shortcuts

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