manager.gno
0.88 Kb · 29 lines
1package v1
2
3import (
4 "gno.land/r/gnoswap/position"
5)
6
7// GetNextId is the next position ID to be minted
8func (p *positionV1) getNextId() uint64 {
9 return p.store.GetPositionNextID()
10}
11
12// incrementNextId increments the next position ID to be minted
13func (p *positionV1) incrementNextId(_ int, rlm realm) error {
14 return p.store.SetPositionNextID(0, rlm, p.getNextId()+1)
15}
16
17// setPosition sets a position for a given position ID.
18// Returns false if position is newly created, true if position already existed and was updated.
19func (p *positionV1) setPosition(_ int, rlm realm, id uint64, pos position.Position) error {
20 return p.store.SetPosition(0, rlm, id, pos)
21}
22
23// mustUpdatePosition updates a position for a given position ID.
24func (p *positionV1) mustUpdatePosition(_ int, rlm realm, id uint64, pos position.Position) {
25 err := p.setPosition(0, rlm, id, pos)
26 if err != nil {
27 panic(err)
28 }
29}