@xfai-labs/sdk
Enumerations
AddressType
Enumeration Members
TradeType
Enumeration Members
Classes
Xfai
This class contains all the information needed to interact with the Xfai protocol. The provider parameter is used to interact with the Ethereum network using ethers.js.
Constructors
constructor()
new Xfai(
provider
,chain
,swapFee
=2
):Xfai
Parameters
Returns
Xfai
Source
Properties
Type Aliases
AccountAddress
AccountAddress:
Address
<Account
>
Source
Address
Address: <
T
>object
Type parameters
Type declaration
Source
BoostOptions
BoostOptions:
Omit
<TransactionOptions
,"slippage"
>
Source
libs/sdk/src/lib/periphery/inft/boost.ts:7
Chain
Chain: <
T
>object
Type parameters
Type declaration
Source
INFT
INFT:
object
Type declaration
Source
libs/sdk/src/lib/inft/core.ts:5
libs/sdk/src/lib/inft/core.ts:10
INFTBalance
INFTBalance:
object
Type declaration
Source
libs/sdk/src/lib/inft/balance.ts:8
INFTState
INFTState:
object
Type declaration
Source
libs/sdk/src/lib/inft/core.ts:26
LiquidityInAmount
LiquidityInAmount: <
P
>object
Type parameters
Type declaration
Source
libs/sdk/src/lib/periphery/liquidity/add.ts:7
ParsedEthersError
ParsedEthersError:
object
Type declaration
Source
libs/sdk/src/lib/xfai-core.ts:4
Pool
Pool:
Address
<Pool
>
Source
libs/sdk/src/lib/pool/core.ts:10
libs/sdk/src/lib/pool/core.ts:11
PoolState
PoolState:
object
Type declaration
Source
libs/sdk/src/lib/pool/core.ts:18
Quote
Quote: <
T
>object
Type parameters
Type declaration
Source
libs/sdk/src/lib/pool/quote.ts:20
QuoteBase
QuoteBase:
"ETH"
|"Token"
Source
libs/sdk/src/lib/pool/quote.ts:6
QuoteResult
QuoteResult: <
T
>T
extends"Token"
? {ethIn
:BigNumber
;tokenIn
:BigNumber
|undefined
;xfAmount
:BigNumber
;} : {ethIn
:BigNumber
|undefined
;tokenIn
:BigNumber
;xfAmount
:BigNumber
;}
Type parameters
Source
libs/sdk/src/lib/pool/quote.ts:8
StakeOptions
StakeOptions:
Omit
<TransactionOptions
,"slippage"
>
Source
libs/sdk/src/lib/periphery/inft/stake.ts:8
SupportedChainIds
SupportedChainIds: keyof typeof
Chains
Source
libs/sdk/src/chains/index.ts:11
libs/sdk/src/chains/index.ts:12
SwapAmount
SwapAmount:
object
Type declaration
Source
libs/sdk/src/lib/pool/swap-amounts.ts:14
TargetTokenAmount
TargetTokenAmount:
object
Type declaration
Source
libs/sdk/src/lib/periphery/liquidity/remove.ts:7
Token
Token:
Address
<Token
> |Pick
<TokenInfo
,"address"
|"decimals"
>
Source
libs/sdk/src/lib/xfai-token.ts:9
libs/sdk/src/lib/xfai-token.ts:11
TransactionOptions
TransactionOptions:
object
Type declaration
Source
libs/sdk/src/lib/periphery/core.ts:12
Variables
BASISPOINT_MAX
const
BASISPOINT_MAX:BigNumber
A utility module for handling basis points and converting them to percentages.
Source
libs/sdk/src/lib/xfai-utils.ts:13
Chains
const
Chains:object
Type declaration
Source
libs/sdk/src/chains/index.ts:6
Mainnet
const
Mainnet:Chain
<59144
> =LINEA_NETWORK
Source
libs/sdk/src/chains/index.ts:5
NATIVE_TOKEN_ADDRESS
const
NATIVE_TOKEN_ADDRESS:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
='0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
Source
PERMILLE_MAX
const
PERMILLE_MAX:BigNumber
A utility module for working with permille values, which represent one-tenth of a percentage point.
Source
libs/sdk/src/lib/xfai-utils.ts:41
SupportedChainIds
const
SupportedChainIds: (5777
|59144
|59140
)[]
Source
libs/sdk/src/chains/index.ts:11
libs/sdk/src/chains/index.ts:12
Functions
AccountAddress()
AccountAddress(
address
):AccountAddress
Parameters
Returns
AccountAddress
Source
Address()
Address<
T
>(type
,address
):Address
<T
>
Type parameters
Parameters
Returns
Address
< T
>
Source
INFT()
INFT(
id
):INFT
Parameters
Returns
INFT
Source
libs/sdk/src/lib/inft/core.ts:10
Pool()
Pool(
address
):Pool
Parameters
Returns
Pool
Source
libs/sdk/src/lib/pool/core.ts:11
Token()
Token(
address
):Token
Parameters
Returns
Token
Source
libs/sdk/src/lib/xfai-token.ts:11
addLiquidity()
addLiquidity<
P
>(xfai
,ethAmount
,target
,options
):Promise
<PopulatedTransaction
>
Add liquidity to a pool, in case you're providing single sided ETH, supplementary should be undefined
Type parameters
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/liquidity/add.ts:15
addSwapFee()
addSwapFee(
xfai
,amount
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/pool/core.ts:94
basisPointToPercent()
basisPointToPercent(
value
):number
Converts a basis point value to its equivalent percentage value.
Parameters
Returns
number
The equivalent percentage value.
Source
libs/sdk/src/lib/xfai-utils.ts:20
boostToken()
boostToken(
xfai
,inft
,amountIn
,minShare
,options
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/inft/boost.ts:9
calculateDeadline()
calculateDeadline(
param0
):string
Convert the date object to unix timestamp
Parameters
Returns
string
unix timestamp
Source
libs/sdk/src/lib/xfai-utils.ts:62
calculatePriceImpact()
calculatePriceImpact(
input
,output
):number
Parameters
Returns
number
Source
libs/sdk/src/lib/xfai-utils.ts:217
calculateShare()
calculateShare(
inftState
,input
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/inft/core.ts:60
calculateSwapFee()
calculateSwapFee(
xfai
,amount
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/pool/core.ts:85
delayMs()
delayMs(
ms
):Promise
<unknown
>
Parameters
Returns
Promise
< unknown
>
Source
libs/sdk/src/lib/xfai-utils.ts:166
deriveToAddress()
deriveToAddress(
__namedParameters
):Promise
<string
>
Parameters
Returns
Promise
< string
>
Source
libs/sdk/src/lib/periphery/core.ts:20
getAdjustedAmountInput()
getAdjustedAmountInput(
pool
,ethOut
):BigNumber
Returns the amount of token that's needed to get the desired eth reserve out
Parameters
Returns
BigNumber
amountIn
Source
libs/sdk/src/lib/xfai-utils.ts:102
getAdjustedAmountOutput()
getAdjustedAmountOutput(
pool
,ethIn
):BigNumber
Parameters
Returns
BigNumber
amountOut
Source
libs/sdk/src/lib/xfai-utils.ts:143
getAdjustedEthInput()
getAdjustedEthInput(
pool
,amountOut
):BigNumber
Returns the xf that's needed to get the desired token amount out
Parameters
Returns
BigNumber
xfIn
Source
libs/sdk/src/lib/xfai-utils.ts:118
getAdjustedEthOutput()
getAdjustedEthOutput(
pool
,amountIn
):BigNumber
Returns the eth reserve out for the token amount in
Parameters
Returns
BigNumber
xfOut
Source
libs/sdk/src/lib/xfai-utils.ts:133
getCore()
getCore(
xfai
):IXfaiV0Core
Parameters
Returns
IXfaiV0Core
Source
libs/sdk/src/lib/xfai-core.ts:10
getFactory()
getFactory(
xfai
):IXfaiFactory
Parameters
Returns
IXfaiFactory
Source
getINFT()
getINFT(
xfai
,signer
=false
):IXfaiINFT
Parameters
Returns
IXfaiINFT
Source
libs/sdk/src/lib/inft/core.ts:32
getINFTBalance()
getINFTBalance(
xfai
,account
):Promise
<number
>
Parameters
Returns
Promise
< number
>
Source
libs/sdk/src/lib/inft/balance.ts:14
getINFTOwnership()
getINFTOwnership(
xfai
,inft
):Promise
< {owner
:string
;} >
Parameters
Returns
Promise
< {owner
: string
;} >
Source
libs/sdk/src/lib/inft/core.ts:39
getINFTPeriphery()
getINFTPeriphery(
xfai
,signer
):IInfinityNFTPeriphery
Parameters
Returns
IInfinityNFTPeriphery
Source
libs/sdk/src/lib/periphery/core.ts:8
getINFTPeripheryAllowance()
getINFTPeripheryAllowance(
xfai
,wallet
,token
):BigNumber
|Promise
<BigNumber
>
Parameters
Returns
BigNumber
| Promise
< BigNumber
>
Source
libs/sdk/src/lib/xfai-token.ts:94
getINFTState()
getINFTState(
xfai
,options
):Promise
<INFTState
>
Parameters
Returns
Promise
< INFTState
>
Source
libs/sdk/src/lib/inft/core.ts:50
getINFTTokenBalance()
getINFTTokenBalance(
xfai
,inft
,token
):Promise
<INFTBalance
>
Parameters
Returns
Promise
< INFTBalance
>
Source
libs/sdk/src/lib/inft/balance.ts:18
getINFTTokenBalanceMulticall()
getINFTTokenBalanceMulticall<
T
>(xfai
,inft
,tokens
,allowFailure
):Promise
<Record
<Token
["address"
],T
extendstrue
?undefined
|INFTBalance
:INFTBalance
> >
Type parameters
Parameters
Returns
Promise
< Record
< Token
["address"
], T
extends true
? undefined
| INFTBalance
: INFTBalance
> >
Source
libs/sdk/src/lib/inft/balance.ts:31
getINFTsForOwner()
getINFTsForOwner(
xfai
,owner
,balance
):Promise
<Record
<string
|number
,BigNumber
> >
Parameters
Returns
Promise
< Record
< string
| number
, BigNumber
> >
Source
libs/sdk/src/lib/inft/balance.ts:67
getInftImage()
getInftImage(
inft
,quality
?):string
Parameters
Returns
string
Source
libs/sdk/src/lib/inft/core.ts:17
getOraclePrice()
getOraclePrice(
xfai
,token
):Promise
<BigNumber
>
Parameters
Returns
Promise
< BigNumber
>
Source
libs/sdk/src/lib/xfai-token.ts:150
getPeriphery()
getPeriphery(
xfai
,signer
):IXfaiV0Periphery03
Parameters
Returns
IXfaiV0Periphery03
Source
libs/sdk/src/lib/periphery/core.ts:4
getPeripheryAllowance()
getPeripheryAllowance(
xfai
,wallet
,token
):BigNumber
|Promise
<BigNumber
>
Parameters
Returns
BigNumber
| Promise
< BigNumber
>
Source
libs/sdk/src/lib/xfai-token.ts:84
getPool()
getPool(
xfai
,pool
):IXfaiPool
Parameters
Returns
IXfaiPool
Source
libs/sdk/src/lib/pool/core.ts:23
getPoolBalance()
getPoolBalance(
xfai
,wallet
,token
):Promise
<BigNumber
>
Parameters
Returns
Promise
< BigNumber
>
Source
libs/sdk/src/lib/pool/balance.ts:6
getPoolBalanceMulticall()
getPoolBalanceMulticall(
xfai
,wallet
,tokens
):Promise
<Record
<string
,BigNumber
|undefined
> >
Parameters
Returns
Promise
< Record
< string
, BigNumber
| undefined
> >
Source
libs/sdk/src/lib/pool/multicall.ts:8
getPoolFromToken()
getPoolFromToken(
xfai
,token
):Pool
Parameters
Returns
Pool
Source
libs/sdk/src/lib/pool/core.ts:35
getPoolFromTokenAddress()
getPoolFromTokenAddress(
xfai
,token
):IXfaiPool
Parameters
Returns
IXfaiPool
Source
libs/sdk/src/lib/pool/core.ts:27
getPoolLiquidityMulticall()
getPoolLiquidityMulticall(
xfai
,tokens
):Promise
<Record
<string
|number
,undefined
|BigNumber
> >
Parameters
Returns
Promise
< Record
< string
| number
, undefined
| BigNumber
> >
Source
libs/sdk/src/lib/pool/multicall.ts:42
getPoolNameForTokenAddress()
getPoolNameForTokenAddress(
xfai
,token
):Promise
<string
>
Parameters
Returns
Promise
< string
>
Source
libs/sdk/src/lib/pool/core.ts:31
getPoolState()
getPoolState(
xfai
,pool
,options
={}
):Promise
<PoolState
>
Parameters
Returns
Promise
< PoolState
>
Source
libs/sdk/src/lib/pool/core.ts:45
getPoolStateMulticall()
getPoolStateMulticall(
xfai
,poolsOrTokens
):Promise
< {} >
Parameters
Returns
Promise
< {} >
Source
libs/sdk/src/lib/pool/core.ts:53
getPoolSupply()
getPoolSupply(
xfai
,token
):Promise
<BigNumber
>
Parameters
Returns
Promise
< BigNumber
>
Source
libs/sdk/src/lib/pool/balance.ts:18
getPoolTokenBalance()
getPoolTokenBalance(
xfai
,token
):Promise
<BigNumber
>
Parameters
Returns
Promise
< BigNumber
>
Source
libs/sdk/src/lib/pool/balance.ts:14
getPoolTokenBalanceMulticall()
getPoolTokenBalanceMulticall(
xfai
,tokens
):Promise
<Record
<string
|number
,undefined
|BigNumber
> >
Parameters
Returns
Promise
< Record
< string
| number
, undefined
| BigNumber
> >
Source
libs/sdk/src/lib/pool/multicall.ts:27
getSpotAmount()
getSpotAmount(
pool
,ethIn
):BigNumber
Return the amount out for a given xf In
Parameters
Returns
BigNumber
amountIn
Source
libs/sdk/src/lib/xfai-utils.ts:79
getSpotEth()
getSpotEth(
pool
,amountIn
):BigNumber
Return the xf out for a given amount in
Parameters
Returns
BigNumber
xfOut
Source
libs/sdk/src/lib/xfai-utils.ts:92
getSwapAmounts()
getSwapAmounts<
T
,P
>(xfai
,tradeType
,tokenIn
,tokenOut
,amount
):SwapAmount
Type parameters
Parameters
Returns
SwapAmount
Source
libs/sdk/src/lib/pool/swap-amounts.ts:126
getSwapInputAmount()
getSwapInputAmount<
P
>(xfai
,tokenIn
,tokenOut
,outputAmount
):SwapAmount
Returns the amount of tokenIn needed for swapping tokenOutAmount of tokenIn
Type parameters
Parameters
Returns
SwapAmount
tokenInInput
Source
libs/sdk/src/lib/pool/swap-amounts.ts:79
getSwapOutputAmount()
getSwapOutputAmount<
P
>(xfai
,tokenIn
,tokenOut
,inputAmount
):SwapAmount
Returns the amount of tokenOut after swapping tokenInAmount of tokenIn
Type parameters
Parameters
Returns
SwapAmount
tokenOutAmount
Source
libs/sdk/src/lib/pool/swap-amounts.ts:26
getToken()
getToken(
xfai
,token
):IERC20Metadata
Parameters
Returns
IERC20Metadata
Source
libs/sdk/src/lib/xfai-token.ts:25
getTokenBalance()
getTokenBalance(
xfai
,wallet
,token
):Promise
<BigNumber
>
Parameters
Returns
Promise
< BigNumber
>
Source
libs/sdk/src/lib/xfai-token.ts:28
getTokenBalanceMulticall()
getTokenBalanceMulticall(
xfai
,wallet
,tokens
):Promise
<Record
<Token
["address"
],BigNumber
|undefined
> >
Parameters
Returns
Promise
< Record
< Token
["address"
], BigNumber
| undefined
> >
Source
libs/sdk/src/lib/xfai-token.ts:39
getTokenDetails()
getTokenDetails(
xfai
,token
):Promise
<TokenInfo
>
Parameters
Returns
Promise
< TokenInfo
>
Source
libs/sdk/src/lib/xfai-token.ts:105
getTransactionGasCost()
getTransactionGasCost(
tx
):undefined
|BigNumber
Tries to estimate the gas limit for a TransactionReceipt or ContractTransaction
Parameters
Returns
undefined
| BigNumber
BigNumber | undefined
Source
libs/sdk/src/lib/xfai-utils.ts:201
handleNativeToken()
handleNativeToken(
xfai
,token
):Token
|Pool
Parameters
Returns
Token
| Pool
Source
libs/sdk/src/lib/xfai-token.ts:143
harvestINFT()
harvestINFT(
xfai
,inft
,token
,amountOut
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/inft/harvest.ts:6
harvestInftErc20()
harvestInftErc20(
xfai
,inft
,token
,amountOut
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/inft/harvest.ts:23
harvestInftEth()
harvestInftEth(
xfai
,inft
,amountOut
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/inft/harvest.ts:18
isNativeToken()
isNativeToken(
token
):boolean
Parameters
Returns
boolean
Source
libs/sdk/src/lib/xfai-token.ts:22
isParsedEthersError()
isParsedEthersError(
error
):error is ParsedEthersError
Parameters
Returns
error is ParsedEthersError
Source
libs/sdk/src/lib/xfai-core.ts:14
isSharedToken()
isSharedToken(
xfai
,token
):boolean
Parameters
Returns
boolean
Source
libs/sdk/src/lib/xfai-token.ts:19
isUnderlyingToken()
isUnderlyingToken(
xfai
,token
):boolean
Parameters
Returns
boolean
Source
libs/sdk/src/lib/xfai-token.ts:13
isWrappedNativeToken()
isWrappedNativeToken(
xfai
,token
):boolean
Parameters
Returns
boolean
Source
libs/sdk/src/lib/xfai-token.ts:16
max()
max(
a
,b
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/xfai-utils.ts:69
min()
min(
a
,b
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/xfai-utils.ts:65
multicall()
multicall<
T
,B
,F
>(xfai
,contract
,calls
,options
?):Promise
<Record
<string
|number
,B
extendstrue
?undefined
|Awaited
<ReturnType
<ReturnType
<T
["connect"
] >["callStatic"
][F
] > > :Awaited
<ReturnType
<ReturnType
<T
["connect"
] >["callStatic"
][F
] > > > >
Type parameters
Parameters
Returns
Promise
< Record
< string
| number
, B
extends true
? undefined
| Awaited
< ReturnType
< ReturnType
< T
["connect"
] >["callStatic"
][F
] > > : Awaited
< ReturnType
< ReturnType
< T
["connect"
] >["callStatic"
][F
] > > > >
Source
libs/sdk/src/lib/multicall.ts:19
negativeSlippage()
negativeSlippage(
amount
,slippage
):BigNumber
Decreases the amount by the provided slippage (100 - 1% slippage) = (99)
Parameters
Returns
BigNumber
amount with negative slippage
Source
libs/sdk/src/lib/xfai-utils.ts:152
positiveSlippage()
positiveSlippage(
amount
,slippage
):BigNumber
Increases the amount by the provided slippage (100 + 1% slippage) = (101)
Parameters
Returns
BigNumber
amount with positive slippage
Source
libs/sdk/src/lib/xfai-utils.ts:162
quote()
quote<
T
>(__namedParameters
):QuoteResult
<T
>
Type parameters
Parameters
Returns
QuoteResult
< T
>
Source
libs/sdk/src/lib/pool/quote.ts:29
removeLiquidity()
removeLiquidity(
xfai
,lpTokenAmount
,target
,supplementary
,options
):Promise
<PopulatedTransaction
>
Remove liquidity from a pool,
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/liquidity/remove.ts:14
requestAllowance()
requestAllowance(
xfai
,token
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/xfai-token.ts:66
requestINFTAllowance()
requestINFTAllowance(
xfai
,token
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/xfai-token.ts:75
sendPopulatedTx()
sendPopulatedTx(
xfai
,populatedTx
):Promise
<TransactionResponse
>
Send a populated transaction
Parameters
Returns
Promise
< TransactionResponse
>
PopulatedTransaction
Source
libs/sdk/src/lib/xfai-utils.ts:176
stakeToken()
stakeToken(
xfai
,amountIn
,minShare
,options
):Promise
<PopulatedTransaction
>
Stake xfit to get an INFT. If INFT is specified in options, the INFT will be boosted instead. Takes a token and an amount in and min share out.
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/inft/stake.ts:15
subtractSwapFee()
subtractSwapFee(
xfai
,amount
):BigNumber
Parameters
Returns
BigNumber
Source
libs/sdk/src/lib/pool/core.ts:91
swapTokens()
swapTokens<
T
>(xfai
,tradeType
,tokenIn
,tokenOut
,amountIn
,desiredAmountOut
,options
):Promise
<PopulatedTransaction
>
Swap tokens.
Type parameters
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/swap/index.ts:10
swapTokens<
T
>(xfai
,tradeType
,tokenIn
,tokenOut
,desiredAmountIn
,amountOut
,options
):Promise
<PopulatedTransaction
>
Swap tokens.
Type parameters
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/periphery/swap/index.ts:19
transfer()
transfer(
xfai
,inft
,newOwner
):Promise
<PopulatedTransaction
>
Parameters
Returns
Promise
< PopulatedTransaction
>
Source
libs/sdk/src/lib/inft/transfer.ts:4
validateBasisPoint()
validateBasisPoint(
number
):BigNumber
Validates a basis point value to ensure it falls within the acceptable range of 0 to 10000.
Throws
An error if the provided basis point value is outside the valid range.
Parameters
Returns
BigNumber
The valid basis point value if it falls within the acceptable range.
Source
libs/sdk/src/lib/xfai-utils.ts:30
validatePermille()
validatePermille(
number
):BigNumber
Validates a permille value to ensure it falls within the acceptable range of 0 to 1000.
Throws
An error if the provided permille value is outside the valid range.
Parameters
Returns
BigNumber
The valid permille value if it falls within the acceptable range.
Source
Last updated