Structure lesson (licence does not allow quoting code)
cross-chain-cp-swap
Cross Chain CP Swap: A cross-chain DEX allows users to easily swap tokens between blockchains like Ethereum and Solana.
- Original
- SushantChandla/cross-chain-cp-swap
- SuperStack fork
- Blockchains/cross-chain-cp-swap @
51c9448 - Stars
- 1
- Last push (original)
- 2024-10-08
- Languages
- TypeScript, Rust, Shell, CSS, Solidity, JavaScript
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- DeFi
- Licence
- none detected: code not quoted on Sol.College
Architecture
67 source files. By extension: .rs ×31, .ts ×20, .tsx ×15, .sol ×1.
| Top-level directory | Source files |
|---|---|
program | 44 |
frontend | 23 |
On-chain programs: program/programs/cp-swap
How it works: instructions and accounts
Each instruction handler and the accounts struct it validates, found by reading the Rust source. Links go to the exact line at the pinned commit.
| Instruction | Accounts | Source |
|---|---|---|
Initialize | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:221 |
AttestToken | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:222 |
CompleteNative | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:223 |
CompleteWrapped | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:224 |
TransferWrapped | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:225 |
TransferNative | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:226 |
RegisterChain | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:227 |
CreateWrapped | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:228 |
UpgradeContract | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:229 |
CompleteNativeWithPayload | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:230 |
CompleteWrappedWithPayload | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:231 |
TransferWrappedWithPayload | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:232 |
TransferNativeWithPayload | native instruction variant | program/programs/cp-swap/src/token_bridge_program_utils.rs:233 |
update_amm_config | UpdateAmmConfig | program/programs/cp-swap/src/lib.rs:91 |
update_pool_status | UpdatePoolStatus | program/programs/cp-swap/src/lib.rs:102 |
update_pool_status | UpdatePoolStatus | program/programs/cp-swap/src/instructions/admin/update_pool_status.rs:15 |
update_amm_config | UpdateAmmConfig | program/programs/cp-swap/src/instructions/admin/update_config.rs:17 |
Where the Solana code lives
Source files that import a Solana SDK, ranked by how many Solana APIs they use, with the APIs each one calls. Read them in this order to see how the app talks to the chain.
| File | Solana APIs used |
|---|---|
program/programs/cp-swap/src/token_bridge_program_utils.rs | seeds, AccountInfo, Pubkey, Program, invoke_signed |
program/tests/utils/instruction.ts | PublicKey, getAssociatedTokenAddressSync, Program, SystemProgram, findProgramAddressSync, ComputeBudgetProgram |
frontend/src/client/program.ts | PublicKey, getAssociatedTokenAddressSync, Program, ComputeBudgetProgram, SystemProgram, findProgramAddressSync |
program/tests/utils/util.ts | PublicKey, Keypair, Connection, SystemProgram, mintTo, getAssociatedTokenAddressSync |
program/programs/cp-swap/src/utils/token.rs | AccountInfo, CpiContext |
program/programs/cp-swap/src/instructions/initialize.rs | seeds, AccountInfo, Program, init_if_needed, transfer, Pubkey |
frontend/src/client/pda.ts | PublicKey |
program/tests/utils/pda.ts | PublicKey |
program/tests/utils/wormhole.utils.ts | Connection, PublicKey, Keypair, TransactionMessage, VersionedTransaction, signTransaction |
frontend/src/context/WalletsContext.tsx | Program, AnchorProvider, Connection, PublicKey, signTransaction |
program/programs/cp-swap/src/utils/account_load.rs | AccountInfo, Pubkey |
program/programs/cp-swap/src/states/pool.rs | Pubkey |
Dapp: devnet deploy pending
⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/cross-chain-cp-swap/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.
How to run, build and test
These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.
| Directory | Command | Runs |
|---|---|---|
frontend | npm run dev | |
frontend | npm run start | |
frontend | npm run build | |
frontend | npm run lint | |
program | npm run test | |
program | npm run lint | |
program | anchor build | |
program | anchor test | |
program | anchor run test |
What you could build from it
- Fork the SuperStack copy and extend it within the DeFi gaps listed on the idea page.