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 authored and onlyhyde committed Dec 20, 2024
1 parent 38ca791 commit ab7c9c5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 98 deletions.
76 changes: 32 additions & 44 deletions position/_RPC_api.gno
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ApiGetPositions() string {
// 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 @@ -92,7 +92,7 @@ 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{
Expand Down Expand Up @@ -128,15 +128,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 @@ -154,11 +154,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 @@ -192,15 +192,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 @@ -218,11 +218,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 @@ -255,15 +255,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 @@ -281,11 +281,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 @@ -309,24 +309,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 @@ -349,24 +349,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 @@ -426,8 +426,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 @@ -437,29 +437,17 @@ func unclaimedFee(tokenId uint64) (*i256.Int, *i256.Int) {

currentTick := pool.Slot0Tick()

_feeGrowthGlobal0X128 := pool.FeeGrowthGlobal0X128() // u256
feeGrowthGlobal0X128 := i256.FromUint256(_feeGrowthGlobal0X128) // i256

_feeGrowthGlobal1X128 := pool.FeeGrowthGlobal1X128() // u256
feeGrowthGlobal1X128 := i256.FromUint256(_feeGrowthGlobal1X128) // i256

_tickUpperFeeGrowthOutside0X128 := pool.GetTickFeeGrowthOutside0X128(tickUpper) // u256
tickUpperFeeGrowthOutside0X128 := i256.FromUint256(_tickUpperFeeGrowthOutside0X128) // i256

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

_tickLowerFeeGrowthOutside0X128 := pool.GetTickFeeGrowthOutside0X128(tickLower) // u256
tickLowerFeeGrowthOutside0X128 := i256.FromUint256(_tickLowerFeeGrowthOutside0X128) // i256
feeGrowthGlobal0X128 := i256.FromUint256(pool.GetFeeGrowthGlobal0X128())
feeGrowthGlobal1X128 := i256.FromUint256(pool.GetFeeGrowthGlobal1X128())

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

_feeGrowthInside0LastX128 := position.feeGrowthInside0LastX128
feeGrowthInside0LastX128 := i256.FromUint256(_feeGrowthInside0LastX128)
tickLowerFeeGrowthOutside0X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside0X128(tickLower))
tickLowerFeeGrowthOutside1X128 := i256.FromUint256(pool.GetTickFeeGrowthOutside1X128(tickLower))

_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 ab7c9c5

Please sign in to comment.