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
Name | Type | Description |
---|---|---|
options | SocketOptions | Socket 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
Name | Type |
---|---|
approvals | typeof Approvals |
balances | typeof Balances |
quotes | typeof Quotes |
routes | typeof Routes |
server | typeof Server |
supported | typeof Supported |
tokenLists | typeof 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
Name | Type | Description |
---|---|---|
provider | Web3Provider | The web3 provider to use as user wallet |
Returns
Defined in
socket-v2-sdk/src/socket.ts:31
continue
▸ continue(activeRouteId
): Promise
<ActiveRouteGenerator
>
Continue an active route
Parameters
Name | Type | Description |
---|---|---|
activeRouteId | number | The 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
Name | Type | Description |
---|---|---|
options | ActiveRoutesRequest | Criteria 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
Name | Type | Description |
---|---|---|
params | QuoteParams | The parameters of the quote |
preferences? | QuotePreferences | Additional 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
Name | Type | Description |
---|---|---|
params | QuoteParams | The parameters of the quote |
preferences? | QuotePreferences | Additional 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
Name | Type | Description |
---|---|---|
chainId | ChainId | The 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
Name | Type |
---|---|
request | TokenListRequest |
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
Name | Type |
---|---|
quote | SocketQuote |
Returns
Promise
<ActiveRouteGenerator
>
An iterator that will yield each transaction required in the route