1

I need some help/insight to fix/make the tests work.

I'm trying to test locally a complete case of Token2022 with interest, but I have 2 problems locally (in devnet everything works as expected).

  1. The user token balance never change (waiting or not, sending other txs, putting the rate to 32k) it never changes no matter what I try...
  2. If I call updateRateInterestBearingMint helper or build the tx with createUpdateRateInterestBearingMintInstruction I can't change the rate to a positive number (weirdly works with 0, but nothing else) the tx never confirms (and nothing is shown in anchor logs)

I put a repo to show what I'm trying, the repo has transfer hook tests too, but if I comment/drop the hook the interest doesn't work anyway. To try just run yarn install; anchor test https://github.com/Shelvak/solana-token2022/blob/master/tests/transferhook.ts#L318

Maybe I'm missing some tx/action between or Anchor config... I had to change Anchor.tml to for speed (other way the tests took too much and timeout)

[test.validator]
ticks_per_slot = 2
slots_per_epoch = "64"

Thanks in advance :muscle:

1
  • 1
    As per the docs on Interest Bearing Tokens, this extension is cosmetic and doesn't change the balance of tokens. Try using the AmountToUiAmount instruction to see the changing balance.
    – Joe C
    Commented Jan 30 at 15:38

1 Answer 1

1

The interest bearing token extension does not actually change the token amounts. Instead it does change the token uiAmount. This is not supported my many wallets and explorers yet. But you can try it out like so in this guide: https://solana.com/developers/guides/token-extensions/interest-bearing-tokens

What you need to do to get the current uiAmounts is:

setInterval(async () => {
    tokenAccounts.value.forEach(async (tokenAccount) => {
        const accountData = AccountLayout.decode(tokenAccount.account.data);
        let uiAmount = await amountToUiAmount(connection, keyPair, accountData.mint, accountData.amount, TOKEN_2022_PROGRAM_ID); 
        console.log(`${new PublicKey(accountData.mint)}   ${accountData.amount}, ${JSON.stringify(uiAmount)}`);
      })
}, 1000); 

Here is a video explaining the extension: https://www.youtube.com/watch?v=YFTUGviKg7A

You can however try to use the ui amount to mint new tokens yourself by putting the mint authority into a program and calling it repeatedly.

1
  • If I put exactly the same code in intervals and some "sleeps" i keep getting the same amount. The demo is tested in devnet, as I put, everything works in devnet, the problem is the local-test
    – Shelvak
    Commented Jan 30 at 20:50

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.