This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add proposal for interest bearing tokens #15927
Add proposal for interest bearing tokens #15927
Changes from 4 commits
8790778
065c2fa
03e80be
dff26ba
1b81a63
76c0b6a
4603d09
2b19499
7320a19
577ec40
e865264
4e7f3aa
c76d041
b005259
1ca6543
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the interest be compounded periodically by the runtime and stored as a number in the i-token? Or would it need to be computed every time by
AmountToUiAmount
and not stored?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The runtime would not be involved at all for this, so it would need to be computed every time and not stored anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to require that i-token holdings conform to any particular layout? As long as the program implements a
SerializeToSPL
method that is called anytime a caller wants to access the account as an SPL token, it seems like the underlying i-token holding could be whatever state is most efficient for the particular program.For instance, in the specific case of interest-bearing tokens laid out below, there wouldn't be any need to store both share amount and a cached token amount (that may always be wrong). It could be instead:
where
SerializeToSPL
converts share_amount to current token_amountThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to expose SerializeToSPL over RPC as well for
spl-token
cli and other front-ends to use if we do this, not bad though.I guess the counter is that we generally expect iTokens to fully implement SPL Token (and then add some), so why wouldn't they need all (or at least most of) these fields. Implementation wise I think we want to encourage a common SPL Token library crate that is built on rather than everybody forking from day 1, so we can easily publish updates for security fixes. Not having a common
struct
to rally around makes integration of new SPL Token releases much harder for the downstreamThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we're going to need to do this regardless in order to return correct token amounts at any given time.
I see your point about new token programs being additive.
I suppose it is only 8 bytes. Just seems a waste, if amount is essentially going to become
unused
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the docs to enforce that new token programs conform their structs to look like SPL token, along with the important difference between UI amount and amount.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that having "set return value" and "get return value" syscalls would be a better approach and a better UX for devs designing programs which return computed information. Tag @jackcmay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, yeah. I had same idea for awhile. :) cc: @joncinque
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this idea and it would be very useful outside of interest bearing tokens. For example, it would allow CPI in Anchor to look like a normal function call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanyoung, @jackcmay, dmakarov and I had a chat about this earlier today. @seanyoung is going to write up a brief design proposal PR soon. Basically we need the same for solang as well to return arbitrary data to the CPI caller
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably just a syscall,
create_ephemeral_account(program_id, size)
, that returns anAccountInfo
. No public key required, the lamport balance is 0 (and probably the instruction fails if the lamport balance is !0 when the current instruction exits).Flesh out more details with @jackcmay though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I had in mind, could add information about the granted ephemeral accounts to
InvokeContext
so we can track it between calls. Need to flesh out granting memory access to the program, etc...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The opposite logic would be to make it possible to lock tokens for certain amount of time to know for how long they would be held. This would allow to calculate voting power based on the long term commitment (skin in the game).
Users don't really like to deposit governance tokens to vote. It makes them very uncomfortable especially when the governance tokens they posses have substantial economic value.
A better solution would be to allow the tokens to be locked to gain voting power while still being in user's possession.