Skip to main content

EVMSpvVaultContract<ChainId>

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:66

EVM SPV vault (UTXO-controlled vault) contract representation.

Extends

  • EVMContractBase<SpvVaultManager>

Type Parameters

Type Parameter
ChainId extends string

Implements

Constructors

Constructor

new EVMSpvVaultContract<ChainId>(
chainInterface,
btcRelay,
bitcoinRpc,
contractAddress,
contractDeploymentHeight?): EVMSpvVaultContract<ChainId>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:101

Parameters

ParameterType
chainInterfaceEVMChainInterface<ChainId>
btcRelayEVMBtcRelay<any>
bitcoinRpcBitcoinRpc<any>
contractAddressstring
contractDeploymentHeight?number

Returns

EVMSpvVaultContract<ChainId>

Overrides

EVMContractBase<SpvVaultManager>.constructor

Properties

chainId

readonly chainId: ChainId;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:93

Chain identifier string

Implementation of

SpvVaultContract.chainId


claimTimeout

readonly claimTimeout: number = 180;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:94


contract

readonly contract: SpvVaultManager;

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

Inherited from

EVMContractBase.contract

Chain

protected readonly Chain: EVMChainInterface<any>;

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

Inherited from

EVMContractBase.Chain

Methods

checkWithdrawalTx()

checkWithdrawalTx(tx): Promise<void>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:193

Checks if given withdrawal tx is valid and correctly parses on-chain, throws error when there is any issue with the validation

Parameters

ParameterTypeDescription
txSpvWithdrawalTransactionData

Returns

Promise<void>

Implementation of

SpvVaultContract.checkWithdrawalTx


claim()

claim(
signer,
vault,
txs,
synchronizer?,
initAta?,
txOptions?): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:682

Signs & sends transactions for claiming the funds from a specific vault

Parameters

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction
vaultEVMSpvVaultDataVault to claim from
txsobject[]
synchronizer?RelaySynchronizer<any, any, 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

SpvVaultContract.claim


createVaultData()

createVaultData(
owner,
vaultId,
utxo,
confirmations,
tokenData): Promise<EVMSpvVaultData>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:201

Creates vault data for a new vault

Parameters

ParameterTypeDescription
ownerstringVault owner
vaultIdbigintVault ID
utxostringUtxo on which to assign the vault initially
confirmationsnumberRequired number of bitcoin confirmations to be able to withdraw funds from the vault
tokenDataSpvVaultTokenData[]Data about the tokens in the vault

Returns

Promise<EVMSpvVaultData>

Implementation of

SpvVaultContract.createVaultData


deposit()

deposit(
signer,
vault,
rawAmounts,
txOptions?): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:691

Signs & sends transactions for depositing funds to a specific spv vault

Parameters

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (can be any)
vaultEVMSpvVaultDataVault to deposit to
rawAmountsbigint[]Raw amounts to deposit (these are unscaled)
txOptions?TransactionConfirmationOptionsTransaction options

Returns

Promise<string>

Implementation of

SpvVaultContract.deposit


fromOpReturnData()

static fromOpReturnData(data): object;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:613

Parses withdrawal params from OP_RETURN data.

Parameters

ParameterTypeDescription
dataBufferData as specified in the OP_RETURN output of the transaction

Returns

object

NameTypeDefined in
executionHash?stringatomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:613
rawAmountsbigint[]atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:613
recipientstringatomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:613

fromOpReturnData()

fromOpReturnData(data): object;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:604

Parses withdrawal params from OP_RETURN data

Parameters

ParameterTypeDescription
dataBufferdata as specified in the OP_RETURN output of the transaction

Returns

object

NameTypeDefined in
executionHash?stringatomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:604
rawAmountsbigint[]atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:604
recipientstringatomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:604

Implementation of

SpvVaultContract.fromOpReturnData


frontLiquidity()

frontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
txOptions?): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:700

Signs & sends transactions for fronting liquidity for a specific withdrawal btc transaction

Parameters

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (payer of the fronted liquidity)
vaultEVMSpvVaultDataVault to deposit to
realWithdrawalTxEVMSpvWithdrawalDataReal withdrawal transaction data
withdrawSequencenumberSequence number of the withdrawal that is being fronted, this used as race condition prevention, such that fronting will not happen if the withdrawal tx is already used in claim()
txOptions?TransactionConfirmationOptionsTransaction options

Returns

Promise<string>

Implementation of

SpvVaultContract.frontLiquidity


getAllVaults()

getAllVaults(owner?): Promise<EVMSpvVaultData[]>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:353

