Error codes
Explanation of what error codes are and how to handle them in your code
Introduction
Like Compound, just because a transaction was successful does not mean it actually did what we expected. Cozy inherited some of Compound's error handling approaches, which means a transaction may be successful—and show as successful on Etherscan and other block explorers—but in reality it didn't succeed. This is because some failed transactions will return an error code and emit a Failure
event instead of reverting. You can find Compound's error codes here, and a brief history of why it's handled this way here.
This approach can be a bit tedious for users and developers, as we now we have to manually ensure our transaction succeeded before continuing to the next step. In the Cozy Developer Guides repo you'll find a method called findLog()
in the utils/utils.ts
folder to help you with this.
This method searches for the expected success log in a transaction and returns it if found. If it's not found, an error is thrown and the Failure
error codes are reported. You can compare those error codes to those in the table below to learn why your transaction failed.
Error codes are defined in ErrorReporter.sol
and provided here for convenience.
Comptroller
If an error code was emitted from a transaction to the Comptroller, refer to these error codes.
Error Codes
Error codes 0–17 are identical to Compound's. Error codes 18 and 19 are unique to Cozy.
Code | Name | Description |
---|---|---|
0 |
| Not a failure |
1 |
| The sender is not authorized to perform this action. |
2 |
| Liquidation cannot be performed in markets with different comptrollers. |
3 |
| The account does not have sufficient shortfall to perform this action. |
4 |
| The account does not have sufficient liquidity to perform this action. |
5 |
| The close factor is not valid. |
6 |
| The collateral factor is not valid. |
7 |
| The liquidation incentive is invalid. |
8 |
| The market has not been entered by the account. |
9 |
| The market is not currently listed by the comptroller. |
10 |
| An admin tried to list the same market more than once. |
11 |
| A math calculation error occurred. |
12 |
| The action cannot be performed since the account carries a borrow balance. |
13 |
| The comptroller could not obtain a required price of an asset. |
14 |
| The comptroller rejects the action requested by the market. |
15 |
| The comptroller could not get the account borrows and exchange rate from the market. |
16 |
| Attempted to enter more markets than are currently supported. |
17 |
| Attempted to repay more than is allowed by the protocol. |
18 |
| The Protection Market cannot be created because the trigger is not a valid trigger, or was already triggered |
19 |
| The admin tried to set the Protection Market Factory to an invalid contract |
Failure Info
TODO
Cozy Token
If an error code was emitted from a transaction to a Cozy Token, refer to these error codes.
Error Codes
Code | Description | |
---|---|---|
0 |
| |
1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
|
Failure Info
TODO
Protection Market Factory
If an error code was emitted from a transaction to the Protection Market Factory, refer to these error codes.
Error Codes
Code | Name | Description |
---|---|---|
0 |
| |
1 |
| |
2 |
|
Failure Info
TODO
Oracle
If an error code was emitted from a transaction to the Oracle, refer to these error codes.
Error Codes
Code | Name | Description |
---|---|---|
0 |
| |
1 |
|
Failure Info
TODO
Last updated