Morphoblue
In this section, we will introduce the Morphoblue SDK interfaces, which provide developers with a convenient and efficient way to interact with the Morphoblue protocol. These interfaces cover various aspects of the protocol, including supply, supply-collateral, withdraw, withdraw-collateral, borrow, repay, and flash-loan. They are designed to be used easily and flexibly.
Before we dive into the SDK interfaces, we would like to provide an overview of the features of Morphoblue. If you are already familiar with Morphoblue, feel free to skip this section. For those who are new to Morphoblue, here's a brief explanation:
Morphoblue is a singleton contract that manages user balances without minting any tokens.
Each market in Morphoblue is independent, meaning that any action performed on the protocol must specify which market it's interacting with.
Once you have identified the market you want to interact with, you can choose to either be a Lender or a Borrower. Let's take the WETH(USDC, 90%, Chainlink, AdaptiveCurveIRM) market as an example:
If you want to be a Lender, you need to supply WETH as the loan token.
If you want to be a Borrower, you must deposit USDC as the collateral token and borrow WETH as the loan token.
Please note that Morphoblue is subject to change and improvements, and we will update our SDK accordingly.
The following section will introduce the interfaces related to the Morphoblue protocol, which can be accessed through the api.protocols.morphoblue.
prefix.
Supply
The following code defines interfaces and functions related to the Morphoblue supply logic:
Types
SupplyFields: A type that represents the fields required for the Morphoblue supply logic.
SupplyLogic: An interface that extends the Logic
interface and represents the Morphoblue supply logic. It includes the rid
, and fields
properties.
Functions
getSupplyTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue supply logic on the specified
chainId
.newSupplyLogic(fields: SupplyFields): A function that creates the Morphoblue supply logic data with the given
fields
object.
Example Code
SupplyCollateral
The following code defines interfaces and functions related to the Morphoblue supply collateral logic:
Types
SupplyCollateralFields: A type that represents the fields required for the Morphoblue supply collateral logic.
SupplyCollateralLogic: An interface that extends the
Logic
interface and represents the Morphoblue supply collateral logic. It includes therid
, andfields
properties.
Functions
getSupplyCollateralTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue supply collateral logic on the specified
chainId
.newSupplyCollateralLogic(fields: SupplyCollateralFields): A function that creates the Morphoblue supply collateral logic data with the given
fields
object.
Example Code
Withdraw
The following code defines interfaces and functions related to the Morphoblue withdraw logic:
Types
WithdrawFields: A type that represents the fields required for the Morphoblue withdraw logic.
WithdrawLogic: An interface that extends the
Logic
interface and represents the Morphoblue withdraw logic. It includes therid
, andfields
properties.
Functions
getWithdrawTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue withdraw logic on the specified
chainId
.newWithdrawLogic(fields: WithdrawFields): A function that creates the Morphoblue withdraw logic data with the given
fields
object.
Example Code
WithdrawCollateral
The following code defines interfaces and functions related to the Morphoblue withdraw collateral logic:
Types
WithdrawCollateralFields: A type that represents the fields required for the Morphoblue withdraw collateral logic.
WithdrawCollateralLogic: An interface that extends the
Logic
interface and represents the Morphoblue withdraw collateral logic. It includes therid
, andfields
properties.
Functions
getWithdrawCollateralTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue withdraw collateral logic on the specified
chainId
.newWithdrawCollateralLogic(fields: WithdrawCollateralFields): A function that creates the Morphoblue withdraw collateral logic data with the given
fields
object.
Example Code
Borrow
The following code defines interfaces and functions related to the Morphoblue borrow logic:
Types
BorrowFields: A type that represents the fields required for the Morphoblue borrow logic.
BorrowLogic: An interface that extends the
Logic
interface and represents the Morphoblue borrow logic. It includes therid
, andfields
properties.
Functions
getBorrowTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue borrow logic on the specified
chainId
.newBorrowLogic(fields: BorrowFields): A function that creates the Morphoblue borrow logic data with the given
fields
object.
Example Code
Repay
The following code defines interfaces and functions related to the Morphoblue repay logic:
Types
RepayParams: A type that represents the input parameters for the Morphoblue repay logic
RepayFields: A type that represents the fields required for the Morphoblue repay logic.
RepayLogic: An interface that extends the
Logic
interface and represents the Morphoblue repay logic. It includes therid
, andfields
properties.
Functions
getRepayTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue repay logic on the specified
chainId
.getRepayQuotation(chainId: number, params: RepayParams): An asynchronous function that retrieves a quotation for repaying a loan on the Morphoblue protocol with the specified
params
object on the specifiedchainId
.newRepayLogic(fields: RepayFields): A function that creates the Morphoblue repay logic data with the given
fields
object.
Example Code
FlashLoan
The following code defines functions related to the Morphoblue flash loan logic:
Types
Please refer to the FlashLoan Logic section for more information.
Functions
getFlashLoanTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Morphoblue flash loan logic on the specified
chainId
.getFlashLoanQuotation(chainId: number, params: FlashLoanParams): An asynchronous function that retrieves a quotation for flash loaning assets on the Morphoblue protocol with the specified
params
object on the specifiedchainId
.newFlashLoanLogic(fields: FlashLoanFields): A function that creates the Morphoblue flash loan logic data with the given
fields
object.newFlashLoanLogicPair(loans: FlashLoanFields['loans']): A function that creates the Morphoblue flash loan logic data pair with the given
loans
object.
Example Code
Last updated