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

getter.gno

4.25 Kb · 144 lines
  1package limit
  2
  3import (
  4	plimit "gno.land/p/gnoswap/order/limit/v0"
  5	rotree "gno.land/p/nt/bptree/rotree/v0"
  6)
  7
  8// Getters return detached copies of stored values. Store trees are returned
  9// as read-only views keyed as in the store layout (see store.gno); views whose
 10// entries are pointers copy every entry they return. Callers page a view
 11// themselves through Iterate, IterateByOffset, or their reverse forms.
 12
 13// ==================================
 14// Config Getters
 15// ==================================
 16
 17// GetConfig returns a detached copy of the current global configuration.
 18//
 19// Returns:
 20//   - *plimit.Config: copy of the stored configuration
 21func GetConfig() *plimit.Config {
 22	return getImplementation().GetConfig()
 23}
 24
 25// GetExecutionFeeRate returns the execution fee rate snapshotted into new orders.
 26//
 27// Returns:
 28//   - int64: execution fee rate, in basis points of gross output
 29func GetExecutionFeeRate() int64 {
 30	return GetConfig().ExecutionFeeRate()
 31}
 32
 33// GetMaxSlippageBps returns the slippage cap for new orders.
 34//
 35// Returns:
 36//   - int64: maximum slippage, in basis points
 37func GetMaxSlippageBps() int64 {
 38	return GetConfig().MaxSlippageBps()
 39}
 40
 41// GetMinMakingAmount returns the minimum input amount for new orders.
 42//
 43// Returns:
 44//   - int64: minimum makingAmount, in raw token units
 45func GetMinMakingAmount() int64 {
 46	return GetConfig().MinMakingAmount()
 47}
 48
 49// GetOrderDeadlines returns the allowed order duration range for new orders.
 50//
 51// Returns:
 52//   - int64: shortest allowed expiresAt - createdAt, in seconds
 53//   - int64: longest allowed expiresAt - createdAt, in seconds
 54func GetOrderDeadlines() (int64, int64) {
 55	config := GetConfig()
 56
 57	return config.MinOrderDuration(), config.MaxOrderDuration()
 58}
 59
 60// GetMaxCleanupBatchSize returns the most orders one CleanupExpiredOrders call examines.
 61//
 62// Returns:
 63//   - int64: maximum cleanup batch size
 64func GetMaxCleanupBatchSize() int64 {
 65	return GetConfig().MaxCleanupBatchSize()
 66}
 67
 68// ==================================
 69// Order Getters
 70// ==================================
 71
 72// GetNextOrderID returns the ID the next created order receives.
 73//
 74// Returns:
 75//   - uint64: next order ID
 76func GetNextOrderID() uint64 {
 77	return getImplementation().GetNextOrderID()
 78}
 79
 80// ExistsOrder reports whether an order is pending.
 81// Settled orders are deleted.
 82//
 83// Parameters:
 84//   - orderID: order to look up
 85//
 86// Returns:
 87//   - bool: true while the order is pending
 88func ExistsOrder(orderID uint64) bool {
 89	return getImplementation().ExistsOrder(orderID)
 90}
 91
 92// GetOrder returns a detached pending order, or nil after it is settled.
 93//
 94// Parameters:
 95//   - orderID: order to look up
 96//
 97// Returns:
 98//   - *plimit.Order: copy of the order; nil when it is not pending
 99func GetOrder(orderID uint64) *plimit.Order {
100	return getImplementation().GetOrder(orderID)
101}
102
103// GetOrders returns a live read-only view of pending orders.
104//
105// Returns:
106//   - *rotree.ReadOnlyTree: plimit.OrderKey(orderID) -> *plimit.Order;
107//     each order read from the view is detached from stored state
108func GetOrders() *rotree.ReadOnlyTree {
109	return getImplementation().GetOrders()
110}
111
112// GetOrdersByOwner returns the read-only owner index of pending orders.
113// Iterate the [plimit.OwnerOrderPrefix(owner), plimit.PrefixEnd(prefix))
114// range for one owner's orders in ID order, choosing the page size.
115//
116// Returns:
117//   - *rotree.ReadOnlyTree: plimit.OwnerOrderKey(owner, orderID) -> uint64 orderID
118func GetOrdersByOwner() *rotree.ReadOnlyTree {
119	return getImplementation().GetOrdersByOwner()
120}
121
122// ==================================
123// Execution Fee Getters
124// ==================================
125
126// GetPendingExecutionFeeAmount returns execution fees held for tokenPath until the
127// protocol fee realm accepts them. A later fill with the same output token retries collection.
128//
129// Parameters:
130//   - tokenPath: fee token path
131//
132// Returns:
133//   - int64: pending execution fee, in raw token units
134func GetPendingExecutionFeeAmount(tokenPath string) int64 {
135	return getImplementation().GetPendingExecutionFeeAmount(tokenPath)
136}
137
138// GetPendingExecutionFees returns the read-only index of pending execution fees.
139//
140// Returns:
141//   - *rotree.ReadOnlyTree: tokenPath -> int64 pending amount
142func GetPendingExecutionFees() *rotree.ReadOnlyTree {
143	return getImplementation().GetPendingExecutionFees()
144}