Skip to main content

EVMSwapContract<ChainId>

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:42

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

Extends​

  • EVMContractBase<EscrowManager>

Type Parameters​

Type ParameterDefault type
ChainId extends stringstring

Implements​

Constructors​

Constructor​

new EVMSwapContract<ChainId>(
chainInterface,
btcRelay,
contractAddress,
handlerAddresses,
contractDeploymentHeight?): EVMSwapContract<ChainId>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:117

Parameters​

ParameterType
chainInterfaceEVMChainInterface<ChainId>
btcRelayEVMBtcRelay<any>
contractAddressstring
handlerAddresses{ claim: { 0: string; 1: string; 2: string; 3: string; }; refund: { timelock: string; }; }
handlerAddresses.claim{ 0: string; 1: string; 2: string; 3: string; }
handlerAddresses.claim.0?string
handlerAddresses.claim.1?string
handlerAddresses.claim.2?string
handlerAddresses.claim.3?string
handlerAddresses.refund?{ timelock: string; }
handlerAddresses.refund.timelock?string
contractDeploymentHeight?number

Returns​

EVMSwapContract<ChainId>

Overrides​

EVMContractBase<EscrowManager>.constructor

Properties​

chainId​

readonly chainId: ChainId;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:59

Chain identifier string

Implementation of​

SwapContract.chainId


claimWithSecretTimeout​

readonly claimWithSecretTimeout: number = 180;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:63

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 = 180;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:64

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


contract​

readonly contract: EscrowManager;

Defined in: atomiq-chain-evm/src/evm/contract/EVMContractBase.ts:33

Inherited from​

EVMContractBase.contract

refundTimeout​

readonly refundTimeout: number = 180;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:65

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


supportsInitWithoutClaimer​

readonly supportsInitWithoutClaimer: true = true;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:55

Whether this chain supports sending initialization without a direct authorization by the claimer

Implementation of​

SwapContract.supportsInitWithoutClaimer


Chain​

protected readonly Chain: EVMChainInterface<any>;

Defined in: atomiq-chain-evm/src/evm/contract/EVMContractBase.ts:39

Inherited from​

EVMBtcRelay.Chain

Methods​

claimWithSecret()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:781

Signs & sends transactions required for claiming an HTLC swap

Parameters​

ParameterTypeDescription
signerEVMSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:797

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

Parameters​

ParameterTypeDescription
signerEVMSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataEVMSwapDataSwap 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?EVMBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<EVMBtcStoredHeader, TransactionRequest, 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,
paymentHash,
sequence,
expiry,
payIn,
payOut,
securityDeposit,
claimerBounty,
depositToken): Promise<EVMSwapData>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:592

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
paymentHashstringPayment 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)
depositTokenstringToken to be used for security deposit and claimer bounty

Returns​

Promise<EVMSwapData>

Implementation of​

SwapContract.createSwapData


deposit()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:894

Deposits funds to the trading LP vault

Parameters​

ParameterTypeDescription
signerEVMSignerSigner 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-evm/src/evm/swaps/EVMSwapContract.ts:671

Returns the token balance of a given signer's address

Parameters​

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

Returns​

Promise<bigint>

Implementation of​

SwapContract.getBalance


getClaimFee()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:938

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

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:931

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

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataEVMSwapDataSwap to claim

Returns​

Promise<string>

Implementation of​

SwapContract.getClaimFeeRate


getCommitFee()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:945

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

Parameters​

ParameterTypeDescription
signerstring
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:334

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

Parameters​

ParameterTypeDescription
signerstring
dataEVMSwapData

Returns​

Promise<SwapCommitState>

Implementation of​

SwapContract.getCommitStatus


getCommitStatuses()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:422

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-evm/src/evm/swaps/EVMSwapContract.ts:212

Signs the given data with the provided signer

Parameters​

ParameterTypeDescription
signerEVMSignerSigner 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-evm/src/evm/swaps/EVMSwapContract.ts:315

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(paymentHash): Buffer;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:306

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

Parameters​

ParameterTypeDescription
paymentHashBuffer

Returns​

Buffer

Implementation of​

SwapContract.getHashForHtlc


getHashForOnchain()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:278

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<ArrayBuffer>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:265

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<ArrayBuffer>

Implementation of​

SwapContract.getHashForTxId


getHistoricalSwaps()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:446

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,
signature,
preFetchedData?): Promise<number>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:184

Returns the expiry timestamp (UNIX milliseconds) of the authorization

Parameters​

ParameterTypeDescription
swapDataEVMSwapDataSwap
signatureSignatureDataSignature data
preFetchedData?EVMPreFetchVerificationOptional pre-fetched data required for signature validation

Returns​

Promise<number>

Implementation of​

SwapContract.getInitAuthorizationExpiry


getInitFeeRate()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:917

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
paymentHash?stringOptional payment hash

Returns​

Promise<string>

Implementation of​

SwapContract.getInitFeeRate


getInitPayInFeeRate()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:910

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
paymentHash?stringOptional payment hash

Returns​

Promise<string>

Implementation of​

SwapContract.getInitPayInFeeRate


getInitSignature()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:170

Generates the initialization signature

Parameters​

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

Returns​

Promise<SignatureData>

Implementation of​

SwapContract.getInitSignature


getIntermediaryData()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:680

Parameters​

ParameterType
addressstring
tokenstring

