-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,211 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,4 @@ project/metals.sbt | |
|
||
config.env | ||
|
||
/.bsp/ | ||
.bsp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../amm-executor/src/main/scala/org/ergoplatform/dex/executor/amm/config/BacklogConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.ergoplatform.dex.executor.amm.config | ||
|
||
import derevo.derive | ||
import derevo.pureconfig.pureconfigReader | ||
import tofu.Context | ||
import tofu.logging.derivation.loggable | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
@derive(pureconfigReader, loggable) | ||
final case class BacklogConfig( | ||
orderLifetime: FiniteDuration, | ||
orderExecutionTime: FiniteDuration, | ||
suspendedOrdersExecutionProbabilityPercent: Int | ||
) | ||
|
||
object BacklogConfig extends Context.Companion[BacklogConfig] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
...s/amm-executor/src/main/scala/org/ergoplatform/dex/executor/amm/modules/CFMMBacklog.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...m-executor/src/main/scala/org/ergoplatform/dex/executor/amm/repositories/CFMMOrders.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.ergoplatform.dex.executor.amm.repositories | ||
|
||
import cats.{FlatMap, Functor} | ||
import derevo.derive | ||
import org.ergoplatform.common.cache.Cache | ||
import org.ergoplatform.dex.domain.amm.{CFMMOrder, OrderId} | ||
import org.ergoplatform.dex.executor.amm.repositories.CFMMPools.{CFMMPoolsTracing, Live} | ||
import tofu.higherKind.Mid | ||
import tofu.higherKind.derived.representableK | ||
import tofu.logging.{Logging, Logs} | ||
import tofu.syntax.logging._ | ||
import tofu.syntax.monadic._ | ||
|
||
@derive(representableK) | ||
trait CFMMOrders[F[_]] { | ||
|
||
def put(order: CFMMOrder): F[Unit] | ||
|
||
def exists(orderId: OrderId): F[Boolean] | ||
|
||
def drop(orderId: OrderId): F[Unit] | ||
|
||
def get(orderId: OrderId): F[Option[CFMMOrder]] | ||
|
||
def getAll: F[List[CFMMOrder]] | ||
} | ||
|
||
object CFMMOrders { | ||
|
||
def make[I[_]: Functor, F[_]: FlatMap](implicit logs: Logs[I, F], cache: Cache[F]): I[CFMMOrders[F]] = | ||
logs.forService[CFMMOrders[F]].map { implicit logging => | ||
new CFMMOrdersTracingMid[F] attach new Live[F](cache) | ||
} | ||
|
||
final private class Live[F[_]](cache: Cache[F]) extends CFMMOrders[F] { | ||
|
||
def put(order: CFMMOrder): F[Unit] = cache.set(order.id, order) | ||
|
||
def exists(orderId: OrderId): F[Boolean] = cache.exists(orderId) | ||
|
||
def drop(orderId: OrderId): F[Unit] = cache.del(orderId) | ||
|
||
def get(orderId: OrderId): F[Option[CFMMOrder]] = cache.get[OrderId, CFMMOrder](orderId) | ||
|
||
def getAll: F[List[CFMMOrder]] = cache.getAll | ||
} | ||
|
||
final private class CFMMOrdersTracingMid[F[_]: FlatMap: Logging] extends CFMMOrders[Mid[F, *]] { | ||
|
||
def put(order: CFMMOrder): Mid[F, Unit] = for { | ||
_ <- trace"put(order=$order)" | ||
r <- _ | ||
_ <- trace"put(order=$order) -> $r" | ||
} yield r | ||
|
||
def exists(orderId: OrderId): Mid[F, Boolean] = for { | ||
_ <- trace"exists(orderId=$orderId)" | ||
r <- _ | ||
_ <- trace"exists(orderId=$orderId) -> $r" | ||
} yield r | ||
|
||
def drop(orderId: OrderId): Mid[F, Unit] = for { | ||
_ <- trace"drop(orderId=$orderId)" | ||
r <- _ | ||
_ <- trace"drop(orderId=$orderId) -> $r" | ||
} yield r | ||
|
||
def get(orderId: OrderId): Mid[F, Option[CFMMOrder]] = for { | ||
_ <- trace"checkLater(order=$orderId)" | ||
r <- _ | ||
_ <- trace"checkLater(order=$orderId) -> $r" | ||
} yield r | ||
|
||
def getAll: Mid[F, List[CFMMOrder]] = for { | ||
_ <- trace"getAll()" | ||
r <- _ | ||
_ <- trace"getAll() -> length: ${r.length}" | ||
} yield r | ||
} | ||
} |
Oops, something went wrong.