Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : Linked List Implementation #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

0xsuryansh
Copy link
Member

This PR implements a linked list mechanism which can be utilised for managing liquidity changes over time for different tokens.

  • Tracking Liquidity Changes: The contract keeps track of liquidity changes (LiqChangeNode) for each token over time. Each node in the linked list represents a change in liquidity (either an inflow or outflow) at a specific timestamp.

  • Maintaining Historical Data: By using a linked list, the contract can maintain a historical record of liquidity changes. This is essential for calculating the current and future liquidity states based on past inflows and outflows.

  • Dynamic Window Management: The linked list allows for dynamic management of the time window for liquidity changes. Nodes can be added or removed as time progresses, enabling the contract to only consider liquidity changes within a relevant time frame (defined by withdrawalPeriod).

  • Efficient Updates and Deletions: The linked list structure enables efficient addition of new liquidity changes at the tail and removal of old changes from the head as they become irrelevant after the withdrawal period. This is crucial for keeping the contract's operations gas-efficient.

  • Rate Limit Enforcement: The linked list supports the enforcement of withdrawal rate limits. By analyzing the liquidity changes within the specified window, the contract can determine if a withdrawal request breaches the set rate limit, thereby preventing excessive outflows that could destabilize the token's liquidity.

  • Grace Period Consideration: The linked list helps in managing a grace period following a rate limit breach. It allows the contract to temporarily bypass the rate limit enforcement, enabling withdrawals under certain conditions, such as after an admin override.

  • Gas Optimization: Traversing and updating the linked list allows for clearing historical data that is no longer relevant, optimizing gas usage for future transactions. This proactive backlog clearing helps in maintaining the contract's efficiency.

@0xsuryansh 0xsuryansh self-assigned this Feb 28, 2024
@0xsuryansh 0xsuryansh added the enhancement New feature or request label Feb 28, 2024
@0xsuryansh 0xsuryansh linked an issue Feb 28, 2024 that may be closed by this pull request
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Linked List Historical Oracle implementation
1 participant