Returns​

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

Inherit Doc​


getIntermediaryReputation()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:690

Returns intermediary's reputation for a given token swaps

Parameters​

ParameterTypeDescription
addressstring
tokenstring

Returns​

Promise<IntermediaryReputationType>

Implementation of​

SwapContract.getIntermediaryReputation


getRefundFee()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:952

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

Parameters​

ParameterTypeDescription
signerstring
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:924

Returns the fee rate for refunding a swap

Parameters​

ParameterTypeDescription
swapDataEVMSwapDataSwap to refund

Returns​

Promise<string>

Implementation of​

SwapContract.getRefundFeeRate


getRefundSignature()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:198

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

Parameters​

ParameterTypeDescription
signerEVMSignerSigner to use for signing the message (must be the same as offerer in swap data)
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:857

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

Parameters​

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (must match claimer in swap data)
swapDataEVMSwapDataSwap 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


isClaimable()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:228

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

Parameters​

ParameterTypeDescription
signerstring
dataEVMSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isClaimable


isCommited()​

isCommited(swapData): Promise<boolean>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:237

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

Parameters​

ParameterTypeDescription
swapDataEVMSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isCommited


isExpired()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:245

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
dataEVMSwapDataSwap to check

Returns​

Promise<boolean>

Implementation of​

SwapContract.isExpired


isInitAuthorizationExpired()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:191

Checks whether a given init signature is already expired

Parameters​

ParameterTypeDescription
swapDataEVMSwapDataSwap
signatureSignatureDataSignature data

Returns​

Promise<boolean>

Implementation of​

SwapContract.isInitAuthorizationExpired


isRequestRefundable()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:255

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
dataEVMSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isRequestRefundable


isValidDataSignature()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:219

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(
sender,
swapData,
signature,
feeRate?,
preFetchedData?): Promise<Buffer<ArrayBufferLike>>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:177

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

Parameters​

ParameterTypeDescription
senderstringAddress of the sender of the transaction (must be either offerer or claimer)
swapDataEVMSwapDataSwap to initialize
signatureSignatureDataSignature data
feeRate?stringFee rate used for the authorization
preFetchedData?EVMPreFetchVerificationOptional 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, signature): Promise<Buffer<ArrayBufferLike>>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:205

Checks whether a given refund signature is valid

Parameters​

ParameterTypeDescription
swapDataEVMSwapDataSwap to refund
signatureSignatureDataSignature received from the claimer

Returns​

Promise<Buffer<ArrayBufferLike>>

Implementation of​

SwapContract.isValidRefundAuthorization


preFetchForInitSignatureVerification()​

preFetchForInitSignatureVerification(): Promise<EVMPreFetchVerification>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:163

Pre-fetches data required for init signature verification

Returns​

Promise<EVMPreFetchVerification>

Implementation of​

SwapContract.preFetchForInitSignatureVerification


refund()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:822

Signs & sends transactions for refunding a timed out swap

Parameters​

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (must match offerer in swap data)
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:839

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

Parameters​

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (must match offerer in swap data)
swapDataEVMSwapDataSwap 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-evm/src/evm/swaps/EVMSwapContract.ts:155

Initializes the swap contract

Returns​

Promise<void>

Implementation of​

SwapContract.start


txsClaimWithSecret()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:703

Returns the unsigned transactions required for claiming an HTLC swap

Parameters​

ParameterTypeDescription
signerstring | EVMSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataEVMSwapDataSwap 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<TransactionRequest[]>

Implementation of​

SwapContract.txsClaimWithSecret


txsClaimWithTxData()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:718

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

Parameters​

ParameterTypeDescription
signerstring | EVMSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataEVMSwapDataSwap 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?EVMBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<EVMBtcStoredHeader, TransactionRequest, 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<TransactionRequest[]>

Implementation of​

SwapContract.txsClaimWithTxData


txsDeposit()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:772

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<TransactionRequest[]>

Implementation of​

SwapContract.txsDeposit


txsInit()​

txsInit(
signer,
swapData,
signature,
skipChecks?,
feeRate?): Promise<TransactionRequest[]>;

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:758

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

Parameters​

ParameterTypeDescription
signerstringTransaction sender address, must be either offerer or claimer
swapDataEVMSwapDataSwap to init
signatureSignatureDataSignature 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<TransactionRequest[]>

Implementation of​

SwapContract.txsInit


txsRefund()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:744

Returns the transactions for refunding a timed out swap

Parameters​

ParameterTypeDescription
signerstringSigner of the refund transaction
swapDataEVMSwapDataSwap 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<TransactionRequest[]>

Implementation of​

SwapContract.txsRefund


txsRefundWithAuthorization()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:751

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

Parameters​

ParameterTypeDescription
signerstringSigner of the refund transaction
swapDataEVMSwapDataSwap 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)
feeRate?stringFee rate to use for the transactions

Returns​

Promise<TransactionRequest[]>

Implementation of​

SwapContract.txsRefundWithAuthorization


txsWithdraw()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:765

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<TransactionRequest[]>

Implementation of​

SwapContract.txsWithdraw


withdraw()​

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

Defined in: atomiq-chain-evm/src/evm/swaps/EVMSwapContract.ts:880

Withdraws funds from the trading LP vault

Parameters​

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

Returns​

Promise<string>

Implementation of​

SwapContract.withdraw