Kind Realm (renderable)
Name v1
Namespace gnoswap / position
Exported functions 1
Module gno.land/r/gnoswap/position/v1
gno 0.9 instance.gno gno
⧉
1 package position 2 3 import ( 4 "errors" 5 6 "gno.land/p/nt/grc721/v0" 7 "gno.land/r/gnoswap/access/v1" 8 NewPositionV1 (positionStore interface {GetPosition func(uint64) (gno.land/r/gnoswap/position.Position, bool); GetPositionNextID func() uint64; GetPositions func() *gno.land/p/nt/bptree/v0.BPTree; HasPosition func(uint64) bool; HasPositionNextIDStoreKey func() bool; HasPositionsStoreKey func() bool; RemovePosition func(int, .uverse.realm, uint64) .uverse.error; SetPosition func(int, .uverse.realm, uint64, gno.land/r/gnoswap/position.Position) .uverse.error; SetPositionNextID func(int, .uverse.realm, uint64) .uverse.error; SetPositions func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error}, accessor interface {Approve func(int, .uverse.realm, .uverse.address, gno.land/p/nt/grc721/v0.TokenID) .uverse.error; Burn func(int, .uverse.realm, gno.land/p/nt/grc721/v0.TokenID); Exists func(gno.land/p/nt/grc721/v0.TokenID) bool; Mint func(int, .uverse.realm, .uverse.address, gno.land/p/nt/grc721/v0.TokenID) gno.land/p/nt/grc721/v0.TokenID; OwnerOf func(gno.land/p/nt/grc721/v0.TokenID) (.uverse.address, .uverse.error); TotalSupply func() int64}) interface {CollectFee func(int, .uverse.realm, uint64) (uint64, string, string, string, string, string); DecreaseLiquidity func(int, .uverse.realm, uint64, string, string, string, int64) (uint64, string, string, string, string, string, string); GetPositionFeeGrowthInside0LastX128 func(uint64) (string, .uverse.error); GetPositionFeeGrowthInside1LastX128 func(uint64) (string, .uverse.error); GetPositionFeeGrowthInsideLastX128 func(uint64) (string, string, .uverse.error); GetPositionLiquidity func(uint64) (string, .uverse.error); GetPositionOperator func(uint64) (.uverse.address, .uverse.error); GetPositionOwner func(uint64) (.uverse.address, .uverse.error); GetPositionPoolKey func(uint64) (string, .uverse.error); GetPositionTickLower func(uint64) (int32, .uverse.error); GetPositionTickUpper func(uint64) (int32, .uverse.error); GetPositionTicks func(uint64) (int32, int32, .uverse.error); GetPositionTokenBalances func(uint64) (int64, int64, .uverse.error); GetPositionTokensOwed func(uint64) (int64, int64, .uverse.error); GetPositionTokensOwed0 func(uint64) (int64, .uverse.error); GetPositionTokensOwed1 func(uint64) (int64, .uverse.error); GetPositions func() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetUnclaimedFee func(uint64) (*gno.land/p/gnoswap/uint256/v1.Uint, *gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); IncreaseLiquidity func(int, .uverse.realm, uint64, string, string, string, string, int64) (uint64, string, string, string, string); IsBurned func(uint64) (bool, .uverse.error); IsInRange func(uint64) (bool, .uverse.error); Mint func(int, .uverse.realm, string, string, uint32, int32, int32, string, string, string, string, int64, .uverse.address, string) (uint64, string, string, string); Render func(string) string; Reposition func(int, .uverse.realm, uint64, int32, int32, string, string, string, string, int64) (uint64, string, int32, int32, string, string); SetPositionOperator func(int, .uverse.realm, uint64, .uverse.address)}
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
This realm does not provide renderable output (vm/qrender → NoRenderDeclError).
View on gnoweb ↗ vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.
"gno.land/r/gnoswap/gnft"
9 "gno.land/r/gnoswap/position"
10 )
11
12 type positionV1 struct {
13 store position.IPositionStore
14 nftAccessor NFTAccessor
15 }
16
17 // NewPositionV1 constructs a position implementation backed by the supplied
18 // position store and NFT accessor.
19 //
20 // Parameters:
21 // - positionStore: storage interface used to read and update position records
22 // - accessor: NFT interface used for position token minting, burning, approval, and ownership
23 //
24 // Returns:
25 // - position: IPosition implementation connected to positionStore and accessor
26 func NewPositionV1(positionStore position.IPositionStore, accessor NFTAccessor) position.IPosition {
27 return &positionV1{
28 store: positionStore,
29 nftAccessor: accessor,
30 }
31 }
32
33 type NFTAccessor interface {
34 // Approve forwards an operator approval for a position NFT.
35 //
36 // Parameters:
37 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
38 // - rlm: propagated realm context validated by the concrete accessor before crossing into the NFT realm
39 // - approved: address to approve for the specified position NFT; the empty address revokes approval
40 // - tid: position NFT token ID whose operator approval is changed
41 //
42 // Returns:
43 // - err: nil when approval succeeds; otherwise the NFT accessor or realm-validation error
44 Approve(_ int , rlm realm, approved address, tid grc721.TokenID) error
45 // Mint creates a position NFT for an address and token ID.
46 //
47 // Parameters:
48 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
49 // - rlm: propagated realm context used to cross into the NFT realm
50 // - to: address that receives the newly minted position NFT
51 // - tid: requested position NFT token ID
52 //
53 // Returns:
54 // - mintedTid: token ID returned by the NFT realm after minting
55 Mint(_ int , rlm realm, to address, tid grc721.TokenID) grc721.TokenID
56 // Burn removes a position NFT from the NFT ledger.
57 //
58 // Parameters:
59 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
60 // - rlm: propagated realm context used to cross into the NFT realm
61 // - tid: position NFT token ID to burn
62 Burn(_ int , rlm realm, tid grc721.TokenID)
63 // TotalSupply returns the number of NFTs currently recorded by the ledger.
64 //
65 // Returns:
66 // - totalSupply: current number of position NFTs in the ledger
67 TotalSupply() int64
68 // Exists reports whether the NFT ledger contains a token ID.
69 //
70 // Parameters:
71 // - tid: position NFT token ID to test
72 //
73 // Returns:
74 // - exists: true when the NFT ledger contains tid
75 Exists(tid grc721.TokenID) bool
76 // OwnerOf returns the current owner of a position NFT.
77 //
78 // Parameters:
79 // - tid: position NFT token ID whose owner is requested
80 //
81 // Returns:
82 // - owner: address recorded as the token owner
83 // - err: nil when the token exists; otherwise the NFT ledger's ownership lookup error
84 OwnerOf(tid grc721.TokenID) (address, error )
85 }
86
87 type gnftAccessor struct {}
88
89 // Approve forwards an operator approval to the GNFT realm.
90 //
91 // Parameters:
92 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
93 // - rlm: propagated realm context that must be current before crossing into GNFT
94 // - approved: address to approve for the specified position NFT; the empty address revokes approval
95 // - tid: position NFT token ID whose operator approval is changed
96 //
97 // Returns:
98 // - err: nil when GNFT accepts the approval; errSpoofedRealm when rlm is not current, otherwise the underlying GNFT error
99 func (n *gnftAccessor) Approve(_ int , rlm realm, approved address, tid grc721.TokenID) error {
100 if !rlm.IsCurrent() {
101 return errors.New(errSpoofedRealm)
102 }
103
104 return gnft.Approve(cross(rlm), approved, tid)
105 }
106
107 // Mint forwards position NFT creation to the GNFT realm.
108 //
109 // Parameters:
110 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
111 // - rlm: propagated realm context asserted current before crossing into GNFT
112 // - to: address that receives the newly minted position NFT
113 // - tid: requested position NFT token ID
114 //
115 // Returns:
116 // - mintedTid: token ID returned by GNFT after minting
117 func (n *gnftAccessor) Mint(_ int , rlm realm, to address, tid grc721.TokenID) grc721.TokenID {
118 access.AssertIsRlmCurrent( 0 , rlm)
119
120 return gnft.Mint(cross(rlm), to, tid)
121 }
122
123 // Burn forwards position NFT destruction to the GNFT realm.
124 //
125 // Parameters:
126 // - _: leading realm-call discriminator for the forwarded NFT operation; callers pass 0
127 // - rlm: propagated realm context asserted current before crossing into GNFT
128 // - tid: position NFT token ID to burn
129 func (n *gnftAccessor) Burn(_ int , rlm realm, tid grc721.TokenID) {
130 access.AssertIsRlmCurrent( 0 , rlm)
131
132 gnft.Burn(cross(rlm), tid)
133 }
134
135 // TotalSupply returns the GNFT ledger's current token count.
136 //
137 // Returns:
138 // - totalSupply: number of NFTs currently recorded by GNFT
139 func (n *gnftAccessor) TotalSupply() int64 {
140 return gnft.TotalSupply()
141 }
142
143 // Exists reports whether GNFT contains a position NFT token ID.
144 //
145 // Parameters:
146 // - tid: position NFT token ID to test
147 //
148 // Returns:
149 // - exists: true when GNFT contains tid
150 func (n *gnftAccessor) Exists(tid grc721.TokenID) bool {
151 return gnft.Exists(tid)
152 }
153
154 // OwnerOf returns the owner recorded by GNFT for a position NFT.
155 //
156 // Parameters:
157 // - tid: position NFT token ID whose owner is requested
158 //
159 // Returns:
160 // - owner: address recorded as the token owner
161 // - err: nil when GNFT finds the token; otherwise GNFT's ownership lookup error
162 func (n *gnftAccessor) OwnerOf(tid grc721.TokenID) (address, error ) {
163 return gnft.OwnerOf(tid)
164 }
165
166 func newGNFTAccessor() NFTAccessor {
167 return &gnftAccessor{}
168 }
169