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

Add rari-fuse strategy [rari-fuse] #714

Merged
merged 39 commits into from
Jul 19, 2022

Conversation

MantisClone
Copy link
Contributor

@MantisClone MantisClone commented Jul 16, 2022

Changes proposed in this pull request:

  • Add a rari-fuse strategy that returns the voter's underlying collateral balances in a given Rari Fuse market (fToken).

@MantisClone
Copy link
Contributor Author

MantisClone commented Jul 16, 2022

Unfortunately, both of the FusePoolLens functions that would return a user's underlying collateral balance revert, and seem to be broken: getPoolUsersWithData and getPoolAssetsWithData

So I'm attempting to reverse engineer them inside the Snapshot Strategy using lower-level calls to the pool (Comptroller) and the cToken.

Reference: https://github.com/Rari-Capital/fuse-v1/blob/b5c269208f48ab413d816ccd5f67bf79caea73fd/src/FusePoolLens.sol#L252-L349

@MantisClone
Copy link
Contributor Author

MantisClone commented Jul 16, 2022

Reading through the FusePoolLens.sol code, I think I can get a user's supplied balance directly from the cToken using:

https://github.com/Rari-Capital/fuse-v1/blob/b5c269208f48ab413d816ccd5f67bf79caea73fd/src/FusePoolLens.sol#L319

            asset.supplyBalance = cToken.balanceOfUnderlying(user);

@MantisClone
Copy link
Contributor Author

After further study of the cToken implementation on etherscan: https://etherscan.io/address/0x67db14e73c2dce786b5bbbfa4d010deab4bbfcf9#code, I realized that cToken.balanceOfUnderlying(user) doesn't exist on-chain. Instead, cToken.balanceOf(user) can be used.

This means that I could plug the cTokenAddress into the standard erc20-balance-of strategy and it would work the same way! 🤦

Nonetheless, I decided to finish off the PR by changing the variable name from address to cTokenAddress and to update the README to make it rari-fuse specific.

@MantisClone MantisClone marked this pull request as ready for review July 17, 2022 12:57
@MantisClone
Copy link
Contributor Author

After spending 8 hours working on this, I realized that getting a user's balance in a given Rari Fuse market is as simple as calling cToken.balanceOf(user), and that the same results could be achieved using existing strategies:

  1. erc20-balance-of strategy by plugging the cToken address into the address parameter.
  2. cToken strategy which adds an optional waiting period between minting and voting, and the option to exclude borrowers by granting them 0 voting weight.

I couldn't find precedents for duplicate strategies.

I briefly considered creating a PR that contains only the rari-fuse README.md which then points the users to the erc20-balance-of and ctoken strategies. But I don't know if this would be compatible with the snapshot app.

I also wondered if rari-fuse could be an alias of erc20-balance-of but then I saw #107 which dismisses the idea of aliases.

Considering all this - I decided to simply close this PR and move on.

@MantisClone MantisClone deleted the rari-fuse branch July 17, 2022 13:06
@MantisClone MantisClone restored the rari-fuse branch July 18, 2022 19:34
@MantisClone MantisClone reopened this Jul 18, 2022
@MantisClone MantisClone marked this pull request as draft July 18, 2022 19:34
@MantisClone
Copy link
Contributor Author

MantisClone commented Jul 18, 2022

I realized my last comment was wrong. In Rari Fuse, there's an exchange rate between the fToken (what I've previously been calling cToken) and the underlying token. So I'm thinking this strategy may still be needed.

https://docs.rari.capital/fuse/#interpreting-exchange-rates

@MantisClone MantisClone marked this pull request as ready for review July 19, 2022 00:29
@MantisClone MantisClone changed the title [WIP] Add rari-fuse strategy [rari-fuse] Add rari-fuse strategy [rari-fuse] Jul 19, 2022
@ChaituVR ChaituVR merged commit 813e0ac into snapshot-labs:master Jul 19, 2022
buchaoqun added a commit to buchaoqun/snapshot-strategies that referenced this pull request Jul 19, 2022
* 'master' of github.com:buchaoqun/snapshot-strategies:
  Update src/strategies/erc3525-vesting-voucher/index.ts
  Update src/strategies/erc3525-vesting-voucher/index.ts
  Add rari-fuse strategy [rari-fuse] (snapshot-labs#714)
  Use brovider in test files (snapshot-labs#717)

# Conflicts:
#	src/strategies/erc3525-vesting-voucher/index.ts
@MantisClone MantisClone deleted the rari-fuse branch July 19, 2022 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants