Search Apps Documentation Source Content File Folder Download Copy Actions Download

errors.gno

2.88 Kb · 49 lines
 1package v1
 2
 3import (
 4	"errors"
 5
 6	ufmt "gno.land/p/nt/ufmt/v0"
 7)
 8
 9// Error definitions for pool operations
10var (
11	errUnsupportedFeeTier        = errors.New("[GNOSWAP-POOL-001] unsupported fee tier")
12	errPoolAlreadyExists         = errors.New("[GNOSWAP-POOL-002] pool already created")
13	errOutOfRange                = errors.New("[GNOSWAP-POOL-003] out of range for numeric value")
14	errInvalidInput              = errors.New("[GNOSWAP-POOL-004] invalid input data")
15	errDataNotFound              = errors.New("[GNOSWAP-POOL-005] requested data not found")
16	errLiquidityCalculation      = errors.New("[GNOSWAP-POOL-006] invalid liquidity calculated")
17	errZeroLiquidity             = errors.New("[GNOSWAP-POOL-007] zero liquidity")
18	errDuplicateTokenInPool      = errors.New("[GNOSWAP-POOL-008] same token used in single pool")
19	errTickLowerInvalid          = errors.New("[GNOSWAP-POOL-009] tickLower is invalid")
20	errTickUpperInvalid          = errors.New("[GNOSWAP-POOL-010] tickUpper is invalid")
21	errInvalidSwapAmount         = errors.New("[GNOSWAP-POOL-011] invalid swap amount")
22	errInvalidProtocolFeePct     = errors.New("[GNOSWAP-POOL-012] invalid protocol fee percentage")
23	errInvalidWithdrawalFeePct   = errors.New("[GNOSWAP-POOL-013] invalid withdrawal fee percentage")
24	errLockedPool                = errors.New("[GNOSWAP-POOL-014] cannot modify pool while locked")
25	errPriceOutOfRange           = errors.New("[GNOSWAP-POOL-015] swap price out of range")
26	errTransferFailed            = errors.New("[GNOSWAP-POOL-016] token transfer failed")
27	errInvalidTickAndTickSpacing = errors.New("[GNOSWAP-POOL-017] invalid tick and tick spacing requested")
28	errInvalidTickRange          = errors.New("[GNOSWAP-POOL-018] tickLower is greater than or equal to tickUpper")
29	errUnderflow                 = errors.New("[GNOSWAP-POOL-019] underflow")
30	errOverflow                  = errors.New("[GNOSWAP-POOL-020] overflow")
31	errBalanceUpdateFailed       = errors.New("[GNOSWAP-POOL-021] balance update failed")
32	errInvalidPayer              = errors.New("[GNOSWAP-POOL-022] invalid payer")
33	errNotAccessEOA              = errors.New("[GNOSWAP-POOL-023] not access EOA")
34	errInsufficientPayment       = errors.New("[GNOSWAP-POOL-024] insufficient payment")
35	errNotInitializedObservation = errors.New("[GNOSWAP-POOL-025] not initialized observation")
36	errObservationTooOld         = errors.New("[GNOSWAP-POOL-026] target timestamp before oldest observation")
37	errSpoofedRealm              = errors.New("[GNOSWAP-POOL-027] rlm does not match the current crossing frame")
38)
39
40// newErrorWithDetail adds detail to an error message.
41func newErrorWithDetail(err error, detail string) string {
42	finalErr := ufmt.Errorf("%s || %s", err.Error(), detail)
43	return finalErr.Error()
44}
45
46// makeErrorWithDetails creates an error with additional context.
47func makeErrorWithDetails(err error, details string) error {
48	return ufmt.Errorf("%s || %s", err.Error(), details)
49}