Skip to content

Commit c28d48d

Browse files
committed
refactor(docs): streamline Firelight vault guides by renumbering sections for clarity
1 parent 6040ff4 commit c28d48d

File tree

9 files changed

+44
-137
lines changed

9 files changed

+44
-137
lines changed

docs/fassets/firelight/deposit.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,15 @@ The script starts by defining constants and importing the required contract inte
4444
Taken from the Firelight GitHub [repository](https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol).
4545
- `IERC20`: Standard [ERC-20](https://eips.ethereum.org/EIPS/eip-20) interface for token interactions.
4646

47-
### 2. Get Asset Information
48-
49-
The script retrieves the underlying asset information to format amounts and calculate the deposit amount from the vault:
50-
51-
- **Asset address**: The token address that the vault accepts (e.g., FXRP).
52-
- **Asset symbol**: The token symbol for display purposes.
53-
- **Asset decimals**: The number of decimals used by the token.
54-
55-
### 3. Calculate Deposit Amount
47+
### 2. Calculate Deposit Amount
5648

5749
The script converts the desired deposit amount into the correct units:
5850

5951
```typescript
6052
const amount = DEPOSIT_AMOUNT * 10 ** assetDecimals;
6153
```
6254

63-
### 4. Check Maximum Deposit Capacity
55+
### 3. Check Maximum Deposit Capacity
6456

6557
Before depositing, the script checks if the requested amount exceeds the maximum allowed:
6658

@@ -72,7 +64,7 @@ The `maxDeposit` function returns the maximum amount of assets that the specifie
7264

7365
If the requested amount exceeds the maximum, the script exits with an error to prevent a failed transaction.
7466

75-
### 5. Approve Token Transfer
67+
### 4. Approve Token Transfer
7668

7769
Before depositing, the script must approve the vault to spend the deposit amount:
7870

@@ -85,7 +77,7 @@ const approveTx = await assetToken.approve(vault.address, amount, {
8577
This approval is required because the vault needs to transfer assets from the user's account.
8678
The approval amount should match or exceed the `amount` value to be deposited.
8779

88-
### 6. Deposit Assets
80+
### 5. Deposit Assets
8981

9082
Finally, the script deposits the assets:
9183

docs/fassets/firelight/mint.mdx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,15 @@ The script starts by defining constants and importing the required contract inte
4444
Taken from the Firelight GitHub [repository](https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol).
4545
- `IERC20`: Standard [ERC-20](https://eips.ethereum.org/EIPS/eip-20) interface for token interactions.
4646

47-
### 2. Get Asset Information
48-
49-
The script retrieves the underlying asset information to format amounts and calculate the required asset amount for minting shares from the vault:
50-
51-
- **Asset address**: The token address that the vault accepts (e.g., FXRP).
52-
- **Asset symbol**: The token symbol for display purposes.
53-
- **Asset decimals**: The number of decimals used by the token.
54-
55-
### 3. Calculate Shares to Mint
47+
### 2. Calculate Shares to Mint
5648

5749
The script converts the desired number of shares to mint into the correct units:
5850

5951
```typescript
6052
const sharesToMint = SHARES_TO_MINT * 10 ** assetDecimalsNum;
6153
```
6254

63-
### 4. Check Maximum Mint Capacity
55+
### 3. Check Maximum Mint Capacity
6456

6557
Before minting, the script checks if the requested amount exceeds the maximum allowed:
6658

@@ -72,7 +64,7 @@ The `maxMint` function returns the maximum number of shares that the specified a
7264

7365
If the requested amount exceeds the maximum, the script exits with an error to prevent a failed transaction.
7466

75-
### 5. Calculate Required Assets
67+
### 4. Calculate Required Assets
7668

7769
The script uses the `previewMint` function to calculate how many assets are needed to mint the desired number of shares:
7870

@@ -82,7 +74,7 @@ const assetsNeeded = await vault.previewMint(sharesToMint);
8274

8375
The `previewMint` function is part of the [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) standard and returns the amount of assets required to mint a specific number of shares, accounting for the current exchange rate between assets and shares.
8476

85-
### 6. Approve Token Transfer
77+
### 5. Approve Token Transfer
8678

8779
Before minting, the script must approve the vault to spend the required amount of assets:
8880

@@ -95,7 +87,7 @@ const approveTx = await assetToken.approve(vault.address, assetsNeeded, {
9587
This approval is required because the vault needs to transfer assets from the user's account.
9688
The approval amount should match or exceed the `assetsNeeded` value calculated in the previous step.
9789

98-
### 7. Mint Vault Shares
90+
### 6. Mint Vault Shares
9991

10092
Finally, the script mints the vault shares:
10193

docs/fassets/firelight/redeem.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ The script starts by defining constants and importing the required contract inte
4545
Taken from the Firelight GitHub [repository](https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol).
4646
- `IERC20`: Standard [ERC-20](https://eips.ethereum.org/EIPS/eip-20) interface for token interactions.
4747

48-
### 2. Get Asset Information
49-
50-
The script retrieves the underlying asset information to format amounts and calculate the redemption amount from the vault:
51-
52-
- **Asset address**: The token address that the vault holds (e.g., FXRP).
53-
- **Asset symbol**: The token symbol for display purposes.
54-
- **Asset decimals**: The number of decimals used by the token.
55-
56-
### 3. Calculate Shares to Redeem
48+
### 2. Calculate Shares to Redeem
5749

5850
The script converts the desired number of shares to redeem into the correct units:
5951

6052
```typescript
6153
const sharesToRedeem = SHARES_TO_REDEEM * 10 ** assetDecimalsNum;
6254
```
6355

64-
### 4. Check Maximum Redemption Capacity
56+
### 3. Check Maximum Redemption Capacity
6557

6658
Before redeeming, the script checks if the requested amount exceeds the maximum allowed:
6759

@@ -72,7 +64,7 @@ const maxRedeem = await vault.maxRedeem(account);
7264
The `maxRedeem` function returns the maximum number of shares that the specified account can redeem.
7365
If the requested amount exceeds the maximum, the script exits with an error to prevent a failed transaction.
7466

75-
### 5. Check User Balance
67+
### 4. Check User Balance
7668

7769
The script displays the user's current vault share balance and validates that they have sufficient shares:
7870

@@ -83,7 +75,7 @@ const userBalance = await vault.balanceOf(account);
8375
The script then validates that the user has sufficient shares to cover the redemption request.
8476
This validation ensures the redemption will succeed before attempting the transaction.
8577

86-
### 6. Create Redemption Request
78+
### 5. Create Redemption Request
8779

8880
Finally, the script creates a redemption request:
8981

docs/fassets/firelight/status.mdx

Lines changed: 10 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import FirelightStatus from "!!raw-loader!/examples/developer-hub-javascript/fir
1212

1313
## Overview
1414

15-
This guide demonstrates how to retrieve and display information about a Firelight vault, including vault metrics, period configuration, user balances, and withdrawal information.
15+
This guide demonstrates how to retrieve information about a Firelight vault, including vault metrics, period configuration, user balances, and withdrawal information.
1616

17-
The Firelight vault is a [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) vault architecture that works with [FAssets](/fassets/overview), allowing users to deposit FXRP tokens and earn rewards through a period-based system.
17+
The Firelight vault is an [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) vault architecture compatible with [FAssets](/fassets/overview).
1818

1919
## Prerequisites
2020

@@ -32,69 +32,14 @@ The following script retrieves and displays information about the Firelight vaul
3232

3333
## Script Breakdown
3434

35-
### 1. Script Setup
35+
The script retrieves the following information:
3636

37-
The script starts by defining the Firelight vault address and importing the required contract interfaces:
38-
39-
- `FIRELIGHT_VAULT_ADDRESS`: The address of the Firelight vault contract on the [Flare Testnet Coston2 network](/network/overview).
40-
- `IFirelightVault`: The interface for interacting with the Firelight vault contract.
41-
Taken from the Firelight GitHub [repository](https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol).
42-
- `IERC20`: Standard [ERC-20](https://eips.ethereum.org/EIPS/eip-20) interface for token interactions.
43-
44-
### 2. Asset Information
45-
46-
The script retrieves basic asset information:
47-
48-
- **Asset address**: The underlying token address (e.g., FXRP).
49-
- **Asset symbol**: The token symbol (e.g., "FXRP").
50-
- **Asset decimals**: The number of decimals used by the token.
51-
52-
### 3. Vault Balances
53-
54-
The script displays key vault metrics:
55-
56-
- **Total assets**: The total amount of assets in the vault.
57-
- **Total supply**: The total number of shares minted by the vault.
58-
- **Exchange rate**: The current exchange rate between assets and shares, calculated as `totalAssets / totalSupply`.
59-
60-
### 4. Period Configuration
61-
62-
Firelight vaults operate on a [period-based logic](https://docs.firelight.finance/technical-documents#period-based-logic).
63-
64-
The script retrieves:
65-
66-
- **Period configurations count**: Total number of period configurations.
67-
- **Current period**: The active period number.
68-
- **Current period start**: Timestamp when the current period started.
69-
- **Current period end**: Timestamp when the current period ends.
70-
- **Next period end**: Timestamp when the next period will end.
71-
- **Current period config**: Configuration details including:
72-
- `epoch`: The epoch number.
73-
- `duration`: Duration of the period in seconds.
74-
- `startingPeriod`: The period when this configuration started.
75-
76-
### 5. User Information
77-
78-
For the connected account, the script displays:
79-
80-
- **User balance (shares)**: The number of vault shares owned by the user.
81-
- **User balance (assets)**: The equivalent asset value of the user's shares.
82-
- **Max deposit**: Maximum amount the user can deposit.
83-
- **Max mint**: Maximum number of shares the user can mint.
84-
- **Max withdraw**: Maximum amount of assets the user can withdraw.
85-
- **Max redeem**: Maximum number of shares the user can redeem.
86-
87-
### 6. User Withdrawals and Redemptions
88-
89-
The script checks withdrawal and redemption information for:
90-
91-
- **Current period**: Withdrawals and redemptions requested in the current period.
92-
- **Previous period**: Withdrawals and redemptions from the previous period.
93-
94-
For each period with pending withdrawals or redemptions, the script displays:
95-
96-
- Period number.
97-
- Withdrawal or redemption amount in both raw units and formatted token units.
37+
1. **Asset Information**: Token address, symbol, and decimals.
38+
2. **Vault Balances**: Total assets, total supply (shares), and exchange rate.
39+
3. **Period Configuration**: Current period details and timing information.
40+
Firelight vaults operate on a [period-based logic](https://docs.firelight.finance/technical-documents#period-based-logic).
41+
4. **User Information**: User balances (shares and assets), and maximum limits for deposit, mint, withdraw, and redeem.
42+
5. **User Withdrawals and Redemptions**: Pending withdrawals and redemptions for the current and previous periods.
9843

9944
## Running the Script
10045

@@ -145,9 +90,7 @@ Max redeem: 61
14590
14691
## Summary
14792
148-
In this guide, you learned how to retrieve status information from a Firelight vault.
149-
150-
This information is essential for building applications that interact with Firelight vaults and for monitoring vault health and user positions.
93+
In this guide, you learned how to retrieve status information from a Firelight vault, including vault metrics, period configuration, user balances, and withdrawal information.
15194
15295
:::tip[What's next]
15396

docs/fassets/firelight/withdraw.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,15 @@ The script starts by defining constants and importing the required contract inte
4545
Taken from the Firelight GitHub [repository](https://github.com/firelight-protocol/firelight-core/blob/main/contracts/FirelightVault.sol).
4646
- `IERC20`: Standard [ERC-20](https://eips.ethereum.org/EIPS/eip-20) interface for token interactions.
4747

48-
### 2. Get Asset Information
49-
50-
The script retrieves the underlying asset information to format amounts and calculate the withdrawal amount from the vault:
51-
52-
- **Asset address**: The token address that the vault holds (e.g., FXRP).
53-
- **Asset symbol**: The token symbol for display purposes.
54-
- **Asset decimals**: The number of decimals used by the token.
55-
56-
### 3. Calculate Withdrawal Amount
48+
### 2. Calculate Withdrawal Amount
5749

5850
The script converts the desired withdrawal amount into the correct units:
5951

6052
```typescript
6153
const amount = WITHDRAW_AMOUNT * 10 ** assetDecimalsNum;
6254
```
6355

64-
### 4. Check Maximum Withdrawal Capacity
56+
### 3. Check Maximum Withdrawal Capacity
6557

6658
Before withdrawing, the script checks if the requested amount exceeds the maximum allowed:
6759

@@ -73,7 +65,7 @@ The `maxWithdraw` function returns the maximum amount of assets that the specifi
7365

7466
If the requested amount exceeds the maximum, the script exits with an error to prevent a failed transaction.
7567

76-
### 5. Check User Balance and Calculate Shares Needed
68+
### 4. Check User Balance and Calculate Shares Needed
7769

7870
The script displays the user's current vault share balance and calculates how many shares are needed for the withdrawal:
7971

@@ -87,7 +79,7 @@ The `previewWithdraw` function is part of the [ERC-4626](https://eips.ethereum.o
8779
The script then validates that the user has sufficient shares.
8880
This validation ensures the withdrawal will succeed before attempting the transaction.
8981

90-
### 6. Create Withdrawal Request
82+
### 5. Create Withdrawal Request
9183

9284
Finally, the script creates a withdrawal request:
9385

examples/developer-hub-javascript/firelight-deposit.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@ async function main() {
2828

2929
const vault = await IFirelightVault.at(FIRELIGHT_VAULT_ADDRESS);
3030

31-
// 2. Get Asset Information
3231
// Get asset address from vault
3332
const assetAddress = await vault.asset();
3433
const assetToken = await IERC20.at(assetAddress);
3534

3635
const symbol = await assetToken.symbol();
3736
const assetDecimals = await assetToken.decimals();
3837

39-
// 3. Calculate Deposit Amount
38+
// 2. Calculate Deposit Amount
4039
const amount = DEPOSIT_AMOUNT * 10 ** assetDecimals;
4140

4241
console.log("=== Deposit (ERC-4626) ===");
@@ -49,7 +48,7 @@ async function main() {
4948
`(= ${DEPOSIT_AMOUNT} ${symbol})`,
5049
);
5150

52-
// 4. Check Maximum Deposit Capacity
51+
// 3. Check Maximum Deposit Capacity
5352
// Check max deposit capacity
5453
const maxDeposit = await vault.maxDeposit(account);
5554
console.log("Max deposit:", maxDeposit.toString());
@@ -60,14 +59,14 @@ async function main() {
6059
process.exit(1);
6160
}
6261

63-
// 5. Approve Token Transfer
62+
// 4. Approve Token Transfer
6463
// Approve + deposit.
6564
const approveTx = await assetToken.approve(vault.address, amount, {
6665
from: account,
6766
});
6867
console.log("Approve tx:", approveTx.tx);
6968

70-
// 6. Deposit Assets
69+
// 5. Deposit Assets
7170
const depositTx = await vault.deposit(amount, account, { from: account });
7271
console.log("Deposit tx:", depositTx.tx);
7372
}

examples/developer-hub-javascript/firelight-mint.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ async function main() {
2828

2929
const vault = await FirelightVault.at(FIRELIGHT_VAULT_ADDRESS);
3030

31-
// 2. Get Asset Information
3231
// Get asset address from vault
3332
const assetAddress = await vault.asset();
3433
const assetToken = await IERC20.at(assetAddress);
@@ -37,7 +36,7 @@ async function main() {
3736
const assetDecimals = await assetToken.decimals();
3837
const assetDecimalsNum = Number(assetDecimals);
3938

40-
// 3. Calculate Shares to Mint
39+
// 2. Calculate Shares to Mint
4140
const sharesToMint = SHARES_TO_MINT * 10 ** assetDecimalsNum;
4241

4342
console.log("=== Mint vault shares (ERC-4626) ===");
@@ -50,7 +49,7 @@ async function main() {
5049
`(= ${SHARES_TO_MINT} share${SHARES_TO_MINT > 1 ? "s" : ""})`,
5150
);
5251

53-
// 4. Check Maximum Mint Capacity
52+
// 3. Check Maximum Mint Capacity
5453
// Check max mint capacity
5554
const maxMint = await vault.maxMint(account);
5655
console.log("Max mint:", maxMint.toString());
@@ -61,19 +60,19 @@ async function main() {
6160
process.exit(1);
6261
}
6362

64-
// 5. Calculate Required Assets
63+
// 4. Calculate Required Assets
6564
// Use previewMint to calculate how much assets we need to approve
6665
const assetsNeeded = await vault.previewMint(sharesToMint);
6766
console.log("Assets needed (from previewMint):", assetsNeeded.toString());
6867

69-
// 6. Approve Token Transfer
68+
// 5. Approve Token Transfer
7069
// Approve + mint vault shares
7170
const approveTx = await assetToken.approve(vault.address, assetsNeeded, {
7271
from: account,
7372
});
7473
console.log("Approve tx:", approveTx.tx);
7574

76-
// 7. Mint Vault Shares
75+
// 6. Mint Vault Shares
7776
const mintTx = await vault.mint(sharesToMint, account, { from: account });
7877
console.log("Mint tx:", mintTx.tx);
7978
}

0 commit comments

Comments
 (0)