Skip to main content

SwapHelper

Table of contents

Constructors

Methods

Constructors

constructor

new SwapHelper(): SwapHelper

Returns

SwapHelper

Methods

getAmounts

getAmounts(_bin, _fp, _activeId, _swapForY, _amountIn): GetAmountsReturn

Returns the swap amounts in the current bin

Parameters

NameType
_binBin
_fpFeeParameters
_activeIdu64
_swapForYbool
_amountInu256

Returns

GetAmountsReturn

GetAmountsReturn: amountInToBin (u256), amountOutOfBin (u256), fees (FeesDistribution)

Defined in

assembly/libraries/SwapHelper.ts:31


getSwapIn

getSwapIn(_pair, _amountOut, _swapForY, isQuote?): Result<GetSwapInReturn>

Simulate a swap in

Parameters

NameTypeDefault valueDescription
_pairIPairundefined-
_amountOutu256undefinedThe amount of token to receive
_swapForYboolundefinedWhether you swap X for Y (true), or Y for X (false)
isQuoteboolfalse-

Returns

Result<GetSwapInReturn>

GetSwapInReturn: amountIn, feesIn

Defined in

assembly/libraries/SwapHelper.ts:87


getSwapOut

getSwapOut(_pair, _amountIn, _swapForY, isQuote?): Result<GetSwapOutReturn>

Simulate a swap out

Parameters

NameTypeDefault valueDescription
_pairIPairundefined-
_amountInu256undefinedThe amount of token sent
_swapForYboolundefinedWhether you swap X for Y (true), or Y for X (false)
isQuoteboolfalseWhether this is a quote or not (will throw or return an error)

Returns

Result<GetSwapOutReturn>

GetSwapOutReturn: amountOut, feesIn

Defined in

assembly/libraries/SwapHelper.ts:176