Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions contracts/AMMQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,7 @@ contract AMMQuoter {
return _getCurveMakerOutAmount(vars, curveVersion, fromTokenCurveIndex, toTokenCurveIndex, swapMethod);
}

function getMakerOutAmount(
address _makerAddr,
address _takerAssetAddr,
address _makerAssetAddr,
uint256 _takerAssetAmount
) public view returns (uint256) {
function getMakerOutAmount(address _makerAddr, address _takerAssetAddr, address _makerAssetAddr, uint256 _takerAssetAmount) public view returns (uint256) {
uint256 makerAssetAmount;
if (_makerAddr == UNISWAP_V2_ROUTER_02_ADDRESS || _makerAddr == SUSHISWAP_ROUTER_ADDRESS) {
IUniswapRouterV2 router = IUniswapRouterV2(_makerAddr);
Expand Down Expand Up @@ -284,12 +279,7 @@ contract AMMQuoter {
return _getCurveTakerInAmount(vars, curveVersion, fromTokenCurveIndex, toTokenCurveIndex, swapMethod, supportGetDx);
}

function getTakerInAmount(
address _makerAddr,
address _takerAssetAddr,
address _makerAssetAddr,
uint256 _makerAssetAmount
) public view returns (uint256) {
function getTakerInAmount(address _makerAddr, address _takerAssetAddr, address _makerAssetAddr, uint256 _makerAssetAmount) public view returns (uint256) {
uint256 takerAssetAmount;
if (_makerAddr == UNISWAP_V2_ROUTER_02_ADDRESS || _makerAddr == SUSHISWAP_ROUTER_ADDRESS) {
IUniswapRouterV2 router = IUniswapRouterV2(_makerAddr);
Expand Down Expand Up @@ -348,7 +338,7 @@ contract AMMQuoter {
address _makerAssetAddr,
uint256 _makerAssetAmount
) external view returns (address bestMaker, uint256 bestAmount) {
bestAmount = 2**256 - 1;
bestAmount = 2 ** 256 - 1;
uint256 poolLength = _makerAddresses.length;
for (uint256 i = 0; i < poolLength; ++i) {
address makerAddress = _makerAddresses[i];
Expand Down
7 changes: 1 addition & 6 deletions contracts/AMMWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,7 @@ contract AMMWrapper is IAMMWrapper, StrategyBase, ReentrancyGuard, BaseLibEIP712
* @dev internal function of `trade`.
* It transfer assets to receiver specified in order.
*/
function _settle(
AMMLibEIP712.Order memory _order,
InternalTxData memory _internalTxData,
uint256 _settleAmount,
uint256 _feeAmount
) internal {
function _settle(AMMLibEIP712.Order memory _order, InternalTxData memory _internalTxData, uint256 _settleAmount, uint256 _feeAmount) internal {
// Transfer token/ETH to receiver
if (_internalTxData.toEth) {
// Withdraw from WETH if internal maker asset is WETH
Expand Down
12 changes: 2 additions & 10 deletions contracts/AMMWrapperWithPath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ contract AMMWrapperWithPath is IAMMWrapperWithPath, AMMWrapper {
return amounts[amounts.length - 1];
}

function _validateAMMPath(
address[] memory _path,
address _takerAssetAddr,
address _makerAssetAddr
) internal pure {
function _validateAMMPath(address[] memory _path, address _takerAssetAddr, address _makerAssetAddr) internal pure {
require(_path.length >= 2, "AMMWrapper: path length must be at least two");
require(_path[0] == _takerAssetAddr, "AMMWrapper: first element of path must match taker asset");
require(_path[_path.length - 1] == _makerAssetAddr, "AMMWrapper: last element of path must match maker asset");
Expand Down Expand Up @@ -341,11 +337,7 @@ contract AMMWrapperWithPath is IAMMWrapperWithPath, AMMWrapper {
return swapSteps;
}

function _buildBalancerV2Limits(
address[] memory _path,
uint256 _takerAssetAmount,
uint256 _makerAssetAmount
) internal pure returns (int256[] memory) {
function _buildBalancerV2Limits(address[] memory _path, uint256 _takerAssetAmount, uint256 _makerAssetAmount) internal pure returns (int256[] memory) {
int256[] memory limits = new int256[](_path.length);
// amount swapped in to balancer will denoted with positive sign
limits[0] = int256(_takerAssetAmount);
Expand Down
31 changes: 4 additions & 27 deletions contracts/LONStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ contract LONStaking is ERC20ForUpgradeable, OwnableForUpgradeable, ReentrancyGua

/* ========== CONSTRUCTOR ========== */

function initialize(
ILon _lonToken,
address _owner,
uint256 _COOLDOWN_IN_DAYS,
uint256 _BPS_RAGE_EXIT_PENALTY
) external {
function initialize(ILon _lonToken, address _owner, uint256 _COOLDOWN_IN_DAYS, uint256 _BPS_RAGE_EXIT_PENALTY) external {
lonToken = _lonToken;

_initializeOwnable(_owner);
Expand Down Expand Up @@ -173,11 +168,7 @@ contract LONStaking is ERC20ForUpgradeable, OwnableForUpgradeable, ReentrancyGua
}
}

function _transfer(
address _from,
address _to,
uint256 _amount
) internal override whenNotPaused {
function _transfer(address _from, address _to, uint256 _amount) internal override whenNotPaused {
uint256 balanceOfFrom = balanceOf(_from);
uint256 balanceOfTo = balanceOf(_to);
uint256 previousSenderCooldown = stakersCooldowns[_from];
Expand All @@ -193,15 +184,7 @@ contract LONStaking is ERC20ForUpgradeable, OwnableForUpgradeable, ReentrancyGua
}

// EIP-2612 permit standard
function permit(
address _owner,
address _spender,
uint256 _value,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external {
function permit(address _owner, address _spender, uint256 _value, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) external {
require(_owner != address(0), "owner is zero address");
require(block.timestamp <= _deadline || _deadline == 0, "permit expired");

Expand Down Expand Up @@ -237,13 +220,7 @@ contract LONStaking is ERC20ForUpgradeable, OwnableForUpgradeable, ReentrancyGua
lonToken.transferFrom(msg.sender, address(this), _amount);
}

function stakeWithPermit(
uint256 _amount,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) public nonReentrant whenNotPaused {
function stakeWithPermit(uint256 _amount, uint256 _deadline, uint8 _v, bytes32 _r, bytes32 _s) public nonReentrant whenNotPaused {
_stake(msg.sender, _amount);
// Use permit to allow LONStaking contract to transferFrom user
lonToken.permit(msg.sender, address(this), _amount, _deadline, _v, _r, _s);
Expand Down
16 changes: 2 additions & 14 deletions contracts/LPStakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,7 @@ contract LPStakingRewards is ILPStakingRewards, ReentrancyGuard, IEmergency {
_;
}

constructor(
address _emergencyRecipient,
address _rewardsDistribution,
address _rewardsToken,
address _lpToken,
uint256 _rewardsDuration
) {
constructor(address _emergencyRecipient, address _rewardsDistribution, address _rewardsToken, address _lpToken, uint256 _rewardsDuration) {
require(_rewardsDuration > 0, "rewards duration is 0");

emergencyRecipient = _emergencyRecipient;
Expand Down Expand Up @@ -82,13 +76,7 @@ contract LPStakingRewards is ILPStakingRewards, ReentrancyGuard, IEmergency {
return rewardRate.mul(rewardsDuration);
}

function stakeWithPermit(
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external nonReentrant updateReward(msg.sender) {
function stakeWithPermit(uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonReentrant updateReward(msg.sender) {
require(amount > 0, "cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
Expand Down
22 changes: 3 additions & 19 deletions contracts/LimitOrder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ contract LimitOrder is ILimitOrder, StrategyBase, BaseLibEIP712, SignatureValida
/// @param _makerFeeFactor The new fee factor for maker
/// @param _takerFeeFactor The new fee factor for taker
/// @param _profitFeeFactor The new fee factor for relayer profit
function setFactors(
uint16 _makerFeeFactor,
uint16 _takerFeeFactor,
uint16 _profitFeeFactor
) external onlyOwner {
function setFactors(uint16 _makerFeeFactor, uint16 _takerFeeFactor, uint16 _profitFeeFactor) external onlyOwner {
require(_makerFeeFactor <= LibConstant.BPS_MAX, "LimitOrder: Invalid maker fee factor");
require(_takerFeeFactor <= LibConstant.BPS_MAX, "LimitOrder: Invalid taker fee factor");
require(_profitFeeFactor <= LibConstant.BPS_MAX, "LimitOrder: Invalid profit fee factor");
Expand Down Expand Up @@ -455,11 +451,7 @@ contract LimitOrder is ILimitOrder, StrategyBase, BaseLibEIP712, SignatureValida

/* order utils */

function _validateOrder(
LimitOrderLibEIP712.Order memory _order,
bytes32 _orderHash,
bytes memory _orderMakerSig
) internal view {
function _validateOrder(LimitOrderLibEIP712.Order memory _order, bytes32 _orderHash, bytes memory _orderMakerSig) internal view {
require(_order.expiry > uint64(block.timestamp), "LimitOrder: Order is expired");
bool isCancelled = LibOrderStorage.getStorage().orderHashToCancelled[_orderHash];
require(!isCancelled, "LimitOrder: Order is cancelled");
Expand All @@ -477,15 +469,7 @@ contract LimitOrder is ILimitOrder, StrategyBase, BaseLibEIP712, SignatureValida
LimitOrderLibEIP712.Order memory _order,
bytes32 _orderHash,
uint256 _takerTokenAmount
)
internal
view
returns (
uint256,
uint256,
uint256
)
{
) internal view returns (uint256, uint256, uint256) {
uint256 takerTokenFilledAmount = LibOrderStorage.getStorage().orderHashToTakerTokenFilledAmount[_orderHash];

require(takerTokenFilledAmount < _order.takerTokenAmount, "LimitOrder: Order is filled");
Expand Down
10 changes: 1 addition & 9 deletions contracts/Lon.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ contract Lon is ERC20, ILon, Ownable {
}

// implement the eip-2612
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external override {
function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external override {
require(owner != address(0), "zero address");
require(block.timestamp <= deadline || deadline == 0, "permit is expired");

Expand Down
12 changes: 2 additions & 10 deletions contracts/MarketMakerProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ contract MarketMakerProxy is Ownable {
address public signer;
mapping(address => bool) public isWithdrawWhitelist;

constructor(
address _owner,
address _signer,
IWETH _weth
) Ownable(_owner) {
constructor(address _owner, address _signer, IWETH _weth) Ownable(_owner) {
require(_signer != address(0), "MarketMakerProxy: zero address");
signer = _signer;
WETH = _weth;
Expand Down Expand Up @@ -70,11 +66,7 @@ contract MarketMakerProxy is Ownable {
}
}

function withdrawToken(
address token,
address to,
uint256 amount
) external onlyOwner {
function withdrawToken(address token, address to, uint256 amount) external onlyOwner {
require(isWithdrawWhitelist[to], "MarketMakerProxy: not in withdraw whitelist");
IERC20(token).safeTransfer(to, amount);
}
Expand Down
32 changes: 5 additions & 27 deletions contracts/MerkleRedeem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,20 @@ contract MerkleRedeem is Ownable, ReentrancyGuard, IEmergency {
mapping(uint256 => mapping(address => bool)) public claimed;

/*==== PUBLIC FUNCTIONS =====*/
constructor(
address _owner,
IERC20 _rewardsToken,
address _emergencyRecipient
) Ownable(_owner) {
constructor(address _owner, IERC20 _rewardsToken, address _emergencyRecipient) Ownable(_owner) {
emergencyRecipient = _emergencyRecipient;
rewardsToken = _rewardsToken;
}

function claimPeriod(
address recipient,
uint256 period,
uint256 balance,
bytes32[] memory proof
) external nonReentrant {
function claimPeriod(address recipient, uint256 period, uint256 balance, bytes32[] memory proof) external nonReentrant {
require(!claimed[period][recipient]);
require(verifyClaim(recipient, period, balance, proof), "incorrect merkle proof");

claimed[period][recipient] = true;
_disburse(recipient, balance);
}

function verifyClaim(
address recipient,
uint256 period,
uint256 balance,
bytes32[] memory proof
) public view returns (bool) {
function verifyClaim(address recipient, uint256 period, uint256 balance, bytes32[] memory proof) public view returns (bool) {
bytes32 leaf = keccak256(abi.encodePacked(recipient, balance));
return MerkleProof.verify(proof, periodMerkleRoots[period], leaf);
}
Expand All @@ -76,11 +62,7 @@ contract MerkleRedeem is Ownable, ReentrancyGuard, IEmergency {
_disburse(recipient, totalBalance);
}

function claimStatus(
address recipient,
uint256 begin,
uint256 end
) external view returns (bool[] memory) {
function claimStatus(address recipient, uint256 begin, uint256 end) external view returns (bool[] memory) {
uint256 size = 1 + end - begin;
bool[] memory arr = new bool[](size);
for (uint256 i = 0; i < size; ++i) {
Expand All @@ -104,11 +86,7 @@ contract MerkleRedeem is Ownable, ReentrancyGuard, IEmergency {
token.transfer(emergencyRecipient, token.balanceOf(address(this)));
}

function seedAllocations(
uint256 period,
bytes32 merkleRoot,
uint256 totalAllocation
) external onlyOwner {
function seedAllocations(uint256 period, bytes32 merkleRoot, uint256 totalAllocation) external onlyOwner {
require(periodMerkleRoots[period] == bytes32(0), "already seed");

periodMerkleRoots[period] = merkleRoot;
Expand Down
18 changes: 2 additions & 16 deletions contracts/PermanentStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ contract PermanentStorage is IPermanentStorage {
}

/// @dev Set permission for entity to write certain storage.
function setPermission(
bytes32 _storageId,
address _role,
bool _enabled
) external onlyOperator {
function setPermission(bytes32 _storageId, address _role, bool _enabled) external onlyOperator {
if (_enabled) {
require(
(_role == operator) || (_role == ammWrapperAddr()) || (_role == rfqAddr()) || (_role == rfqv2Addr()) || (_role == limitOrderAddr()),
Expand Down Expand Up @@ -124,17 +120,7 @@ contract PermanentStorage is IPermanentStorage {
address _makerAddr,
address _takerAssetAddr,
address _makerAssetAddr
)
external
view
override
returns (
int128 takerAssetIndex,
int128 makerAssetIndex,
uint16 swapMethod,
bool supportGetDx
)
{
) external view override returns (int128 takerAssetIndex, int128 makerAssetIndex, uint16 swapMethod, bool supportGetDx) {
// underlying_coins
int128 i = AMMWrapperStorage.getStorage().curveTokenIndexes[_makerAddr][_takerAssetAddr];
int128 j = AMMWrapperStorage.getStorage().curveTokenIndexes[_makerAddr][_makerAssetAddr];
Expand Down
6 changes: 1 addition & 5 deletions contracts/ProxyPermanentStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ pragma solidity 0.7.6;
import "@openzeppelin/contracts/proxy/TransparentUpgradeableProxy.sol";

contract ProxyPermanentStorage is TransparentUpgradeableProxy {
constructor(
address _logic,
address _admin,
bytes memory _data
) payable TransparentUpgradeableProxy(_logic, _admin, _data) {}
constructor(address _logic, address _admin, bytes memory _data) payable TransparentUpgradeableProxy(_logic, _admin, _data) {}
}
6 changes: 1 addition & 5 deletions contracts/RFQ.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ contract RFQ is IRFQ, StrategyBase, ReentrancyGuard, SignatureValidator, BaseLib
return _settle(_order, vars);
}

function _emitFillOrder(
RFQLibEIP712.Order memory _order,
GroupedVars memory _vars,
uint256 settleAmount
) internal {
function _emitFillOrder(RFQLibEIP712.Order memory _order, GroupedVars memory _vars, uint256 settleAmount) internal {
emit FillOrder(
SOURCE,
_vars.transactionHash,
Expand Down
6 changes: 1 addition & 5 deletions contracts/RFQv2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,7 @@ contract RFQv2 is IRFQv2, StrategyBase, TokenCollector, SignatureValidator, Base
_emitFilledRFQEvent(offerHash, order, makerTokenToTaker);
}

function _emitFilledRFQEvent(
bytes32 _offerHash,
RFQOrder calldata _rfqOrder,
uint256 _makerTokenToTaker
) internal {
function _emitFilledRFQEvent(bytes32 _offerHash, RFQOrder calldata _rfqOrder, uint256 _makerTokenToTaker) internal {
emit FilledRFQ(
_offerHash,
_rfqOrder.offer.taker,
Expand Down
Loading
Loading