nolash / erc20-pool

Permission erc20 swap pool for EVM
1 stars 1 forks source link

Algo. Discussion #1

Open WillRuddick opened 8 months ago

WillRuddick commented 8 months ago

Specification for Developing Optimization Algorithms for Networks of SwapPools:

Use Case #1: Optimal Pathfinding

Use Case #2: Pool Balancing (Obligation Clearing)

For both use cases, the algorithms should be designed to run at specified intervals or triggered by certain thresholds being met (e.g., liquidity imbalance). They should also be robust enough to handle the dynamic nature of the pools, where liquidity and valuations can change frequently. The algorithms must be transparent and verifiable to maintain trust among participants in the network. Additionally, the implementation should prioritize security and auditability, especially when integrating with blockchain-based SwapPools.

Use Case #3: Multi-Asset Exchange Maximization

For this use case, the algorithm should consider the liquidity in each SwapPool to fulfill orders without causing significant imbalance. It must also be capable of handling complex multi-party trades that could involve more than two participants to find the optimal trade cycles. This optimization task will likely be computationally intensive and require sophisticated mathematical models to execute effectively.

michielbdejong commented 8 months ago

Yes, well described! Use case 1 is basically https://interledger.org - multi-hop payments. See also an old blog post of mine about Ripple Classic, Interledger, and multihop with hashlocks.

Use case 2 is different from that because the user is not synchronously waiting for a payment to complete; the rebalancing can happen asynchronously, so the time constraints are much less strict. And indeed instead of path finding we then call it cycle detection, like in https://ledgerloops.com.

And use case 3 is maybe the combination of the two, but taking into account how one trade can sometimes block the possibility of a different trade? As in "find an optimal set of trades". A trade might be beneficial in itself, but in the bigger picture it can lead to a suboptimal end result for the network as a whole.

Do read https://www.mdpi.com/1911-8074/13/12/295 if you haven't yet.

This optimization task will likely be computationally intensive and require sophisticated mathematical models to execute effectively.

Not if you start with a complete bird's eye view of the market. You could use the algorithm that Slovenia uses (I can't find the link right now, I think there is a 4-letter acronym for it but I forgot, so quoting from memory):

My research interest is also in solving this without a bird's eye view of the network, so by only sending signalling messages through the network. One way of doing that is using market forces, to get netting at equilibrium although we had a discussion about this at CoFi'24, since it may be optimal for individual agents to incentivise market makers, but of course society as a whole is better off without brokers who just exploit their network position to charge a toll.