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

Storage slot for pool owned tokens #28

Open
gabririgo opened this issue Sep 3, 2023 · 0 comments
Open

Storage slot for pool owned tokens #28

gabririgo opened this issue Sep 3, 2023 · 0 comments

Comments

@gabririgo
Copy link
Contributor

gabririgo commented Sep 3, 2023

Summary

Add a storage slot for pool-owned tokens.

Motivation

Currently owned tokens are retrieved by querying positive balances on the protocol-whitelisted tokens. There is reason to remove the whitelist requirement in the future, in line with the ultimate vision of facilitating earning without using other people’s capital. This would allow a pool to own any token. In that case, it would be helpful to keep track of owned tokens in the pool state.

Specification

  • allocate deterministic storage slot to indexed mapping of owned token addresses
  • allocate deterministic storage slot to number of owned tokens
  • add a token to the mapping when it is first added to the pool
  • remove the token from the mapping when it is removed from the pool (should check whether to leave an empty slot in the mapping or to reorganize the mapping (which could be cost intensive). We can always retrieve the array of tokens by try/catch so that we return the actual length and can have a mapping with empty values).
  • upgrade pool implementation (requires governance onchain voting).

Rationale

Removing the token whitelist would allow a pool to potentially own any token, but it is desirable to have a method that returns all owned tokens.

Notes

NFTs and contract positions (like staking to other applications) could be added to the mapping, but they won't have an address.
Allowing trading any token would allow a pool operator to create a rogue token and empty the pool. This is already possible by routing to a whitelisted token by a route involving a rogue token in the middle, however, doing this would be explicit pool operator rogue behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant