Skip to content

Latest commit

 

History

History
319 lines (181 loc) · 5.2 KB

Client_L2Client.md

File metadata and controls

319 lines (181 loc) · 5.2 KB

L2Client /

Class: L2Client

Hierarchy

  • L2Client

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new L2Client(identity: Identity, transport: HTTPClient | string, options: L2ClientOptions): L2Client

Constructor

Parameters:

Name Type Description
identity Identity A JsonRPCIdentity or PrivateKeyIdentity object for the user's wallet.
transport HTTPClient | string Used for communicating with the server.
options L2ClientOptions Various configuration options including the operatorAddress, etc.

Returns: L2Client


Properties

address

address: string


assets

assets: string[]


identity

identity: Identity


ledger

ledger: MetaLedger


mediator

mediator: IMediatorAsync


persistence

persistence: knex


transport

transport: HTTPClient


Accessors

isConnected

get isConnected(): boolean

Checks if the client is connected to the server

Returns: boolean


quarter

get quarter(): 0 | 1 | 2 | 3

Returns the current quarter

Returns: 0 | 1 | 2 | 3


round

get round(): number

Returns the current round

Returns: number


roundJoined

get roundJoined(): number

Gets the round number when the client first joined the operator

Returns: number


roundSize

get roundSize(): BigNumber | undefined

Gets the round size for the mediator

Returns: BigNumber | undefined


Methods

cancelOrder

cancelOrder(approvalId: string): Promise<void>

Cancels an active order

Parameters:

Name Type Description
approvalId string Order Approval ID

Returns: Promise<void>


confirmWithdrawal

confirmWithdrawal(asset: string): Promise<void>

Confirms a withdrawal that has been previously initiated by the user

Parameters:

Name Type Description
asset string Address of the asset for withdrawal

Returns: Promise<void>


createOrder

createOrder(order: IApproval, fee: IApproval): Promise<string>

Creates a new BUY or SELL order also passing in required fee approval

Parameters:

Name Type Description
order IApproval Order Approval object
fee IApproval Fee Approval object

Returns: Promise<string>


deposit

deposit(asset: string, amount: BigNumber, approve: boolean): Promise<void>

Deposit asset from client wallet to the mediator

Parameters:

Name Type Description
asset string Address of the asset to deposit
amount BigNumber Amount of asset to deposit (in wei)
approve boolean Whether to call ERC20.approve before doing the token transfer

Returns: Promise<void>


getInstanceId

getInstanceId(): string

Returns the instanceId (mediator contract address) that the client is connected to

Returns: string


hasFill

hasFill(round: number, fill: ISignedFill): Promise<boolean>

Checks if a given round has a fill

Parameters:

Name Type Description
round number Round number
fill ISignedFill Fill object to check for

Returns: Promise<boolean>


init

init(): Promise<void>

Initialize the client

Returns: Promise<void>


isHalted

isHalted(): Promise<boolean>

Checks if the mediator is in HALTED mode

Returns: Promise<boolean>


join

join(): Promise<void>

Joins the layer 2 network

throws {SignatureError}

Returns: Promise<void>


leave

leave(): Promise<void>

Gracefull cleanup

Returns: Promise<void>


withdraw

withdraw(asset: string, amount: BigNumber): Promise<TransactionReceipt>

Initiates a new withdrawal for a given asset

Parameters:

Name Type Description
asset string Address of the asset to withdraw
amount BigNumber Amount to withdraw (in wei)

Returns: Promise<TransactionReceipt>