pragma solidity >=0.8.6;
import "@openzeppelin/contracts/access/Ownable.sol";
contract RouteTrade is Ownable{
uint32 tradeId;
uint128 private stopTime; //在空投发布后三天
struct tradePair{
uint32 tradePairId; //交易id
uint224 tradePrice; //交易价格
uint128 tradeAmount; //交易数量
uint128 alreadyAmount; //已经完成交易的数量
uint128 startTime; //开始世界
uint128 endTime; //结束时间
address solder; //出售者
}
tradePair[] public _tradePair;
event createTradePair(uint32 thisId,uint224 thisPrice,uint128 thisAmount,uint128 finishAmount,uint128 thisStartTime,uint128 thisEndTime,address thisSolder);
//设置代币空投后最终交割时间
function setAirdropTime(uint256 airdropDate)external onlyOwner{
stopTime=uint128(airdropDate) + 3 days;
}
//创建route pair
function createRoutePair(uint256 buyPrice,uint256 buyAmount,uint256 _endTime)external{
require(_endTime<stopTime); //结束时间需要小于交割时间
_tradePair.push(tradePair(tradeId,uint224(buyPrice),uint128(buyAmount),0,uint128(block.timestamp),uint128(_endTime),msg.sender));
emit createTradePair(tradeId,uint224(buyPrice),uint128(buyAmount),0,uint128(block.timestamp),uint128(_endTime),msg.sender);
tradeId++;
}
//得到最新的最高价格列表,最多为20个
function fetchLastHighPrice()external view returns(tradePair[] memory){
uint256 a;
if(_tradePair.length>=20){
a=20;
}else{
a=_tradePair.length;
}
tradePair[] memory newTradePair=new tradePair[](a);
}
}