KyberNetwork / smart-contracts

Main smart contracts for Kyber Network, including the main platform contract, reserve contracts etc.
https://kyber.network
MIT License
378 stars 341 forks source link

Enable direct token approve call from kyber network contract #1058

Open ilanDoron opened 4 years ago

ilanDoron commented 4 years ago

Currently in kyber network token.safeApprove is called as part of the token listing process.

when adding token we approve to MAX_INT. when removing token approving to 0.

when approving to MAX_INT the current value must be 0 or the approve call reverts. with current issue. a token was migrated to a new contract and the allowance array was copied. so network already had allowance for this token and this reserve. this caused the listing process to fail. since token.safeApprove was approving to non zero while the allowance was already non zero.