Vulnerability: Certain functions lack input validation routines
Severity: high

Description:
The functions should first check if the passed arguments are valid first. The checks-effects-interactions pattern should be implemented throughout the code.\\nThese checks should include, but not be limited to:\\n`uint` should be larger than `0` when `0` is considered invalid\\n`uint` should be within constraints\\n`int` should be positive in some cases\\nlength of arrays should match if more arrays are sent as arguments\\naddresses should not be `0x0`\\nThe function `includeAsset` does not do any checks before changing the contract state.\\n```\\nfunction includeAsset (address \\_numeraire, address \\_nAssim, address \\_reserve, address \\_rAssim, uint256 \\_weight) public onlyOwner {\\n    shell.includeAsset(\\_numeraire, \\_nAssim, \\_reserve, \\_rAssim, \\_weight);\\n}\\n```\\n\\nThe internal function called by the public method `includeAsset` again doesn't check any of the data.\\n```\\nfunction includeAsset (Shells.Shell storage shell, address \\_numeraire, address \\_numeraireAssim, address \\_reserve, address \\_reserveAssim, uint256 \\_weight) internal {\\n\\n    Assimilators.Assimilator storage \\_numeraireAssimilator = shell.assimilators[\\_numeraire];\\n\\n    \\_numeraireAssimilator.addr = \\_numeraireAssim;\\n\\n    \\_numeraireAssimilator.ix = uint8(shell.numeraires.length);\\n\\n    shell.numeraires.push(\\_numeraireAssimilator);\\n\\n    Assimilators.Assimilator storage \\_reserveAssimilator = shell.assimilators[\\_reserve];\\n\\n    \\_reserveAssimilator.addr = \\_reserveAssim;\\n\\n    \\_reserveAssimilator.ix = uint8(shell.reserves.length);\\n\\n    shell.reserves.push(\\_reserveAssimilator);\\n\\n    shell.weights.push(\\_weight.divu(1e18).add(uint256(1).divu(1e18)));\\n\\n}\\n```\\n\\nSimilar with `includeAssimilator`.\\n```\\nfunction includeAssimilator (address \\_numeraire, address \\_derivative, address \\_assimilator) public onlyOwner {\\n    shell.includeAssimilator(\\_numeraire, \\_derivative, \\_assimilator);\\n}\\n```\\n\\nAgain no checks are done in any function.\\n```\\nfunction includeAssimilator (Shells.Shell storage shell, address \\_numeraire, address \\_derivative, address \\_assimilator) internal {\\n\\n    Assimilators.Assimilator storage \\_numeraireAssim = shell.assimilators[\\_numeraire];\\n\\n    shell.assimilators[\\_derivative] = Assimilators.Assimilator(\\_assimilator, \\_numeraireAssim.ix);\\n    // shell.assimilators[\\_derivative] = Assimilators.Assimilator(\\_assimilator, \\_numeraireAssim.ix, 0, 0);\\n\\n}\\n```\\n\\nNot only does the administrator functions not have any checks, but also user facing functions do not check the arguments.\\nFor example `swapByOrigin` does not check any of the arguments if you consider it calls `MainnetDaiToDaiAssimilator`.\\n```\\nfunction swapByOrigin (address \\_o, address \\_t, uint256 \\_oAmt, uint256 \\_mTAmt, uint256 \\_dline) public notFrozen returns (uint256 tAmt\\_) {\\n\\n    return transferByOrigin(\\_o, \\_t, \\_dline, \\_mTAmt, \\_oAmt, msg.sender);\\n\\n}\\n```\\n\\nIt calls `transferByOrigin` and we simplify this example and consider we have `_o.ix == _t.ix`\\n```\\nfunction transferByOrigin (address \\_origin, address \\_target, uint256 \\_dline, uint256 \\_mTAmt, uint256 \\_oAmt, address \\_rcpnt) public notFrozen nonReentrant returns (uint256 tAmt\\_) {\\n\\n    Assimilators.Assimilator memory \\_o = shell.assimilators[\\_origin];\\n    Assimilators.Assimilator memory \\_t = shell.assimilators[\\_target];\\n\\n    // TODO: how to include min target amount\\n    if (\\_o.ix == \\_t.ix) return \\_t.addr.outputNumeraire(\\_rcpnt, \\_o.addr.intakeRaw(\\_oAmt));\\n```\\n\\nIn which case it can call 2 functions on an assimilatior such as `MainnetDaiToDaiAssimilator`.\\nThe first called function is `intakeRaw`.\\n```\\n// transfers raw amonut of dai in, wraps it in cDai, returns numeraire amount\\nfunction intakeRaw (uint256 \\_amount) public returns (int128 amount\\_, int128 balance\\_) {\\n\\n    dai.transferFrom(msg.sender, address(this), \\_amount);\\n\\n    amount\\_ = \\_amount.divu(1e18);\\n\\n}\\n```\\n\\nAnd its result is used in `outputNumeraire` that again does not have any checks.\\n```\\n// takes numeraire amount of dai, unwraps corresponding amount of cDai, transfers that out, returns numeraire amount\\nfunction outputNumeraire (address \\_dst, int128 \\_amount) public returns (uint256 amount\\_) {\\n\\n    amount\\_ = \\_amount.mulu(1e18);\\n\\n    dai.transfer(\\_dst, amount\\_);\\n\\n    return amount\\_;\\n\\n}\\n```\\n

Impact:

Recommended mitigation:
Resolution\\nComment from the development team:\\nNow all functions in the Orchestrator revert on incorrect arguments.\\nAll functions in Loihi in general revert on incorrect arguments.\\nImplement the `checks-effects-interactions` as a pattern to write code. Add tests that check if all of the arguments have been validated.\\nConsider checking arguments as an important part of writing code and developing the system.