Skip to main content

EdenCore Contract

The EdenCore contract is the main orchestrator for the EdenVest protocol. It routes deposits, performs token swaps to cNGN, mints LP tokens and NFT positions, handles withdrawals (with optional swap on exit), and coordinates pool lifecycle via the factory.

Assetchain Mainnet

Assetchain Enugu Testnet

What EdenCore Does

Process Investments

Accepts direct cNGN or performs swap-then-invest in one transaction

Mint Receipts

Issues LP tokens (ERC‑20) and non-transferable NFT positions (ERC‑721)

Handle Withdrawals

Redeem to cNGN or swap to chosen token on exit

Manage Pools

Create and toggle pool activation through the factory

Key Features

Architecture Flow

Key Data Structures

InvestmentParams

Used for swap-and-invest operations:

WithdrawAndSwapParams

Used for withdraw-and-swap operations:

Core Functions

Investment Functions

invest()

Direct investment using cNGN tokens without swapping.
Parameters:
  • pool: Target investment pool address
  • amount: Investment amount in cNGN
  • title: Custom title for the investment
  • deadline: Transaction deadline (0 for no deadline)
Process Flow:
  1. Validates pool registration and active status
  2. Transfers cNGN from user and approves pool
  3. Calls InvestmentPool.invest() to mint LP and NFT
  4. Collects protocol tax in LP tokens to TaxCollector
  5. Emits InvestmentMade event
Returns:
  • tokenId: NFT position token ID
  • lpTokens: LP tokens minted to investor

investWithSwap()

Invest using any ERC‑20 token. EdenCore swaps to cNGN then invests in one transaction.
Advanced Features:
  • Slippage Protection: Applies default 1% slippage protection
  • Liquidity Validation: Checks available swap liquidity
  • Balance Verification: Ensures swap executed correctly
InvestmentParams Structure:

Withdrawal Functions

withdraw()

Withdraw matured positions to receive cNGN directly, by burning LP tokens and NFT.
Important: User must approve LP tokens to the pool address (not EdenCore). Process:
  1. Validates investment maturity and ownership
  2. Burns LP tokens and NFT position
  3. Transfers principal + returns to investor

withdrawAndSwap() - Withdraw with Token Swap

Withdraw to cNGN then optionally swap to another token in a single transaction.
Process:
  1. Validates pool and transfers LP tokens
  2. Withdraws to cNGN via InvestmentPool.withdraw()
  3. If tokenOut == cNGN: sends cNGN directly to user
  4. Otherwise: swaps cNGN to tokenOut with slippage protection

Pool Management Functions

createPool()

Create new investment pools (Admin only).
PoolParams Structure:

View Functions

getAllPools() / getActivePools()

Retrieve pool information.

checkSwapLiquidity()

Check available liquidity for token swaps.

Access Control

The contract implements OpenZeppelin’s AccessControl with these roles:

Events

Investment Events

Administrative Events

Error Handling

The contract includes comprehensive error checking:

Integration Examples

React Frontend Integration

Pool Creation Example

Security Considerations

Input Validation

  • All amounts must be greater than zero
  • Pool addresses must be registered and active
  • Deadlines must be in the future
  • Token addresses must be valid contracts

Slippage Protection

  • Automatic slippage calculation for swaps
  • Configurable maximum slippage limits
  • Real-time liquidity checks

Access Controls

  • Role-based function access
  • Multisig requirements for critical operations
  • Emergency pause capabilities

Upgrade Mechanism

EdenCore uses the UUPS (Universal Upgradeable Proxy Standard) pattern:
  • Proxy Contract: Handles storage and delegatecalls
  • Implementation Contract: Contains business logic
  • Admin Controls: Only ADMIN_ROLE can authorize upgrades
Upgrades must be carefully planned and tested to ensure storage layout compatibility and prevent data corruption.

Next Steps

Investment Pools

Learn about individual pool mechanics and configuration

NFT Positions

Understand how investment positions are tracked via NFTs

Tax Collection

Explore the protocol fee collection and distribution system

Integration Guide

Build applications using the EdenVest protocol