6

In Ethereum some ERC20 tokens use a calculation to compute the balance, is not just a value stored in a map.

Take for example AAVE. When you deposit 100 USDT in AAVE, you get 100 aUSDT, this aUSDT is an AToken that represents your share in the pool and is 1:1 convertible back to USDT. Initially your balance is 100, but (simplifying a lot) if interest rate is 5%, and you ask aUSDT.balanceOf(me) after a year, you get 105.

Just for reference, this is the AAVE's AToken code: https://github.com/aave/protocol-v2/blob/master/contracts/protocol/tokenization/AToken.sol#L208

This would be possible with native tokens in Cardano? My understanding is no custom code is executed to get the balance (custom code is run in any other operation besides mint/burn?).

If not possible, what will be the best way to model something like this in Cardano.

1 Answer 1

1

No. Not exactly.

Since all the tokens on Cardano are native, they all have the same behavior; they just sit there. It's only through transactions that you can change the state of the chain.

I think you can get the desired behavior though!

Let's say when you submit your USDT for aUSDT you get a "receipt" UTxO. The receipt includes two pieces of data: deposit amount and deposit slot. Whenever you want to receive your interest, you could submit a transaction to the issuance script with your aUSDT and the receipt UTxO and the contract will calculate the interest based on time since deposit slot. Then the script can either re-issue you aUSDT with the interest and a new receipt or pay out your USDT with interest.

There might be better ways too, but that's an example how it could probably work.

Your Answer

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

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