Utility

In this section, we will cover the functionalities provided by our Utility logics, which includes FlashLoan Aggregator, Multi Send, Send Token, and Wrapped Native Token. These logics are designed to make common operations more streamlined and efficient for developers. Whether you're building a dApp or working on a complex project, our Utility logics can help you save time and improve your workflow.

The following section will introduce the interfaces of Utility logics, which can be accessed through the api.protocols.utility. prefix.

FlashLoan Aggregator

The following code defines functions related to the Utility flash loan aggregator logic:

Types

  • FlashLoanAggregatorLogicParams: This type represents the params used to configure the parameters required for making Flash Loan quote requests. By using the loans or repays parameter, you can specify the desired loan or repayment amounts.

import * as common from '@protocolink/common';

type FlashLoanAggregatorLoanParams = {
  loans: common.TokenAmounts;
  protocolId?: string;
};

type FlashLoanAggregatorRepayParams = {
  repays: common.TokenAmounts;
  protocolId?: string;
};

type FlashLoanAggregatorLogicParams = FlashLoanAggregatorLoanParams | FlashLoanAggregatorRepayParams;
  • FlashLoanAggregatorLogicFields: This type represents the fields required for FlashLoanAggregatorLogic, including the unique id, loans, a boolean isLoan and protocolId field.

  • FlashLoanAggregatorFields: A type that represents the fields required for the Utility flash loan aggregator logic.

  • FlashLoanAggregatorLogic: An interface that extends the Logic interface and represents the Utility flash loan aggregator logic. It includes the rid, and fields properties.

Functions

  • getFlashLoanAggregatorTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Utility flash loan aggregator logic on the specified chainId.

  • getFlashLoanAggregatorQuotation(chainId: number, params: FlashLoanParams): An asynchronous function that retrieves a quotation for flash loaning assets on the lending protocol with the specified params object on the specified chainId.

  • newFlashLoanAggregatorLogic(fields: FlashLoanFields): A function that creates the Utility flash loan aggregator logic data with the given fields object.

  • newFlashLoanAggregatorLogicPair(loans: FlashLoanFields['loans']): A function that creates the Utility flash loan aggregator logic data pair with the given loans object.

Example Code

WrappedNativeToken

The following code defines interfaces and functions related to the Utility wrapped native token logic:

Types

  • WrappedNativeTokenParams: A type that represents the input parameters for the Utility wrapped native token logic

  • WrappedNativeTokenFields: A type that represents the fields required for the Utility wrapped native token logic.

  • WrappedNativeTokenLogic: An interface that extends the Logic interface and represents the Utility wrapped native token logic. It includes the rid, and fields properties.

Functions

  • getWrappedNativeTokenTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Utility wrapped native token logic on the specified chainId.

  • getWrappedNativeTokenQuotation(chainId: number, params: WrappedNativeTokenParams): An asynchronous function that retrieves a quotation for wrapping or unwrapping native token with the specified params object on the specified chainId.

  • newWrappedNativeTokenLogic(fields: WrappedNativeTokenFields): A function that creates the Utility wrapped native token logic data with the given fields object.

Example Code

SendToken

The following code defines interfaces and functions related to the Utility send token logic:

Types

  • SendTokenFields: A type that represents the fields required for the Utility send token logic.

  • SendTokenLogic: An interface that extends the Logic interface and represents the Utility send token logic. It includes the rid, and fields properties.

Functions

  • getSendTokenTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Utility send token logic on the specified chainId.

  • newSendTokenLogic(fields: SendTokenFields): A function that creates the Utility send token logic data with the given fields object.

Example Code

MultiSend

The following code defines interfaces and functions related to the Utility multi-send logic:

Types

  • MultiSendFields: A type that represents the fields required for the Utility multi-send logic.

  • MultiSendLogic: An interface that extends the Logic interface and represents the Utility multi-send logic. It includes the rid, and fields properties.

Functions

  • getMultiSendTokenList(chainId: number): An asynchronous function that retrieves the list of tokens supported by the Utility multi-send logic on the specified chainId.

  • newMultiSendLogic(fields: MultiSendFields): A function that creates the Utility multi-send logic data with the given fields object.

Example Code

CustomData

If you want to interact with protocols that are not currently supported by our SDK, you can combine the intended transaction to and data, along with the amount of tokens to be spent and received, to create the Utility custom data logic data. And you can also use this with our supported protocols.

The following code defines interfaces and functions related to the Utility custom data logic:

Types

  • CustomDataFields: A type that represents the fields required for the Utility custom data logic.

  • CustomDataLogic: An interface that extends the Logic interface and represents the Utility custom data logic. It includes the rid, and fields properties.

Functions

  • newCustomDataLogic(fields: CustomDataFields): A function that creates the Utility custom data logic data with the given fields object.

Example Code

Last updated