LP Free Market

A pair lending market, which accepts BNB as collateral and lends Dinero. This lending market supplies the collateral in Venus to provide earnings to the depositor.

Open Zeppelin Contracts

COLLATERAL

function COLLATERAL() external view returns(address);
Summary
It returns the address of the collateral token supported by this market.

liquidationFee

function liquidationFee() external view returns(uint96);
Summary
It is the penalty a user must pay when liquidated. It is a percentage, 1e18 being 100%.

POOL_ID

function POOL_ID() external view returns(uint96);
Summary
It returns the Id of the collateral's Casa De Papel pool.

maxLTVRatio

function maxLTVRatio() external view returns(uint128);
Summary
It returns the maximum loan-to-value ratio a user can have before being liquidated. It is a percentage, 1e18 being 100%.

totalCollateral

function totalCollateral() external view returns(uint128);
Summary
It returns the amount of collateral this contract has.

maxBorrowAmount

function maxBorrowAmount() external view returns(uint128);
Summary
It returns the maximum amount of Dinero this contract can lend out.

totalRewardsPerToken

function totalRewardsPerToken() external view returns(uint128);
Summary
The total amount of rewards per token this contract has collected.

accountOf

function accountOf(address user) external view returns(
uint128 collateral,
uint128 rewards,
uint256 rewardDebt,
uint256 principal
);
Summary
It returns a user's account.
  • collateral: Amount of collateral the user has deposited.
  • rewards: The amount of rewards the user has accrued.
  • rewardDebt: The amount of rewards paid to the user.
  • principal: The amount of Dinero shares the user has borrowed.

collateralEarnings

function collateralEarnings() external view returns(uint256);
Summary
It returns the contract's profit from liquidations. It is in collateral.

treasury

function treasury() external view returns(address);
Summary
It returns the treasury's address.

getPendingRewards

function getPendingRewards(address account) external view returns(uint256);
Parameters
  1. 1.
    The pending rewards of this address will be returned.
Summary
It returns the pending rewards of a user.

getCollateralEarnings

function getCollateralEarnings() external;
Event
event GetCollateralEarnings(address indexed treasury, uint256 amount);
Summary
It mints the treasury's profit from lending Dinero.

compound

function compound() external;
Event
event Compound(uint256 rewards, uint256 fee);
Summary
It compounds the rewards by harvesting them from Casa De Papel farm and IPX pool and re-invests them in the pool.
This contract uses the UUPS upgradeable pattern. Therefore, the interfaces and functionalities can change in the future.

deposit

function deposit(address to, uint256 amount) external;
Parameters
  1. 1.
    Address that will receive the collateral sent by the msg.sender.
  2. 2.
    The number of tokens to deposit.
Restrictions
  • approval: The msg.sender has to give approval to the contract.
  • require: To argument address cannot be the zero address.
  • require: The amount cannot be zero.
Event
event Deposit(address indexed from, address indexed to, uint256 amount);
Summary
It allows a user to deposit an ERC20 as collateral. It will deposit the tokens in a farm to accrue rewards.

withdraw

function withdraw(address to, uint256 amount) external;
Parameters
  1. 1.
    The msg.sender will withdraw his/her tokens to this address.
  2. 2.
    The number of tokens to withdraw.
Restrictions
  • require: The amount cannot withdraw zero tokens.
  • isSolvent modifier: The msg.sender LTV must remain below the contract's maxLTVRatio
Event
event Withdraw(
address indexed from,
address indexed recipient,
uint256 amount
);
Summary
It allows a user to withdraw collateral from the contract.

borrow

function borrow(address to, uint256 amount) external;
Parameters
  1. 1.
    The address that will receive the borrowed Dinero.
  2. 2.
    The amount of Dinero to borrow.
Restrictions:
  • isSolvent modifier: The msg.sender LTV must remain below the contract's maxLTVRatio.
  • maxBorrowAmount: The total amount lent out must be below this value.
Event
event Borrow(
address indexed borrower,
address indexed receiver,
uint256 principal,
uint256 amount
);
Summary
It allows the msg.sender to borrow Dinero.

repay

function repay(address account, uint256 amount) external;
Parameters
  1. 1.
    The msg.sender will pay the debt of this account.
  2. 2.
    The amount to repay.
Event
event Repay(address indexed payer, address indexed payee, uint256 amount);
The second argument in the function is actual amount of Dinero to repay. This market has no interest rate cost!
Summary
It allows the msg.sender to repay the debt of an account.

request

function request(uint256[] calldata requests, bytes[] calldata requestArgs)
external;
Parameters
  1. 1.
    A list of requests to process.
    • The number 0 represents a deposit request.
    • The number 1 represents a withdrawal request.
    • The number 2 represents a borrow request.
    • The number 3 represents a repayment request.
  2. 2.
    A list of the arguments to call the requested function with. It is packed as an array of bytes.
The requests and requestArgs must have the same length.
Restrictions:
  • isSolvent modifier: The msg.sender LTV must remain below the contract's maxLTVRatio.
  • maxBorrowAmount: The total amount lent out must be below this value.
Event
event Deposit(address indexed from, address indexed to, uint256 amount);
event Withdraw(address indexed from, address indexed to, uint256 amount);
event Borrow(
address indexed borrower,
address indexed receiver,
uint256 amount
);
event Repay(address indexed payer, address indexed payee, uint256 amount);
Summary
It bundles several transactions. Instead of calling the deposit and withdraw functions separately, a user calls the request function with the appropriate data. It supports withdrawing, depositing, borrowing, and repaying. It has the same restrictions as the individual functions.

liquidate

function liquidate(
address[] calldata accounts,
uint256[] calldata principals,
address recipient,
bytes calldata data
) external;
Parameters
  1. 1.
    An array of accounts to be liquidated.
  2. 2.
    An array containing the number of shares to liquidate.
  3. 3.
    The address that will receive the reward for closing underwater positions.
  4. 4.
    Arbitrary data to call the recipient with. If this argument is not empty, the contract will redeem the underlying tokens and call the function below from the recipient address. Otherwise, it will send the LP tokens to the recipient.
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.9;
interface ISwap {
function sellTwoTokens(
bytes calldata data,
address tokenA,
address tokenB,
uint256 amountA,
uint256 amountB,
uint256 debt
) external;
}
Restrictions:
  • require: The Accounts must have underwater positions.
Event
event Liquidate(
address indexed liquidator,
address indexed debtor,
uint256 principal,
uint256 collateralToCover,
uint256 fee
);
It allows third parties to maintain the system afloat by closing underwater positions. They receive a reward fee. By the end of the transaction, the msg.sender has enough Dinero to cover the amount liquidated. The caller will receive the collateral beforehand.