Initial commit
This commit is contained in:
53
docs/zagros/user-fee-level.md
Normal file
53
docs/zagros/user-fee-level.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Market: dynamic trade fee
|
||||
|
||||
###### Sprint: ?
|
||||
|
||||
### Outcome:
|
||||
in every trade exchange take some fee from users as revenue.these fees are some percentages from all trade value.
|
||||
these percentages must be dynamic toward last thirty days trades amount.
|
||||
exchange sets some levels and amount of them. if users reach every target, exchange change the fee level of them.
|
||||
|
||||
#### File destination:
|
||||
|
||||
{$Dena_Path}/app/models/trade.rb
|
||||
|
||||
{$Dena_Path}/app/models/member.rb
|
||||
|
||||
#### Commits:
|
||||
|
||||
|
||||
#### What did we implement:
|
||||
|
||||
* trades are executed in different markets and every market has different quote currency.
|
||||
for simplifying calculation of the last thirty days trades amount we create new call back(before save) to calculate last thirty days trades amount in irt and save them in new column.
|
||||
|
||||
```def rial_total!```
|
||||
|
||||
this function has to case:
|
||||
1. quote currency is irt: total saved
|
||||
2. quote currency is usdt: first get price_now of tether and calculate rial amount(total value of trade in irt)
|
||||
|
||||
|
||||
* before creating and submitting orders, fee level of user Determined and applied on calculations.
|
||||
this calculations runs on order creation validations.
|
||||
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A[API] -->|order attrs| B(order creation)
|
||||
B --> C{calculating last 30 days amount}
|
||||
C -->|touch new target| D[update its group]
|
||||
C -->|no changes| E[no change in group]
|
||||
D --> F[order created]
|
||||
E --> F
|
||||
F --> G[ ___MATCH ENGINE___]
|
||||
G --> |matched with another order|H[create trade]
|
||||
H --> I[calculate irt based amount]
|
||||
I --> J[save trade]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user