CreditNotes
CreditNotes are tokens that represent borrowed collateral in the fx-protocol's Long-Short Pool lending system. It acts as a debt instrument that tracks how much collateral the Short Pool has borrowed from the Long Pool.
For each short pool, one type of CreditNote is generated. For example, we currently have two short pools in the system β the wstETH short pool and the WBTC short pool. Thus, there are two types of CreditNotes in the system, named:
fxETH (CreditNotes for wstETH Pool)
fxBTC (CreditNotes for WBTC Short Pool)
CreditNotes are primarily held by protocol contracts, though users may also receive CreditNotes from the protocol. In such cases, several methods are provided to allow users to redeem their CreditNotes for standard asset types.
1. Redemption Mechanism:
Users can redeem CreditNote tokens for underlying fxUSD collateral:
// Users call ShortPoolManager.redeemByCreditNote()
function redeemByCreditNote(address pool, uint256 debts, uint256 minColls) external {
// Transfer CreditNote from user
IERC20(creditNote).safeTransferFrom(_msgSender(), address(this), debts);
// Redeem equivalent collateral
colls = IShortPool(pool).redeemByCreditNote(rawDebts);
// Apply protocol fees
uint256 protocolFees = (colls * getRedeemFeeRatio()) / FEE_PRECISION;
colls -= protocolFees;
// Transfer net collateral to user
_transferOut(fxUSD, colls, _msgSender());
}
In the end, when the short pool reaches the end of its life cycle, all CreditNotes should be burned.
For more details on how to use it in a keeper bot, see the redeemByCreditNote section.
Last updated