A decentralized co-investment protocol with dynamic profit sharing, unified B-side liquidity pool, and liquidation-free leverage for crypto and tokenized real-world assets (RWAs).
2xSwap replaces interest-based lending with a partnership model where two parties —
A (Initiator) and B (Capital Provider) — co-invest into real on-chain assets.
Profits are shared according to a utilization-based ratio, and positions never face forced liquidation.
-
Test the PriceOracle contract in your browser using Remix:
- Open https://remix.ethereum.org
- Create a new file
contracts/PriceOracle.soland paste the contract code from this PR. - In the "Solidity Compiler" panel, compile
PriceOracle.sol. - In "Deploy & Run Transactions" choose environment
JavaScript VMand pressDeploy. - Use
setPrice(owner) with a sample asset address0x000000000000000000000000000000000000abcdand value2500e18and then callgetPricewith the same asset to verify.
-
Or add files via GitHub web UI:
- In the repo, click "Add file" → "Create new file".
- Create
contracts/PriceOracle.soland paste the contract code from this PR. Commit.
-
Next recommended step (optional): add
ERC20Mock.solandMockSwapRouter.solfor local testing or unit tests.
This PR also adds a minimal PriceOracle contract in contracts/PriceOracle.sol to allow quick manual testing and to serve as a seed for future development.
- Liquidation-Free Leverage – positions stay open until voluntary close or maturity
- Dynamic Profit Sharing – A/B split adjusts automatically per pool utilization
- Unified B-Side Liquidity Pool (ERC-4626)
- Real Asset Exposure – swaps executed on-chain via DEX aggregators
- RWA-Ready Architecture – supports tokenized stocks, bonds, real estate
- Idle Liquidity Optimization – unused funds auto-deployed into MakerDAO DSR
- Fully Non-Custodial & MEV-Protected order flow
The protocol consists of four main smart contract modules:
- Accepts USDC deposits from B participants
- Issues 2xLP tokens
- Tracks free and allocated liquidity
- FIFO withdrawal queue when utilization reaches 100%
- Auto-deploy idle liquidity into MakerDAO DSR
Handles A-side positions:
- Creates Position NFTs
- Calculates dynamic profit-share via utilization
- Executes swaps (buy/sell)
- Settlement logic (profit waterfall, downside ordering)
- Stateless intent verification
- Routing to CoWSwap / UniswapX
- MEV-protected execution via private relays
- TWAP deviation checks
- Staleness protection
- Validation only at entry/exit
Profit share is determined at the moment a position is opened, based on pool utilization U.
Threshold Model v2:
| Utilization | Mode | A : B Split |
|---|---|---|
| 0–90% | Normal | 80 : 20 |
| 90–92% | Pre-Stress | 70 : 30 |
| 92–94% | Overload | 60 : 40 |
| >94% | Critical | 50 : 50 |
2xswap-protocol/
├── contracts/
├── test/
├── scripts/
└── docs/
└── specs/
├── profit-share-spec.md
├── settlement-spec.md
├── position-nft-spec.md
└── utilization-spec.md
npm install
npx hardhat test
REPORT_GAS=true npx hardhat test
We welcome contributions via Pull Requests.
- Fork the repository
- Create a feature branch
- Commit with clear messages
- Submit a PR
- All PRs must pass tests, linting, and code review
Contribution guidelines and PR template will be added soon.
- Independent audits required before mainnet
- Multisig-controlled governance
- Timelocked upgrades
- Community bug bounties
- No custodial components
MIT License.
To replace debt with partnership — and speculation with shared ownership.
2xSwap introduces a new financial primitive:
interest-free, liquidation-free, profit-sharing co-investment for crypto and the $10T on-chain RWA economy.