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: The pubkey and nonce changed;
BalanceUpdate: The assets of account and nonce changed;
OrderUpdate: The order slot of the account has changed.
[update]: this update may occur, update(account): the update related to a certain account. The account id of global_asset is 1, and the account id of fee is 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:
"updates": [
// The balance of the from_account decreased
{
"type": "BalanceUpdate",
"updateId": 12,
"accountId": 2,
"subAccountId": 0,
"coinId": 18,
"oldBalance": "3018976060000000000000",
"newBalance": "3018975850000000000000",
"oldNonce": 115,
"newNonce": 116
},
// The balance of the to_account increased. Noted that the to_accountId is the same as the from_accountId, but the subAccountId is different
// It means that this transaction is a token transfer between separate sub-accounts of the same account
{
"type": "BalanceUpdate",
"updateId": 13,
"accountId": 2,
"subAccountId": 1,
"coinId": 18,
"oldBalance": "114000000000000",
"newBalance": "115000000000000",
"oldNonce": 115,
"newNonce": 116
},
// The balance of the fee account increased
{
"type": "BalanceUpdate",
"updateId": 14,
"accountId": 0,
"subAccountId": 0,
"coinId": 18,
"oldBalance": "1023826000000000000",
"newBalance": "1024035000000000000",
"oldNonce": 0,
"newNonce": 0
}
]