Skip to main content

StarknetSwapContract

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:78

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

Extends​

  • StarknetContractBase<typeof EscrowManagerAbi>

Implements​

Constructors​

Constructor​

new StarknetSwapContract(
chainInterface,
btcRelay,
contractAddress,
_handlerAddresses?,
contractDeploymentHeight?): StarknetSwapContract;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:149

Constructs the swap contract (escrow manager)

Parameters​

ParameterTypeDescription
chainInterfaceStarknetChainInterfaceUnderlying chain interface to use
btcRelayStarknetBtcRelay<any>Btc relay light client contract
contractAddressstringOptional underlying contract address (default is used otherwise)
_handlerAddresses?{ claim?: { 0?: string; 1?: string; 2?: string; 3?: string; }; refund?: { timelock?: string; }; }Optional handler addresses (defaults are used otherwise)
_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?numberThe height at which this contract was deployed (default is used otherwise)

Returns​

StarknetSwapContract

Overrides​

StarknetContractBase<typeof EscrowManagerAbi>.constructor

Properties​

btcRelay​

readonly btcRelay: StarknetBtcRelay<any>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:135


chainId​

readonly chainId: "STARKNET" = "STARKNET";

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:96

Chain identifier string

Implementation of​

SwapContract.chainId


Claim​

readonly Claim: StarknetSwapClaim;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:124


claimHandlersByAddress​

readonly claimHandlersByAddress: object = {};

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:129

Index Signature​

[address: string]: IClaimHandler<any, any>

claimHandlersBySwapType​

readonly claimHandlersBySwapType: object = {};

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:130

0?​

optional 0: IClaimHandler<any, any>;

1?​

optional 1: IClaimHandler<any, any>;

2?​

optional 2: IClaimHandler<any, any>;

3?​

optional 3: IClaimHandler<any, any>;

claimWithSecretTimeout​

readonly claimWithSecretTimeout: number = 180;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:103

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:107

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: TypedContractV2<T>;

Defined in: atomiq-chain-starknet/src/starknet/contract/StarknetContractBase.ts:11

Inherited from​

StarknetContractBase.contract

Init​

readonly Init: StarknetSwapInit;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:122


LpVault​

readonly LpVault: StarknetLpVault;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:125


Refund​

readonly Refund: StarknetSwapRefund;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:123


refundHandlersByAddress​

readonly refundHandlersByAddress: object = {};

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:132

Index Signature​

[address: string]: IHandler<any, any>

refundTimeout​

readonly refundTimeout: number = 180;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:111

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:92

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

Implementation of​

SwapContract.supportsInitWithoutClaimer


timelockRefundHandler​

readonly timelockRefundHandler: IHandler<any, any>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:133

Methods​

claimWithSecret()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:864

Signs & sends transactions required for claiming an HTLC swap

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:880

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

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataStarknetSwapDataSwap 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?StarknetBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<StarknetBtcStoredHeader, StarknetTx, 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,
claimData,
sequence,
expiry,
payIn,
payOut,
securityDeposit,
claimerBounty,
depositToken): Promise<StarknetSwapData>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:676

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
claimDatastringPayment 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<StarknetSwapData>

Implementation of​

SwapContract.createSwapData


deposit()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:978

Deposits funds to the trading LP vault

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:767

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:1022

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

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:1015

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

Parameters​

ParameterTypeDescription
signerstringSigner claiming the swap
swapDataStarknetSwapDataSwap to claim

Returns​

Promise<string>

Implementation of​

SwapContract.getClaimFeeRate


getCommitFee()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:1029

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

Parameters​

ParameterTypeDescription
signerstring
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:374

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

Parameters​

ParameterTypeDescription
signerstring
dataStarknetSwapData

Returns​

Promise<SwapCommitState>

Implementation of​

SwapContract.getCommitStatus


getCommitStatuses()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:468

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:252

Signs the given data with the provided signer

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:355

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:346

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:318

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:305

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

Implementation of​

SwapContract.getHashForTxId


getHistoricalSwaps()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:492

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:224

Returns the expiry timestamp (UNIX milliseconds) of the authorization

Parameters​

ParameterTypeDescription
swapDataStarknetSwapDataSwap
sigSignatureDataSignature data
preFetchedData?StarknetPreFetchVerificationOptional 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:1001

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:994

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:210

Generates the initialization signature

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner to use for signing the message
swapDataStarknetSwapDataSwap 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


getIntermediaryReputation()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:777

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-starknet/src/starknet/swaps/StarknetSwapContract.ts:1036

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

