Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GSW-1839 refactor: use avl.Tree in position #440

Merged
merged 16 commits into from
Dec 20, 2024
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
Loading