Make Swap from Contract

Is it possible to make multiple exchanges within a contract?

I have a code here that uses Ethereum main net, but I want to use Polygon and I can’t find the address.

Eth main net = 0xC586BeF4a0992C495Cf22e1aeEE4E446CECDee0E

Polygon = ???

Is there any example?

...
       (uint256 _returnAmount, uint256[] memory _distribution )
         = _oneSplitContract.getExpectedReturn( _fromIERC20, _toIERC20, loanAmount,   PARTS, FLAGS);

        // Approve tokens
        _fromIERC20.approve( polygon_address???????, _returnAmount);
        
        _oneSplitContract.swap(_fromIERC20, _toIERC20, _returnAmount, _returnAmount, _distribution, FLAGS);
1 Like

Hi @Menezes,
OneSplit was deprecated over a year ago and was never deployed on a chain other than ethereum mainnet.

2 Likes

Forced to throw that my doubt.
Alem of Solidity being lousy, has a lot of incompatibility between versions.
I wasted an entire day trying to sort this out and nothing.
Does it have any way of calling 1inch swap within the solidity contract, I want to do triangular arbitrage, I got to research an oracle, but it seems to be slow and does not allow to be synchronized within the return function of the flash loan.

Do you have any sayings for me?

2 Likes

The current way to use 1inch would be through the API see https://docs.1inch.io

You could call the contract on-chain with some of the simpler functions i.e. unoswap, swapOnUniswapV3. This doesn’t give you the aggregation power of 1inch though and you’d still need to get the route data somewhere else.

1 Like