Skip to main content

LnForGasSwap<T>

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:88

Trusted swap for Bitcoin Lightning -> Smart chains, to be used for minor amounts to get gas tokens on the destination chain, which is only needed for Solana, which still uses legacy swaps

Extends​

Type Parameters​

Type ParameterDefault type
T extends ChainTypeChainType

Implements​

Constructors​

Constructor​

new LnForGasSwap<T>(wrapper, init): LnForGasSwap<T>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:122

Parameters​

ParameterType
wrapperLnForGasWrapper<T>
initLnForGasSwapInit

Returns​

LnForGasSwap<T>

Overrides​

ISwap.constructor

Constructor​

new LnForGasSwap<T>(wrapper, obj): LnForGasSwap<T>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:123

Parameters​

ParameterType
wrapperLnForGasWrapper<T>
objany

Returns​

LnForGasSwap<T>

Overrides​

ISwap.constructor

Properties​

chainIdentifier​

readonly chainIdentifier: T["ChainId"];

Defined in: atomiq-sdk/src/swaps/ISwap.ts:168

Smart chain identifier string corresponding to this swap

Inherited from​

ISwap.chainIdentifier


createdAt​

createdAt: number;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:176

A UNIX milliseconds timestamps of when this swap was created

Inherited from​

ISwap.createdAt


events​

readonly events: EventEmitter<{
swapState: [LnForGasSwap<T>];
}>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:160

Event emitter emitting "swapState" event when swap's state changes

Inherited from​

ISwap.events


exactIn​

readonly exactIn: boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:172

Whether a swap is an exact input swap

Inherited from​

ISwap.exactIn


url?​

readonly optional url: string;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:164

URL of the intermediary (LP) used for this swap, already has the swap service specific path appended

Inherited from​

ISwap.url


TYPE​

protected readonly TYPE: TRUSTED_FROM_BTCLN = SwapType.TRUSTED_FROM_BTCLN;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:89

Swap type

Overrides​

ISwap.TYPE

Methods​

execute()​

execute(): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:416

Returns​

Promise<boolean>

Remarks​

Not supported

Overrides​

ISwap.execute


getAddress()​

