Search Apps Documentation Source Content File Folder Download Copy Actions Download

errors.gno

2.76 Kb ยท 48 lines
 1package v1
 2
 3import (
 4	"errors"
 5
 6	"gno.land/p/nt/ufmt"
 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 swap while pool is 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)
38
39// newErrorWithDetail adds detail to an error message.
40func newErrorWithDetail(err error, detail string) string {
41	finalErr := ufmt.Errorf("%s || %s", err.Error(), detail)
42	return finalErr.Error()
43}
44
45// makeErrorWithDetails creates an error with additional context.
46func makeErrorWithDetails(err error, details string) error {
47	return ufmt.Errorf("%s || %s", err.Error(), details)
48}