swap

package
v0.5.9-0...-ba7202b Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package swap wraps the 'swap' Ethereum smart contract. It is an abstraction layer to hide implementation details about the different Swap contract iterations (Simple Swap, Soft Swap, etc.)

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotDeployedByFactory is given when a contract was not deployed by the factory
	ErrNotDeployedByFactory = errors.New("not deployed by factory")

	// Deployments maps from network ids to deployed contract factories
	Deployments = map[uint64]common.Address{

		3: common.HexToAddress("0x878Ccb2e3c2973767e431bAec86D1EFd809480d5"),
	}
)

Functions

func FactoryAddressForNetwork

func FactoryAddressForNetwork(networkID uint64) (common.Address, error)

FactoryAddressForNetwork gets the default factory address for a given network id

Types

type CashChequeResult

type CashChequeResult struct {
	Beneficiary      common.Address // beneficiary of the cheque
	Recipient        common.Address // address which received the funds
	Caller           common.Address // caller of cashCheque
	TotalPayout      *big.Int       // total amount that was paid out in this call
	CumulativePayout *big.Int       // cumulative payout of the cheque that was cashed
	CallerPayout     *big.Int       // payout for the caller of cashCheque
	Bounced          bool           // indicates wether parts of the cheque bounced
}

CashChequeResult summarizes the result of a CashCheque or CashChequeBeneficiary call

type Contract

type Contract interface {
	// Withdraw attempts to withdraw ERC20-token from the chequebook
	Withdraw(auth *bind.TransactOpts, amount *big.Int) (*types.Receipt, error)
	// Deposit sends a raw transaction to the chequebook, triggering the fallback—depositing amount
	Deposit(auth *bind.TransactOpts, amout *big.Int) (*types.Receipt, error)
	// CashChequeBeneficiaryStart sends the transaction to cash a cheque as the beneficiary
	CashChequeBeneficiaryStart(opts *bind.TransactOpts, beneficiary common.Address, cumulativePayout *int256.Uint256, ownerSig []byte) (*types.Transaction, error)
	// CashChequeBeneficiaryResult processes the receipt from a CashChequeBeneficiary transaction
	CashChequeBeneficiaryResult(receipt *types.Receipt) *CashChequeResult
	// LiquidBalance returns the LiquidBalance (total balance in ERC20-token - total hard deposits in ERC20-token) of the chequebook
	LiquidBalance(auth *bind.CallOpts) (*big.Int, error)
	// Token returns the address of the ERC20 contract, used by the chequebook
	Token(auth *bind.CallOpts) (common.Address, error)
	// BalanceAtTokenContract returns the balance of the account for the underlying ERC20 contract of the chequebook
	BalanceAtTokenContract(opts *bind.CallOpts, account common.Address) (*big.Int, error)
	// ContractParams returns contract info (e.g. deployed address)
	ContractParams() *Params
	// Issuer returns the contract owner from the blockchain
	Issuer(opts *bind.CallOpts) (common.Address, error)
	// PaidOut returns the total paid out amount for the given address
	PaidOut(opts *bind.CallOpts, addr common.Address) (*big.Int, error)
}

Contract interface defines the methods exported from the underlying go-bindings for the smart contract

func InstanceAt

func InstanceAt(address common.Address, backend chain.Backend) (Contract, error)

InstanceAt creates a new instance of a contract at a specific address. It assumes that there is an existing contract instance at the given address, or an error is returned This function is needed to communicate with remote Swap contracts (e.g. sending a cheque)

type Params

type Params struct {
	ContractCode    string
	ContractAbi     string
	ContractAddress common.Address
}

Params encapsulates some contract parameters (currently mostly informational)

type SimpleSwapFactory

type SimpleSwapFactory interface {
	// DeploySimpleSwap deploys a new SimpleSwap contract from the factory and returns the ready to use Contract abstraction
	DeploySimpleSwap(auth *bind.TransactOpts, issuer common.Address, defaultHardDepositTimeoutDuration *big.Int) (Contract, error)
	// VerifyContract verifies that the supplied address was deployed by this factory
	VerifyContract(address common.Address) error
	// VerifySelf verifies that this is a valid factory on the network
	VerifySelf() error
}

SimpleSwapFactory interface defines the methods available for a factory contract for SimpleSwap

func FactoryAt

func FactoryAt(address common.Address, backend chain.Backend) (SimpleSwapFactory, error)

FactoryAt creates a SimpleSwapFactory instance for the given address and backend

Jump to

Keyboard shortcuts

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