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

keeper source realm

Package keeper is the role-based access realm of the GnoSwap order realms.

Overview

Package keeper is the role-based access realm of the GnoSwap order realms.

It owns a manager.State (gno.land/p/gnoswap/order/access/manager/v0). Roles are granted to keeper accounts, and each order realm function (target package path and selector) is assigned the role allowed to call it, or PublicRole for anyone.

Administration is not a manager role: every management call is checked against the GnoSwap admin or governance (gno.land/r/gnoswap/access). manager.AdminRole is never granted here.

Roles registered at deployment:

  • DCAKeeperRole (1): DCA order keepers
  • LimitKeeperRole (2): limit order keepers
  • PoolManagerRole (3): DCA/Limit pool whitelist and DCA pool policy managers

DCA ExecuteGroup and ForceCancelOrder are assigned to DCAKeeperRole at deployment, so only granted keepers run DCA rounds and force-cancel orders that block them. The whitelist realm's AddWhitelistedPool and RemoveWhitelistedPool, and DCA's SetTokenMinAmountPerExecution and SetPairPriceLimit are assigned to PoolManagerRole, so only granted managers pick the pools and the price limits rounds trade with (admin and governance may call them too). This role intentionally manages both targets' whitelists and DCA's token minimums and pair price limits; target-specific manager roles are not required. It does not grant ExecuteGroup, ForceCancelOrder, or ExecuteOrder. Keeping the two roles on separate accounts means a single leaked key cannot both choose a round's pool or price and run it.

Admin or governance adds custom roles with AddRole.

Order realms check authorization with IsAuthorized(target, selector, caller), passing their own package path, or with the non-crossing AssertIsAuthorizedCaller(0, cur, selector), which derives the target from cur.

Constants 3

const DCATarget, SelectorExecuteGroup, SelectorAddWhitelistedPool, SelectorRemoveWhitelistedPool, SelectorForceCancelOrder, SelectorSetTokenMinAmountPerExecution, SelectorSetPairPriceLimit, LimitTarget, SelectorExecuteOrder, WhitelistTarget

 1const (
 2	DCATarget                                      = "gno.land/r/gnoswap/order/dca"
 3	SelectorExecuteGroup          manager.Selector = "ExecuteGroup"
 4	SelectorAddWhitelistedPool    manager.Selector = "AddWhitelistedPool"
 5	SelectorRemoveWhitelistedPool manager.Selector = "RemoveWhitelistedPool"
 6	SelectorForceCancelOrder      manager.Selector = "ForceCancelOrder"
 7
 8	SelectorSetTokenMinAmountPerExecution manager.Selector = "SetTokenMinAmountPerExecution"
 9	SelectorSetPairPriceLimit             manager.Selector = "SetPairPriceLimit"
10
11	LimitTarget                           = "gno.land/r/gnoswap/order/limit"
12	SelectorExecuteOrder manager.Selector = "ExecuteOrder"
13
14	WhitelistTarget = "gno.land/r/gnoswap/order/whitelist"
15)
source

Order realm targets and keeper selectors.

Functions 18

func AddRole

crossing Action
1func AddRole(cur realm, label string) manager.RoleId
source

AddRole registers a custom role with label and returns its id. Admin or governance only.

func AssertIsAuthorizedCaller

Action
1func AssertIsAuthorizedCaller(_ int, rlm realm, selector manager.Selector)
source

AssertIsAuthorizedCaller panics unless the caller of rlm may call selector on the realm of rlm. Order realms call it with their own realm value, so a realm can only assert for itself.

func GetRoleGrantDelay

Action
1func GetRoleGrantDelay(role manager.RoleId) uint32
source

GetRoleGrantDelay returns the grant delay of role in effect now, in seconds.

func GetRoleLabel

Action
1func GetRoleLabel(role manager.RoleId) string
source

GetRoleLabel returns the label of a registered role, or "".

func GetRoleMemberSince

Action
1func GetRoleMemberSince(role manager.RoleId, account address) int64
source

GetRoleMemberSince returns when account's membership of role becomes active, or 0 if account is not a member.

func GetRolesJSON

Action
1func GetRolesJSON() string
source

GetRolesJSON returns the registered roles as a JSON array of {"id", "label"} objects, ordered by id.

func GetTargetFunctionRole

Action
1func GetTargetFunctionRole(target string, selector manager.Selector) manager.RoleId
source

GetTargetFunctionRole returns the role assigned to selector on target. Unassigned selectors return manager.AdminRole, which no account holds.

func GrantRole

crossing Action
1func GrantRole(cur realm, role manager.RoleId, account address) bool
source

GrantRole grants role to account and reports whether account is a new member. Membership starts after the role's grant delay. Admin or governance only.

func HasRole

Action
1func HasRole(role manager.RoleId, account address) bool
source

HasRole reports whether account is an active member of role.

func IsAuthorized

Action
1func IsAuthorized(target string, selector manager.Selector, caller address) bool
source

IsAuthorized reports whether caller may call selector on target now.

func RenounceRole

crossing Action
1func RenounceRole(cur realm, role manager.RoleId, callerConfirmation address) bool
source

RenounceRole revokes role from the caller. callerConfirmation must be the caller's address.

func RevokeRole

crossing Action
1func RevokeRole(cur realm, role manager.RoleId, account address) bool
source

RevokeRole revokes role from account and reports whether it was a member. Admin or governance only.

func SetRoleGrantDelay

crossing Action
1func SetRoleGrantDelay(cur realm, role manager.RoleId, delay uint32)
source

SetRoleGrantDelay schedules the delay, in seconds, before new members of role become active. The change itself waits manager.MinSetback. Admin or governance only.

func SetRoleLabel

crossing Action
1func SetRoleLabel(cur realm, role manager.RoleId, label string)
source

SetRoleLabel renames a registered role. Admin or governance only.

func SetTargetClosed

crossing Action
1func SetTargetClosed(cur realm, target string, closed bool)
source

SetTargetClosed closes or reopens target. A closed target rejects every call, whatever its selector roles. Admin or governance only.

func SetTargetFunctionRole

crossing Action
1func SetTargetFunctionRole(cur realm, target string, selector manager.Selector, role manager.RoleId)
source

SetTargetFunctionRole assigns role, or manager.PublicRole for anyone, to selector on target (a realm package path). Admin or governance only.

func SetTargetFunctionRoles

crossing Action
1func SetTargetFunctionRoles(cur realm, target string, selectors []manager.Selector, role manager.RoleId)
source

SetTargetFunctionRoles assigns role to several selectors on target. Admin or governance only.

Dependencies

Source Files 9