Skip to content

Commit

Permalink
Clean up path validity
Browse files Browse the repository at this point in the history
  • Loading branch information
alsco77 committed Feb 18, 2021
1 parent 205e2ac commit c2e4ca4
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions contracts/feeders/FeederPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,7 @@ contract FeederPool is
Status memory input = _getAsset2(_input);
Status memory output = _getAsset2(_output);
require(_pathIsValid(input, output), "Invalid pair");
// todo - if input exists, output must be 1, same with output. No mpAsst -> mAsset allowed

// do deposit (move to internal fn)
Asset memory in_i = _transferIn(input, _inputQuantity);
// 1. [f/mAsset ->][ f/mAsset] : Y - normal in, SWAP, normal out
// 3. [mpAsset -> mAsset][ -> fAsset] : Y - mint in , SWAP, normal out
Expand All @@ -460,19 +458,14 @@ contract FeederPool is
}

function _pathIsValid(Status memory _in, Status memory _out) internal returns (bool isValid) {
return true;
// // Valid if:
// isValid = true;
// if(!_in.exists && !_out.exists) isValid = false;
// if(_in.idx == 0 && !_out.exists) isValid = false;
// if(_out.idx == 0 && !_in.exists) isValid = false;
// // Straight swap
// if(_in.exists && _out.exists) return true;
// // mpAsset -> mpAsset
// if(!_in.exists && !_out.exists) return false;
// // 1 must exist
// if(_in.exists && _in.idx == 1) return true;
// if(_out.exists && _out.idx == 1) return true;
// mpAsset -> mpAsset
if(!_in.exists && !_out.exists) return false;
// f/mAsset -> f/mAsset
if(_in.exists && _out.exists) return true;
// fAsset -> mpAsset
if(_in.exists && _in.idx == 1) return true;
// mpAsset -> fAsset
if(_out.exists && _out.idx == 1) return true;
}

function _transferIn(Status memory _input, uint256 _inputQuantity)
Expand Down

0 comments on commit c2e4ca4

Please sign in to comment.