Skip to content

Commit d390274

Browse files
authored
feat(docs): introduce Upshift vaults documentation with deposit, redeem, and claim guides (#1153)
1 parent 39388ae commit d390274

File tree

16 files changed

+1754
-8
lines changed

16 files changed

+1754
-8
lines changed

docs/fxrp/overview.mdx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ keywords: [fassets, fxrp, xrp, flare-network, firelight, vault, defi]
66

77
import DocCardList from "@theme/DocCardList";
88
import Firelight from "./firelight/_firelight.mdx";
9+
import Upshift from "./upshift/_upshift.mdx";
910

1011
FXRP is the [FAsset](/fassets/overview) representation of XRP on the Flare network.
1112
It is an [ERC-20](https://eips.ethereum.org/EIPS/eip-20) token that represents XRP bridged from the XRP Ledger (XRPL) to Flare.
@@ -123,11 +124,4 @@ FXRP is deployed as an [Omnichain Fungible Token (OFT)](/fxrp/oft) using LayerZe
123124

124125
## Upshift Vaults
125126

126-
[Upshift vault](https://app.upshift.finance/pools/14/0x373D7d201C8134D4a2f7b5c63560da217e3dEA28) is part of the XRP finance stack on Flare Network.
127-
It inherits the transparency model of the [FAssets](/fassets/overview) system: minting and redemption are proof-backed, and vault interactions are recorded on-chain.
128-
129-
- **Funds are on-chain:** User deposits, vault balances, withdrawal requests, and claims are executed as smart contract state changes on Flare.
130-
You can verify all vault holdings on [DeBank](https://debank.com/profile/0xEDb7B1e92B8D3621b46843AD024949F10438374B) portfolio tracker.
131-
- **User ownership is verifiable:** A user's position is represented directly on-chain and can be queried from smart contracts.
132-
- **Instruction flow is auditable:** XRPL-triggered actions are executed on Flare via [Smart Accounts](/smart-accounts/overview) with [Flare Data Connector](/fdc/overview) backed verification and onchain execution.
133-
You can verify all smart account activity on the [Flare Systems Explorer](https://flare-systems-explorer.flare.network/smart-accounts).
127+
<Upshift />

docs/fxrp/upshift/01-status.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Get Upshift Vault Status
3+
tags: [intermediate, upshift, fassets]
4+
slug: status
5+
description: Learn how to get Upshift vault status
6+
keywords: [fassets, flare-network, fxrp, upshift, vault]
7+
sidebar_position: 1
8+
---
9+
10+
import CodeBlock from "@theme/CodeBlock";
11+
import UpshiftStatus from "!!raw-loader!/examples/developer-hub-javascript/upshift-status.ts";
12+
13+
This guide demonstrates how to retrieve information about an Upshift vault, including vault configuration, LP token info, user balances, and withdrawal epoch information.
14+
15+
The Upshift vault is an [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) style tokenized vault compatible with [FAssets](/fassets/overview).
16+
17+
## Prerequisites
18+
19+
- [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit)
20+
- [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts)
21+
- Understanding of [FAssets](/fassets/overview)
22+
23+
## Upshift Vault Status Script
24+
25+
The following script retrieves and displays information about the Upshift vault:
26+
27+
<CodeBlock language="typescript" title="scripts/upshift/status.ts">
28+
{UpshiftStatus}
29+
</CodeBlock>
30+
31+
## Script Breakdown
32+
33+
The `main()` function executes the following steps:
34+
35+
1. **Initialize:** Gets the user account and logs the vault and user addresses.
36+
2. **Connect to vault:** Creates an instance of the Upshift vault contract.
37+
3. **Get reference asset info:** Retrieves the vault's reference asset (FXRP) address, symbol, and decimals.
38+
4. **Get LP token info:** Retrieves the vault's LP token address, which represents user shares.
39+
5. **Get vault configuration:** Fetches key vault parameters.
40+
6. **Get withdrawal epoch info:** Retrieves the current withdrawal epoch (year, month, day) and claimable epoch.
41+
7. **Get user balances:** Shows the user's reference asset balance and LP token balance.
42+
8. **Check allowances:** Displays the user's token allowances to the vault for both the reference asset and LP token.
43+
44+
## Running the Script
45+
46+
To run the Upshift vault status script:
47+
48+
1. Ensure you have the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit) set up.
49+
2. Update the `VAULT_ADDRESS` constant with the correct vault address for your network.
50+
3. Run the script using Hardhat:
51+
52+
```bash
53+
npx hardhat run scripts/upshift/status.ts --network coston2
54+
```
55+
56+
## Output
57+
58+
The script outputs the following information about the Upshift vault:
59+
60+
```bash
61+
VAULT STATUS
62+
63+
Vault Address: 0x24c1a47cD5e8473b64EAB2a94515a196E10C7C81
64+
User Address: 0x0d09ff7630588E05E2449aBD3dDD1D8d146bc5c2
65+
66+
Reference Asset
67+
Address: 0x0b6A3645c240605887a5532109323A3E12273dc7
68+
Symbol: FTestXRP
69+
Decimals: 6
70+
71+
LP Token
72+
Address: 0x1234567890abcdef1234567890abcdef12345678
73+
74+
Vault Configuration
75+
Withdrawals Paused: false
76+
Lag Duration: 86400 seconds
77+
Withdrawal Fee: 0.5%
78+
Instant Redemption Fee: 1.0%
79+
Max Withdrawal Amount: 1000000.0 FTestXRP
80+
81+
Withdrawal Epoch
82+
Year: 2025, Month: 1, Day: 15
83+
Claimable Epoch: 14
84+
85+
User Balances
86+
FTestXRP Balance: 100.0
87+
LP Token Balance: 95.5
88+
89+
Allowances
90+
FTestXRP Allowance to Vault: 0.0
91+
LP Token Allowance to Vault: 0.0
92+
```
93+
94+
## Summary
95+
96+
In this guide, you learned how to retrieve status information from an Upshift vault, including vault configuration, LP token details, user balances, and withdrawal epoch information.
97+
98+
:::tip[What's next]
99+
100+
To continue your Upshift development journey, you can:
101+
102+
- Learn more about [FAssets](/fassets/overview) and how the system works.
103+
- Learn how to [deposit assets into an Upshift vault](/fxrp/upshift/deposit).
104+
- Learn how to [instantly redeem from an Upshift vault](/fxrp/upshift/instant-redeem) for immediate liquidity.
105+
- Learn how to [request a redemption from an Upshift vault](/fxrp/upshift/request-redeem) for delayed liquidity.
106+
- Learn how to [claim assets from an Upshift vault](/fxrp/upshift/claim) after your requested redemption is claimable.
107+
108+
:::

docs/fxrp/upshift/02-deposit.mdx

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
title: Deposit Assets into Upshift Vault
3+
tags: [intermediate, upshift, fassets]
4+
slug: deposit
5+
description: Learn how to deposit assets into an Upshift vault
6+
keywords: [fassets, flare-network, fxrp, upshift, vault]
7+
sidebar_position: 2
8+
---
9+
10+
import CodeBlock from "@theme/CodeBlock";
11+
import UpshiftDeposit from "!!raw-loader!/examples/developer-hub-javascript/upshift-deposit.ts";
12+
13+
This guide demonstrates how to deposit assets into an Upshift vault.
14+
The Upshift vault implements an [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) style tokenized vault, allowing users to deposit assets (e.g., FXRP) and receive LP tokens (vault shares) in return.
15+
16+
Depositing assets is the process of transferring them to the vault and receiving LP tokens that represent your proportional ownership of the vault's assets.
17+
18+
## Prerequisites
19+
20+
- [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit)
21+
- [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts)
22+
- Understanding of [FAssets](/fassets/overview)
23+
- Sufficient asset balance (e.g., FXRP) to deposit into the vault.
24+
25+
## Upshift Vault Deposit Script
26+
27+
The following script demonstrates how to deposit assets into the Upshift vault:
28+
29+
<CodeBlock language="typescript" title="scripts/upshift/deposit.ts">
30+
{UpshiftDeposit}
31+
</CodeBlock>
32+
33+
## Script Breakdown
34+
35+
The `main()` function executes the following steps:
36+
37+
1. **Initialize:** Gets the user account and logs the vault and user addresses.
38+
2. **Connect to vault:** Creates an instance of the Upshift vault contract.
39+
3. **Get reference asset info:** Retrieves the vault's reference asset (FXRP) address, symbol, and decimals.
40+
4. **Calculate deposit amount:** Converts the desired amount into the correct units based on decimals.
41+
5. **Check balance:** Verifies the user has sufficient balance to cover the deposit.
42+
6. **Approve allowance:** Approves the vault to spend the deposit amount if needed.
43+
7. **Preview deposit:** Calls [`previewDeposit()`](https://docs.upshift.finance/developer-docs/vault-contract-interface#id-7.-previewdeposit-uint256-assets) to see the expected shares and amount in reference tokens.
44+
8. **Get LP token info:** Records the LP token balance before the deposit.
45+
9. **Execute deposit:** Calls [`deposit()`](https://docs.upshift.finance/developer-docs/vault-contract-interface#id-1.-deposit-uint256-assets-address-receiver) to transfer assets and mint LP tokens.
46+
10. **Verify deposit:** Confirms the deposit by checking the new LP token balance and shares received.
47+
48+
## Running the Script
49+
50+
To run the Upshift vault deposit script:
51+
52+
1. Ensure you have the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit) set up.
53+
2. Update the `VAULT_ADDRESS` constant with the correct vault address for your network.
54+
3. Adjust the `DEPOSIT_AMOUNT` constant to the desired number of tokens.
55+
4. Ensure your account has sufficient asset balance (e.g., FXRP) to cover the deposit.
56+
5. Run the script using Hardhat:
57+
58+
```bash
59+
npx hardhat run scripts/upshift/deposit.ts --network coston2
60+
```
61+
62+
## Output
63+
64+
The script outputs the following information about the deposit:
65+
66+
```bash
67+
DEPOSIT TO VAULT
68+
69+
Vault Address: 0x24c1a47cD5e8473b64EAB2a94515a196E10C7C81
70+
User Address: 0x0d09ff7630588E05E2449aBD3dDD1D8d146bc5c2
71+
72+
Reference Asset (asset depositing): 0x0b6A3645c240605887a5532109323A3E12273dc7
73+
74+
Deposit Amount: 1 FTestXRP (1000000)
75+
Balance: 100.0 FTestXRP
76+
Current Allowance: 0.0 FTestXRP
77+
78+
Approving vault to spend 1 FTestXRP tokens
79+
Approval Tx: 0x87a36c1009575719fd3adb9a1bb2e3062a601bf910fc7fac3248da71891c39a4
80+
81+
Expected Shares: 0.99
82+
Amount in Reference Tokens: 1.0
83+
LP Balance Before: 0.0
84+
85+
Deposit: (tx: 0x446b7a171859d676677fc870cff81c7e8c0d618fc3588e60665792da86b94c50 , block: 12345678 )
86+
87+
Verifying deposit...
88+
LP Balance After: 0.99
89+
Shares Received: 0.99
90+
```
91+
92+
## Summary
93+
94+
In this guide, you learned how to deposit assets into an Upshift vault by specifying the amount of assets to deposit and receiving LP tokens in return.
95+
96+
:::tip[What's next]
97+
98+
To continue your Upshift development journey, you can:
99+
100+
- Learn more about [FAssets](/fassets/overview) and how the system works.
101+
- Learn how to [get Upshift vault status](/fxrp/upshift/status) to monitor your position.
102+
- Learn how to [instantly redeem from an Upshift vault](/fxrp/upshift/instant-redeem) for immediate liquidity.
103+
- Learn how to [request a redemption from an Upshift vault](/fxrp/upshift/request-redeem) for delayed liquidity.
104+
- Learn how to [claim assets from an Upshift vault](/fxrp/upshift/claim) after your requested redemption is claimable.
105+
106+
:::
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: Instant Redeem from Upshift Vault
3+
tags: [intermediate, upshift, fassets]
4+
slug: instant-redeem
5+
description: Learn how to instantly redeem LP tokens from an Upshift vault
6+
keywords: [fassets, flare-network, fxrp, upshift, vault, redeem]
7+
sidebar_position: 3
8+
---
9+
10+
import CodeBlock from "@theme/CodeBlock";
11+
import UpshiftInstantRedeem from "!!raw-loader!/examples/developer-hub-javascript/upshift-instant-redeem.ts";
12+
13+
This guide demonstrates how to perform an instant redemption from an Upshift vault.
14+
The Upshift vault implements an [ERC-4626](https://eips.ethereum.org/EIPS/eip-4626) style tokenized vault that supports instant redemptions for immediate liquidity when available.
15+
16+
Instant redemption burns your LP tokens (vault shares) and immediately returns the underlying assets to your wallet, subject to an instant redemption fee.
17+
18+
## Prerequisites
19+
20+
- [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit)
21+
- [Flare Network Periphery Contracts](https://www.npmjs.com/package/@flarenetwork/flare-periphery-contracts)
22+
- Understanding of [FAssets](/fassets/overview)
23+
- LP tokens (vault shares) in the Upshift vault to redeem.
24+
25+
## Upshift Vault Instant Redeem Script
26+
27+
The following script demonstrates how to perform an instant redemption from the Upshift vault:
28+
29+
<CodeBlock language="typescript" title="scripts/upshift/instantRedeem.ts">
30+
{UpshiftInstantRedeem}
31+
</CodeBlock>
32+
33+
## Script Breakdown
34+
35+
The `main()` function executes the following steps:
36+
37+
1. **Initialize:** Gets the user account and logs the vault and user addresses.
38+
2. **Connect to vault:** Creates an instance of the Upshift vault contract.
39+
3. **Get reference asset info:** Retrieves the vault's reference asset (FXRP) address, symbol, and decimals.
40+
4. **Get LP token info:** Retrieves the LP token address and the user's current LP balance.
41+
5. **Validate balance:** Converts the shares amount and checks if the user has sufficient LP tokens.
42+
6. **Preview redemption:** Calls [`previewRedemption()`](https://docs.upshift.finance/developer-docs/vault-contract-interface#id-8.-previewredeem-uint256-shares) to see the expected assets before and after the instant redemption fee.
43+
7. **Get asset balance:** Records the user's asset balance before redemption.
44+
8. **Execute instant redemption:** Calls [`instantRedeem()`](https://docs.upshift.finance/developer-docs/vault-contract-interface#id-4.-instantredeem-uint256-shares-address-receiveraddr-address-holderaddr) to burn LP tokens and receive assets immediately.
45+
9. **Verify redemption:** Confirms the redemption by checking the updated LP and asset balances.
46+
47+
## Understanding Instant Redemption
48+
49+
The Upshift vault supports two types of redemptions:
50+
51+
- **Instant Redemption**: Immediately burns LP tokens and returns assets, but incurs an instant redemption fee.
52+
- **Requested Redemption**: Creates a withdrawal request that is processed after a lag period, with a lower fee.
53+
54+
The instant redemption fee compensates the vault for providing immediate liquidity.
55+
The [`previewRedemption()`](https://docs.upshift.finance/developer-docs/vault-contract-interface#id-8.-previewredeem-uint256-shares) function shows both the gross and net amounts you'll receive.
56+
57+
## Running the Script
58+
59+
To run the Upshift vault instant redeem script:
60+
61+
1. Ensure you have the [Flare Hardhat Starter Kit](/network/guides/hardhat-foundry-starter-kit) set up.
62+
2. Update the `VAULT_ADDRESS` constant with the correct vault address for your network.
63+
3. Adjust the `SHARES_TO_REDEEM` constant to the desired number of shares.
64+
4. Ensure your account has sufficient LP tokens (vault shares) to cover the redemption.
65+
5. Run the script using Hardhat:
66+
67+
```bash
68+
npx hardhat run scripts/upshift/instantRedeem.ts --network coston2
69+
```
70+
71+
## Output
72+
73+
The script outputs the following information about the instant redemption:
74+
75+
```bash
76+
INSTANT REDEEM FROM VAULT
77+
78+
Vault Address: 0x24c1a47cD5e8473b64EAB2a94515a196E10C7C81
79+
User Address: 0x0d09ff7630588E05E2449aBD3dDD1D8d146bc5c2
80+
Reference Asset (asset receiving): 0x0b6A3645c240605887a5532109323A3E12273dc7
81+
82+
LP Balance: 10.0
83+
Shares to Redeem: 1 (1000000)
84+
85+
Instant Redemption Fee: 1.0%
86+
Expected Assets (before fee): 1.0 FTestXRP
87+
Expected Assets (after fee): 0.99 FTestXRP
88+
89+
Asset Balance Before: 50.0 FTestXRP
90+
91+
Instant Redeem: (tx: 0x3f1bd8c766852d3b835bcde79f6d8e20afeeb227d737e0ed28d057dc0e6b2ba9 , block: 12345678 )
92+
93+
Verifying redemption...
94+
LP Balance After: 9.0
95+
Shares Redeemed: 1.0
96+
Assets Received: 0.99 FTestXRP
97+
```
98+
99+
## Summary
100+
101+
In this guide, you learned how to perform an instant redemption from an Upshift vault by specifying the number of LP tokens (shares) to redeem.
102+
The instant redemption provides immediate liquidity but incurs a fee.
103+
104+
:::tip[What's next]
105+
106+
To continue your Upshift development journey, you can:
107+
108+
- Learn more about [FAssets](/fassets/overview) and how the system works.
109+
- Learn how to [deposit assets into an Upshift vault](/fxrp/upshift/deposit).
110+
- Learn how to [request a redemption from an Upshift vault](/fxrp/upshift/request-redeem) for delayed liquidity.
111+
- Learn how to [claim assets from an Upshift vault](/fxrp/upshift/claim) after your requested redemption is claimable.
112+
113+
:::

0 commit comments

Comments
 (0)