Returns all currently opened vaults NOTE: This will take a long time, since the implementation will have to go through all the prior events

Parameters

ParameterType
owner?string

Returns

Promise<EVMSpvVaultData[]>

Implementation of

SpvVaultContract.getAllVaults


getClaimFee()

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

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:926

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

Parameters

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

Returns

Promise<bigint>

Implementation of

SpvVaultContract.getClaimFee


getClaimGas()

getClaimGas(
signer,
vault?,
data?): number;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:878

Returns an estimated gas amount for a claim transaction.

Parameters

ParameterTypeDescription
signerstringSigner address executing the claim
vault?EVMSpvVaultDataVault data used to determine transfer paths
data?EVMSpvWithdrawalDataParsed withdrawal data

Returns

number


getFronterAddress()

getFronterAddress(
owner,
vaultId,
withdrawal): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:236

Returns the party which currently fronted the withdrawal transaction

Parameters

ParameterTypeDescription
ownerstringOwner of the vault
vaultIdbigintVault ID
withdrawalEVMSpvWithdrawalDataWithdrawal transaction to check the fronting for

Returns

Promise<string>

Implementation of

SpvVaultContract.getFronterAddress


getFronterAddresses()

getFronterAddresses(withdrawals): Promise<{
[btcTxId: string]: string;
}>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:245

Returns the parties which currently fronted the withdrawal transactions

Parameters

ParameterTypeDescription
withdrawalsobject[]withdrawals to query

Returns

Promise<{ [btcTxId: string]: string; }>

Implementation of

SpvVaultContract.getFronterAddresses


getFrontFee()

getFrontFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:934

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

Parameters

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

Returns

Promise<bigint>

Implementation of

SpvVaultContract.getFrontFee


getFrontGas()

getFrontGas(
signer,
vault,
data?): number;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:907

Returns an estimated gas amount for a front-liquidity transaction.

Parameters

ParameterTypeDescription
signerstringSigner address executing the front action
vaultEVMSpvVaultDataVault data used to determine transfer paths
data?EVMSpvWithdrawalDataParsed withdrawal data

Returns

number


getHistoricalWithdrawalStates()

getHistoricalWithdrawalStates(recipient, startBlockheight?): Promise<{
latestBlockheight?: number;
withdrawals: {
[btcTxId: string]: SpvWithdrawalFrontedState | SpvWithdrawalClaimedState;
};
}>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:569

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

Parameters

ParameterTypeDescription
recipientstringA recipient to check the history for
startBlockheight?number

Returns

Promise<{ latestBlockheight?: number; withdrawals: { [btcTxId: string]: SpvWithdrawalFrontedState | SpvWithdrawalClaimedState; }; }>

Implementation of

SpvVaultContract.getHistoricalWithdrawalStates


getMultipleVaultData()

getMultipleVaultData(vaults): Promise<{
[owner: string]: object;
}>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:301

Returns current vault data for multiple vaults

Parameters

ParameterTypeDescription
vaultsobject[]Vault data to query

Returns

Promise<{ [owner: string]: object; }>

Implementation of

SpvVaultContract.getMultipleVaultData


getVaultData()

getVaultData(owner, vaultId): Promise<EVMSpvVaultData>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:269

Returns current vault data

Parameters

ParameterTypeDescription
ownerstringOwner of the vault
vaultIdbigintVault ID

Returns

Promise<EVMSpvVaultData>

Implementation of

SpvVaultContract.getVaultData


getVaultLatestUtxo()

getVaultLatestUtxo(owner, vaultId): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:322

Returns the latest utxo of a vault (or null if vault closed or not found)

Parameters

ParameterTypeDescription
ownerstringOwner of the vault
vaultIdbigintVault ID

Returns

Promise<string>

Implementation of

SpvVaultContract.getVaultLatestUtxo


getVaultLatestUtxos()

getVaultLatestUtxos(vaults): Promise<{
[owner: string]: object;
}>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:332

Returns the latest utxos of for multiple vaults (or null if vault closed or not found)

Parameters

ParameterTypeDescription
vaultsobject[]Vault data to query

Returns

Promise<{ [owner: string]: object; }>

Implementation of

SpvVaultContract.getVaultLatestUtxos


getWithdrawalData()

getWithdrawalData(btcTx): Promise<EVMSpvWithdrawalData>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:596

Parses withdrawal data from the parsed bitcoin transaction

Parameters

ParameterTypeDescription
btcTxBtcTx

Returns

Promise<EVMSpvWithdrawalData>

Implementation of

SpvVaultContract.getWithdrawalData


getWithdrawalState()

