diff --git a/pool/position.gno b/pool/position.gno index 64d37e9d5..c2432d421 100644 --- a/pool/position.gno +++ b/pool/position.gno @@ -24,14 +24,14 @@ func positionGetKey( if !owner.IsValid() { panic(addDetailToError( errInvalidAddress, - ufmt.Sprintf("position.gno__positionGetKey() || invalid owner address %s", owner.String()), + ufmt.Sprintf("invalid owner address %s", owner.String()), )) } if tickLower > tickUpper { panic(addDetailToError( errInvalidTickRange, - ufmt.Sprintf("position.gno__positionGetKey() || tickLower(%d) is greater than tickUpper(%d)", tickLower, tickUpper), + ufmt.Sprintf("tickLower(%d) is greater than tickUpper(%d)", tickLower, tickUpper), )) } @@ -74,7 +74,7 @@ func positionUpdate( if position.liquidity.IsZero() { panic(addDetailToError( errZeroLiquidity, - "position.gno__positionUpdate() || both liquidityDelta and current position's liquidity are zero", + "both liquidityDelta and current position's liquidity are zero", )) } diff --git a/pool/position_test.gno b/pool/position_test.gno index 46928b6a8..6f34dc871 100644 --- a/pool/position_test.gno +++ b/pool/position_test.gno @@ -25,9 +25,9 @@ func TestPositionGetKey(t *testing.T) { panicMsg string expectedKey string }{ - {invalidAddr, 100, 200, true, `[GNOSWAP-POOL-023] invalid address || position.gno__positionGetKey() || invalid owner address invalidAddr`, ""}, // invalid address - {validAddr, 200, 100, true, `[GNOSWAP-POOL-024] tickLower is greater than tickUpper || position.gno__positionGetKey() || tickLower(200) is greater than tickUpper(100)`, ""}, // tickLower > tickUpper - {validAddr, -100, -200, true, `[GNOSWAP-POOL-024] tickLower is greater than tickUpper || position.gno__positionGetKey() || tickLower(-100) is greater than tickUpper(-200)`, ""}, // tickLower > tickUpper + {invalidAddr, 100, 200, true, `[GNOSWAP-POOL-023] invalid address || invalid owner address invalidAddr`, ""}, // invalid address + {validAddr, 200, 100, true, `[GNOSWAP-POOL-024] tickLower is greater than tickUpper || tickLower(200) is greater than tickUpper(100)`, ""}, // tickLower > tickUpper + {validAddr, -100, -200, true, `[GNOSWAP-POOL-024] tickLower is greater than tickUpper || tickLower(-100) is greater than tickUpper(-200)`, ""}, // tickLower > tickUpper {validAddr, 100, 100, false, "", "ZzF3ZXNrYzZ0eWc5anhndWpsdGEwNDdoNmx0YTA0N2g2bGRqbHVkdV9fMTAwX18xMDA="}, // tickLower == tickUpper {validAddr, 100, 200, false, "", "ZzF3ZXNrYzZ0eWc5anhndWpsdGEwNDdoNmx0YTA0N2g2bGRqbHVkdV9fMTAwX18yMDA="}, // tickLower < tickUpper } @@ -70,7 +70,7 @@ func TestPositionUpdateWithKey(t *testing.T) { panicMsg string expectedLiquidity string }{ - {i256.MustFromDecimal("0"), u256.Zero(), u256.Zero(), true, `[GNOSWAP-POOL-010] zero liquidity || position.gno__positionUpdate() || both liquidityDelta and current position's liquidity are zero`, ""}, + {i256.MustFromDecimal("0"), u256.Zero(), u256.Zero(), true, `[GNOSWAP-POOL-010] zero liquidity || both liquidityDelta and current position's liquidity are zero`, ""}, {i256.MustFromDecimal("100000"), u256.Zero(), u256.Zero(), false, "", "100000"}, } @@ -104,7 +104,7 @@ func TestPositionUpdate(t *testing.T) { feeGrowthInside0X128: u256.Zero(), feeGrowthInside1X128: u256.Zero(), shouldPanic: true, - panicMsg: `[GNOSWAP-POOL-010] zero liquidity || position.gno__positionUpdate() || both liquidityDelta and current position's liquidity are zero`, + panicMsg: `[GNOSWAP-POOL-010] zero liquidity || both liquidityDelta and current position's liquidity are zero`, }, { initialLiquidity: u256.Zero(), diff --git a/pool/tests/__TEST_pool_spec_#6_test.gnoA b/pool/tests/__TEST_pool_spec_#6_test.gnoA index 03aed8d62..2a1c4eecf 100644 --- a/pool/tests/__TEST_pool_spec_#6_test.gnoA +++ b/pool/tests/__TEST_pool_spec_#6_test.gnoA @@ -81,7 +81,7 @@ func TestPokeIsNotAllowedOnUninitilaizedPosition(t *testing.T) { std.TestSetRealm(posRealm) uassert.PanicsWithMessage( t, - `[GNOSWAP-POOL-010] zero liquidity || position.gno__positionUpdate() || both liquidityDelta and (self)liquidity are zero`, + `[GNOSWAP-POOL-010] zero liquidity || both liquidityDelta and (self)liquidity are zero`, func() { Burn( barPath, diff --git a/position/position.gno b/position/position.gno index f33ffd0b6..094878ce4 100644 --- a/position/position.gno +++ b/position/position.gno @@ -17,6 +17,7 @@ import ( ) var ( + // TODO: use avl positions map[uint64]Position = make(map[uint64]Position) // tokenId -> Position nextId uint64 = 1 // lp token id ) @@ -51,7 +52,7 @@ func Mint( if !(isUserCalled || isStakerCalled) { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__Mint() || only user or staker can call isUserCalled(%t) || isStakerCalled(%t), but called from %s", isUserCalled, isStakerCalled, prev.Addr().String()), + ufmt.Sprintf("only user or staker can call isUserCalled(%t) || isStakerCalled(%t), but called from %s", isUserCalled, isStakerCalled, prev.Addr().String()), )) } } @@ -150,7 +151,7 @@ func handleNativeToken(token0IsNative, token1IsNative bool, caller std.Address) if (newUserWugnotBalance - oldUserWugnotBalance) != ugnotSent { panic(addDetailToError( errWrapUnwrap, - ufmt.Sprintf("position.gno__Mint() || ugnot sent(%d) != wugnot received(%d)", ugnotSent, newUserWugnotBalance-oldUserWugnotBalance), + ufmt.Sprintf("ugnot sent(%d) != wugnot received(%d)", ugnotSent, newUserWugnotBalance-oldUserWugnotBalance), )) } } @@ -287,7 +288,7 @@ func increaseLiquidity(params IncreaseLiquidityParams) (uint64, *u256.Uint, *u25 if !exists(params.tokenId) { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__increaseLiquidity() || tokenId(%d) doesn't exist", params.tokenId), + ufmt.Sprintf("tokenId(%d) doesn't exist", params.tokenId), )) } @@ -298,7 +299,7 @@ func increaseLiquidity(params IncreaseLiquidityParams) (uint64, *u256.Uint, *u25 if owner != caller { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__increaseLiquidity() || only owner(%s) can increase liquidity for tokenId(%d), but called from %s", owner, params.tokenId, caller), + ufmt.Sprintf("only owner(%s) can increase liquidity for tokenId(%d), but called from %s", owner, params.tokenId, caller), )) } @@ -367,7 +368,7 @@ func DecreaseLiquidity( if !isNormalRange { panic(addDetailToError( errOutOfRange, - ufmt.Sprintf("position.gno__decreaseLiquidity() || liquidityRatio(%d) should be in range 1 ~ 100", liquidityRatio), + ufmt.Sprintf("liquidityRatio(%d) should be in range 1 ~ 100", liquidityRatio), )) } @@ -428,7 +429,7 @@ func decreaseLiquidity(params DecreaseLiquidityParams) (uint64, *u256.Uint, *u25 if positionLiquidity.IsZero() { panic(addDetailToError( errZeroLiquidity, - ufmt.Sprintf("position.gno__decreaseLiquidity() || position(tokenId:%d) has 0 liquidity", params.tokenId), + ufmt.Sprintf("position(tokenId:%d) has 0 liquidity", params.tokenId), )) } @@ -531,7 +532,7 @@ func Reposition( if !exists(tokenId) { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__Reposition() || tokenId(%d) doesn't exist", tokenId), + ufmt.Sprintf("tokenId(%d) doesn't exist", tokenId), )) } @@ -542,7 +543,7 @@ func Reposition( if owner != caller { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__Reposition() || only owner(%s) can reposition for tokenId(%d), but called from %s", owner, tokenId, caller), + ufmt.Sprintf("only owner(%s) can reposition for tokenId(%d), but called from %s", owner, tokenId, caller), )) } @@ -554,7 +555,7 @@ func Reposition( if !(position.isClear()) { panic(addDetailToError( errNotClear, - ufmt.Sprintf("position.gno__Reposition() || position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), + ufmt.Sprintf("position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), )) } @@ -647,7 +648,7 @@ func CollectFee(tokenId uint64, unwrapResult bool) (uint64, string, string, stri if !exists(tokenId) { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__CollectFee() || tokenId(%d) doesn't exist", tokenId), + ufmt.Sprintf("tokenId(%d) doesn't exist", tokenId), )) } @@ -659,7 +660,7 @@ func CollectFee(tokenId uint64, unwrapResult bool) (uint64, string, string, stri if !exist { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__CollectFee() || position(%d) doesn't exist", tokenId), + ufmt.Sprintf("position(%d) doesn't exist", tokenId), )) } @@ -781,7 +782,7 @@ func burnNFT(tokenId uint64) { if !(position.isClear()) { panic(addDetailToError( errNotClear, - ufmt.Sprintf("position.gno__burnNFT() || position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), + ufmt.Sprintf("position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), )) } delete(positions, tokenId) @@ -793,7 +794,7 @@ func burnPosition(tokenId uint64) { if !(position.isClear()) { panic(addDetailToError( errNotClear, - ufmt.Sprintf("position.gno__burnPosition() || position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), + ufmt.Sprintf("position(%d) isn't clear(liquidity:%s, tokensOwed0:%s, tokensOwed1:%s)", tokenId, position.liquidity.ToString(), position.tokensOwed0.ToString(), position.tokensOwed1.ToString()), )) } @@ -805,7 +806,7 @@ func isAuthorizedForToken(tokenId uint64) { if !(isOwnerOrOperator(std.PrevRealm().Addr(), tokenId)) { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__isAuthorizedForToken() || caller(%s) is not approved or owner of tokenId(%d)", std.PrevRealm().Addr(), tokenId), + ufmt.Sprintf("caller(%s) is not approved or owner of tokenId(%d)", std.PrevRealm().Addr(), tokenId), )) } } @@ -814,7 +815,7 @@ func verifyTokenIdAndOwnership(tokenId uint64) { if !exists(tokenId) { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__verifyTokenIdAndOwnership() || tokenId(%d) doesn't exist", tokenId), + ufmt.Sprintf("tokenId(%d) doesn't exist", tokenId), )) } @@ -823,7 +824,7 @@ func verifyTokenIdAndOwnership(tokenId uint64) { if owner != caller { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__verifyTokenIdAndOwnership() || only owner(%s) can decrease liquidity(tokenId:%d), but called from %s", owner, tokenId, caller), + ufmt.Sprintf("only owner(%s) can decrease liquidity(tokenId:%d), but called from %s", owner, tokenId, caller), )) } } @@ -841,7 +842,7 @@ func verifyBurnedAmounts(burnedAmount0, burnedAmount1, amount0Min, amount1Min *u if !(burnedAmount0.Gte(amount0Min) && burnedAmount1.Gte(amount1Min)) { panic(addDetailToError( errSlippage, - ufmt.Sprintf("position.gno__verifyBurnedAmounts() || burnedAmount0(%s) >= amount0Min(%s) && burnedAmount1(%s) >= amount1Min(%s)", burnedAmount0.ToString(), amount0Min.ToString(), burnedAmount1.ToString(), amount1Min.ToString()), + ufmt.Sprintf("burnedAmount0(%s) >= amount0Min(%s) && burnedAmount1(%s) >= amount1Min(%s)", burnedAmount0.ToString(), amount0Min.ToString(), burnedAmount1.ToString(), amount1Min.ToString()), )) } } @@ -859,7 +860,7 @@ func SetPositionOperator(tokenId uint64, operator std.Address) { if caller != consts.STAKER_PATH { panic(addDetailToError( errNoPermission, - ufmt.Sprintf("position.gno__SetPositionOperator() || caller(%s) is not staker", caller), + ufmt.Sprintf("caller(%s) is not staker", caller), )) } @@ -867,7 +868,7 @@ func SetPositionOperator(tokenId uint64, operator std.Address) { if !exist { panic(addDetailToError( errDataNotFound, - ufmt.Sprintf("position.gno__SetPositionOperator() || position(%d) doesn't exist", tokenId), + ufmt.Sprintf("position(%d) doesn't exist", tokenId), )) } diff --git a/position/tests/__TEST_position_increase_decrease_test.gnoA b/position/tests/__TEST_position_increase_decrease_test.gnoA index cf356b53c..455c40c69 100644 --- a/position/tests/__TEST_position_increase_decrease_test.gnoA +++ b/position/tests/__TEST_position_increase_decrease_test.gnoA @@ -200,7 +200,7 @@ func TestDecreaseLiquidityAllThenAgainShouldPanic(t *testing.T) { // decreasing position(with 0 liquidity) should panic uassert.PanicsWithMessage( t, - `[GNOSWAP-POOL-010] zero liquidity || position.gno__positionUpdate() || both liquidityDelta and (self)liquidity are zero`, + `[GNOSWAP-POOL-010] zero liquidity || both liquidityDelta and (self)liquidity are zero`, func() { DecreaseLiquidity( uint64(1), // tokenId diff --git a/position/tests/__TEST_position_reposition_grc20_pair_test.gnoA b/position/tests/__TEST_position_reposition_grc20_pair_test.gnoA index 944827793..e631bad75 100644 --- a/position/tests/__TEST_position_reposition_grc20_pair_test.gnoA +++ b/position/tests/__TEST_position_reposition_grc20_pair_test.gnoA @@ -226,7 +226,7 @@ func TestRepositionNotOwner(t *testing.T) { std.TestSetRealm(std.NewUserRealm(test1)) uassert.PanicsWithMessage( t, - `[GNOSWAP-POSITION-001] caller has no permission || position.gno__Reposition() || only owner(g17290cwvmrapvp869xfnhhawa8sm9edpufzat7d) can reposition for tokenId(1), but called from g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5`, + `[GNOSWAP-POSITION-001] caller has no permission || only owner(g17290cwvmrapvp869xfnhhawa8sm9edpufzat7d) can reposition for tokenId(1), but called from g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5`, func() { Reposition(uint64(1), -1000, 1000, "500", "500", "0", "0") }) @@ -236,7 +236,7 @@ func TestRepositionOwnerButNowBurned(t *testing.T) { std.TestSetRealm(adminRealm) uassert.PanicsWithMessage( t, - `[GNOSWAP-POSITION-009] position is not clear || position.gno__Reposition() || position(2) isn't clear(liquidity:341464938, tokensOwed0:0, tokensOwed1:0)`, + `[GNOSWAP-POSITION-009] position is not clear || position(2) isn't clear(liquidity:341464938, tokensOwed0:0, tokensOwed1:0)`, func() { Reposition(uint64(2), -1000, 1000, "500", "500", "0", "0") }) diff --git a/position/wrap_unwrap.gno b/position/wrap_unwrap.gno index e1c97f9d0..f0fe53955 100644 --- a/position/wrap_unwrap.gno +++ b/position/wrap_unwrap.gno @@ -17,7 +17,7 @@ func wrap(ugnotAmount uint64, to std.Address) { if ugnotAmount < consts.UGNOT_MIN_DEPOSIT_TO_WRAP { panic(addDetailToError( errWugnotMinimum, - ufmt.Sprintf("wrap.gno__wrap() || amount(%d) < minimum(%d)", ugnotAmount, consts.UGNOT_MIN_DEPOSIT_TO_WRAP), + ufmt.Sprintf("amount(%d) < minimum(%d)", ugnotAmount, consts.UGNOT_MIN_DEPOSIT_TO_WRAP), )) }