SwapHelper
Table of contents
Constructors
Methods
Constructors
constructor
• new SwapHelper(): SwapHelper
Returns
Methods
getAmounts
▸ getAmounts(_bin
, _fp
, _activeId
, _swapForY
, _amountIn
): GetAmountsReturn
Returns the swap amounts in the current bin
Parameters
Name | Type |
---|---|
_bin | Bin |
_fp | FeeParameters |
_activeId | u64 |
_swapForY | bool |
_amountIn | u256 |
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
Name | Type | Default value | Description |
---|---|---|---|
_pair | IPair | undefined | - |
_amountOut | u256 | undefined | The amount of token to receive |
_swapForY | bool | undefined | Whether you swap X for Y (true), or Y for X (false) |
isQuote | bool | false | - |
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
Name | Type | Default value | Description |
---|---|---|---|
_pair | IPair | undefined | - |
_amountIn | u256 | undefined | The amount of token sent |
_swapForY | bool | undefined | Whether you swap X for Y (true), or Y for X (false) |
isQuote | bool | false | Whether this is a quote or not (will throw or return an error) |
Returns
Result
<GetSwapOutReturn
>
GetSwapOutReturn: amountOut, feesIn