@mayflower-fi/solidity-interfaces
v0.0.3
Published
Solidity interfaces for May Prog EVM protocol - for use in smart contract development
Downloads
19
Readme
@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 instead.
Installation
npm install @mayflower-fi/solidity-interfacesor with yarn:
yarn add @mayflower-fi/solidity-interfacesUsage
Import the interfaces in your Solidity contracts:
// 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 contractsITenant- Main tenant contract managing market groups and platform feesIMarketGroup- Groups of markets with shared fee structuresIMarket- Individual bonding curve markets with trading functionality
Key Functions
ITenant
createMarketGroup()- Create a new market groupplatformFeeRate()- Get platform fee ratecollectPlatformFees()- Collect accumulated platform fees
IMarketGroup
createMarket()- Deploy a new market with bonding curvesetFeeRates()- Update fee rates for the groupcollectFeesFromMarket()- Collect fees from specific market
IMarket
buyWithExactBaseIn()- Buy tokens with exact input amountsellWithExactTokenIn()- Sell tokens for base currencybuyCallOptions()- Purchase call optionsexerciseCallOptions()- Exercise call optionsdepositCollateral()- Deposit tokens as collateralborrow()- Borrow against collateralrepay()- Repay borrowed amount
Events
All interfaces include comprehensive events for monitoring on-chain activity:
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
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
// 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.