Parameters​

ParameterTypeDescription
signerstring
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:1008

Returns the fee rate for refunding a swap

Parameters​

ParameterTypeDescription
swapDataStarknetSwapDataSwap to refund

Returns​

Promise<string>

Implementation of​

SwapContract.getRefundFeeRate


getRefundSignature()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:238

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

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner to use for signing the message (must be the same as offerer in swap data)
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:941

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

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner to use for the transaction (must match claimer in swap data)
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:268

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

Parameters​

ParameterTypeDescription
signerstring
dataStarknetSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isClaimable


isCommited()​

isCommited(swapData): Promise<boolean>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:277

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

Parameters​

ParameterTypeDescription
swapDataStarknetSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isCommited


isExpired()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:285

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

Returns​

Promise<boolean>

Implementation of​

SwapContract.isExpired


isInitAuthorizationExpired()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:231

Checks whether a given init signature is already expired

Parameters​

ParameterTypeDescription
swapDataStarknetSwapDataSwap
sigSignatureDataSignature data

Returns​

Promise<boolean>

Implementation of​

SwapContract.isInitAuthorizationExpired


isRequestRefundable()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:295

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
dataStarknetSwapData

Returns​

Promise<boolean>

Implementation of​

SwapContract.isRequestRefundable


isValidDataSignature()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:259

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,
sig,
feeRate?,
preFetchedData?): Promise<null>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:217

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)
swapDataStarknetSwapDataSwap to initialize
sigSignatureDataSignature data
feeRate?stringFee rate used for the authorization
preFetchedData?StarknetPreFetchVerificationOptional pre-fetched data required for signature validation

Returns​

Promise<null>

The message being signed if valid or null if invalid signature

Implementation of​

SwapContract.isValidInitAuthorization


isValidRefundAuthorization()​

isValidRefundAuthorization(swapData, sig): Promise<null>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:245

Checks whether a given refund signature is valid

Parameters​

ParameterTypeDescription
swapDataStarknetSwapDataSwap to refund
sigSignatureDataSignature received from the claimer

Returns​

Promise<null>

Implementation of​

SwapContract.isValidRefundAuthorization


preFetchForInitSignatureVerification()​

preFetchForInitSignatureVerification(): Promise<StarknetPreFetchVerification>;

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:203

Pre-fetches data required for init signature verification

Returns​

Promise<StarknetPreFetchVerification>

Implementation of​

SwapContract.preFetchForInitSignatureVerification


refund()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:906

Signs & sends transactions for refunding a timed out swap

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner to use for the transaction (must match offerer in swap data)
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:923

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

Parameters​

ParameterTypeDescription
signerStarknetSignerSigner to use for the transaction (must match offerer in swap data)
swapDataStarknetSwapDataSwap 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-starknet/src/starknet/swaps/StarknetSwapContract.ts:195

Initializes the swap contract

Returns​

Promise<void>

Implementation of​

SwapContract.start


txsClaimWithSecret()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:786

Returns the unsigned transactions required for claiming an HTLC swap

Parameters​

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

Implementation of​

SwapContract.txsClaimWithSecret


txsClaimWithTxData()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:801

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

Parameters​

ParameterTypeDescription
signerstring | StarknetSignerSigner for which the transaction should be created (doesn't need to match the claimer)
swapDataStarknetSwapDataSwap 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?StarknetBtcStoredHeaderOptional already retrieved stored header to use for proving
synchronizer?RelaySynchronizer<StarknetBtcStoredHeader, StarknetTx, 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<StarknetTx[]>

Implementation of​

SwapContract.txsClaimWithTxData


txsDeposit()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:855

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

Implementation of​

SwapContract.txsDeposit


txsInit()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:841

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

Parameters​

ParameterTypeDescription
senderstringTransaction sender address, must be either offerer or claimer
swapDataStarknetSwapDataSwap 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<StarknetTx[]>

Implementation of​

SwapContract.txsInit


txsRefund()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:827

Returns the transactions for refunding a timed out swap

Parameters​

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

Implementation of​

SwapContract.txsRefund


txsRefundWithAuthorization()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:834

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

Parameters​

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

Implementation of​

SwapContract.txsRefundWithAuthorization


txsWithdraw()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:848

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

Implementation of​

SwapContract.txsWithdraw


withdraw()​

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

Defined in: atomiq-chain-starknet/src/starknet/swaps/StarknetSwapContract.ts:964

Withdraws funds from the trading LP vault

Parameters​

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

Returns​

Promise<string>

Implementation of​

SwapContract.withdraw