Skip to main content

SolanaSwapProgram

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:53

Solana swap (escrow manager) program representation handling PrTLC (on-chain) and HTLC (lightning) based swaps.

Extends​

  • SolanaProgramBase<SwapProgram>

Implements​

Constructors​

Constructor​

new SolanaSwapProgram(
chainInterface,
btcRelay,
storage,
programAddress?): SolanaSwapProgram;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:156

Parameters​

ParameterType
chainInterfaceSolanaChainInterface
btcRelaySolanaBtcRelay<any>
storageIStorageManager<StoredDataAccount>
programAddress?string

Returns​

SolanaSwapProgram

Overrides​

SolanaProgramBase<SwapProgram>.constructor

Properties​

_SwapEscrowState​

readonly _SwapEscrowState: any;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:98


_SwapUserVault​

readonly _SwapUserVault: any;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:92


_SwapVault​

readonly _SwapVault: any;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:84


_SwapVaultAuthority​

readonly _SwapVaultAuthority: PublicKey;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:78


chainId​

readonly chainId: "SOLANA" = "SOLANA";

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:105

Chain identifier string

Implementation of​

SwapContract.chainId


claimWithSecretTimeout​

readonly claimWithSecretTimeout: number = 45;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:109

A timeout to be used when claiming the escrow with a secret (HTLC), recommended to wait at least this long after sending a transaction before considering it a failure

Implementation of​

SwapContract.claimWithSecretTimeout


claimWithTxDataTimeout​

readonly claimWithTxDataTimeout: number = 120;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:113

A timeout to be used when claiming the escrow with bitcoin transaction data (PrTLC), recommended to wait at least this long after sending a transaction before considering it a failure

Implementation of​

SwapContract.claimWithTxDataTimeout


ESCROW_STATE_RENT_EXEMPT​

readonly ESCROW_STATE_RENT_EXEMPT: 2658720 = 2658720;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:69

Rent-exempt amount (lamports) for escrow state accounts.


program​

program: Program<T>;

Defined in: atomiq-chain-solana/src/solana/program/SolanaProgramBase.ts:21

Inherited from​

SolanaProgramBase.program

refundTimeout​

readonly refundTimeout: number = 45;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:117

A timeout to be used when refunding the escrow, recommended to wait at least this long after sending a transaction before considering it a failure

Implementation of​

SwapContract.refundTimeout

Methods​

claimDeposits()​

claimDeposits(signer): Promise<{
count: number;
totalValue: bigint;
txIds: string[];
}>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:188

Claims the funds from claimable deposits

Parameters​

ParameterTypeDescription
signerSolanaSignerOwner of the deposits, transaction signer

Returns​

Promise<{ count: number; totalValue: bigint; txIds: string[]; }>

Implementation of​

SwapContract.claimDeposits


claimWithSecret()​

