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

Ideation: Find ways to allocate and calculate returns for lenders #728

Open
InoMurko opened this issue Jan 11, 2021 · 7 comments
Open

Ideation: Find ways to allocate and calculate returns for lenders #728

InoMurko opened this issue Jan 11, 2021 · 7 comments
Assignees

Comments

@InoMurko
Copy link
Contributor

InoMurko commented Jan 11, 2021

Some points in the scope of this issue to research/explore-

  • fixed fee or a percentage of the UTXO value? (fixed can be simple and work for our use case)
  • estimate the value of the fee that would be apt, for maybe ETH and OMG outputs for now (margin from a UTXO as a fee)?
    in the future, we could have fee to be only OMG (as a fee input)
  • decide on the way to maintain/calculate returns for an individual lender
@InoMurko
Copy link
Contributor Author

InoMurko commented Jan 11, 2021

In progress, just leaving it here for time being
How I imagine this would work:

  • we should not allow you to exit our lending pool until all the exits you helped fund mature (that's because we don't have funds to pay you out - since they're in the standard exit) but you should be allowed to mark yourself as "not in the market" so that the next time a ticket is issued, your assets are not being calculated with it.
  • fee gets distributed and split to the lenders based on the percentage amounts of the total pool size (per asset!) on the block height of when the Quasar ticket was issued.
    Example:
    Asset: ETH
    Block: 114235
    Pool size participants: 5
    Pool size: 100 ETH (participant A=30Eth,B=20,C=20,D=10,E=10)
    Fee: 0.01
    When the Exit matures, the Quasar distributes fees: A gets 0.003, B 0.002, C=0.001, E=0.001.
    How do we distribute fees?

I was looking at the compound implementation where they use CTokens ERC20.

@souradeep-das
Copy link
Contributor

Some thoughts-

  1. "not in market" is a good idea imo. I think for withdrawals we can however allow people to withdraw as long as the pool can suffice, instead of explicitly blocking until an exit matures? If the pool is big enough( for example ETH pool) withdrawals should be possible every time? unless a lot of people decide to withdraw. And if lot of people withdraw, the fee per lender would increase resulting in incentivising more people to supply
  2. Yes, I think distributing fees will be gas intensive, if we update it on every round? The compound implementation of ctokens or something along that terms could be useful?

@InoMurko
Copy link
Contributor Author

on point 1.
I think it makes sense to simply follow the model of: if you lend your asset to the pool, you're lending it for at least block height + 2 weeks. This way exiting our pool is equal for all. Because if you let lenders exit "prematurely" you may ran out of assets (since exits didn't mature yet).

  1. so yeah, I don't see particular reason why we would need ERC20 ctokens issued to lenders, because what we really need is a ledger that will keep track on your accrued fees.
    do you see a particular added value for issuing qOMG (quasar OMG) erc20 tokens?

@souradeep-das
Copy link
Contributor

  1. yeah okay, this makes sense. In terms of being fair for everyone 👍, and a minimum lock-in period of 2 weeks isn't bad. pouring some other thoughts too-
  • a) how often should the quasar owner exit from plasma? could be something like this?
    either i) when it has accumulated 10 outputs or ii) it has been more than a 1 week since the last output and now has to merge and exit whatever it has and repay the pool

  • b) this would clearly depend on the number of exit. but do you think the minimum lock-in period should take the repayment rate over the block timestamp? ( since returns would accumulate every time repayments happen which might be slightly more than 2 weeks from a) )

  1. I feel if we try to maintain this accrued fees record for each lender on contract's storage it would be pretty expensive? an off-chain record keeping is possible though but would make things different
    issuing qOMG tokens and increasing the worth of these tokens could be one way to give out accrued fees? not sure

@souradeep-das
Copy link
Contributor

souradeep-das commented Jan 15, 2021

Here is an attempt to calculate returns the qtokens way. Please let me know if you find any mistakes or faulty assumptions.

Return rates are dependent on the qtokens and the exchange rate k, for that specific token, at that point of time.
Deposits to the pool, for instance OMG will mint qOMG = OMG / k for the supplier
On Withdraqwals, qOMG is burnt and OMG = qOMG * k is withdrawn.
Edit: qTokens need not be tokens, can just be a weight or a counter for an address?
Fees accumulate in the pool every time a fast exit happens, and k updates to
k’ = f / Tq + k

Screenshot 2021-01-15 at 6 27 05 PM

Screenshot 2021-01-15 at 6 27 45 PM

Screenshot 2021-01-15 at 6 28 01 PM

Screenshot 2021-01-15 at 6 28 12 PM

@souradeep-das
Copy link
Contributor

cc @kevsul

@souradeep-das
Copy link
Contributor

a minimal script run for the calculation https://gist.github.com/souradeep-das/de89e2b3336d515f59e344f8d85ea26a

@souradeep-das souradeep-das self-assigned this Jan 20, 2021
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

2 participants