Supply
The supply flow allows the protocol to initiate a position on a third party money market on behalf of a user.
Frontend Requests Whitelisted Lenders/Tokens
This request is used to display available lenders, and their associated tokens to the user in the UI.
****API ENDPOINT TO BE CALLED HERE****
User Requests Supply via Frontend
This request is originated on the frontend. The backend should take in the parameters, compare them to the known data for the selected lender and return loan information as pertinent.
****API ENDPOINT TO BE CALLED****
String
Lender
The name of the lender the user has chosen
Number
supplyAmount
The amount of collateral the user wishes to supply
TBD
TBD
TBD
RETURN VALUES
number
APR
The APR offered by the lender
Number
LTV
The lenders LTV limits
User Confirms Desire To Supply Collateral
The user will review the returned information from the above call and indicate that they would like to proceed.
User Sends Funds To Backend Wallet
A transaction is initiated on the frontend prompting the user to send the collateral to the previously provided backend wallet address. Once this transaction is complete and confirmed, the following
****API ENDPOINT TO BE CALLED****
Params
String
tokenAddress
The address of the collateral token
Number
amount
The amount of collateral being sent
String
lender
The name of the lender being supplied
String
userAddress
The address of the user making request
Number
etherValue
The value of ether being sent (0 for none)
Backend Calls onBoard (for new users)
Step 1 Create onBoard Data
THE BELOW PYTHON RELATED ENCODING FUNCTIONS MUST BE CONFIRMED
onboardData = contract.encodeABI(fn_name="onBoard", args=[value, txGas, lender, userAddress)
Step 2: Execute Function Call
protocol.execute("LenderModule", etherValue, onboardData, Enum.Operation.Call)
Backend calls supplyToLender
Step 1: Create Action Data
supplyBytesData = encode(
[string, uint256, string, string],
[tokenAddress, amount, marketAddress, userAddress]
)
Step 2: Create Supply Data
supplyData = contract.encodeABI(
fn_name="supplyToLender",
args=[supplyBytesData, value, userAddress, lender]
)
Step 3: Execute Function Call
protocol.execute("LenderModule", 0 ether, supplyData, Enum.Operation.Call);
Backend calls mintLoanToken
Step 1: Create Action Data (Initial Loan Data)
loanData = abi.encode(userAddress, lender);
Step 2: Create Action Financial Terms Data
fTData = abi.encode(userAddress, 0, 0, amount, tokenAddress)
Step 3: Create Module Data
moduleData = contract.encodeABI(
fn_name="mintLoanToken",
args=[userAddress, uniqueId, loanData, loanFinancialTermsData]
)
Step 4: Execute Function call
protocol.execute("LenderModule", 0 ether, moduleData, Enum.Operation.Call)
This concludes the backend responsibilities for the supply flow
Last updated