getWithdrawalState(withdrawalTx, scStartHeight?): Promise<SpvWithdrawalState>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:452

Returns current state of the withdrawal, optionally only check withdrawals from the provided block height

Parameters

ParameterTypeDescription
withdrawalTxEVMSpvWithdrawalData
scStartHeight?number

Returns

Promise<SpvWithdrawalState>

Implementation of

SpvVaultContract.getWithdrawalState


getWithdrawalStates()

getWithdrawalStates(withdrawalTxs): Promise<{
[btcTxId: string]: SpvWithdrawalState;
}>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:492

Returns current state of the withdrawals, optionally only check withdrawals from the provided block height

Parameters

ParameterTypeDescription
withdrawalTxsobject[]Object with the withdrawal tx to check + an optional start blockheight

Returns

Promise<{ [btcTxId: string]: SpvWithdrawalState; }>

Implementation of

SpvVaultContract.getWithdrawalStates


open()

open(
signer,
vault,
txOptions?): Promise<string>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:709

Signs & sends transactions for opening a specific spv vault

Parameters

ParameterTypeDescription
signerEVMSignerSigner to use for the transaction (must match owner in vault)
vaultEVMSpvVaultDataVault to init
txOptions?TransactionConfirmationOptionsTransaction options

Returns

Promise<string>

Implementation of

SpvVaultContract.open


toOpReturnData()

static toOpReturnData(
recipient,
rawAmounts,
executionHash?): Buffer;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:653

Serializes withdrawal params to OP_RETURN data.

Parameters

ParameterTypeDescription
recipientstringRecipient of the withdrawn tokens
rawAmountsbigint[]Raw amount of tokens to withdraw
executionHash?stringOptional execution hash of the actions to execute

Returns

Buffer


toOpReturnData()

toOpReturnData(
recipient,
rawAmounts,
executionHash?): Buffer;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:642

Serializes the withdrawal params to the OP_RETURN data

Parameters

ParameterTypeDescription
recipientstringRecipient of the withdrawn tokens
rawAmountsbigint[]Raw amount of tokens to withdraw
executionHash?stringOptional execution hash of the actions to execute

Returns

Buffer

Implementation of

SpvVaultContract.toOpReturnData


txsClaim()

txsClaim(
signer,
vault,
txs,
synchronizer?,
initAta?,
feeRate?): Promise<TransactionRequest[]>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:719

Returns the unsigned transactions for claiming the funds from a specific vault

Parameters

ParameterTypeDescription
signerstringSigner to use for the transaction
vaultEVMSpvVaultDataVault to claim from
txsobject[]
synchronizer?RelaySynchronizer<any, any, 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 transaction

Returns

Promise<TransactionRequest[]>

Implementation of

SpvVaultContract.txsClaim


txsDeposit()

txsDeposit(
signer,
vault,
rawAmounts,
feeRate?): Promise<TransactionRequest[]>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:773

Returns the unsigned transactions for depositing funds to a specific spv vault

Parameters

ParameterTypeDescription
signerstringSigner to use for the transaction (can be any)
vaultEVMSpvVaultDataVault to deposit to
rawAmountsbigint[]Raw amounts to deposit (these are unscaled)
feeRate?stringFee rate to use for the transaction

Returns

Promise<TransactionRequest[]>

Implementation of

SpvVaultContract.txsDeposit


txsFrontLiquidity()

txsFrontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
feeRate?): Promise<TransactionRequest[]>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:815

Returns the unsigned transactions for fronting liquidity for a specific withdrawal btc transaction

Parameters

ParameterTypeDescription
signerstringSigner to use for the transaction (payer of the fronted liquidity)
vaultEVMSpvVaultDataVault to deposit to
realWithdrawalTxEVMSpvWithdrawalDataReal withdrawal transaction data
withdrawSequencenumberSequence number of the withdrawal that is being fronted, this used as race condition prevention, such that fronting will not happen if the withdrawal tx is already used in claim()
feeRate?stringFee rate to use for the transaction

Returns

Promise<TransactionRequest[]>

Implementation of

SpvVaultContract.txsFrontLiquidity


txsOpen()

txsOpen(
signer,
vault,
feeRate?): Promise<TransactionRequest[]>;

Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:859

Returns the unsigned transactions for opening a specific spv vault

Parameters

ParameterTypeDescription
signerstringSigner to use for the transaction (must match owner in vault)
vaultEVMSpvVaultDataVault to init
feeRate?stringFee rate to use for the transaction

Returns

Promise<TransactionRequest[]>

Implementation of

SpvVaultContract.txsOpen