Skip to content

Commit

Permalink
GSW-1839 refactor: use avl.Tree in position (#440)
Browse files Browse the repository at this point in the history
* GSW-1839 refactor: use avl.Tree to manage list of position object
- keep tokenId type as uint64 ( seqid is not necessary for position contract )
* GSW-1839 fix: getting avl data size
* fix: sonarcube warning
* fix: delete duplication
* fix: missing error msg
* fix: remove token register for pool
* fix: error code changes
* chore: remove `filename__function()` in error msg template
* fix: run test fail issue
---------

Co-authored-by: Lee ByeongJun <[email protected]>
Co-authored-by: 0xTopaz <[email protected]>
  • Loading branch information
3 people authored Dec 20, 2024
1 parent 38d013a commit 808b22a
Show file tree
Hide file tree
Showing 25 changed files with 315 additions and 266 deletions.
35 changes: 23 additions & 12 deletions position/_GET_no_receiver.gno
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,62 @@ import (

// type Position
func PositionGetPosition(tokenId uint64) Position {
return positions[tokenId]
position, _ := GetPosition(tokenId)
return position
}

func PositionGetPositionNonce(tokenId uint64) *u256.Uint {
return positions[tokenId].nonce
position := MustGetPosition(tokenId)
return position.nonce
}

func PositionGetPositionOperator(tokenId uint64) std.Address {
return positions[tokenId].operator
position := MustGetPosition(tokenId)
return position.operator
}

func PositionGetPositionPoolKey(tokenId uint64) string {
return positions[tokenId].poolKey
position := MustGetPosition(tokenId)
return position.poolKey
}

func PositionGetPositionTickLower(tokenId uint64) int32 {
return positions[tokenId].tickLower
position := MustGetPosition(tokenId)
return position.tickLower
}

func PositionGetPositionTickUpper(tokenId uint64) int32 {
return positions[tokenId].tickUpper
position := MustGetPosition(tokenId)
return position.tickUpper
}

func PositionGetPositionLiquidity(tokenId uint64) *u256.Uint {
return positions[tokenId].liquidity
position := MustGetPosition(tokenId)
return position.liquidity
}

func PositionGetPositionFeeGrowthInside0LastX128(tokenId uint64) *u256.Uint {
return positions[tokenId].feeGrowthInside0LastX128
position := MustGetPosition(tokenId)
return position.feeGrowthInside0LastX128
}

func PositionGetPositionFeeGrowthInside1LastX128(tokenId uint64) *u256.Uint {
return positions[tokenId].feeGrowthInside1LastX128
position := MustGetPosition(tokenId)
return position.feeGrowthInside1LastX128
}

func PositionGetPositionTokensOwed0(tokenId uint64) *u256.Uint {
return positions[tokenId].tokensOwed0
position := MustGetPosition(tokenId)
return position.tokensOwed0
}

func PositionGetPositionTokensOwed1(tokenId uint64) *u256.Uint {
return positions[tokenId].tokensOwed1
position := MustGetPosition(tokenId)
return position.tokensOwed1
}

func PositionIsInRange(tokenId uint64) bool {
position := positions[tokenId]
position := MustGetPosition(tokenId)
poolPath := position.poolKey
poolCurrentTick := pl.PoolGetSlot0Tick(poolPath)

Expand Down
12 changes: 6 additions & 6 deletions position/_GET_no_receiver_string.gno
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ package position

// type Position
func PositionGetPositionNonceStr(tokenId uint64) string {
return positions[tokenId].nonce.ToString()
return MustGetPosition(tokenId).nonce.ToString()
}

func PositionGetPositionLiquidityStr(tokenId uint64) string {
return positions[tokenId].liquidity.ToString()
return MustGetPosition(tokenId).liquidity.ToString()
}

func PositionGetPositionFeeGrowthInside0LastX128Str(tokenId uint64) string {
return positions[tokenId].feeGrowthInside0LastX128.ToString()
return MustGetPosition(tokenId).feeGrowthInside0LastX128.ToString()
}

func PositionGetPositionFeeGrowthInside1LastX128Str(tokenId uint64) string {
return positions[tokenId].feeGrowthInside1LastX128.ToString()
return MustGetPosition(tokenId).feeGrowthInside1LastX128.ToString()
}

func PositionGetPositionTokensOwed0Str(tokenId uint64) string {
return positions[tokenId].tokensOwed0.ToString()
return MustGetPosition(tokenId).tokensOwed0.ToString()
}

func PositionGetPositionTokensOwed1Str(tokenId uint64) string {
return positions[tokenId].tokensOwed1.ToString()
return MustGetPosition(tokenId).tokensOwed1.ToString()
}
Loading

0 comments on commit 808b22a

Please sign in to comment.