Skip to content

Commit

Permalink
Merge pull request #74 from gnoswap-labs/GSW-418-feat-dry-swap
Browse files Browse the repository at this point in the history
GSW-418 feat: dry swap + fix: various bug
  • Loading branch information
r3v4s authored Oct 13, 2023
2 parents 100992b + 9584555 commit d624686
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions pool/pool.gno
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func Swap(
require(amountSpecified != 0, "[POOL] pool.gno__Swap() || amountSpecified can't be zero")

pool := GetPool(pToken0, pToken1, pFee)
require(pool.liquidity > 0, ufmt.Sprintf("[POOL] math_logic.gno__swapAmount() || pool.liquidity(%d) must be > 0", pool.liquidity))

slot0Start := pool.slot0
require(slot0Start.unlocked, "[POOL] pool.gno__Swap() || slot0 must be unlocked")
Expand Down Expand Up @@ -298,6 +299,8 @@ func Swap(
state.amountCalculated += (step.amountIn + step.feeAmount)
}

require(step.amountIn != 0 && step.amountOut != 0, ufmt.Sprintf("[POOL] pool.gno__Swap() || step.amountIn(%d) != 0 && step.amountOut(%d) != 0", step.amountIn, step.amountOut))

if cache.feeProtocol > 0 {
delta := step.feeAmount / bigint(uint64(cache.feeProtocol))
requireUnsigned(delta, ufmt.Sprintf("[POOL] pool.gno__Swap() || delta(%s) >= 0", delta))
Expand Down
2 changes: 1 addition & 1 deletion pool/pool_router.gno
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func poolPathDivide(poolPath string) (string, string, uint16) {
panic(ufmt.Sprintf("[POOL] pool_router.gno__poolPathDivide() || len(poolPathSplit) != 3, poolPath: %s", poolPath))
}

feeInt, err := strconv.ParseInt(poolPathSplit[2], 10, 16)
feeInt, err := strconv.Atoi(poolPathSplit[2])
if err != nil {
panic(ufmt.Sprintf("[POOL] pool_router.gno__poolPathDivide() || cannot convert fee(%s) to uint16", poolPathSplit[2]))
}
Expand Down

0 comments on commit d624686

Please sign in to comment.