-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement redemptions with a proxy for redemption integrations (#814)
In this PR we introduce a RedeemerProxy interface that can be used by integrators to route tBTC redemption through the tBTC Bridge. An example of the integrator is Acre's [BitcoinRedeemer contract](https://github.com/thesis/acre/blob/main/solidity/contracts/BitcoinRedeemer.sol) that requires the redemption data to handle stBTC -> tBTC -> Bitcoin conversion in one transaction. When redeeming tBTC the challenge is to assemble redemption data to contain valid wallet UTXO and other data in the format expected by the Bridge. It is expected that the integrator will implement `RedeemerProxy` interface by exposing two functions: - `redeemerAddress(): ChainIdentifier` - that will return the Ethereum address to which the tBTC balance will be assigned in case of problems with redemption, - `requestRedemption(redemptionData: Hex): Promise<Hex>` - a callback function that will be called with assembled `redemptionData` to proceed with a custom integrator's logic. The integrator should use the `requestRedemptionWithProxy` function to execute the redemption.
- Loading branch information
Showing
13 changed files
with
480 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Interface: RedeemerProxy | ||
|
||
Interface defining functions required to route tBTC redemption requests through | ||
the tBTC bridge by custom integrators. | ||
|
||
## Table of contents | ||
|
||
### Methods | ||
|
||
- [redeemerAddress](RedeemerProxy.md#redeemeraddress) | ||
- [requestRedemption](RedeemerProxy.md#requestredemption) | ||
|
||
## Methods | ||
|
||
### redeemerAddress | ||
|
||
▸ **redeemerAddress**(): [`ChainIdentifier`](ChainIdentifier.md) | ||
|
||
Chain identifier of the redeemer. This is the address that will be able to | ||
claim the tBTC tokens if anything goes wrong during the redemption process. | ||
|
||
#### Returns | ||
|
||
[`ChainIdentifier`](ChainIdentifier.md) | ||
|
||
#### Defined in | ||
|
||
[src/services/redemptions/redeemer-proxy.ts:13](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redeemer-proxy.ts#L13) | ||
|
||
___ | ||
|
||
### requestRedemption | ||
|
||
▸ **requestRedemption**(`redemptionData`): `Promise`\<[`Hex`](../classes/Hex.md)\> | ||
|
||
Requests redemption of tBTC token with determined redemption data. | ||
|
||
#### Parameters | ||
|
||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `redemptionData` | [`Hex`](../classes/Hex.md) | Data required to redeem the tBTC tokens. | | ||
|
||
#### Returns | ||
|
||
`Promise`\<[`Hex`](../classes/Hex.md)\> | ||
|
||
Target chain hash of the request redemption transaction | ||
(for example, Ethereum transaction hash) | ||
|
||
#### Defined in | ||
|
||
[src/services/redemptions/redeemer-proxy.ts:21](https://github.com/keep-network/tbtc-v2/blob/main/typescript/src/services/redemptions/redeemer-proxy.ts#L21) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./redemptions-service" | ||
export * from "./redeemer-proxy" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ChainIdentifier } from "../../lib/contracts" | ||
import { Hex } from "../../lib/utils" | ||
|
||
/** | ||
* Interface defining functions required to route tBTC redemption requests through | ||
* the tBTC bridge by custom integrators. | ||
*/ | ||
export interface RedeemerProxy { | ||
/** | ||
* Chain identifier of the redeemer. This is the address that will be able to | ||
* claim the tBTC tokens if anything goes wrong during the redemption process. | ||
*/ | ||
redeemerAddress(): ChainIdentifier | ||
|
||
/** | ||
* Requests redemption of tBTC token with determined redemption data. | ||
* @param redemptionData Data required to redeem the tBTC tokens. | ||
* @returns Target chain hash of the request redemption transaction | ||
* (for example, Ethereum transaction hash) | ||
*/ | ||
requestRedemption(redemptionData: Hex): Promise<Hex> | ||
} |
Oops, something went wrong.