Comments (2)
The way streams / flows work looks confusing, I'm assuming it's not defined yet.
If I were you, I'd store all info in a single struct:
struct UbiStream {
address to;
uint32 streamAmount;
}
struct UbiAccount {
uint152 balance;
uint32 accruedSince; // timestamp of last redeem
uint32 accrualPerSecond; // if you're not a human, you can still be streamed ubi.
bool isHuman; // allows to NOT require a poh check on transfer, which saves 2600 gas.
// when the third party disables the isHuman and streams, it gets all the UBI the human didn't redeem.
// even the UBI that is streamed to the disabled human (for technical reasons).
uint32 streamedToOthers; // sum of ubi that this human is streaming to others.
Stream[] streamsTo; // purposely not a mapping. allows a third party to disable the streams
// on everyone that has been awarded an ubi stream from this party.
// (should be slightly cheap since this array will be set to zero as it iterates, refunding gas)
}
note that im considering that every human is able to do multiple streams but I think that's a bad idea. I would just have each human either not streaming, or streaming everything to another human. That makes a few steps easier, and removes computation (that also results in less gas costs for everyone)
so, this is what id do. It's will be cheaper and way easier to interact with in the edge cases (revoking streams, awarding streams, updating human status of an account...)
struct UbiAccount {
uint176 balance;
uint32 accruedSince; // timestamp of last redeem.
uint32 nStreams; // counts how many ubi streams are pointing at you.
bool isHuman; // allows to NOT require a poh check on transfer, which saves 2600 gas.
// when a third party disables the isHuman, it gets all the accrued UBI of one stream.
// but the UBI that was streamed from other to this human will stay in the human.
bool streamingToOther; // makes transfer cheaper, otherwise you'd have to SLOAD the "streamsTo"
// address of this struct, that lives in another slot.
// --- 2nd slot ---
address streamsTo; // if streamingToOther, a whole human stream is awarded to this address.
uint96 freespace;
}
from ubi.
For the first comment about the improvement:
Any change like that would require a UIP so I would recommend you to fork UBI, create the implementation and then write a UIP with the change proposal.
For the second about delegations:
The way streams / flows work looks confusing, I'm assuming it's not defined yet.
Yes, The way flows and streams work IS defined already, however, streams will not be released on UIP-1, only flows which is MUCH simpler and cheaper in gas.
The UBI Delegation pattern is based on a "Plugin" system where the delegation contract should implement the IUBIDelegator
interface. I encourage you to push a version of your own IUBIDelegator implementation with all your proposed implementations.
from ubi.
Related Issues (12)
- Investor update HOT 2
- UBI Token Review HOT 6
- What are the addresses on Mainnet and testnet? HOT 3
- Stream tokens directly to humans HOT 9
- Quadratic Voting for governance HOT 9
- Broken link in the smart contract HOT 3
- Implement `_msg.sender()` for meta-transaction for the UBI token HOT 1
- Review HOT 1
- Add permit feature to UBI HOT 7
- UBIv v2 fails to get delegator balance after delegated withdraws HOT 1
- UBI Stream cancellation test failing
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 ubi.