getAddress(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:230

Returns the lightning network BOLT11 invoice that needs to be paid as an input to the swap

Returns​

string

Implementation of​

IAddressSwap.getAddress


getDirection()​

getDirection(): SwapDirection;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:560

Returns the direction of the swap

Returns​

SwapDirection

Inherited from​

ISwap.getDirection


getExecutionAction()​

getExecutionAction(): Promise<
| SwapExecutionActionSendToAddress<true>
| SwapExecutionActionWait<"LP">>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:560

Returns a current state-dependent action for the user to execute, or undefined if there is no more action required for this swap - this means that the swap is probably finished (either expired, failed or settled).

Returns​

Promise< | SwapExecutionActionSendToAddress<true> | SwapExecutionActionWait<"LP">>

Overrides​

ISwap.getExecutionAction


getExecutionStatus()​

getExecutionStatus(options?): Promise<{
currentAction: | SwapExecutionActionSendToAddress<true>
| SwapExecutionActionWait<"LP">;
stateInfo: SwapStateInfo<LnForGasSwapState>;
steps: [SwapExecutionStepPayment<"LIGHTNING">, SwapExecutionStepSettlement<T["ChainId"], never>];
}>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:572

Returns the current action and the full execution steps for a given swap. Prefer this to calling getExecutionSteps and getExecutionAction separately - if called sequentially they might return the respective steps/actions in different states if you hit the state transition boundary.

Parameters​

ParameterTypeDescription
options?{ skipBuildingAction?: boolean; }Optional options argument for the additional execution status context, see the actual type in the respective swap classes
options.skipBuildingAction?boolean-

Returns​

Promise<{ currentAction: | SwapExecutionActionSendToAddress<true> | SwapExecutionActionWait<"LP">; stateInfo: SwapStateInfo<LnForGasSwapState>; steps: [SwapExecutionStepPayment<"LIGHTNING">, SwapExecutionStepSettlement<T["ChainId"], never>]; }>

Overrides​

ISwap.getExecutionStatus


getExecutionSteps()​

getExecutionSteps(): Promise<[SwapExecutionStepPayment<"LIGHTNING">, SwapExecutionStepSettlement<T["ChainId"], never>]>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:594

Returns a list of execution steps the user has to go through for a given swap, to see the possible execution steps check out SwapExecutionStep.

Returns​

Promise<[SwapExecutionStepPayment<"LIGHTNING">, SwapExecutionStepSettlement<T["ChainId"], never>]>

Overrides​

ISwap.getExecutionSteps


getFee()​

getFee(): Fee<T["ChainId"], BtcToken<true>, SCToken<T["ChainId"]>>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:395

Returns total fee for the swap, the fee is represented in source currency & destination currency, but is paid only once

Returns​

Fee<T["ChainId"], BtcToken<true>, SCToken<T["ChainId"]>>

Overrides​

ISwap.getFee


getFeeBreakdown()​

getFeeBreakdown(): [{
fee: Fee<T["ChainId"], BtcToken<true>, SCToken<T["ChainId"]>>;
type: SWAP;
}];

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:402

Returns the breakdown of all the fees paid

Returns​

[{ fee: Fee<T["ChainId"], BtcToken<true>, SCToken<T["ChainId"]>>; type: SWAP; }]

Overrides​

ISwap.getFeeBreakdown


getHyperlink(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:237

Returns a string that can be displayed as QR code representation of the lightning invoice (with lightning: prefix)

Returns​

string

Implementation of​

IAddressSwap.getHyperlink


getId()​

getId(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:220

Returns the ID of the swap, as used in the storage

Returns​

string

Overrides​

ISwap.getId


getInput()​

getInput(): TokenAmount<BtcToken<true>, true>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:346

Returns input amount of the swap, user needs to pay this much

Returns​

TokenAmount<BtcToken<true>, true>

Overrides​

ISwap.getInput


getInputAddress()​

getInputAddress(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:199

Returns source address of the swap

Returns​

string

Overrides​

ISwap.getInputAddress


getInputToken()​

getInputToken(): BtcToken<true>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:339

Returns the input token of the swap

Returns​

BtcToken<true>

Overrides​

ISwap.getInputToken


getInputTxId()​

getInputTxId(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:206

Returns swap input transaction ID on the source chain

Returns​

string

Overrides​

ISwap.getInputTxId


getInputWithoutFee()​

getInputWithoutFee(): TokenAmount<BtcToken<true>, true>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:357

Returns input amount of the swap without the fees (swap fee, network fee)

Returns​

TokenAmount<BtcToken<true>, true>

Overrides​

ISwap.getInputWithoutFee


getOutput()​

getOutput(): TokenAmount<SCToken<T["ChainId"]>, true>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:329

Returns output amount of the swap, user receives this much

Returns​

TokenAmount<SCToken<T["ChainId"]>, true>

Overrides​

ISwap.getOutput


getOutputAddress()​

getOutputAddress(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:192

Returns destination address of the swap

Returns​

string

Overrides​

ISwap.getOutputAddress


getOutputToken()​

getOutputToken(): SCToken<T["ChainId"]>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:322

Returns the output token of the swap

Returns​

SCToken<T["ChainId"]>

Overrides​

ISwap.getOutputToken


getOutputTxId()​

getOutputTxId(): string;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:213

Returns swap output transaction ID on the destination chain

Returns​

string

Overrides​

ISwap.getOutputTxId


getPriceInfo()​

getPriceInfo(): object;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:388

Returns pricing info about the swap

Returns​

object

NameTypeDefined in
differencePercentagePPMatomiq-sdk/src/swaps/ISwap.ts:391
marketPrice?numberatomiq-sdk/src/swaps/ISwap.ts:389
swapPricenumberatomiq-sdk/src/swaps/ISwap.ts:390

Inherited from​

ISwap.getPriceInfo


getQuoteExpiry()​

getQuoteExpiry(): number;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:546

Returns quote expiry in UNIX millis

Returns​

number

Inherited from​

ISwap.getQuoteExpiry


getState()​

getState(): LnForGasSwapState;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:567

Returns the current state of the swap

Returns​

LnForGasSwapState

Inherited from​

ISwap.getState


getStateInfo()​

getStateInfo(): SwapStateInfo<LnForGasSwapState>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:574

Returns the current state of the swap along with the human-readable description of the state

Returns​

SwapStateInfo<LnForGasSwapState>

Inherited from​

ISwap.getStateInfo


getType()​

getType(): SwapType;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:553

Returns the type of the swap

Returns​

SwapType

Inherited from​

ISwap.getType


hasValidPrice()​

hasValidPrice(): boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:380

Checks if the pricing for the swap is valid, according to max allowed price difference set in the ISwapPrice

Returns​

boolean

Inherited from​

ISwap.hasValidPrice


isFailed()​

isFailed(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:272

Returns whether the swap failed (e.g. was refunded)

Returns​

boolean

Overrides​

ISwap.isFailed


isFinished()​

isFinished(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:251

Returns whether the swap is finished and in its terminal state (this can mean successful, refunded or failed)

Returns​

boolean

Overrides​

ISwap.isFinished


isInitiated()​

isInitiated(): boolean;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:539

Whether a swap was initialized, a swap is considered initialized on first interaction with it, i.e. calling commit() on a Smart chain -> Bitcoin swaps, calling waitForPayment() or similar on the other direction. Not initiated swaps are not saved to the persistent storage by default (see SwapperOptions.saveUninitializedSwaps)

Returns​

boolean

Inherited from​

ISwap.isInitiated


isInProgress()​

isInProgress(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:286

Returns whether the swap is currently being processed

Returns​

boolean

Overrides​

ISwap.isInProgress


isQuoteExpired()​

isQuoteExpired(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:258

Checks whether the swap's quote has definitely expired and cannot be committed anymore, we can remove such swap

Returns​

boolean

Overrides​

ISwap.isQuoteExpired


isQuoteSoftExpired()​

isQuoteSoftExpired(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:265

Checks whether the swap's quote is soft expired (this means there is not enough time buffer for it to commit, but it still can happen)

Returns​

boolean

Overrides​

ISwap.isQuoteSoftExpired


isSuccessful()​

isSuccessful(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:279

Returns whether the swap finished successful

Returns​

boolean

Overrides​

ISwap.isSuccessful


refreshPriceData()​

refreshPriceData(): Promise<void>;

Defined in: atomiq-sdk/src/swaps/ISwap.ts:336

Re-fetches & revalidates the price data based on the current market prices

Returns​

Promise<void>

Inherited from​

ISwap.refreshPriceData


requiresAction()​

requiresAction(): boolean;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:244

Checks whether there is some action required from the user for this swap - can mean either refundable or claimable

Returns​

boolean

Overrides​

ISwap.requiresAction


serialize()​

serialize(): any;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:706

Serializes the swap to a JSON stringifiable representation (i.e. no bigints, buffers etc.)

Returns​

any

Overrides​

ISwap.serialize


waitForPayment()​

waitForPayment(
checkIntervalSeconds?,
abortSignal?,
onPaymentReceived?): Promise<boolean>;

Defined in: atomiq-sdk/src/swaps/trusted/ln/LnForGasSwap.ts:672

A blocking promise resolving when payment was received by the intermediary and client can continue, rejecting in case of failure. The swap must be in LnForGasSwapState.PR_CREATED or LnForGasSwapState.PR_PAID state!

Parameters​

ParameterTypeDescription
checkIntervalSeconds?numberHow often to poll the intermediary for answer (default 5 seconds)
abortSignal?AbortSignalAbort signal
onPaymentReceived?(txId) => voidCallback as for when the LP reports having received the ln payment

Returns​

Promise<boolean>

Throws​

When in invalid state (not PR_CREATED)