State Update
Updates are generated after zkLinkTx execution, details can be found in StateUpdateResp. Parsing the updates can get some data that is only known after the transaction is executed, such as the actual withdraw amount of FullExit
AccountUpdate.
There are 4 types of AccountUpdate:
AccountCreate: A new account created on the state tree;AccountChangePubkeyUpdate: Thepubkeyandnoncechanged;BalanceUpdate: The assets of account andnoncechanged;OrderUpdate: The order slot of the account has changed.
type
String
Update Name
updateId
i32
Update id
address
String
The account address
Transaction that generate AccountCreate:
For Example:
{
"type": "AccountCreate",
"updateId": 40,
"accountId": 42,
"address": "0xe4efc3d7b69a19d3ae574cbc2915ddf598efe43f"
}type
String
Update name
updateId
i32
Update Id
Transaction that generate AccountChangePubkeyUpdate:
For example:
{
"type": "AccountChangePubkeyUpdate",
"updateId": 10,
"accountId": 39,
"oldPubkeyHash": "0x0000000000000000000000000000000000000000",
"newPubkeyHash": "0xbfb4f4a68dc9e49f7785082a8c12354ed663b6e0",
"oldNonce": 0,
"newNonce": 1
}type
String
The update name
updateId
i32
The update id
oldBalance
String
The old balance of subaccount
newBalance
String
The new balance of subaccount
Transaction that generate BalanceUpdate:
For example
type
String
Update name
updateId
i32
Update id
where ResponseTidyOrder is
residue
String
The string format of BigDecimal, the residue balance of slot
Transaction that generate OrderUpdate:
For Example:
GlobalVarUpdate
GlobalVarsUpdate is an enumeration type used to represent the update status of global variables. It includes the following 4 types:
FeeAccountUpdate: The fee account of global variables changedInsuranceFundAccountUpdate: The Insurance fund account of global variables changedMarginParamsUpdate: The margin parameter of global variables changedContractParamsUpdate: The contract parameter of global variables changed
type
String
The update name
update_id
i32
update index
Transaction that generate FeeAccountUpdate:
For Example:
type
String
The update name
update_id
i32
update index
Transaction that generate InsuranceFundAccountUpdate:
For example:
type
String
The update name
update_id
i32
update index
old_symbol
String
Old symbol of the margin token
new_symbol
String
New symbol of the margin token
old_index_price
String
Old index price of the margin token
new_index_price
String
New index price of the margin token
old_ratio
u8
Old margin ratio of the margin token
new_ratio
u8
New margin ratio of the margin token
Transaction that generate MarginParamsUpdate:
For example
update_id
i32
update id
old_symbol
String
old symbol of the contract pair
new_symbol
String
new symbol of the contract pair
old_maintenance_margin_rate
u16
old maintenance margin rate of the contract pair
new_maintenance_margin_rate
u16
new maintenance margin rate of the contract pair
old_initial_margin_rate
u16
old initial margin rate of the contract pair
new_initial_margin_rate
u16
new initial margin rate of the contract pair
old_acc_funding_price
String
old accumulated funding price the contract pair
new_acc_funding_price
String
new accumulative funding price the contract pair
old_mark_price
String
old mark price of the contract pair
new_mark_price
String
new mark price of the contract pair
Transaction that generate ContractParamsUpdate:
For Example:
Deposit
Updates generated by Deposit:
[
update]: this update may occur,update(account): the update related to a certain account. The account id ofglobal_assetis 1, and the account id offeeis 0.
When the to account does not exist, a new account will be automatically created by AccountCreate.
Example
FullExit
Updates generated by FullExit:
Example
ChangePubKey
Updates generated by ChangePubKey:
Example
Transfer
Updates generated by Transfer:
Similar to Deposit, when the to account does not exist, a new account will be automatically created by AccountCreate.
Example
Withdraw
Updates generated by Withdraw:
Example
ForcedExit
Updates generated by ForcedExit:
Example
OrderMatching
Updates generated by OrderMatching:
Example
ContractMatching
Updates generated by ContractMatching:
Example
Liquidation
Updates generated by Liquidation:
Example
AutoDeleveraging
Updates generated by AutoDeleveraging:
Example
funding
Updates generated by funding:
Example
update_global_var
All updates that may be generated by update_global_var:
Example
version: fa4618
Last updated
Was this helpful?