Skip to content

tahmidbintaslim/Web3-App

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

legendary-robot

Task1 โ€“ Monitoring System Design

Scenario: Implement a robust system to monitor USDT transfer to the ZERO address (https://etherscan.io/address/0x0000000000000000000000000000000000000000) on Ethereum mainnet. In case the transfer happens, our team would like to be notified to take appropriate actions. Design the system, such that:

  • Once the token transfer event happens, our team gets notified within 2 minutes.
  • Resilient โ€“ No downtime
  • Cost-effective
  • Can easily be modified to add more token transfer monitorings (e.g. to other addresses, or monitor other token addresses)

Q1: Please provide technical details (can be as in-depth as pseudo-code and/or an

overview of the algorithm or approaches used), including the analysis of why the design is good, compared to other possible designs.

Q2: Please also state the analysis of potential loopholes / trade-offs that the design you

proposed may have (that may cause the monitoring to not function properly).

Task 2 โ€“ Reward Distribution

Q3: Write a Python3 code that calculates how much each user should receive the reward.

Please include any test cases to test the functionality, including normal and edge cases as well.

Implement the Python function according to the format below: def calculate_reward(events: list[tuple[str,int]]) -> dict[str, float]: raise NotImplemented()

TODO

Problem statement: We have 10,000 USDT to be distributed to our users who use our lending protocol during the timestamp 0 to 3600 (1 hour duration). The reward distribution algorithm is such that the 1000 tokens are distributed at the rate of ~2.778 USDT / sec, where at each point in time, the tokens will be distributed proportionally based on the total number of userโ€™s shares. Each userโ€™s action can either be:

  1. Increase shares by XX, or
  2. Decrease shares by YY (userโ€™s shares can never be negative)

Example: โ— User action events โ€“ format will be a list of tuples of (user, timestamp, share_adjust): โ—‹ [ (โ€œAโ€, 0, 2), (โ€œBโ€, 2, 1), (โ€œAโ€, 10, -1) ] The above example list of events means that

  • User A increases 2 shares at time t=0
  • User B increases 1 share at time t=2
  • User A decreases 1 share at time t=10

So,

  • Between time t=0 & t=1, only user A is getting the rewards โ†’ A gets 2.778 USDT
  • Between time t=1 & t=10, A has 2 shares, while B has 1 share โ†’ A gets 2โ„3 of whatโ€™s distributed, and B gets 1โ„3 of whatโ€™s distributed โ†’ A gets 16.667 USDT and B gets 8.333 USDT
  • Between time t=10 & t=3600, A and B has 1 share each โ†’ A gets 1โ„2 of whatโ€™s distributed, and B gets 1โ„2 of whatโ€™s distributed โ†’ A and B each gets 4986.111 USDT So, in total, A gets 5005.556 USDT and B gets 4994.444 USDT Expected Output: a dictionary of {โ€œAโ€ : 5005.556, โ€œBโ€ : 4994.444 }

About

Well, its kinda Test ๐Ÿ˜‚

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published