Skip to content

What is USR Token? #46

@zjuchenyuan

Description

@zjuchenyuan

Info: current mainnet eth block number: 11210219

I'm wondering where the interest come from, so I made some investigations for dUSDx:

The contract address for dUSDx is 0x109917f7c3b6174096f9e1744e41ac073b3e1f72 etherscan, and it has two handlers:

The code for calculating exchange ratio, namely how many USDx can 1 dUSDx exchange, is getCurrentExchangeRate, which is implemented by summing up the handlers' getRealBalance(_token) and then divided by totalSupply

dToken/contracts/DToken.sol

Lines 357 to 377 in 563d7d0

function getCurrentExchangeRateByHandler(
address[] memory _handlers,
address _token
) internal returns (uint256) {
uint256 _totalToken = 0;
// Get the total underlying token amount from handlers
for (uint256 i = 0; i < _handlers.length; i++)
_totalToken = _totalToken.add(
IHandler(_handlers[i]).getRealBalance(_token)
);
// Reset exchange rate to 1 when there is no dToken left
uint256 _exchangeRate = (totalSupply == 0)
? BASE
: rdiv(_totalToken, totalSupply);
require(_exchangeRate > 0, "Exchange rate should not be 0!");
return _exchangeRate;
}

By calling getBaseData for different blocks (using MetaMask API), I find that getCurrentExchangeRate update for each block:

def getbasedata(id, blockid):
    data = '{"id":%d,"jsonrpc":"2.0","method":"eth_call","params":[{"data":"0x148a95ea","to":"0x109917f7c3b6174096f9e1744e41ac073b3e1f72"},"%s"]}'%(id, blockid)
    response = sess.post('https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161', headers=headers, data=data)
    res = response.json()
    #print(res)
    data = base64.b16decode(res["result"][2:].upper())
    i = 1
    rate = int.from_bytes(data[i*32:i*32+32],"big")
    return rate

>>> getbasedata(1,hex(11210217))
1008824037259265003
>>> getbasedata(1,hex(11210218))
1008824072639567928
>>> getbasedata(1,hex(11210219))
1008824108020446490

The InternalHandler's getRealBalance can be easily called via etherscan dapp getRealBalance 0xeb269732ab75a6fd61ea60b06fe994cd32a83549
image

And this output seems stable 83373969497199741501815, not change for hours. So this is not the source of interest.

However, I cannot find way to call USRHandler's getRealBalance, and the implementation code is not available on Etherscan.

So, my question is:

  • What is USR Token?
  • Where can I find the implementation of USR Token, i.e. the code for contract 0xd4eef282f58ecaf12118e96ed4c06f60f88009c6
  • Where does the interest come from, and why this is updating for every block? I guess the calculation involves block number?

Thanks for your answering~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions