npm package: @mayflower-fi/solidity-interfaces
Description: Solidity interfaces for May Prog EVM protocol - for use in smart contract development
Author: Mayflower Finance
Latest version: 0.0.3

# @mayflower-fi/solidity-interfaces

Pure Solidity interfaces for integrating with the May Prog EVM protocol. This package contains only the `.sol` interface files for use in Solidity smart contract development.

> **Note:** For deployment, testing with bytecode, or TypeScript development, use [@mayflower-fi/evm-bytecode](https://www.npmjs.com/package/@mayflower-fi/evm-bytecode) instead.

## Installation

```bash
npm install @mayflower-fi/solidity-interfaces
```

or with yarn:

```bash
yarn add @mayflower-fi/solidity-interfaces
```

## Usage

Import the interfaces in your Solidity contracts:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "@mayflower-fi/solidity-interfaces/contracts/ITenant.sol";
import "@mayflower-fi/solidity-interfaces/contracts/IMarket.sol";
import "@mayflower-fi/solidity-interfaces/contracts/IMarketGroup.sol";

contract YourContract {
    ITenant public tenant;
    
    constructor(address tenantAddress) {
        tenant = ITenant(tenantAddress);
    }
    
    function createMarketGroup(
        address admin,
        uint256 buyFeeRate,
        uint256 sellFeeRate,
        uint256 borrowFeeRate,
        uint256 exerciseOptionsFeeRate
    ) external returns (address) {
        return tenant.createMarketGroup(
            admin,
            buyFeeRate,
            sellFeeRate,
            borrowFeeRate,
            exerciseOptionsFeeRate
        );
    }
}
```

## Available Interfaces

### Core Protocol Interfaces

- **`ITenantFactory`** - Factory for creating tenant contracts
- **`ITenant`** - Main tenant contract managing market groups and platform fees
- **`IMarketGroup`** - Groups of markets with shared fee structures
- **`IMarket`** - Individual bonding curve markets with trading functionality

### Key Functions

#### ITenant
- `createMarketGroup()` - Create a new market group
- `platformFeeRate()` - Get platform fee rate
- `collectPlatformFees()` - Collect accumulated platform fees

#### IMarketGroup  
- `createMarket()` - Deploy a new market with bonding curve
- `setFeeRates()` - Update fee rates for the group
- `collectFeesFromMarket()` - Collect fees from specific market

#### IMarket
- `buyWithExactBaseIn()` - Buy tokens with exact input amount
- `sellWithExactTokenIn()` - Sell tokens for base currency
- `buyCallOptions()` - Purchase call options
- `exerciseCallOptions()` - Exercise call options
- `depositCollateral()` - Deposit tokens as collateral
- `borrow()` - Borrow against collateral
- `repay()` - Repay borrowed amount

## Events

All interfaces include comprehensive events for monitoring on-chain activity:

```solidity
event TokensBought(address indexed buyer, uint256 baseIn, uint256 tokensOut);
event TokensSold(address indexed seller, uint256 tokensIn, uint256 baseOut);
event CallOptionsBought(address indexed buyer, uint256 baseIn, uint256 optionsOut);
event CallOptionsExercised(address indexed holder, uint256 optionsIn, uint256 tokensOut);
```

## Integration Example

### Reading Market Data

```solidity
IMarket market = IMarket(marketAddress);

// Get current price at supply
uint256 currentSupply = market.derivativeSupply();
uint256 price = market.getPriceAtSupply(currentSupply);

// Check available liquidity
uint256 liquidity = market.availableLiquidity();

// Get user position
(uint256 collateral, uint256 debt) = market.getPosition(userAddress);
```

### Executing Trades

```solidity
// Buy tokens
uint256 tokensOut = market.buyWithExactBaseIn(
    1000 * 10**18,  // 1000 base tokens in
    900 * 10**18,   // min tokens out (slippage protection)
    msg.sender      // recipient
);

// Sell tokens
uint256 baseOut = market.sellWithExactTokenIn(
    500 * 10**18,   // 500 tokens to sell
    450 * 10**18,   // min base out
    msg.sender      // recipient
);
```

## Version Compatibility

- Solidity: ^0.8.24
- OpenZeppelin Contracts: ^5.0.0

## License

MIT

## Support

For questions and support, please contact Mayflower Finance.