71 lines
2.3 KiB
Markdown
71 lines
2.3 KiB
Markdown
|
|
||
|
# Liquidity Pool Contract
|
||
|
|
||
|
|
||
|
> [More info see here](liquidity_pool.md)
|
||
|
|
||
|
|
||
|
## some further specs
|
||
|
|
||
|
```mermaid
|
||
|
graph TB
|
||
|
Start((Start)) --> Register[Register Participant]
|
||
|
Register --> SetPreferences[Set Price Preferences]
|
||
|
SetPreferences --> JoinPool[Join Liquidity Pool]
|
||
|
|
||
|
JoinPool --> Transaction{Transaction?}
|
||
|
Transaction -->|Buy| BuyProcess[Buy Process]
|
||
|
Transaction -->|Sell| SellProcess[Sell Process]
|
||
|
Transaction -->|No Transaction| Monitor[Monitor Pool]
|
||
|
|
||
|
BuyProcess --> CheckLiquidity{Sufficient Liquidity?}
|
||
|
CheckLiquidity -->|Yes| ExecuteBuy[Execute Buy]
|
||
|
CheckLiquidity -->|No| QueueRequest[Queue Buy Request]
|
||
|
|
||
|
SellProcess --> CheckPriceLimit{Meet Price Limit?}
|
||
|
CheckPriceLimit -->|Yes| ExecuteSell[Execute Sell]
|
||
|
CheckPriceLimit -->|No| WaitForPrice[Wait for Price Change]
|
||
|
|
||
|
ExecuteBuy --> UpdateAccounts[Update All Accounts]
|
||
|
ExecuteSell --> UpdateAccounts
|
||
|
UpdateAccounts --> CalculateDiscount[Calculate TFGrid Discount]
|
||
|
|
||
|
QueueRequest --> Monitor
|
||
|
WaitForPrice --> Monitor
|
||
|
|
||
|
Monitor --> AggregateStats[Aggregate Daily Stats]
|
||
|
AggregateStats --> PublishStats[Publish Aggregate Stats]
|
||
|
|
||
|
PublishStats --> CheckLockup{Lockup Period?}
|
||
|
CheckLockup -->|Yes| ContinueHolding[Continue Holding]
|
||
|
CheckLockup -->|No| Withdraw{Withdraw?}
|
||
|
|
||
|
Withdraw -->|Yes| ProcessWithdrawal[Process Withdrawal]
|
||
|
Withdraw -->|No| Transaction
|
||
|
|
||
|
ProcessWithdrawal --> UpdateAccounts
|
||
|
ContinueHolding --> Transaction
|
||
|
|
||
|
subgraph "Liquidity Pool Operations"
|
||
|
Transaction
|
||
|
BuyProcess
|
||
|
SellProcess
|
||
|
CheckLiquidity
|
||
|
CheckPriceLimit
|
||
|
ExecuteBuy
|
||
|
ExecuteSell
|
||
|
QueueRequest
|
||
|
WaitForPrice
|
||
|
UpdateAccounts
|
||
|
Monitor
|
||
|
AggregateStats
|
||
|
PublishStats
|
||
|
end
|
||
|
|
||
|
classDef process fill:#f9f,stroke:#333,stroke-width:2px;
|
||
|
classDef decision fill:#ff9,stroke:#333,stroke-width:2px;
|
||
|
classDef start fill:#9f9,stroke:#333,stroke-width:2px;
|
||
|
class Start start;
|
||
|
class Transaction,CheckLiquidity,CheckPriceLimit,Withdraw,CheckLockup decision;
|
||
|
class Register,SetPreferences,JoinPool,BuyProcess,SellProcess,ExecuteBuy,ExecuteSell,QueueRequest,WaitForPrice,UpdateAccounts,CalculateDiscount,Monitor,AggregateStats,PublishStats,ContinueHolding,ProcessWithdrawal process;
|
||
|
```
|