Skip to content

Commit

Permalink
feat: two more scenarios for ac
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohill-Patel committed Dec 4, 2023
1 parent 1c4b7fc commit 38b374a
Showing 1 changed file with 61 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,22 +153,69 @@ Feature: Test fee discounts for one off transfers
# transfer depletes fees discount total
Given the parties submit the following one off transfers:
| id | from | from_account_type | to | to_account_type | asset | amount | delivery_time |
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH | 12580 | 2021-08-26T00:00:10Z |
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH | 12490 | 2021-08-26T00:00:10Z |
When time is updated to "2021-08-26T00:00:10Z"
Then the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 10 |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 55 |

Given the following transfers should happen:
| from | to | from account | to account | market id | amount | asset |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 0 | ETH |
When the network moves ahead "1" epochs
# fee discount decay = 55 * 0.9 = 49.5 < 50 so it becomes 0
Then the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 0 |

@transfer @fee-discount
Scenario: 0057-TRAN-027 when a party makes a transfer and f would be the theoretical fee the party should pay then the fee on the transfer that is actually charged is -min(f-c,0). The system subsequently updates c <- max(0,c-f). At the end of epoch, update c <- c x D and c <- c + all_trading_fees_for_trades_involved_in, if c < M x quantum(M is transfer.feeDiscountMinimumTrackedAmount), then set c <- 0
# Scenario make a trade that generates discount above transfer.feeDiscountMinimumTrackedAmount and next epoch check total discount is retained

# fee free discount total = 4000 + 2000 + 1000
Given the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 7000 |
# min fee discount = transfer.feeDiscountMinimumTrackedAmount x quamtum = 0.5 x 100 = 50
And the following network parameters are set:
| name | value |
| transfer.feeDiscountMinimumTrackedAmount | 0.5 |
And the following assets are updated:
| id | decimal places | quantum |
| ETH | 0 | 100 |

# transfer depletes fees discount total
Given the parties submit the following one off transfers:
| id | from | from_account_type | to | to_account_type | asset | amount | delivery_time |
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH | 13950 | 2021-08-26T00:00:10Z |
When time is updated to "2021-08-26T00:00:10Z"
Then the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 25 |
And the following transfers should happen:
| from | to | from account | to account | market id | amount | asset |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 0 | ETH |
# fee discount previous epoch was 10 < 50 so it becomes 0

Given the parties place the following orders:
| party | market id | side | volume | price | resulting trades | type | tif |
| a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ETH/DEC19 | buy | 5 | 1000 | 0 | TYPE_LIMIT | TIF_GTC |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH/DEC19 | sell | 5 | 1000 | 1 | TYPE_LIMIT | TIF_GTC |
When the network moves ahead "1" epochs
Then the following transfers should happen:
| from | to | from account | to account | market id | amount | asset |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC19 | 20 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 10 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC19 | 5 | ETH |
| market | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | ETH/DEC19 | 20 | ETH |
# fee discount previous epoch decayed to 25 * 0.9 = 22.5 + (trade fees - 20 + 10 + 5) = 57.5 > 50
# trade at previous epoch generated total fee discount of 16 + 8 + 4 = 28 < 50 so it becomes 0
And the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 0 |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 58 |

@transfer @fee-discount
Scenario: 0057-TRAN-027 when a party makes a transfer and f would be the theoretical fee the party should pay then the fee on the transfer that is actually charged is -min(f-c,0). The system subsequently updates c <- max(0,c-f). At the end of epoch, update c <- c x D and c <- c + all_trading_fees_for_trades_involved_in, if c < M x quantum(M is transfer.feeDiscountMinimumTrackedAmount), then set c <- 0
# Scenario make a trade that generates discount below transfer.feeDiscountMinimumTrackedAmount and next epoch check total discount = 0
# Scenario make a trade that generates discount below transfer.feeDiscountMinimumTrackedAmount and next epoch check total discount is 0

# fee free discount total = 4000 + 2000 + 1000
Given the parties have the following transfer fee discounts:
Expand All @@ -185,27 +232,27 @@ Feature: Test fee discounts for one off transfers
# transfer depletes fees discount total
Given the parties submit the following one off transfers:
| id | from | from_account_type | to | to_account_type | asset | amount | delivery_time |
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH | 14000 | 2021-08-26T00:00:10Z |
| 1 | f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ACCOUNT_TYPE_GENERAL | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_GENERAL | ETH | 13950 | 2021-08-26T00:00:10Z |
When time is updated to "2021-08-26T00:00:10Z"
Then the parties have the following transfer fee discounts:
| party | asset | available discount |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 0 |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH | 25 |
And the following transfers should happen:
| from | to | from account | to account | market id | amount | asset |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 0 | ETH |

Given the parties place the following orders:
| party | market id | side | volume | price | resulting trades | type | tif |
| a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ETH/DEC19 | buy | 4 | 1000 | 0 | TYPE_LIMIT | TIF_GTC |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH/DEC19 | sell | 4 | 1000 | 1 | TYPE_LIMIT | TIF_GTC |
| a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ETH/DEC19 | buy | 3 | 1000 | 0 | TYPE_LIMIT | TIF_GTC |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | ETH/DEC19 | sell | 3 | 1000 | 1 | TYPE_LIMIT | TIF_GTC |
When the network moves ahead "1" epochs
Then the following transfers should happen:
| from | to | from account | to account | market id | amount | asset |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC19 | 16 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 8 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC19 | 4 | ETH |
| market | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | ETH/DEC19 | 16 | ETH |
# fee discount previous epoch was 10 < 50 so it becomes 0
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_MAKER | ETH/DEC19 | 12 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_INFRASTRUCTURE | | 6 | ETH |
| f0b40ebdc5b92cf2cf82ff5d0c3f94085d23d5ec2d37d0b929e177c6d4d37e4c | market | ACCOUNT_TYPE_GENERAL | ACCOUNT_TYPE_FEES_LIQUIDITY | ETH/DEC19 | 3 | ETH |
| market | a7c4b181ef9bf5e9029a016f854e4ad471208020fd86187d07f0b420004f06a4 | ACCOUNT_TYPE_FEES_MAKER | ACCOUNT_TYPE_GENERAL | ETH/DEC19 | 12 | ETH |
# fee discount previous epoch decayed to 25 * 0.9 = 22.5 + (trade fees = 12 + 6 + 3=21) = 43.5 < 50
# trade at previous epoch generated total fee discount of 16 + 8 + 4 = 28 < 50 so it becomes 0
And the parties have the following transfer fee discounts:
| party | asset | available discount |
Expand Down

0 comments on commit 38b374a

Please sign in to comment.