github.com/status-im/status-go@v1.1.0/services/wallet/router/pathprocessor/processor.go (about) 1 package pathprocessor 2 3 import ( 4 "math/big" 5 6 ethTypes "github.com/ethereum/go-ethereum/core/types" 7 8 "github.com/ethereum/go-ethereum/common" 9 "github.com/status-im/status-go/account" 10 "github.com/status-im/status-go/eth-node/types" 11 "github.com/status-im/status-go/params" 12 "github.com/status-im/status-go/services/wallet/token" 13 ) 14 15 type PathProcessor interface { 16 // Name returns the name of the bridge 17 Name() string 18 // AvailableFor checks if the bridge is available for the given networks/tokens 19 AvailableFor(params ProcessorInputParams) (bool, error) 20 // CalculateFees calculates the fees for the bridge and returns the amount BonderFee and TokenFee (used for bridges) 21 CalculateFees(params ProcessorInputParams) (*big.Int, *big.Int, error) 22 // PackTxInputData packs tx for sending 23 PackTxInputData(params ProcessorInputParams) ([]byte, error) 24 // EstimateGas estimates the gas 25 EstimateGas(params ProcessorInputParams) (uint64, error) 26 // CalculateAmountOut calculates the amount out 27 CalculateAmountOut(params ProcessorInputParams) (*big.Int, error) 28 // Send sends the tx, returns the hash and the used nonce (lastUsedNonce is -1 if it's the first tx) 29 Send(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64, verifiedAccount *account.SelectedExtKey) (types.Hash, uint64, error) 30 // GetContractAddress returns the contract address 31 GetContractAddress(params ProcessorInputParams) (common.Address, error) 32 // BuildTransaction builds the transaction based on MultipathProcessorTxArgs, returns the transaction and the used nonce (lastUsedNonce is -1 if it's the first tx) 33 BuildTransaction(sendArgs *MultipathProcessorTxArgs, lastUsedNonce int64) (*ethTypes.Transaction, uint64, error) 34 } 35 36 type PathProcessorClearable interface { 37 // Clear clears the local cache 38 Clear() 39 } 40 41 type ProcessorInputParams struct { 42 FromChain *params.Network 43 ToChain *params.Network 44 FromAddr common.Address 45 ToAddr common.Address 46 FromToken *token.Token 47 ToToken *token.Token 48 AmountIn *big.Int 49 AmountOut *big.Int 50 51 // extra params 52 BonderFee *big.Int 53 Username string 54 PublicKey string 55 PackID *big.Int 56 57 // for testing purposes 58 TestsMode bool 59 TestEstimationMap map[string]Estimation // [bridge-name, estimation] 60 TestBonderFeeMap map[string]*big.Int // [token-symbol, bonder-fee] 61 TestApprovalGasEstimation uint64 62 TestApprovalL1Fee uint64 63 } 64 65 type Estimation struct { 66 Value uint64 67 Err error 68 }