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
SpvVaultContract<EVMTx,EVMSigner,ChainId,EVMSpvWithdrawalData,EVMSpvVaultData>
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
| Parameter | Type |
|---|---|
chainInterface | EVMChainInterface<ChainId> |
btcRelay | EVMBtcRelay<any> |
bitcoinRpc | BitcoinRpc<any> |
contractAddress | string |
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
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:192
Checks if given withdrawal tx is valid and correctly parses on-chain, throws error when there is any issue with the validation
Parameters
| Parameter | Type | Description |
|---|---|---|
tx | SpvWithdrawalTransactionData |
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:681
Signs & sends transactions for claiming the funds from a specific vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | EVMSigner | Signer to use for the transaction |
vault | EVMSpvVaultData | Vault to claim from |
txs | object[] | |
synchronizer? | RelaySynchronizer<any, any, any> | Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight |
initAta? | boolean | Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs) |
txOptions? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
Implementation of
createVaultData()
createVaultData(
owner,
vaultId,
utxo,
confirmations,
tokenData): Promise<EVMSpvVaultData>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:200
Creates vault data for a new vault
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Vault owner |
vaultId | bigint | Vault ID |
utxo | string | Utxo on which to assign the vault initially |
confirmations | number | Required number of bitcoin confirmations to be able to withdraw funds from the vault |
tokenData | SpvVaultTokenData[] | 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:690
Signs & sends transactions for depositing funds to a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | EVMSigner | Signer to use for the transaction (can be any) |
vault | EVMSpvVaultData | Vault to deposit to |
rawAmounts | bigint[] | Raw amounts to deposit (these are unscaled) |
txOptions? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
Implementation of
fromOpReturnData()
static fromOpReturnData(data): object;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:612
Parses withdrawal params from OP_RETURN data.
Parameters
| Parameter | Type | Description |
|---|---|---|
data | Buffer | Data as specified in the OP_RETURN output of the transaction |
Returns
object
| Name | Type | Defined in |
|---|---|---|
executionHash? | string | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:612 |
rawAmounts | bigint[] | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:612 |
recipient | string | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:612 |
fromOpReturnData()
fromOpReturnData(data): object;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:603
Parses withdrawal params from OP_RETURN data
Parameters
| Parameter | Type | Description |
|---|---|---|
data | Buffer | data as specified in the OP_RETURN output of the transaction |
Returns
object
| Name | Type | Defined in |
|---|---|---|
executionHash? | string | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:603 |
rawAmounts | bigint[] | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:603 |
recipient | string | atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:603 |
Implementation of
SpvVaultContract.fromOpReturnData
frontLiquidity()
frontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
txOptions?): Promise<string>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:699
Signs & sends transactions for fronting liquidity for a specific withdrawal btc transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | EVMSigner | Signer to use for the transaction (payer of the fronted liquidity) |
vault | EVMSpvVaultData | Vault to deposit to |
realWithdrawalTx | EVMSpvWithdrawalData | Real withdrawal transaction data |
withdrawSequence | number | Sequence 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? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
Implementation of
SpvVaultContract.frontLiquidity
getAllVaults()
getAllVaults(owner?): Promise<EVMSpvVaultData[]>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:352
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
| Parameter | Type |
|---|---|
owner? | string |
Returns
Promise<EVMSpvVaultData[]>
Implementation of
getClaimFee()
getClaimFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:925
Returns the fee in native token base units to claim the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | EVMSpvVaultData | |
withdrawalData? | EVMSpvWithdrawalData | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
Implementation of
getClaimGas()
getClaimGas(
signer,
vault?,
data?): number;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:877
Returns an estimated gas amount for a claim transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer address executing the claim |
vault? | EVMSpvVaultData | Vault data used to determine transfer paths |
data? | EVMSpvWithdrawalData | Parsed withdrawal data |
Returns
number
getFronterAddress()
getFronterAddress(
owner,
vaultId,
withdrawal): Promise<string>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:235
Returns the party which currently fronted the withdrawal transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Owner of the vault |
vaultId | bigint | Vault ID |
withdrawal | EVMSpvWithdrawalData | Withdrawal 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:244
Returns the parties which currently fronted the withdrawal transactions
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawals | object[] | 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:933
Returns the fee in native token base units to claim the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | EVMSpvVaultData | |
withdrawalData? | EVMSpvWithdrawalData | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
Implementation of
getFrontGas()
getFrontGas(
signer,
vault,
data?): number;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:906
Returns an estimated gas amount for a front-liquidity transaction.
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer address executing the front action |
vault | EVMSpvVaultData | Vault data used to determine transfer paths |
data? | EVMSpvWithdrawalData | Parsed 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:568
Returns the full history as fetched from the chain for a specific recipient
Parameters
| Parameter | Type | Description |
|---|---|---|
recipient | string | A 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:300
Returns current vault data for multiple vaults
Parameters
| Parameter | Type | Description |
|---|---|---|
vaults | object[] | 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:268
Returns current vault data
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Owner of the vault |
vaultId | bigint | Vault ID |
Returns
Promise<EVMSpvVaultData>
Implementation of
getVaultLatestUtxo()
getVaultLatestUtxo(owner, vaultId): Promise<string>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:321
Returns the latest utxo of a vault (or null if vault closed or not found)
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Owner of the vault |
vaultId | bigint | Vault 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:331
Returns the latest utxos of for multiple vaults (or null if vault closed or not found)
Parameters
| Parameter | Type | Description |
|---|---|---|
vaults | object[] | 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:595
Parses withdrawal data from the parsed bitcoin transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
btcTx | BtcTx |
Returns
Promise<EVMSpvWithdrawalData>
Implementation of
SpvVaultContract.getWithdrawalData
getWithdrawalState()
getWithdrawalState(withdrawalTx, scStartHeight?): Promise<SpvWithdrawalState>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:451
Returns current state of the withdrawal, optionally only check withdrawals from the provided block height
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawalTx | EVMSpvWithdrawalData | |
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:491
Returns current state of the withdrawals, optionally only check withdrawals from the provided block height
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawalTxs | object[] | 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:708
Signs & sends transactions for opening a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | EVMSigner | Signer to use for the transaction (must match owner in vault) |
vault | EVMSpvVaultData | Vault to init |
txOptions? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
Implementation of
toOpReturnData()
static toOpReturnData(
recipient,
rawAmounts,
executionHash?): Buffer;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:652
Serializes withdrawal params to OP_RETURN data.
Parameters
| Parameter | Type | Description |
|---|---|---|
recipient | string | Recipient of the withdrawn tokens |
rawAmounts | bigint[] | Raw amount of tokens to withdraw |
executionHash? | string | Optional 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:641
Serializes the withdrawal params to the OP_RETURN data
Parameters
| Parameter | Type | Description |
|---|---|---|
recipient | string | Recipient of the withdrawn tokens |
rawAmounts | bigint[] | Raw amount of tokens to withdraw |
executionHash? | string | Optional 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:718
Returns the unsigned transactions for claiming the funds from a specific vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer to use for the transaction |
vault | EVMSpvVaultData | Vault to claim from |
txs | object[] | |
synchronizer? | RelaySynchronizer<any, any, any> | Optiona synchronizer to be used if BTC relay contract is not synced up to the required blockheight |
initAta? | boolean | Whether to initialize a token account if it doesn't exist (applies to e.g. Solana, with token specific ATAs) |
feeRate? | string | Fee rate to use for the transaction |
Returns
Promise<TransactionRequest[]>
Implementation of
txsDeposit()
txsDeposit(
signer,
vault,
rawAmounts,
feeRate?): Promise<TransactionRequest[]>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:772
Returns the unsigned transactions for depositing funds to a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer to use for the transaction (can be any) |
vault | EVMSpvVaultData | Vault to deposit to |
rawAmounts | bigint[] | Raw amounts to deposit (these are unscaled) |
feeRate? | string | Fee rate to use for the transaction |
Returns
Promise<TransactionRequest[]>
Implementation of
txsFrontLiquidity()
txsFrontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
feeRate?): Promise<TransactionRequest[]>;
Defined in: atomiq-chain-evm/src/evm/spv_swap/EVMSpvVaultContract.ts:814
Returns the unsigned transactions for fronting liquidity for a specific withdrawal btc transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer to use for the transaction (payer of the fronted liquidity) |
vault | EVMSpvVaultData | Vault to deposit to |
realWithdrawalTx | EVMSpvWithdrawalData | Real withdrawal transaction data |
withdrawSequence | number | Sequence 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? | string | Fee 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:858
Returns the unsigned transactions for opening a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer to use for the transaction (must match owner in vault) |
vault | EVMSpvVaultData | Vault to init |
feeRate? | string | Fee rate to use for the transaction |
Returns
Promise<TransactionRequest[]>