Skip to content

Commit

Permalink
chore: remove filename__function() in error msg template
Browse files Browse the repository at this point in the history
  • Loading branch information
r3v4s committed Dec 17, 2024
1 parent 34e1014 commit 529fd2f
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 100 deletions.
80 changes: 34 additions & 46 deletions position/_RPC_api.gno
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ func ApiGetPositions() string {
}

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, position := range r.Response {
_positionNode := json.ObjectNode("", map[string]*json.Node{
positionNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(position.LpTokenId)),
"burned": json.BoolNode("burned", position.Burned),
"owner": json.StringNode("owner", gnft.OwnerOf(tokenIdFrom(position.LpTokenId)).String()),
Expand All @@ -95,11 +95,11 @@ func ApiGetPositions() string {
"fee0Unclaimed": json.StringNode("fee0Unclaimed", position.FeeUnclaimed0),
"fee1Unclaimed": json.StringNode("fee1Unclaimed", position.FeeUnclaimed1),
})
responses.AppendArray(_positionNode)
responses.AppendArray(positionNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand Down Expand Up @@ -131,15 +131,15 @@ func ApiGetPosition(lpTokenId uint64) string {
}

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, position := range r.Response {
_positionNode := json.ObjectNode("", map[string]*json.Node{
positionNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(position.LpTokenId)),
"burned": json.BoolNode("burned", position.Burned),
"owner": json.StringNode("owner", gnft.OwnerOf(tokenIdFrom(position.LpTokenId)).String()),
Expand All @@ -157,11 +157,11 @@ func ApiGetPosition(lpTokenId uint64) string {
"fee0Unclaimed": json.StringNode("fee0Unclaimed", position.FeeUnclaimed0),
"fee1Unclaimed": json.StringNode("fee1Unclaimed", position.FeeUnclaimed1),
})
responses.AppendArray(_positionNode)
responses.AppendArray(positionNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand Down Expand Up @@ -195,15 +195,15 @@ func ApiGetPositionsByPoolPath(poolPath string) string {
}

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, position := range r.Response {
_positionNode := json.ObjectNode("", map[string]*json.Node{
positionNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(position.LpTokenId)),
"burned": json.BoolNode("burned", position.Burned),
"owner": json.StringNode("owner", gnft.OwnerOf(tokenIdFrom(position.LpTokenId)).String()),
Expand All @@ -221,11 +221,11 @@ func ApiGetPositionsByPoolPath(poolPath string) string {
"fee0Unclaimed": json.StringNode("fee0Unclaimed", position.FeeUnclaimed0),
"fee1Unclaimed": json.StringNode("fee1Unclaimed", position.FeeUnclaimed1),
})
responses.AppendArray(_positionNode)
responses.AppendArray(positionNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand Down Expand Up @@ -258,15 +258,15 @@ func ApiGetPositionsByAddress(address std.Address) string {
}

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, position := range r.Response {
_positionNode := json.ObjectNode("", map[string]*json.Node{
positionNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(position.LpTokenId)),
"burned": json.BoolNode("burned", position.Burned),
"owner": json.StringNode("owner", gnft.OwnerOf(tokenIdFrom(position.LpTokenId)).String()),
Expand All @@ -284,11 +284,11 @@ func ApiGetPositionsByAddress(address std.Address) string {
"fee0Unclaimed": json.StringNode("fee0Unclaimed", position.FeeUnclaimed0),
"fee1Unclaimed": json.StringNode("fee1Unclaimed", position.FeeUnclaimed1),
})
responses.AppendArray(_positionNode)
responses.AppendArray(positionNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand All @@ -312,24 +312,24 @@ func ApiGetPositionsUnclaimedFee() string {
}

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, unclaimedFee := range rpcUnclaimedFee {
_unclaimedFeeNode := json.ObjectNode("", map[string]*json.Node{
unclaimedFeeNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(unclaimedFee.LpTokenId)),
"fee0": json.StringNode("fee0", unclaimedFee.Fee0),
"fee1": json.StringNode("fee1", unclaimedFee.Fee1),
})
responses.AppendArray(_unclaimedFeeNode)
responses.AppendArray(unclaimedFeeNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand All @@ -352,24 +352,24 @@ func ApiGetPositionUnclaimedFeeByLpTokenId(lpTokenId uint64) string {
})

// STAT NODE
_stat := json.ObjectNode("", map[string]*json.Node{
stat := json.ObjectNode("", map[string]*json.Node{
"height": json.NumberNode("height", float64(std.GetHeight())),
"timestamp": json.NumberNode("timestamp", float64(time.Now().Unix())),
})

// RESPONSE (ARRAY) NODE
responses := json.ArrayNode("", []*json.Node{})
for _, unclaimedFee := range rpcUnclaimedFee {
_unclaimedFeeNode := json.ObjectNode("", map[string]*json.Node{
unclaimedFeeNode := json.ObjectNode("", map[string]*json.Node{
"lpTokenId": json.NumberNode("lpTokenId", float64(unclaimedFee.LpTokenId)),
"fee0": json.StringNode("fee0", unclaimedFee.Fee0),
"fee1": json.StringNode("fee1", unclaimedFee.Fee1),
})
responses.AppendArray(_unclaimedFeeNode)
responses.AppendArray(unclaimedFeeNode)
}

node := json.ObjectNode("", map[string]*json.Node{
"stat": _stat,
"stat": stat,
"response": responses,
})

Expand Down Expand Up @@ -429,8 +429,8 @@ func unclaimedFee(tokenId uint64) (*i256.Int, *i256.Int) {

position := MustGetPosition(tokenId)

_liquidity := position.liquidity
liquidity := i256.FromUint256(_liquidity)
liquidityU256 := position.liquidity
liquidity := i256.FromUint256(liquidityU256)

tickLower := position.tickLower
tickUpper := position.tickUpper
Expand All @@ -440,29 +440,17 @@ func unclaimedFee(tokenId uint64) (*i256.Int, *i256.Int) {

currentTick := pool.GetSlot0Tick()

_feeGrowthGlobal0X128 := pool.GetFeeGrowthGlobal0X128() // u256
feeGrowthGlobal0X128 := i256.FromUint256(_feeGrowthGlobal0X128) // i256
feeGrowthGlobal0X128 := i256.FromUint256(pool.GetFeeGrowthGlobal0X128())
feeGrowthGlobal1X128 := i256.FromUint256(pool.GetFeeGrowthGlobal1X128())

_feeGrowthGlobal1X128 := pool.GetFeeGrowthGlobal1X128() // u256
feeGrowthGlobal1X128 := i256.FromUint256(_feeGrowthGlobal1X128) // i256
tickUpperFeeGrowthOutside0X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside0X128(tickUpper))
tickUpperFeeGrowthOutside1X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside1X128(tickUpper))

_tickUpperFeeGrowthOutside0X128 := pool.GetTickFeeGrowthOutside0X128(tickUpper) // u256
tickUpperFeeGrowthOutside0X128 := i256.FromUint256(_tickUpperFeeGrowthOutside0X128) // i256
tickLowerFeeGrowthOutside0X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside0X128(tickLower))
tickLowerFeeGrowthOutside1X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside1X128(tickLower))

_tickUpperFeeGrowthOutside1X128 := pool.GetTickFeeGrowthOutside1X128(tickUpper) // u256
tickUpperFeeGrowthOutside1X128 := i256.FromUint256(_tickUpperFeeGrowthOutside1X128) // i256

_tickLowerFeeGrowthOutside0X128 := pool.GetTickFeeGrowthOutside0X128(tickLower) // u256
tickLowerFeeGrowthOutside0X128 := i256.FromUint256(_tickLowerFeeGrowthOutside0X128) // i256

_tickLowerFeeGrowthOutside1X128 := pool.GetTickFeeGrowthOutside1X128(tickLower) // u256
tickLowerFeeGrowthOutside1X128 := i256.FromUint256(_tickLowerFeeGrowthOutside1X128) // i256

_feeGrowthInside0LastX128 := position.feeGrowthInside0LastX128
feeGrowthInside0LastX128 := i256.FromUint256(_feeGrowthInside0LastX128)

_feeGrowthInside1LastX128 := position.feeGrowthInside1LastX128
feeGrowthInside1LastX128 := i256.FromUint256(_feeGrowthInside1LastX128)
feeGrowthInside0LastX128 := i256.FromUint256(position.feeGrowthInside0LastX128)
feeGrowthInside1LastX128 := i256.FromUint256(position.feeGrowthInside1LastX128)

var tickLowerFeeGrowthBelow0, tickLowerFeeGrowthBelow1, tickUpperFeeGrowthAbove0, tickUpperFeeGrowthAbove1 *i256.Int

Expand Down
2 changes: 1 addition & 1 deletion position/liquidity_management.gno
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func addLiquidity(params AddLiquidityParams) (*u256.Uint, *u256.Uint, *u256.Uint
if !(amount0Cond && amount1Cond) {
panic(addDetailToError(
errSlippage,
ufmt.Sprintf("liquidity_management.gno__addLiquidity() || LM_Price Slippage Check(amount0(%s) >= params.amount0Min(%s), amount1(%s) >= params.amount1Min(%s))", amount0Uint.ToString(), params.amount0Min.ToString(), amount1Uint.ToString(), params.amount1Min.ToString()),
ufmt.Sprintf("LM_Price Slippage Check(amount0(%s) >= params.amount0Min(%s), amount1(%s) >= params.amount1Min(%s))", amount0Uint.ToString(), params.amount0Min.ToString(), amount1Uint.ToString(), params.amount1Min.ToString()),
))
}

Expand Down
Loading

0 comments on commit 529fd2f

Please sign in to comment.