-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* GITBOOK-16: No subject * GITBOOK-17: No subject * GITBOOK-19: No subject
- Loading branch information
Showing
13 changed files
with
786 additions
and
20 deletions.
There are no files selected for viewing
Binary file not shown.
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,3 @@ | ||
# Stellar Asset Contract Handler | ||
|
||
Coming Soon |
106 changes: 106 additions & 0 deletions
106
docs/reference/contracts/certificate-of-deposit-client.md
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,2 +1,108 @@ | ||
# Certificate of Deposit Client | ||
|
||
The `CertificateOfDepositClient` class extends `ContractEngine` to interact with a specific smart contract implementation for a Certificate of Deposit on the Stellar network. It implements methods for managing deposits, withdrawals, and fetching contract-related data. | ||
|
||
{% hint style="info" %} | ||
Refer to the [e2e-certificate-of-deposit-demo.md](../../tutorials/e2e-certificate-of-deposit-demo.md "mention") for a detailed use case and code example including this client. A fully integrated version of this contract implementation with UI can also be seen at the [Custodial Asset Sandbox](https://stellar.cheesecakelabs.com/). | ||
{% endhint %} | ||
|
||
## **Constructor** | ||
|
||
* **Parameters**: | ||
* `contractId`: Contract ID of the deployed contract. | ||
* `network`: Network configuration. | ||
* `rpcHandler`: RPC handler for interactions. | ||
* **Purpose**: Initializes the client with the necessary configurations to interact with the Certificate of Deposit contract. | ||
|
||
## **Methods** | ||
|
||
### deposit | ||
|
||
* **Purpose**: Deposits assets into the contract. | ||
* **Parameters**: | ||
* `address`: Account address making the deposit. | ||
* `amount`: Deposit amount. | ||
* `signers`: Authorizing signers. | ||
* `header`: Transaction header. | ||
* `feeBump`: Optional fee bump. | ||
|
||
### withdraw | ||
|
||
* **Purpose**: Withdraws assets from the contract. | ||
* **Parameters**: | ||
* `address`: Account address withdrawing assets. | ||
* `acceptPrematureWithdraw`: Flag for premature withdrawal acceptance. | ||
* `signers`: Authorizing signers. | ||
* `header`: Transaction header. | ||
* `feeBump`: Optional fee bump. | ||
|
||
### getEstimatedYield | ||
|
||
* **Purpose**: Fetches estimated yield. | ||
* **Parameters**: | ||
* `address`: Account address. | ||
* `header`: Transaction header. | ||
|
||
### getPosition | ||
|
||
* **Purpose**: Retrieves current position. | ||
* **Parameters**: | ||
* `address`: Account address. | ||
* `header`: Transaction header. | ||
|
||
### getEstimatedPrematureWithdraw | ||
|
||
* **Purpose**: Estimates premature withdrawal amount. | ||
* **Parameters**: | ||
* `address`: Account address. | ||
* `header`: Transaction header. | ||
|
||
### getTimeLeft | ||
|
||
* **Purpose**: Determines time left for penalty-free withdrawal. | ||
* **Parameters**: | ||
* `address`: Account address. | ||
* `header`: Transaction header. | ||
|
||
### initialize | ||
|
||
* **Purpose**: Initializes contract state. | ||
* **Parameters**: | ||
* `admin`, `asset`, `term`, `compoundStep`, `yieldRate`, `minDeposit`, `penaltyRate`, `allowancePeriod`: Contract parameters. | ||
* `signers`: Authorizing signers. | ||
* `header`: Transaction header. | ||
* `feeBump`: Optional fee bump. | ||
|
||
{% hint style="info" %} | ||
The initialization parameters affect the CD rules as the following: | ||
|
||
|
||
|
||
* **Admin**\ | ||
Defines which account can manage the CD contract and also receives and provides the funds from/to the users. | ||
* **Asset** \ | ||
The contract id of the Stellar Asset Contract for the wrapped Classic Asset this CD interacts with. | ||
* **Term** (seconds)\ | ||
For how long this CD will accrue interest to a open deposit position. | ||
* **Compound Step** (seconds)\ | ||
How often will the interest be paid/compound. If set to '0', a different yield rate calculation is used and the interest rate will be applied linearly until the end of the term. | ||
* **Yield Rate** (1 unit = 0.01%)\ | ||
How much interest will be paid out. For compounding interest, this means at every compound interval, while the linear rate will reach this rate at the end of the term. | ||
* **Minimum Deposit**\ | ||
Minimum amount accepted for a deposit. | ||
* **Penalty Rate** (1 unit = 0.01%)\ | ||
If a user accepts the early withdraw, before the term is finished, this penalty rate will be applied to the earned interest. \ | ||
\ | ||
E.g. _A 200 units position (100 deposit + 100 earned yield) withdrawing early with a penalty rate of 50% will receive 150 units(100 deposit + 50 earned yield)_  | ||
|
||
$$ | ||
Withdrawn Amount=Deposit+(Yield−Penalty Rate×Yield) | ||
$$ | ||
|
||
* **Allowance Period** (Expiration ledger number)\ | ||
Until which ledger will the allowance for the contract to access the admin funds be valid. | ||
{% endhint %} | ||
|
||
|
||
|
||
This class provides a structured and convenient way to interact with the Certificate of Deposit contract on the Stellar network, encapsulating complex contract interactions into simpler method calls. |
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
97 changes: 97 additions & 0 deletions
97
docs/reference/core/channel-accounts-transaction-submitter.md
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,2 +1,99 @@ | ||
# Channel Accounts Transaction Submitter | ||
|
||
### ChannelAccountsTransactionSubmitter Class Overview | ||
|
||
The `ChannelAccountsTransactionSubmitter` class, implementing the `TransactionSubmitter` interface, is specifically designed for submitting transactions using a pool of channel accounts. This class is vital in scenarios where high transaction throughput is required on the Stellar network. It manages multiple channel accounts to parallelize transaction submissions, optimizing network interactions and reducing potential sequence errors. \ | ||
\ | ||
For more in-depth information refer to Stellar's official documentation on [Channel Accounts](https://developers.stellar.org/docs/encyclopedia/channel-accounts). | ||
|
||
|
||
|
||
{% hint style="info" %} | ||
See the [bulk-payments.md](../../tutorials/bulk-payments.md "mention") tutorial on how this class can be utilized to perform several payments in parallel | ||
{% endhint %} | ||
|
||
### Core Functionalities | ||
|
||
* #### Constructor | ||
|
||
* **Parameters**: | ||
* `network`: Configuration for the Stellar network. | ||
* `feeBump` (optional): Details for fee bumping transactions.\ | ||
|
||
|
||
#### registerChannels | ||
|
||
* **Purpose**: Adds channel accounts to the pool for transaction processing. | ||
* **Parameters**: `channels` (Array of `DefaultAccountHandler`).\ | ||
|
||
|
||
#### createEnvelope | ||
|
||
* **Purpose**: Creates a transaction envelope using a channel account. | ||
* **Parameters**: `txInvocation` (TransactionInvocation). | ||
* **Returns**: Object containing `TransactionBuilder` and updated transaction invocation.\ | ||
|
||
|
||
#### submit | ||
|
||
* **Purpose**: Submits a transaction to the Stellar network. | ||
* **Parameters**: `envelope` (Transaction or FeeBumpTransaction). | ||
* **Returns**: Response from the Horizon server.\ | ||
|
||
|
||
#### postProcessTransaction | ||
|
||
* **Purpose**: Handles the response after transaction submission. | ||
* **Parameters**: `response` (HorizonNamespace.SubmitTransactionResponse). | ||
* **Returns**: Processed transaction data or error on failure.\ | ||
|
||
|
||
#### noChannelPipeline | ||
|
||
* **Purpose**: Provides a fallback mechanism when no free channel is available. | ||
* **Returns**: Allocated `DefaultAccountHandler` after a waiting period.\ | ||
|
||
|
||
#### getChannels | ||
|
||
* **Purpose**: Retrieves the list of registered channel accounts. | ||
* **Returns**: Array of `DefaultAccountHandler`.\ | ||
|
||
|
||
The `ChannelAccountsTransactionSubmitter` plays a critical role in the transaction processing pipeline, especially when handling high volumes of transactions. It ensures efficient transaction submission by utilizing channel accounts, and it manages the allocation and release of these accounts to optimize network throughput. | ||
|
||
### How to use | ||
|
||
1. **Create TransactionSubmitter Instance**: Instantiate the `ChannelAccountsTransactionSubmitter` with the Stellar network configuration and optional fee bump settings. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
const transactionSubmitter = new | ||
StellarPlus.Core.Classic.ChannelAccountsTransactionSubmitter(network, | ||
defaultFeeBump); | ||
``` | ||
{% endcode %} | ||
2. **Register Channel Accounts**: Initialize and register channel accounts for transaction processing. This step is crucial for handling high-frequency transactions. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
await transactionSubmitter.registerChannels( | ||
await StellarPlus.Utils.ChannelAccountsHandler.openChannels({ | ||
/* ... */ }) | ||
); | ||
``` | ||
{% endcode %} | ||
3. **Use the Submitter:** Provide the submitter to a Soroban class that extends the [soroban-transaction-processor.md](soroban-transaction-processor.md "mention") and accepts a Submitter instance. All transactions processed by this instance will make use of the channel accounts. | ||
|
||
{% code overflow="wrap" %} | ||
```typescript | ||
const cakeToken = new StellarPlus.Asset.ClassicAssetHandler( | ||
"CAKE", | ||
issuerAccount.getPublicKey(), | ||
network, | ||
issuerAccount, | ||
transactionSubmitter | ||
); | ||
``` | ||
{% endcode %} |
Oops, something went wrong.