Skip to main content

Socket

The Socket represents the socket sdk. This is the starting point for interacting with the socket SDK. It allows you to retrieve routes and start the execution of trades based on quotes

It includes direct access to the socket api.

Hierarchy

  • BaseSocket

    Socket

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Socket(options)

Parameters

NameTypeDescription
optionsSocketOptionsSocket sdk options

Inherited from

BaseSocket.constructor

Defined in

socket-v2-sdk/src/baseSocket.ts:68

Properties

client

client: Object

API client for accessing the socket api directly

Type declaration

NameType
approvalstypeof Approvals
balancestypeof Balances
quotestypeof Quotes
routestypeof Routes
servertypeof Server
supportedtypeof Supported
tokenListstypeof TokenLists

Inherited from

BaseSocket.client

Defined in

socket-v2-sdk/src/baseSocket.ts:54

Methods

connect

connect(provider): Web3ConnectedSocket

Connect Socket to a web3 provider that will be used to execute routes

Parameters

NameTypeDescription
providerWeb3ProviderThe web3 provider to use as user wallet

Returns

Web3ConnectedSocket

Defined in

socket-v2-sdk/src/socket.ts:31


continue

continue(activeRouteId): Promise<ActiveRouteGenerator>

Continue an active route

Parameters

NameTypeDescription
activeRouteIdnumberThe active route id of the desired route to continue

Returns

Promise<ActiveRouteGenerator>

An iterator that will yield each transaction required in the route

Defined in

socket-v2-sdk/src/socket.ts:23


getActiveRoutes

getActiveRoutes(options): Promise<{ activeRoutes: ActiveRouteResponse[] ; pagination: { limit: number ; offset: number ; totalRecords: number } }>

Retrieve the active routes. Active routes can be used to continue a quote

Parameters

NameTypeDescription
optionsActiveRoutesRequestCriteria for returning active routes. Commonly address is most useful

Returns

Promise<{ activeRoutes: ActiveRouteResponse[] ; pagination: { limit: number ; offset: number ; totalRecords: number } }>

list of active routes

Inherited from

BaseSocket.getActiveRoutes

Defined in

socket-v2-sdk/src/baseSocket.ts:201


getAllQuotes

getAllQuotes(params, preferences?): Promise<SocketQuote[]>

Get All quotes

Parameters

NameTypeDescription
paramsQuoteParamsThe parameters of the quote
preferences?QuotePreferencesAdditional route preferences for retrieving the quote from the api

Returns

Promise<SocketQuote[]>

All quotes found

Inherited from

BaseSocket.getAllQuotes

Defined in

socket-v2-sdk/src/baseSocket.ts:161


getBestQuote

getBestQuote(params, preferences?): Promise<null | SocketQuote>

Get the best quote

Parameters

NameTypeDescription
paramsQuoteParamsThe parameters of the quote
preferences?QuotePreferencesAdditional route preferences for retrieving the quote from the api

Returns

Promise<null | SocketQuote>

The best quote if found or null

Inherited from

BaseSocket.getBestQuote

Defined in

socket-v2-sdk/src/baseSocket.ts:150


getChain

getChain(chainId): Promise<Chain>

Get a chain by id

Parameters

NameTypeDescription
chainIdChainIdThe numeric id of the chain

Returns

Promise<Chain>

The requested chain

Inherited from

BaseSocket.getChain

Defined in

socket-v2-sdk/src/baseSocket.ts:92


getChains

getChains(): Promise<Chain[]>

Get all supported chains

Returns

Promise<Chain[]>

List of chains

Inherited from

BaseSocket.getChains

Defined in

socket-v2-sdk/src/baseSocket.ts:77


getTokenList

getTokenList(request): Promise<{ from: TokenList ; to: TokenList }>

Get the list of tokens available for each chain for a given path

Parameters

NameType
requestTokenListRequest

Returns

Promise<{ from: TokenList ; to: TokenList }>

The from and to token lists

Inherited from

BaseSocket.getTokenList

Defined in

socket-v2-sdk/src/baseSocket.ts:110


start

start(quote): Promise<ActiveRouteGenerator>

Start executing a socket quote/route.

Parameters

NameType
quoteSocketQuote

Returns

Promise<ActiveRouteGenerator>

An iterator that will yield each transaction required in the route

Defined in

socket-v2-sdk/src/socket.ts:14