0

A reminder on how reflection tokens like safemoon work is every ones balance is simply an equation instead of a fixed number. That way everyone's balance can be instantly updated with no gas needed when someone sells their coin. My question is is this possible on solona?

3 Answers 3

1

Sure! The SPL token program includes instructions called AmountToUiAmount and UiAmountToAmount: https://github.com/solana-labs/solana-program-library/blob/6ed80b3a353042df7a60353fa38d9460628b40de/token/program/src/instruction.rs#L442-L471

These instructions convert from some "base" amount of tokens in an account to a "UI" amount. So for example, if you have 10,500,000,000 base tokens, and the token has 9 decimal places, the UI amount would be 10.5.

You could fork the program and write these converters to do any math that you want!

Note that if you need more data from the outside than the mint and the account in question, it might be more difficult for outside people to use. Also, it's very difficult to get adoption of new token programs on Solana at the moment, but it's technically possible.

2
  • this is what chat cpt told me. "Reflection tokens on Ethereum work by automatically redistributing a portion of transaction fees to all token holders, which is facilitated by the stateful nature of Ethereum smart contracts. Solana’s architecture, being stateless, requires explicit read and write operations to account data for each transaction, which would involve computing power and transaction fees12.
    – OPP
    Commented Dec 6, 2023 at 3:42
  • Chat gpt kinda misses the point
    – Jon C
    Commented Dec 6, 2023 at 11:26
1

Balances aren't stored the same way in Solana as they are stored on the EVM. In Solana, token balance is stored in a token account, not on the state of a contract. The end goal of safemoon's reflection token, if I'm not mistaken, is to reward holders of the token with transaction fees, right? You MAY be able to implement something similar using a transfer hook. Let me know if you're successful!

1
  • here's what chatgpt told me "However, while a transfer hook could allow for additional actions to be taken during a token transfer, it does not change the fundamental way that Solana handles account balances and state. In Solana, each account’s balance is still a discrete value stored in the account data, and updating this balance requires explicit read and write operations1."
    – OPP
    Commented Dec 6, 2023 at 3:51
1

Token 2022 will allow you to hook transfer instructions and to implement your own logic. It even supports tax logic by default but I am not sure if it's really what you're looking for. https://spl.solana.com/token-2022#extensions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.