feat: bridges, PMM, flash workflow, token-aggregation, and deployment docs
- CCIP/trustless bridge contracts, GRU tokens, DEX/PMM tests, reserve vault. - Token-aggregation service routes, planner, chain config, relay env templates. - Config snapshots and multi-chain deployment markdown updates. - gitignore services/btc-intake/dist/ (tsc output); do not track dist. Run forge build && forge test before deploy (large solc graph). Made-with: Cursor
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.19;
|
||||
|
||||
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
/**
|
||||
* @title MockDVMPool
|
||||
* @notice Minimal mock of a DODO PMM pool so DODOPMMIntegration can deploy and create pools on Chain 138
|
||||
@@ -12,6 +14,8 @@ contract MockDVMPool {
|
||||
uint256 public baseReserve;
|
||||
uint256 public quoteReserve;
|
||||
uint256 public midPrice;
|
||||
uint256 public totalSupply;
|
||||
mapping(address => uint256) private _shares;
|
||||
uint256 public constant _K_ = 0.5e18; // 50% slippage factor (DODO convention)
|
||||
uint256 public constant _LP_FEE_RATE_ = 3; // 0.03% in basis points
|
||||
|
||||
@@ -47,6 +51,10 @@ contract MockDVMPool {
|
||||
return (baseReserve, quoteReserve);
|
||||
}
|
||||
|
||||
function balanceOf(address owner) external view returns (uint256) {
|
||||
return _shares[owner];
|
||||
}
|
||||
|
||||
function getMidPrice() external view returns (uint256) {
|
||||
return midPrice;
|
||||
}
|
||||
@@ -56,15 +64,71 @@ contract MockDVMPool {
|
||||
return midPrice;
|
||||
}
|
||||
|
||||
function sellBase(uint256) external returns (uint256) {
|
||||
return 0;
|
||||
function querySellBase(address, uint256 amount) external view returns (uint256, uint256) {
|
||||
return ((amount * midPrice) / 1e18, 0);
|
||||
}
|
||||
|
||||
function sellQuote(uint256) external returns (uint256) {
|
||||
return 0;
|
||||
function querySellQuote(address, uint256 amount) external view returns (uint256, uint256) {
|
||||
if (midPrice == 0) {
|
||||
return (0, 0);
|
||||
}
|
||||
return ((amount * 1e18) / midPrice, 0);
|
||||
}
|
||||
|
||||
function buyShares(address) external returns (uint256, uint256, uint256) {
|
||||
return (0, 0, 0);
|
||||
function sellBase(address to) external returns (uint256 receiveQuoteAmount) {
|
||||
uint256 baseBal = IERC20(baseToken).balanceOf(address(this));
|
||||
require(baseBal >= baseReserve, "MockDVMPool: base");
|
||||
uint256 baseInput = baseBal - baseReserve;
|
||||
if (baseInput == 0) return 0;
|
||||
(receiveQuoteAmount,) = this.querySellBase(address(0), baseInput);
|
||||
require(IERC20(quoteToken).transfer(to, receiveQuoteAmount), "MockDVMPool: q");
|
||||
baseReserve = IERC20(baseToken).balanceOf(address(this));
|
||||
quoteReserve = IERC20(quoteToken).balanceOf(address(this));
|
||||
}
|
||||
|
||||
function sellQuote(address to) external returns (uint256 receiveBaseAmount) {
|
||||
uint256 quoteBal = IERC20(quoteToken).balanceOf(address(this));
|
||||
require(quoteBal >= quoteReserve, "MockDVMPool: quote");
|
||||
uint256 quoteInput = quoteBal - quoteReserve;
|
||||
if (quoteInput == 0) return 0;
|
||||
(receiveBaseAmount,) = this.querySellQuote(address(0), quoteInput);
|
||||
require(IERC20(baseToken).transfer(to, receiveBaseAmount), "MockDVMPool: b");
|
||||
baseReserve = IERC20(baseToken).balanceOf(address(this));
|
||||
quoteReserve = IERC20(quoteToken).balanceOf(address(this));
|
||||
}
|
||||
|
||||
function buyShares(address to) external returns (uint256, uint256, uint256) {
|
||||
uint256 baseBal = IERC20(baseToken).balanceOf(address(this));
|
||||
uint256 quoteBal = IERC20(quoteToken).balanceOf(address(this));
|
||||
require(baseBal >= baseReserve && quoteBal >= quoteReserve, "MockDVMPool: reserve");
|
||||
|
||||
uint256 baseInput = baseBal - baseReserve;
|
||||
uint256 quoteInput = quoteBal - quoteReserve;
|
||||
require(baseInput > 0 && quoteInput > 0, "MockDVMPool: no input");
|
||||
|
||||
uint256 lpShare;
|
||||
if (totalSupply == 0) {
|
||||
lpShare = baseBal;
|
||||
require(lpShare > 2001, "MockDVMPool: MINT_AMOUNT_NOT_ENOUGH");
|
||||
totalSupply = lpShare;
|
||||
_shares[address(0)] = 1001;
|
||||
lpShare -= 1001;
|
||||
_shares[to] += lpShare;
|
||||
} else {
|
||||
uint256 baseShares = (baseInput * totalSupply) / baseReserve;
|
||||
uint256 quoteShares = (quoteInput * totalSupply) / quoteReserve;
|
||||
lpShare = baseShares < quoteShares ? baseShares : quoteShares;
|
||||
totalSupply += lpShare;
|
||||
_shares[to] += lpShare;
|
||||
}
|
||||
|
||||
baseReserve = baseBal;
|
||||
quoteReserve = quoteBal;
|
||||
return (baseInput, quoteInput, lpShare);
|
||||
}
|
||||
|
||||
function sync() external {
|
||||
baseReserve = IERC20(baseToken).balanceOf(address(this));
|
||||
quoteReserve = IERC20(quoteToken).balanceOf(address(this));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user