To begin with, given:
address public daiAddress = 0x6b175474e89094c44da98b954eedeac495271d0f;
address public kyberAddress = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755;
You should probably change this:
KyberNetworkProxyInterface KNPI = KyberNetworkProxyInterface(daiAddress);
To this:
KyberNetworkProxyInterface KNPI = KyberNetworkProxyInterface(kyberAddress);
As it's not really clear why you are converting the ERC20 DAI token into a Kyber-Network proxy.
Another problem seems to be in:
uint256 received = KNPI.swapEtherToToken.value(quantity)(ERC20(daiAddress), slippageRate);
Where the second input argument should probably be expectedRate
rather than slippageRate
.
Another potential problem is the fact that your contract must own at least quantity
wei ether.
One way to ensure this is by passing that value when you call the function.
And by "passing that value", I don't mean as an input parameter to the function, but as a value to the transaction.
Note that for consistency, the Kyber contract might be requiring that you also pass it as an input parameter to the function.