SpvVaultContract<TX, Signer, ChainId, WithdrawalTX, Data>
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:20
Represents an SPV vault (UTXO-controlled vault) contract, exposes operations on the vaults
Type Parameters
| Type Parameter | Default type |
|---|---|
TX | any |
Signer extends AbstractSigner | AbstractSigner |
ChainId extends string | string |
WithdrawalTX extends SpvWithdrawalTransactionData | SpvWithdrawalTransactionData |
Data extends SpvVaultData<WithdrawalTX> | SpvVaultData<WithdrawalTX> |
Properties
chainId
readonly chainId: ChainId;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:31
Chain identifier string
Methods
checkWithdrawalTx()
checkWithdrawalTx(tx): Promise<void>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:237
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 | WithdrawalTX |
Returns
Promise<void>
claim()
claim(
signer,
vault,
txs,
synchronizer?,
initAta?,
txOptions?): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:105
Signs & sends transactions for claiming the funds from a specific vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer to use for the transaction |
vault | Data | Vault to claim from |
txs | object[] | |
synchronizer? | RelaySynchronizer<any, TX, 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>
createVaultData()
createVaultData(
owner,
vaultId,
utxo,
confirmations,
tokenData): Promise<Data>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:140
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<Data>
deposit()
deposit(
signer,
vault,
rawAmounts,
txOptions?): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:59
Signs & sends transactions for depositing funds to a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer to use for the transaction (can be any) |
vault | Data | Vault to deposit to |
rawAmounts | bigint[] | Raw amounts to deposit (these are unscaled) |
txOptions? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
fromOpReturnData()
fromOpReturnData(data): object;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:253
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-base/src/spv_swap/SpvVaultContract.ts:253 |
rawAmounts | bigint[] | atomiq-base/src/spv_swap/SpvVaultContract.ts:253 |
recipient | string | atomiq-base/src/spv_swap/SpvVaultContract.ts:253 |
frontLiquidity()
frontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
txOptions?): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:81
Signs & sends transactions for fronting liquidity for a specific withdrawal btc transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer to use for the transaction (payer of the fronted liquidity) |
vault | Data | Vault to deposit to |
realWithdrawalTx | WithdrawalTX | 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>
getAllVaults()
getAllVaults(owner?): Promise<Data[]>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:192
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<Data[]>
getClaimFee()
getClaimFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:263
Returns the fee in native token base units to claim the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | Data | |
withdrawalData? | WithdrawalTX | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
getFronterAddress()
getFronterAddress(
owner,
vaultId,
withdrawal): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:149
Returns the party which currently fronted the withdrawal transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Owner of the vault |
vaultId | bigint | Vault ID |
withdrawal | WithdrawalTX | Withdrawal transaction to check the fronting for |
Returns
Promise<string>
getFronterAddresses()
getFronterAddresses(withdrawals): Promise<{
[btcTxId: string]: string;
}>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:156
Returns the parties which currently fronted the withdrawal transactions
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawals | object[] | withdrawals to query |
Returns
Promise<{
[btcTxId: string]: string;
}>
getFrontFee()
getFrontFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:283
Returns the fee in native token base units to claim the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | Data | |
withdrawalData? | WithdrawalTX | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
getHistoricalWithdrawalStates()?
optional getHistoricalWithdrawalStates(recipient, startBlockheight?): Promise<{
latestBlockheight?: number;
withdrawals: {
[btcTxId: string]: SpvWithdrawalFrontedState | SpvWithdrawalClaimedState;
};
}>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:217
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;
};
}>
getMultipleVaultData()
getMultipleVaultData(vaults): Promise<{
[owner: string]: object;
}>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:171
Returns current vault data for multiple vaults
Parameters
| Parameter | Type | Description |
|---|---|---|
vaults | object[] | Vault data to query |
Returns
Promise<{
[owner: string]: object;
}>
getRawClaimFee()?
optional getRawClaimFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:273
Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | Data | |
withdrawalData? | WithdrawalTX | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
getRawFrontFee()?
optional getRawFrontFee(
signer,
vault?,
withdrawalData?,
feeRate?): Promise<bigint>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:293
Returns raw fee (not including any refunds we might get that would make the getClaimFee negative) for claiming the swap
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | string | Signer claiming the swap |
vault? | Data | |
withdrawalData? | WithdrawalTX | Withdrawal to claim |
feeRate? | string | Optional fee rate (fetched on-demand if not provided) |
Returns
Promise<bigint>
getVaultData()
getVaultData(owner, vaultId): Promise<Data>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:164
Returns current vault data
Parameters
| Parameter | Type | Description |
|---|---|---|
owner | string | Owner of the vault |
vaultId | bigint | Vault ID |
Returns
Promise<Data>
getVaultLatestUtxo()
getVaultLatestUtxo(owner, vaultId): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:179
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>
getVaultLatestUtxos()
getVaultLatestUtxos(vaults): Promise<{
[owner: string]: object;
}>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:186
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;
}>
getWithdrawalData()
getWithdrawalData(btcTx): Promise<WithdrawalTX>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:229
Parses withdrawal data from the parsed bitcoin transaction
Parameters
| Parameter | Type | Description |
|---|---|---|
btcTx | BtcTx |
Returns
Promise<WithdrawalTX>
getWithdrawalState()
getWithdrawalState(withdrawalTx, scStartBlockheight?): Promise<SpvWithdrawalState>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:201
Returns current state of the withdrawal, optionally only check withdrawals from the provided block height
Parameters
| Parameter | Type | Description |
|---|---|---|
withdrawalTx | WithdrawalTX | |
scStartBlockheight? | number |
Returns
Promise<SpvWithdrawalState>
getWithdrawalStates()
getWithdrawalStates(withdrawalTxs): Promise<{
[btcTxId: string]: SpvWithdrawalState;
}>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:209
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;
}>
open()
open(
signer,
vault,
txOptions?): Promise<string>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:40
Signs & sends transactions for opening a specific spv vault
Parameters
| Parameter | Type | Description |
|---|---|---|
signer | Signer | Signer to use for the transaction (must match owner in vault) |
vault | Data | Vault to init |
txOptions? | TransactionConfirmationOptions | Transaction options |
Returns
Promise<string>
toOpReturnData()
toOpReturnData(
recipient,
rawAmounts,
executionHash?): Buffer;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:246
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
txsClaim()
txsClaim(
signer,
vault,
txs,
synchronizer?,
initAta?,
feeRate?): Promise<TX[]>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:123
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 | Data | Vault to claim from |
txs | object[] | |
synchronizer? | RelaySynchronizer<any, TX, 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<TX[]>
txsDeposit()
txsDeposit(
signer,
vault,
rawAmounts,
feeRate?): Promise<TX[]>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:69
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 | Data | Vault to deposit to |
rawAmounts | bigint[] | Raw amounts to deposit (these are unscaled) |
feeRate? | string | Fee rate to use for the transaction |
Returns
Promise<TX[]>
txsFrontLiquidity()
txsFrontLiquidity(
signer,
vault,
realWithdrawalTx,
withdrawSequence,
feeRate?): Promise<TX[]>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:93
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 | Data | Vault to deposit to |
realWithdrawalTx | WithdrawalTX | 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<TX[]>
txsOpen()
txsOpen(
signer,
vault,
feeRate?): Promise<TX[]>;
Defined in: atomiq-base/src/spv_swap/SpvVaultContract.ts:49
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 | Data | Vault to init |
feeRate? | string | Fee rate to use for the transaction |
Returns
Promise<TX[]>