claimWithSecret(
signer,
swapData,
secret,
checkExpiry?,
initAta?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:790

Signs & sends transactions required for claiming an HTLC swap

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataSolanaSwapDataSwap to claim
secretstringSecret pre-image that hashes to the swap hash
checkExpiry?booleanWhether to check expiration of the swap before executing transactions
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.claimWithSecret


claimWithTxData()​

claimWithTxData(
signer,
swapData,
tx,
requiredConfirmations,
vout,
commitedHeader?,
synchronizer?,
initAta?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:806

Signs & sends transactions required for claiming an on-chain PTLC (proof-time locked contract) swap

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataSolanaSwapDataSwap to claim
tx{ blockhash: string; confirmations: number; height: number; hex: string; txid: string; }Bitcoin transaction containing the required output
tx.blockhashstring-
tx.confirmationsnumber-
tx.heightnumber-
tx.hex?string-
tx.txid?string-
requiredConfirmations?numberRequired confirmations for the escrow to be claimed
vout?numberBitcoin tx's output index of the required output
commitedHeader?SolanaBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<any, SolanaTx, any>Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.claimWithTxData


createSwapData()​

createSwapData(
type,
offerer,
claimer,
token,
amount,
claimHash,
sequence,
expiry,
payIn,
payOut,
securityDeposit,
claimerBounty,
depositToken?): Promise<SolanaSwapData>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:616

Create a swap data for this given chain

Parameters​

ParameterTypeDescription
typeChainSwapTypeType of the swap
offererstringOfferer address
claimerstringClaimer addres
tokenstringToken to use for the swap
amountbigintAmount of tokens for the swap
claimHashstringPayment hash identifying the swap
sequencebigintSwap sequence uniquelly defining this swap
expirybigintExpiration of the swap
payInbooleanWhether the swap is payIn (offerer paying to the contract, or not payIn offerer using funds in his LP vault)
payOutbooleanWhether the swap is payOut (claimer getting the funds to his on-chain address, or no payOut claimer getting his funds into his LP vault)
securityDepositbigintSecurity deposit for the swap paid by the claimer (options premium)
claimerBountybigintBounty for the claimer of the swap (used for watchtowers)
depositToken?stringToken to be used for security deposit and claimer bounty

Returns​

Promise<SolanaSwapData>

Implementation of​

SwapContract.createSwapData


deposit()​

deposit(
signer,
token,
amount,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:925

Deposits funds to the trading LP vault

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to sign the deposit with
tokenstringToken to deposit
amountbigintAmount of the token to deposit
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.deposit


getBalance()​

getBalance(
signer,
tokenAddress,
inContract): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:665

Returns the token balance of a given signer's address

Parameters​

ParameterTypeDescription
signerstringAddress to check the balance of
tokenAddressstringToken
inContractbooleanWhether we are checking the liquidity deposited into the LP vault or just on-chain balance

Returns​

Promise<bigint>

Implementation of​

SwapContract.getBalance


getClaimableDeposits()​

getClaimableDeposits(signer): Promise<{
count: number;
totalValue: bigint;
}>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:181

Returns the amount of deposits (in native token) that we can claim back (this is useful for SVM chains with the PDAs requiring you to put some deposit in order to store data)

Parameters​

ParameterTypeDescription
signerstringSigner to check the claimable deposits for

Returns​

Promise<{ count: number; totalValue: bigint; }>

Implementation of​

SwapContract.getClaimableDeposits


getClaimFee()​

getClaimFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:981

Returns the fee in native token base units to claim the swap

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataSolanaSwapDataSwap to claim
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getClaimFee


getClaimFeeRate()​

getClaimFeeRate(signer, swapData): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:974

Returns the fee rate for claiming a swap as a specific signer

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataSolanaSwapDataSwap to claim

Returns​

Promise<string>

Implementation of​

SwapContract.getClaimFeeRate


getClaimHashStatus()​

getClaimHashStatus(claimHash): Promise<SwapCommitStateType>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:426

Parameters​

ParameterType
claimHashstring

Returns​

Promise<SwapCommitStateType>

Inherit Doc​


getCommitedData()​

getCommitedData(claimHashHex): Promise<SolanaSwapData>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:458

Parameters​

ParameterType
claimHashHexstring

Returns​

Promise<SolanaSwapData>

Inherit Doc​


getCommitFee()​

getCommitFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:995

Returns the fee in native token base units to commit (initiate) the swap

Parameters​

ParameterTypeDescription
signerstring
swapDataSolanaSwapDataSwap to initiate
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getCommitFee


getCommitStatus()​

getCommitStatus(signer, data): Promise<SwapCommitState>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:347

Returns the full status of the swap, expiry is handled by the isExpired function so also requires a signer/sender

Parameters​

ParameterTypeDescription
signerstring
dataSolanaSwapData

Returns​

Promise<SwapCommitState>

Implementation of​

SwapContract.getCommitStatus


getCommitStatuses()​

getCommitStatuses(request): Promise<{
[p: string]: SwapCommitState;
}>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:403

Returns the full status of the passed swaps, expiry is handled by the isExpired function so also requires a signer/sender

Parameters​

ParameterTypeDescription
requestobject[]

Returns​

Promise<{ [p: string]: SwapCommitState; }>

Implementation of​

SwapContract.getCommitStatuses


getDataSignature()​

getDataSignature(signer, data): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:253

Signs the given data with the provided signer

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to sign the message
dataBufferData to sign

Returns​

Promise<string>

Implementation of​

SwapContract.getDataSignature


getExtraData()​

getExtraData(
outputScript,
amount,
confirmations,
nonce?): Buffer;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:1023

Returns additional data to be included in the data-carrier (extra data) part of the PrTLC escrow initialization this provides helpers for 3rd party claimers

Parameters​

ParameterTypeDescription
outputScriptBufferA bitcoin output script required in the bitcoin transaction to claim the escrow
amountbigintAn amount of bitcoin (in satoshis) required in the bitcoin transaction to claim the escrow
confirmationsnumberConfirmations of the bitcoin transaction required for claiming the escrow
nonce?bigintAn optional nonce applied to the transaction

Returns​

Buffer

Implementation of​

SwapContract.getExtraData


getHashForHtlc()​

getHashForHtlc(swapHash): Buffer;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:323

Compute the claim hash for an HTLC swap with a given swap hash

Parameters​

ParameterTypeDescription
swapHashBuffer

Returns​

Buffer

Implementation of​

SwapContract.getHashForHtlc


getHashForOnchain()​

getHashForOnchain(
outputScript,
amount,
confirmations,
nonce?): Buffer;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:310

Compute the claim hash for a given transaction output, either nonced or just output locked

Parameters​

ParameterTypeDescription
outputScriptBufferBitcoin output locking script
amountbigintAmount of sats in the output
confirmationsnumberRequired number of confirmations for the swap to be claimable
nonce?bigintNonce to be used as replay protection

Returns​

Buffer

Implementation of​

SwapContract.getHashForOnchain


getHashForTxId()​

getHashForTxId(txId, confirmations): Buffer;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:334

Compute the claim hash for a given transaction id

Parameters​

ParameterTypeDescription
txIdstringBitcoin transaction ID
confirmationsnumberRequired number of confirmations for the swap to be claimable

Returns​

Buffer

Implementation of​

SwapContract.getHashForTxId


getHistoricalSwaps()​

getHistoricalSwaps(signer, startBlockheight?): Promise<{
latestBlockheight?: number;
swaps: {
[escrowHash: string]: object;
};
}>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:474

Returns the full history as fetched from the chain for a specific signer

Parameters​

ParameterTypeDescription
signerstring
startBlockheight?number

Returns​

Promise<{ latestBlockheight?: number; swaps: { [escrowHash: string]: object; }; }>

Implementation of​

SwapContract.getHistoricalSwaps


getInitAuthorizationExpiry()​

getInitAuthorizationExpiry(
swapData,
sig,
preFetchedData?): Promise<number>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:225

Returns the expiry timestamp (UNIX milliseconds) of the authorization

Parameters​

ParameterTypeDescription
swapDataSolanaSwapDataSwap
sigSignatureDataSignature data
preFetchedData?SolanaPreFetchVerificationOptional pre-fetched data required for signature validation

Returns​

Promise<number>

Implementation of​

SwapContract.getInitAuthorizationExpiry


getInitFeeRate()​

getInitFeeRate(
offerer?,
claimer?,
token?,
claimHash?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:954

Returns the fee rate for committing (initializing) a non-payIn swap

Parameters​

ParameterTypeDescription
offerer?stringOfferer of the swap
claimer?stringClaimer of the swap
token?stringToken to be swapped
claimHash?stringOptional payment hash

Returns​

Promise<string>

Implementation of​

SwapContract.getInitFeeRate


getInitPayInFeeRate()​

getInitPayInFeeRate(
offerer?,
claimer?,
token?,
claimHash?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:941

Returns the fee rate for committing (initializing) a payIn swap

Parameters​

ParameterTypeDescription
offerer?stringOfferer of the swap
claimer?stringClaimer of the swap
token?stringToken to be swapped
claimHash?stringOptional payment hash

Returns​

Promise<string>

Implementation of​

SwapContract.getInitPayInFeeRate


getInitSignature()​

getInitSignature(
signer,
swapData,
authorizationTimeout,
preFetchedBlockData?,
feeRate?): Promise<SignatureData>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:211

Generates the initialization signature

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for signing the message
swapDataSolanaSwapDataSwap to sign
authorizationTimeoutnumberTimeout of the authorization
preFetchedBlockData?SolanaPreFetchDataOptional pre-fetched data required for creating the signature
feeRate?stringOptional fee rate to use for the authorization

Returns​

Promise<SignatureData>

Implementation of​

SwapContract.getInitSignature


getIntermediaryBalance()​

getIntermediaryBalance(address, token): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:699

Returns intermediary vault balance for a specific token.

Parameters​

ParameterTypeDescription
addressPublicKeyIntermediary address
tokenPublicKeyToken mint

Returns​

Promise<bigint>


getIntermediaryData()​

getIntermediaryData(address, token): Promise<{
balance: bigint;
reputation: IntermediaryReputationType;
}>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:679

Parameters​

ParameterType
addressstring
tokenstring

Returns​

Promise<{ balance: bigint; reputation: IntermediaryReputationType; }>

Inherit Doc​


getIntermediaryReputation()​

getIntermediaryReputation(address, token): Promise<IntermediaryReputationType>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:689

Returns intermediary's reputation for a given token swaps

Parameters​

ParameterTypeDescription
addressstring
tokenstring

Returns​

Promise<IntermediaryReputationType>

Implementation of​

SwapContract.getIntermediaryReputation


getRawClaimFee()​

getRawClaimFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:988

Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataSolanaSwapDataSwap to claim
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getRawClaimFee


getRawCommitFee()​

getRawCommitFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:1002

Returns raw fee (not including any account deposits we might need) for initiating the swap

Parameters​

ParameterTypeDescription
signerstring
swapDataSolanaSwapDataSwap to initiate
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getRawCommitFee


getRawRefundFee()​

getRawRefundFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:1016

Returns raw fee (not including any refunds we might get that would make the getRefundFee negative) for claiming the swap

Parameters​

ParameterTypeDescription
signerstring
swapDataSolanaSwapDataSwap to claim
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getRawRefundFee


getRefundFee()​

getRefundFee(
signer,
swapData,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:1009

Returns the fee in native token base units to refund the swap

Parameters​

ParameterTypeDescription
signerstring
swapDataSolanaSwapDataSwap to refund
feeRate?stringOptional fee rate (fetched on-demand if not provided)

Returns​

Promise<bigint>

Implementation of​

SwapContract.getRefundFee


getRefundFeeRate()​

getRefundFeeRate(swapData): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:967

Returns the fee rate for refunding a swap

Parameters​

ParameterTypeDescription
swapDataSolanaSwapDataSwap to refund

Returns​

Promise<string>

Implementation of​

SwapContract.getRefundFeeRate


getRefundSignature()​

getRefundSignature(
signer,
swapData,
authorizationTimeout): Promise<SignatureData>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:239

Generates the refund signature for a given swap allowing the offerer to refund before expiration

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for signing the message (must be the same as offerer in swap data)
swapDataSolanaSwapDataSwap to refund
authorizationTimeoutnumberTimeout of the provided refund authorization

Returns​

Promise<SignatureData>

Implementation of​

SwapContract.getRefundSignature


init()​

init(
signer,
swapData,
signature,
skipChecks?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:868

Signs & sends transactions for initializing a non-payIn swap (BTC -> SC)

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for the transaction (must match claimer in swap data)
swapDataSolanaSwapDataSwap to init
signatureSignatureDataSignature data from the offerer
skipChecks?booleanWhether to skip verification of the signature & checking if the swap is already committed
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.init


initAndClaimWithSecret()​

initAndClaimWithSecret(
signer,
swapData,
signature,
secret,
skipChecks?,
txOptions?): Promise<string[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:891

Signs & sends transactions for initializing and instantly (upon init confirmation) claiming the HTLC, used for BTC-LN -> SC swaps

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for the transaction (must match claimer in swap data)
swapDataSolanaSwapDataSwap to process
signatureSignatureDataSignature data from the offerer
secretstringSecret pre-image that hashes to the swap hash
skipChecks?booleanWhether to skip verification of the signature & checking if the swap is already committed
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string[]>

Implementation of​

SwapContract.initAndClaimWithSecret


isClaimable()​

isClaimable(signer, data): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:269

Checks whether a swap is claimable for the signer, i.e. it is not expired yet and is committed on-chain

Parameters​

ParameterTypeDescription
signerstring
dataSolanaSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isClaimable


isCommited()​

isCommited(swapData): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:278

Checks whether a given swap is committed on chain (initialized)

Parameters​

ParameterTypeDescription
swapDataSolanaSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isCommited


isExpired()​

isExpired(signer, data): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:290

Checks whether a swap is already expired, swap expires a bit sooner for the claimer & a bit later for offerer, this is used to account for possible on-chain time skew

Parameters​

ParameterTypeDescription
signerstringSigner to use for checking the expiry
dataSolanaSwapDataSwap to check

Returns​

Promise<boolean>

Implementation of​

SwapContract.isExpired


isInitAuthorizationExpired()​

isInitAuthorizationExpired(swapData, sig): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:232

Checks whether a given init signature is already expired

Parameters​

ParameterTypeDescription
swapDataSolanaSwapDataSwap
sigSignatureDataSignature data

Returns​

Promise<boolean>

Implementation of​

SwapContract.isInitAuthorizationExpired


isRequestRefundable()​

isRequestRefundable(signer, data): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:300

Checks whether a given swap is refundable by us, i.e. it is already expired, we are offerer & swap is committed on-chain

Parameters​

ParameterTypeDescription
signerstring
dataSolanaSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isRequestRefundable


isValidDataSignature()​

isValidDataSignature(
data,
signature,
publicKey): Promise<boolean>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:260

Checks whether a provided data is signature is valid

Parameters​

ParameterTypeDescription
dataBufferData to sign
signaturestringSignature
publicKeystringPublic key of the signer

Returns​

Promise<boolean>

Implementation of​

SwapContract.isValidDataSignature


isValidInitAuthorization()​

isValidInitAuthorization(
signer,
swapData,
sig,
feeRate?,
preFetchedData?): Promise<Buffer<ArrayBufferLike>>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:218

Checks whether a signature is a valid initialization signature for a given swap

Parameters​

ParameterTypeDescription
signerstringAddress of the sender of the transaction (must be either offerer or claimer)
swapDataSolanaSwapDataSwap to initialize
sigSignatureDataSignature data
feeRate?stringFee rate used for the authorization
preFetchedData?SolanaPreFetchVerificationOptional pre-fetched data required for signature validation

Returns​

Promise<Buffer<ArrayBufferLike>>

The message being signed if valid or null if invalid signature

Implementation of​

SwapContract.isValidInitAuthorization


isValidRefundAuthorization()​

isValidRefundAuthorization(swapData, sig): Promise<Buffer<ArrayBufferLike>>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:246

Checks whether a given refund signature is valid

Parameters​

ParameterTypeDescription
swapDataSolanaSwapDataSwap to refund
sigSignatureDataSignature received from the claimer

Returns​

Promise<Buffer<ArrayBufferLike>>

Implementation of​

SwapContract.isValidRefundAuthorization


preFetchBlockDataForSignatures()​

preFetchBlockDataForSignatures(): Promise<SolanaPreFetchData>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:204

Pre-fetches data required for creating init signature

Returns​

Promise<SolanaPreFetchData>

Implementation of​

SwapContract.preFetchBlockDataForSignatures


preFetchForInitSignatureVerification()​

preFetchForInitSignatureVerification(data): Promise<SolanaPreFetchVerification>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:197

Pre-fetches data required for init signature verification

Parameters​

ParameterTypeDescription
dataSolanaPreFetchData

Returns​

Promise<SolanaPreFetchVerification>

Implementation of​

SwapContract.preFetchForInitSignatureVerification


refund()​

refund(
signer,
swapData,
check?,
initAta?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:833

Signs & sends transactions for refunding a timed out swap

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for the transaction (must match offerer in swap data)
swapDataSolanaSwapDataSwap to refund
check?booleanWhether to check if the swap contract still exists on-chain
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.refund


refundWithAuthorization()​

refundWithAuthorization(
signer,
swapData,
signature,
check?,
initAta?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:850

Signs & sends transactions for refunding a swap with a valid refund signature from the claimer

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to use for the transaction (must match offerer in swap data)
swapDataSolanaSwapDataSwap to refund
signatureSignatureDataRefund signature received from the claimer
check?booleanWhether to check if the swap contract still exists on-chain
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.refundWithAuthorization


start()​

start(): Promise<void>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:174

Initializes the swap contract

Returns​

Promise<void>

Implementation of​

SwapContract.start


txsClaimWithSecret()​

txsClaimWithSecret(
signer,
swapData,
secret,
checkExpiry?,
initAta?,
feeRate?,
skipAtaCheck?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:708

Returns the unsigned transactions required for claiming an HTLC swap

Parameters​

ParameterTypeDescription
signerstring | SolanaSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataSolanaSwapDataSwap to claim
secretstringSecret pre-image that hashes to the swap hash
checkExpiry?booleanWhether to check expiration of the swap before returning the transactions
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
feeRate?stringFee rate to use for the transactions
skipAtaCheck?booleanWhether to skip checking if token account exists

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsClaimWithSecret


txsClaimWithTxData()​

txsClaimWithTxData(
signer,
swapData,
tx,
requiredConfirmations,
vout,
commitedHeader?,
synchronizer?,
initAta?,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:723

Returns the unsigned transactions required for claiming an on-chain PTLC (proof-time locked contract) swap

Parameters​

ParameterTypeDescription
signerstring | SolanaSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataSolanaSwapDataSwap to claim
tx{ blockhash: string; confirmations: number; height: number; hex: string; txid: string; }Bitcoin transaction containing the required output
tx.blockhashstring-
tx.confirmationsnumber-
tx.heightnumber-
tx.hex?string-
tx.txid?string-
requiredConfirmations?numberRequired confirmations for the escrow to be claimed
vout?numberBitcoin tx's output index of the required output
commitedHeader?SolanaBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<any, SolanaTx, any>Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
feeRate?stringFee rate to use for the transactions

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsClaimWithTxData


txsDeposit()​

txsDeposit(
signer,
token,
amount,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:781

Returns transactions required for signer to deposit funds to the trading LP vault

Parameters​

ParameterTypeDescription
signerstringOwner of the funds
tokenstringToken to deposit
amountbigintAmount of the token to deposit
feeRate?stringOptional fee rate to use for the transaction (fetched on-demand if not provided)

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsDeposit


txsInit()​

txsInit(
sender,
swapData,
sig,
skipChecks?,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:761

Returns the unsigned transactions required for initializing a non-payIn swap (BTC -> SC)

Parameters​

ParameterTypeDescription
senderstringTransaction sender address, must be either offerer or claimer
swapDataSolanaSwapDataSwap to init
sigSignatureDataSignature data from the offerer
skipChecks?booleanWhether to skip verification of the signature & checking if the swap is already committed
feeRate?stringFee rate to use for the transaction

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsInit


txsRefund()​

txsRefund(
signer,
swapData,
check?,
initAta?,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:745

Returns the transactions for refunding a timed out swap

Parameters​

ParameterTypeDescription
signerstringSigner of the refund transaction
swapDataSolanaSwapDataSwap to refund
check?booleanWhether to check if the swap contract still exists on-chain
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
feeRate?stringFee rate to use for the transactions

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsRefund


txsRefundWithAuthorization()​

txsRefundWithAuthorization(
signer,
swapData,
sig,
check?,
initAta?,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:753

Returns the transactions for refunding a swap with a valid refund signature from the claimer

Parameters​

ParameterTypeDescription
signerstringSigner of the refund transaction
swapDataSolanaSwapDataSwap to refund
sigSignatureDataRefund signature received from the claimer
check?booleanWhether to check if the swap contract still exists on-chain
initAta?booleanWhether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs)
feeRate?stringFee rate to use for the transactions

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsRefundWithAuthorization


txsWithdraw()​

txsWithdraw(
signer,
token,
amount,
feeRate?): Promise<SolanaTx[]>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:774

Returns transactions required for signer to withdraw funds from the trading LP vault

Parameters​

ParameterTypeDescription
signerstringOwner of the funds
tokenstringToken to withdraw
amountbigintAmount of the token to withdraw
feeRate?stringOptional fee rate to use for the transaction (fetched on-demand if not provided)

Returns​

Promise<SolanaTx[]>

Implementation of​

SwapContract.txsWithdraw


withdraw()​

withdraw(
signer,
token,
amount,
txOptions?): Promise<string>;

Defined in: atomiq-chain-solana/src/solana/swaps/SolanaSwapProgram.ts:911

Withdraws funds from the trading LP vault

Parameters​

ParameterTypeDescription
signerSolanaSignerSigner to sign the withdrawal with
tokenstringToken to withdraw
amountbigintAmount of the token to withdraw
txOptions?TransactionConfirmationOptionsTransaction options

Returns​

Promise<string>

Implementation of​

SwapContract.withdraw