-
Notifications
You must be signed in to change notification settings - Fork 566
/
errors.go
135 lines (105 loc) · 3.6 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package types
import (
"errors"
"fmt"
"github.com/osmosis-labs/osmosis/osmomath"
)
const (
amountOutPlaceholder = "out"
amountInPlaceholder = "in"
)
var (
ErrEmptyRoutes = errors.New("provided empty routes")
ErrTooFewPoolAssets = errors.New("pool should have at least 2 assets, as they must be swapping between at least two assets")
ErrTooManyPoolAssets = errors.New("pool has too many assets (currently capped at 8 assets per pool)")
ErrDuplicateRoutesNotAllowed = errors.New("duplicate multihop routes are not allowed")
)
type nonPositiveAmountError struct {
Amount string
}
func (e nonPositiveAmountError) Error() string {
return fmt.Sprintf("min out amount or max in amount should be positive, was (%s)", e.Amount)
}
type FailedToFindRouteError struct {
PoolId uint64
}
func (e FailedToFindRouteError) Error() string {
return fmt.Sprintf("failed to find route for pool id (%d)", e.PoolId)
}
type UndefinedRouteError struct {
PoolType PoolType
PoolId uint64
}
func (e UndefinedRouteError) Error() string {
return fmt.Sprintf("route is not defined for the given pool type (%s) and pool id (%d)", e.PoolType, e.PoolId)
}
type FinalAmountIsNotPositiveError struct {
IsAmountOut bool
Amount osmomath.Int
}
func (e FinalAmountIsNotPositiveError) Error() string {
amountPlaceholder := amountOutPlaceholder
if !e.IsAmountOut {
amountPlaceholder = amountInPlaceholder
}
return fmt.Sprintf("final total amount (%s) must be positive, was (%d)", amountPlaceholder, e.Amount)
}
type PriceImpactProtectionExactInError struct {
Actual osmomath.Int
MinAmount osmomath.Int
}
func (e PriceImpactProtectionExactInError) Error() string {
return fmt.Sprintf("price impact protection: expected %s to be at least %s", e.Actual, e.MinAmount)
}
type PriceImpactProtectionExactOutError struct {
Actual osmomath.Int
MaxAmount osmomath.Int
}
func (e PriceImpactProtectionExactOutError) Error() string {
return fmt.Sprintf("price impact protection: expected %s to be at most %s", e.Actual, e.MaxAmount)
}
type InvalidFinalTokenOutError struct {
TokenOutGivenA string
TokenOutGivenB string
}
func (e InvalidFinalTokenOutError) Error() string {
return fmt.Sprintf("invalid final token out, each path must end on the same token out, had (%s) and (%s) mismatch", e.TokenOutGivenA, e.TokenOutGivenB)
}
type InvalidSenderError struct {
Sender string
}
func (e InvalidSenderError) Error() string {
return fmt.Sprintf("Invalid sender address (%s)", e.Sender)
}
type InvalidPoolCreatorError struct {
CreatorAddresss string
}
func (e InvalidPoolCreatorError) Error() string {
return fmt.Sprintf("invalid pool creator (%s), only poolmanager can create pools with no fee", e.CreatorAddresss)
}
type InvalidPoolTypeError struct {
PoolType PoolType
}
func (e InvalidPoolTypeError) Error() string {
return fmt.Sprintf("invalid pool type (%s)", PoolType_name[int32(e.PoolType)])
}
type IncorrectPoolIdError struct {
ExpectedPoolId uint64
ActualPoolId uint64
}
func (e IncorrectPoolIdError) Error() string {
return fmt.Sprintf("Pool was attempted to be created with incorrect pool ID. Expected (%d), actual (%d)", e.ExpectedPoolId, e.ActualPoolId)
}
type IncorrectPoolAddressError struct {
ExpectedPoolAddress string
ActualPoolAddress string
}
func (e IncorrectPoolAddressError) Error() string {
return fmt.Sprintf("Pool was attempted to be created with incorrect pool address. Expected (%s), actual (%s)", e.ExpectedPoolAddress, e.ActualPoolAddress)
}
type InactivePoolError struct {
PoolId uint64
}
func (e InactivePoolError) Error() string {
return fmt.Sprintf("Pool %d is not active.", e.PoolId)
}