OTC Trading (ERC1155)
Native ERC1155 fCash transfers are a powerful tool that can be used to trade fCash OTC (over the counter) without impacting fCash markets.
ERC1155 IDs
/**
* 256 bits encoded as:
* | 0 (192 bits) | 16 bits (currency id) | 40 bits (maturity) | 8 bits (asset type) |
*
* assetType is as follows:
* 1 = fCash
* 2 to 8 = Liquidity Token for Market Index 1-7
*/
function encodeAssetId(
uint256 currencyId,
uint256 maturity,
uint256 assetType
) internal pure returns (uint256) {
require(currencyId <= Constants.MAX_CURRENCIES);
require(maturity <= type(uint40).max);
require(assetType <= Constants.MAX_LIQUIDITY_TOKEN_INDEX);
return
uint256(
(bytes32(uint256(uint16(currencyId))) << 48) |
(bytes32(uint256(uint40(maturity))) << 8) |
bytes32(uint256(uint8(assetType)))
);
}
function decodeAssetId(uint256 id) internal pure returns (
uint256 currencyId,
uint256 maturity,
uint256 assetType
) {
assetType = uint8(id);
maturity = uint40(id >> 8);
currencyId = uint16(id >> 48);
}balanceOf vs signedBalanceOf
Transfers
Example: Lending and Borrowing OTC at Idiosyncratic Maturity
Example: Bi-Directional fCash Swap
Last updated