Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

getters.gno

0.80 Kb · 34 lines
 1package whitelist
 2
 3import (
 4	rotree "gno.land/p/nt/bptree/rotree/v0"
 5
 6	"gno.land/r/gnoswap/pool"
 7)
 8
 9func IsWhitelistedPool(target, poolPath string) bool {
10	return getState(target).HasPool(poolPath)
11}
12
13// GetWhitelistedPools returns only target's read-only poolPath -> true tree.
14func GetWhitelistedPools(target string) *rotree.ReadOnlyTree {
15	return getState(target).Pools()
16}
17
18// HasWhitelistedPool reports whether target allows an existing direct pool of the pair.
19func HasWhitelistedPool(target, tokenIn, tokenOut string) bool {
20	state := getState(target)
21
22	if tokenIn == tokenOut {
23		return false
24	}
25
26	for fee := range pool.GetFeeAmountTickSpacings() {
27		poolPath := pool.GetPoolPath(tokenIn, tokenOut, uint32(fee))
28		if state.HasPool(poolPath) && pool.ExistsPoolPath(poolPath) {
29			return true
30		}
31	}
32
33	return false
34}