OnchainForGasSwap<T>
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:104
Trusted swap for Bitcoin -> 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
ISwap<T,OnchainForGasSwapTypeDefinition<T>,OnchainForGasSwapState>
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends ChainType | ChainType |
Implements
Constructors
Constructor
new OnchainForGasSwap<T>(wrapper, init): OnchainForGasSwap<T>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:155
Parameters
| Parameter | Type |
|---|---|
wrapper | OnchainForGasWrapper<T> |
init | OnchainForGasSwapInit |
Returns
OnchainForGasSwap<T>
Overrides
Constructor
new OnchainForGasSwap<T>(wrapper, obj): OnchainForGasSwap<T>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:156
Parameters
| Parameter | Type |
|---|---|
wrapper | OnchainForGasWrapper<T> |
obj | any |
Returns
OnchainForGasSwap<T>
Overrides
Properties
chainIdentifier
readonly chainIdentifier: T["ChainId"];
Defined in: atomiq-sdk/src/swaps/ISwap.ts:148
Smart chain identifier string corresponding to this swap
Inherited from
createdAt
createdAt: number;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:156
A UNIX milliseconds timestamps of when this swap was created
Inherited from
events
readonly events: EventEmitter<{
swapState: [OnchainForGasSwap<T>];
}>;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:140
Event emitter emitting "swapState" event when swap's state changes
Inherited from
exactIn
readonly exactIn: boolean;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:152
Whether a swap is an exact input swap
Inherited from
url?
readonly optional url: string;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:144
URL of the intermediary (LP) used for this swap, already has the swap service specific path appended
Inherited from
TYPE
protected readonly TYPE: TRUSTED_FROM_BTC = SwapType.TRUSTED_FROM_BTC;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:105
Swap type
Overrides
Methods
estimateBitcoinFee()
estimateBitcoinFee(_bitcoinWallet, feeRate?): Promise<TokenAmount<any, BtcToken<false>, true>>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:529
Estimates a bitcoin on-chain fee paid for the bitcoin swap transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
_bitcoinWallet | | IBitcoinWallet | MinimalBitcoinWalletInterface | Sender's bitcoin wallet |
feeRate? | number | Optional fee rate in sats/vB for the transaction |
Returns
Promise<TokenAmount<any, BtcToken<false>, true>>
Implementation of
IBTCWalletSwap.estimateBitcoinFee
execute()
execute(): Promise<boolean>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:598
Returns
Promise<boolean>
Remark
Not supported
Overrides
getAddress()
getAddress(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:264
An address to which the user needs to send funds on the source chain
Returns
string
Implementation of
getCurrentActions()
getCurrentActions(options?): Promise<SwapExecutionAction<T>[]>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:608
Returns a state-dependent set of actions for the user to execute, or empty array if there is currently no action required from the user to execute.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | { bitcoinWallet?: MinimalBitcoinWalletInterface; } | - |
options.bitcoinWallet? | MinimalBitcoinWalletInterface | Optional bitcoin wallet address specification to return a funded PSBT, if not provided an address is returned instead. |
Returns
Promise<SwapExecutionAction<T>[]>
Overrides
getDirection()
getDirection(): SwapDirection;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:506
Returns the direction of the swap
Returns
Inherited from
getFee()
getFee(): Fee<T["ChainId"], BtcToken<false>, SCToken<T["ChainId"]>>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:428
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<false>, SCToken<T["ChainId"]>>
Overrides
getFeeBreakdown()
getFeeBreakdown(): [{
fee: Fee<T["ChainId"], BtcToken<false>, SCToken<T["ChainId"]>>;
type: SWAP;
}];
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:435
Returns the breakdown of all the fees paid
Returns
[{
fee: Fee<T["ChainId"], BtcToken<false>, SCToken<T["ChainId"]>>;
type: SWAP;
}]
Overrides
getFundedPsbt()
getFundedPsbt(
_bitcoinWallet,
feeRate?,
additionalOutputs?): Promise<{
psbt: Transaction;
psbtBase64: string;
psbtHex: string;
signInputs: number[];
}>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:452
Returns the PSBT that is already funded with wallet's UTXOs (runs a coin-selection algorithm to choose UTXOs to use), also returns inputs indices that need to be signed by the wallet before submitting the PSBT back to the SDK with submitPsbt
Parameters
| Parameter | Type | Description |
|---|---|---|
_bitcoinWallet | | IBitcoinWallet | MinimalBitcoinWalletInterface | Sender's bitcoin wallet |
feeRate? | number | Optional fee rate in sats/vB for the transaction |
additionalOutputs? | ( | { amount: bigint; outputScript: Uint8Array; } | { address: string; amount: bigint; })[] | additional outputs to add to the PSBT - can be used to collect fees from users |
Returns
Promise<{
psbt: Transaction;
psbtBase64: string;
psbtHex: string;
signInputs: number[];
}>
Implementation of
getHyperlink()
getHyperlink(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:271
A hyperlink representation of the address + amount that the user needs to sends on the source chain. This is suitable to be displayed in a form of QR code.
Returns
string
Implementation of
getId()
getId(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:257
Returns the ID of the swap, as used in the storage
Returns
string
Overrides
getInput()
getInput(): TokenAmount<T["ChainId"], BtcToken<false>, true>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:382
Returns input amount of the swap, user needs to pay this much
Returns
TokenAmount<T["ChainId"], BtcToken<false>, true>
Overrides
getInputAddress()
getInputAddress(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:235
Returns source address of the swap
Returns
string
Overrides
getInputToken()
getInputToken(): BtcToken<false>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:375
Returns the input token of the swap
Returns
BtcToken<false>
Overrides
getInputTxId()
getInputTxId(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:243
Returns swap input transaction ID on the source chain
Returns
string
Overrides
getInputWithoutFee()
getInputWithoutFee(): TokenAmount<T["ChainId"], BtcToken<false>, true>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:389
Returns input amount of the swap without the fees (swap fee, network fee)
Returns
TokenAmount<T["ChainId"], BtcToken<false>, true>
Overrides
getOutput()
getOutput(): TokenAmount<T["ChainId"], SCToken<T["ChainId"]>, true>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:365
Returns output amount of the swap, user receives this much
Returns
TokenAmount<T["ChainId"], SCToken<T["ChainId"]>, true>
Overrides
getOutputAddress()
getOutputAddress(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:228
Returns destination address of the swap
Returns
string
Overrides
getOutputToken()
getOutputToken(): SCToken<T["ChainId"]>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:358
Returns the output token of the swap
Returns
SCToken<T["ChainId"]>
Overrides
getOutputTxId()
getOutputTxId(): string;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:250
Returns swap output transaction ID on the destination chain
Returns
string
Overrides
getPriceInfo()
getPriceInfo(): object;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:346
Returns pricing info about the swap
Returns
object
| Name | Type | Defined in |
|---|---|---|
difference | PercentagePPM | atomiq-sdk/src/swaps/ISwap.ts:349 |
marketPrice? | number | atomiq-sdk/src/swaps/ISwap.ts:347 |
swapPrice | number | atomiq-sdk/src/swaps/ISwap.ts:348 |
Inherited from
getQuoteExpiry()
getQuoteExpiry(): number;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:492
Returns quote expiry in UNIX millis
Returns
number
Inherited from
getRequiredConfirmationsCount()
getRequiredConfirmationsCount(): number;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:445
Returns the number of confirmations required for the bitcoin transaction for this swap to complete and settle
Returns
number
Implementation of
IBTCWalletSwap.getRequiredConfirmationsCount
getState()
getState(): OnchainForGasSwapState;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:513
Returns the current state of the swap
Returns
Inherited from
getStateInfo()
getStateInfo(): SwapStateInfo<OnchainForGasSwapState>;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:520
Returns the current state of the swap along with the human-readable description of the state
Returns
SwapStateInfo<OnchainForGasSwapState>
Inherited from
getType()
getType(): SwapType;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:499
Returns the type of the swap
Returns
Inherited from
hasValidPrice()
hasValidPrice(): boolean;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:338
Checks if the pricing for the swap is valid, according to max allowed price difference set in the ISwapPrice
Returns
boolean
Inherited from
isFailed()
isFailed(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:306
Returns whether the swap failed (e.g. was refunded)
Returns
boolean
Overrides
isFinished()
isFinished(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:285
Returns whether the swap is finished and in its terminal state (this can mean successful, refunded or failed)
Returns
boolean
Overrides
isInitiated()
isInitiated(): boolean;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:485
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
isInProgress()
isInProgress(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:320
Returns whether the swap is currently being processed
Returns
boolean
Overrides
isQuoteExpired()
isQuoteExpired(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:292
Checks whether the swap's quote has definitely expired and cannot be committed anymore, we can remove such swap
Returns
boolean
Overrides
isQuoteSoftExpired()
isQuoteSoftExpired(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:299
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
isSuccessful()
isSuccessful(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:313
Returns whether the swap finished successful
Returns
boolean
Overrides
refreshPriceData()
refreshPriceData(): Promise<void>;
Defined in: atomiq-sdk/src/swaps/ISwap.ts:305
Re-fetches & revalidates the price data based on the current market prices
Returns
Promise<void>
Inherited from
requestRefund()
requestRefund(refundAddress?, abortSignal?): Promise<void>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:797
Requests a refund after the swap failed, this also waits till the refund is actually sent by the intermediary (LP). The swap must be in OnchainForGasSwapState.REFUNDABLE state
Parameters
| Parameter | Type | Description |
|---|---|---|
refundAddress? | string | Bitcoin address to receive the refund to |
abortSignal? | AbortSignal | Abort signal |
Returns
Promise<void>
requiresAction()
requiresAction(): boolean;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:278
Checks whether there is some action required from the user for this swap - can mean either refundable or claimable
Returns
boolean
Overrides
sendBitcoinTransaction()
sendBitcoinTransaction(wallet, feeRate?): Promise<string>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:539
Sends a swap bitcoin transaction via the passed bitcoin wallet
Parameters
| Parameter | Type | Description |
|---|---|---|
wallet | | IBitcoinWallet | MinimalBitcoinWalletInterfaceWithSigner | Sender's bitcoin wallet |
feeRate? | number | Optional fee rate in sats/vB for the transaction |
Returns
Promise<string>
Implementation of
IBTCWalletSwap.sendBitcoinTransaction
serialize()
serialize(): any;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:809
Serializes the swap to a JSON stringifiable representation (i.e. no bigints, buffers etc.)
Returns
any
Overrides
submitPsbt()
submitPsbt(_psbt): Promise<string>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:504
Submits a PSBT signed by the wallet back to the SDK
Parameters
| Parameter | Type | Description |
|---|---|---|
_psbt | any | A PSBT, either a Transaction object or a hex or base64 encoded PSBT string |
Returns
Promise<string>
Implementation of
txsExecute()
txsExecute(options?): Promise<[SwapExecutionActionBitcoin<"ADDRESS" | "FUNDED_PSBT">]>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:565
Returns a list of steps or transactions required to finish and settle the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | { bitcoinWallet?: MinimalBitcoinWalletInterface; } | Additional options for executing the swap |
options.bitcoinWallet? | MinimalBitcoinWalletInterface | Optional bitcoin wallet address specification to return a funded PSBT, if not provided an address is returned instead. |
Returns
Promise<[SwapExecutionActionBitcoin<"ADDRESS" | "FUNDED_PSBT">]>
Overrides
waitForBitcoinTransaction()
waitForBitcoinTransaction(
updateCallback?,
checkIntervalSeconds?,
abortSignal?): Promise<string>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:722
Waits till the bitcoin transaction gets the required number of confirmations
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
updateCallback? | (txId?, confirmations?, targetConfirmations?, txEtaMs?) => void | undefined | Callback called when txId is found, and also called with subsequent confirmations |
checkIntervalSeconds? | number | 5 | How often to check the bitcoin transaction |
abortSignal? | AbortSignal | undefined | Abort signal |
Returns
Promise<string>
Throws
if in invalid state
Implementation of
IBTCWalletSwap.waitForBitcoinTransaction
waitTillRefunded()
waitTillRefunded(checkIntervalSeconds?, abortSignal?): Promise<void>;
Defined in: atomiq-sdk/src/swaps/trusted/onchain/OnchainForGasSwap.ts:770
Waits till the LP processes a refund for a failed swap. The swap must be in OnchainForGasSwapState.REFUNDABLE state
Parameters
| Parameter | Type | Description |
|---|---|---|
checkIntervalSeconds? | number | How often to check (default 5 seconds) |
abortSignal? | AbortSignal | Abort signal |
Returns
Promise<void>