L2Client /
- L2Client
- cancelOrder
- confirmWithdrawal
- createOrder
- deposit
- getInstanceId
- hasFill
- init
- isHalted
- join
- leave
- withdraw
+ 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
● address: string
● assets: string[]
● identity: Identity
● ledger: MetaLedger
● mediator: IMediatorAsync
● persistence: knex
● transport: HTTPClient
● get isConnected(): boolean
Checks if the client is connected to the server
Returns: boolean
● get quarter(): 0
| 1
| 2
| 3
Returns the current quarter
Returns: 0
| 1
| 2
| 3
● get round(): number
Returns the current round
Returns: number
● get roundJoined(): number
Gets the round number when the client first joined the operator
Returns: number
● get roundSize(): BigNumber
| undefined
Gets the round size for the mediator
Returns: BigNumber
| undefined
▸ cancelOrder(approvalId
: string): Promise<void>
Cancels an active order
Parameters:
Name | Type | Description |
---|---|---|
approvalId |
string | Order Approval ID |
Returns: Promise<void>
▸ 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(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(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(): string
Returns the instanceId (mediator contract address) that the client is connected to
Returns: string
▸ 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(): Promise<void>
Initialize the client
Returns: Promise<void>
▸ isHalted(): Promise<boolean>
Checks if the mediator is in HALTED mode
Returns: Promise<boolean>
▸ join(): Promise<void>
Joins the layer 2 network
throws
{SignatureError}
Returns: Promise<void>
▸ leave(): Promise<void>
Gracefull cleanup
Returns: Promise<void>
▸ 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>