Rain subparser and extern words for ERC-4626 tokenised vaults.
Provides two words that call conversion functions on any ERC-4626 vault contract.
using-words-from <ERC4626Words address>
assets: erc4626-convert-to-assets(vault-address shares);
shares: erc4626-convert-to-shares(vault-address assets);
Converts vault shares to underlying assets.
| Input 0 | Vault contract address |
| Input 1 | Share amount as a Float |
| Output | Equivalent underlying asset amount as a Float |
assets: erc4626-convert-to-assets(0xVaultAddress 1e18);
Converts underlying assets to vault shares.
| Input 0 | Vault contract address |
| Input 1 | Asset amount as a Float |
| Output | Equivalent vault share amount as a Float |
shares: erc4626-convert-to-shares(0xVaultAddress 1e18);
Both words read decimals() from the vault share token and decimals() from
the underlying asset token to handle correct float conversion for any decimal
combination (e.g. an 18-decimal share token backed by 6-decimal USDC).
Enter the nix dev shell first — it provides forge, rain,
erc4626-words-prelude, and all other tools:
nix developInstall Solidity dependencies (soldeer) after cloning or when soldeer.lock
changes:
nix develop github:rainlanguage/rainix#sol-shell -c forge soldeer installRequires soldeer dependencies to be installed first (see above).
forge buildRequires soldeer dependencies to be installed first (see above).
forge testRun the prelude to produce the CBOR-encoded meta, then regenerate the pointer constants:
./script/build.sh
nix develop github:rainlanguage/rainix#sol-shell -c forge script script/BuildPointers.sol
nix develop github:rainlanguage/rainix#sol-shell -c forge fmtEquivalent via flake prelude + pointer script:
nix run .#erc4626-words-prelude
nix develop github:rainlanguage/rainix#sol-shell -c forge script script/BuildPointers.solThe generated file src/generated/ERC4626Words.pointers.sol and
meta/ERC4626Words.rain.meta must be committed. The Git is clean CI job
runs script/build.sh, script/BuildPointers.sol, format, and fails on
git diff --exit-code.
DEPLOYMENT_KEY=<private-key> forge script script/Deploy.sol \
--rpc-url <rpc-url> \
--broadcast \
--verifyOr trigger the Manual sol artifacts GitHub Actions workflow from the Actions tab, selecting the target network.
| Workflow | Trigger | What it does |
|---|---|---|
| rainix-sol | push | Reusable Rainix workflow: test, static analysis, REUSE (rainix-sol) |
| Git is clean | push | Reusable rainix-copy-artifacts: meta, pointers, format, fails if dirty |
| Manual sol artifacts | manual dispatch | Deploys to chosen network via rainix-sol-artifacts |
Required secrets (for the Manual sol artifacts deploy workflow, network=base):
PRIVATE_KEY, CI_DEPLOY_BASE_RPC_URL, CI_DEPLOY_BASE_ETHERSCAN_API_KEY,
CI_DEPLOY_BASE_VERIFY, CI_DEPLOY_BASE_VERIFIER, CI_DEPLOY_BASE_VERIFIER_URL.
For other networks substitute BASE with the network name in uppercase.
The CI workflows also use CACHIX_AUTH_TOKEN (org-level, passed via secrets: inherit).