Comments (1)
In my investigations, 2 aspects which are relevant for the project triggering it, but which are otherwise independent of each other, were considered:
ERC-4626
ERC-4626 is an extension to ERC-20 which defines a standard interface for the interactions between the representing shares (the tokens managed by this contract itsefl) and the underlying asset which is also expected to be an ERC-20 token.
This is essentially the same we have in Super Tokens, just with different terminology.
ERC-4626 -> Super Token
asset() -> getUnderlyingToken()
totalAssets() -> totalSupply() (since Super Token has a 1:1 peg)
convertToShares() -> not yet implemented, may become fromUnderlyingAmount(), see #1317
convertToAssets() -> toUnderlyingAmount()
mint() -> upgrade()
deposit() -> not yet implemented - basically the same as mint(), but with the amount argument denominated in assets / underlying
redeem() -> downgrade()
withdraw() -> not yet implemented - basically the same as redeem(), but with the amount argument denominated in assets / underlying
The interface has a few more functions, e.g. previewX() view functions for simulating actions and maxMint() for allowing to cap how much can be deposited, also events.
The most significant difference between Super Token Wrappers as is and an ERC-4626 enabled Super Token would be that there's no 1:1 peg between underlying and Super Token anymore.
I believe a Super Token Wrapper without 1:1 peg wouldn't violate any assumptions.
The conversion between Super Token amounts and underlying amounts currently only takes into account the possibility of having to shift decimals. A ERC-4626 implementation would bring its own logic for doing this conversion - usually just a proportional mapping.
Possible next step
Implement a Custom Super Token which implements a simple ERC-4626.
Requires custom Super Token logic (not just custom proxy).
If there's demand for it, we could consider providing builtin support for ERC-4626, e.g. add methods to the SuperTokenFactory for creating instances.
Streaming Mint
One of the projects looking into ERC-4626 Super Tokens is said to want to do streaming mint.
My understanding is that the shares
argument of function mint(uint256 shares, address receiver)
- which is usually the amount of shares minted to the receiver - shall be interpreted as a flowrate in that scenario.
Option 1: use CFA
We do have a (currently unmaintained) experimental Custom Super Token implementation doing streaming mint: StreamFromMint.sol. Here, type(int256).max
tokens are minted to the token contract itself, so it can create an effectively never ending (in practice it may become insolvent in a gazillion years or so) CFA "minting stream".
This implementation works using the stock SuperToken logic. Caveat: the sum of all balances is not equal to totalSupply(). Which may in theory not matter, but isn't pretty.
Pro: quite easy, can be done using canonical SuperToken logic
Contra: a bit dirty / hacky
Option 2: customize balanceOf()
An alternative implementation could override balanceOf()
and do something like this:
function balanceOf(address account) external returns(uint256 balance) {
if (account == _mintingReceiver) {
return toU256(_mintingRate) * (block.timestamp - _mintingStartTime);
} else {
_fallback();
}
}
This currently requires customization of the SuperToken logic as the proxy's balanceOf() won't be used by internal calls.
Pro: would satisfy the invariant sum(balanceOf()) = totalSupply()
Contra: currently not doable without customized SuperToken logic, thus increased maintenance cost for the resulting token
Option 3 (?): use SemanticMoney library
This is speculation, I didn't spend time verifying my gut feeling.
Interpreting ERC-4626 shares as a flowrate means the resulting gauge is an integration of this shares over time. That's the same we're doing with GDA Pool units in flow distributions.
Thus it may be possible (and a good idea?) to leverage the semantic-money library for implementing this use case.
Pro: seems elegant
Contra: not sure if viable, engineering effort
from protocol-monorepo.
Related Issues (20)
- [OPS] Deploy contracts v1.9.1 HOT 15
- [ETHEREUM-CONTRACTS] Get rid of compiler warnings HOT 2
- [Deployer Whitelisting Request] HOT 4
- [PROTOCOL-OPS] scroll-sepolia cannot be upgraded HOT 1
- [SUBGRAPH][FEATURE] Inconsistency: AccountTokenSnapshot has `updatedAt(Timestamp/BlockNumber)` but not the equivalent for "created at"
- [SUBGRAPH] superTokenLogicCreatedEvents missing recent events HOT 3
- [BUG] Ask about the scope of bug bounty HOT 1
- [OPS] DegenChain verification of framework and yoink related contracts HOT 3
- [AUTOMATION] Vesting scheduler execution failed because of repeated create HOT 2
- Subgraph endpoint update required HOT 1
- [ETHEREUM-CONTRACTS] Superfluid: make app gas limit configurable
- [ETHEREUM-CONTRACTS] Superfluid host: allow batchcall operations to fail
- [SUBGRAPH] Native Super Token name empty
- [ETHEREUM-CONTRACTS] Disable FlowNFT hooks
- [ETHEREUM-CONTRACTS] [METADATA] [SDK-CORE] remove flowNFT code
- [PROTO-OPS] Upgrade eth-mainnet from 1.8 to 1.11 HOT 3
- SQF Superapp Factory on Arbitrum HOT 2
- [Deployer Whitelisting Request] SQF on Optimism HOT 2
- [Deployer Whitelisting Request] SQF on Base HOT 2
- [ETHEREUM-CONTRACTS] Upgrade to OpenZeppelin 5 and Rework Its Dependency Management (Breaking Chnage)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protocol-monorepo.