Gno.land
| 1 | package pool |
| 2 | |
| 3 | import ( |
| 4 | ufmt "gno.land/p/nt/ufmt/v0" |
| 5 | pl "gno.land/r/gnoswap/pool" |
| 6 | ) |
| 7 | |
| 8 | func assertIsNotUserCall(_ int, rlm realm) { |
| 9 | previousRealm := rlm.Previous() |
| 10 | if previousRealm.IsUserCall() { |
| 11 | panic(newErrorWithDetail( |
| 12 | errNotAccessEOA, |
| 13 | ufmt.Sprintf("previousRealm(%s) is EOA", previousRealm.Address()), |
| 14 | )) |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | // assertIsNotEqualsTokens asserts that the token0Path and token1Path are not equal. |
| 19 | func assertIsNotEqualsTokens(token0Path, token1Path string) { |
| 20 | if token0Path == token1Path { |
| 21 | panic(newErrorWithDetail( |
| 22 | errDuplicateTokenInPool, |
| 23 | ufmt.Sprintf("expected token0Path(%s) != token1Path(%s)", token0Path, token1Path), |
| 24 | )) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // assertIsSupportedFeeTier asserts that the fee is a supported fee tier. |
| 29 | func assertIsSupportedFeeTier(fee uint32) { |
| 30 | if !isValidFeeTier(fee) { |
| 31 | panic(newErrorWithDetail( |
| 32 | errUnsupportedFeeTier, |
| 33 | ufmt.Sprintf("expected fee(%d) to be one of %d, %d, %d, %d", fee, FeeTier100, FeeTier500, FeeTier3000, FeeTier10000), |
| 34 | )) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // assertIsNotExistsPoolPath asserts that the pool path does not exist. |
| 39 | func assertIsNotExistsPoolPath(instance *poolV1, token0Path, token1Path string, fee uint32) { |
| 40 | poolPath := pl.GetPoolPath(token0Path, token1Path, fee) |
| 41 | |
| 42 | pools := instance.store.GetPools() |
| 43 | if pools.Has(poolPath) { |
| 44 | panic(newErrorWithDetail( |
| 45 | errPoolAlreadyExists, |
| 46 | ufmt.Sprintf("expected poolPath(%s:%s:%d) not to exist", token0Path, token1Path, fee), |
| 47 | )) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func assertIsValidTokenOrder(token0Path, token1Path string) { |
| 52 | if token0Path >= token1Path { |
| 53 | panic(newErrorWithDetail( |
| 54 | errInvalidInput, |
| 55 | ufmt.Sprintf("expected token0Path(%s) < token1Path(%s)", token0Path, token1Path), |
| 56 | )) |
| 57 | } |
| 58 | } |
| Function | Parameters |
|---|---|
| NewTickEventInfo | (tickID int32, tickInfo struct{liquidityGross string; liquidityNet string; feeGrowthOutside0X128 string; feeGrowthOutside1X128 string; tickCumulativeOutside int64; secondsPerLiquidityOutsideX128 string; secondsOutside uint32; initialized bool}) |
| GetPoolPath | (token0Path string, token1Path string, fee uint32) |
| NewPoolV1 | (store interface {GetFeeAmountTickSpacing func() map[uint32]int32; GetObservations func() *gno.land/p/nt/bptree/v0.BPTree; GetPendingProtocolFee func(string) int64; GetPendingProtocolFees func() map[string]int64; GetPoolCreationFee func() int64; GetPools func() *gno.land/p/nt/bptree/v0.BPTree; GetSlot0FeeProtocol func() uint8; GetSwapEndHook func() func(.uverse.realm, string) .uverse.error; GetSwapStartHook func() func(.uverse.realm, string, int64); GetTickCrossHook func() func(.uverse.realm, string, int32, bool, int64); GetUnlocked func() bool; GetWithdrawalFeeBPS func() uint64; HasFeeAmountTickSpacing func() bool; HasObservations func() bool; HasPendingProtocolFees func() bool; HasPoolCreationFee func() bool; HasPools func() bool; HasSlot0FeeProtocol func() bool; HasSwapEndHook func() bool; HasSwapStartHook func() bool; HasTickCrossHook func() bool; HasUnlocked func() bool; HasWithdrawalFeeBPS func() bool; RemovePendingProtocolFee func(int, .uverse.realm, string) .uverse.error; SetFeeAmountTickSpacing func(int, .uverse.realm, map[uint32]int32) .uverse.error; SetObservations func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetPendingProtocolFee func(int, .uverse.realm, string, int64) .uverse.error; SetPendingProtocolFees func(int, .uverse.realm, map[string]int64) .uverse.error; SetPoolCreationFee func(int, .uverse.realm, int64) .uverse.error; SetPools func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetSlot0FeeProtocol func(int, .uverse.realm, uint8) .uverse.error; SetSwapEndHook func(int, .uverse.realm, func(.uverse.realm, string) .uverse.error) .uverse.error; SetSwapStartHook func(int, .uverse.realm, func(.uverse.realm, string, int64)) .uverse.error; SetTickCrossHook func(int, .uverse.realm, func(.uverse.realm, string, int32, bool, int64)) .uverse.error; SetUnlocked func(int, .uverse.realm, bool) .uverse.error; SetWithdrawalFeeBPS func(int, .uverse.realm, uint64) .uverse.error}) |
N/A
| Function | Caller | Age |
|---|
None