Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Member "trade" not found #1073

Open
nance2uiuc opened this issue May 18, 2019 · 1 comment
Open

TypeError: Member "trade" not found #1073

nance2uiuc opened this issue May 18, 2019 · 1 comment

Comments

@nance2uiuc
Copy link

nance2uiuc commented May 18, 2019

From the docs, we are instructed to implement the following function in our contract:

function swapEtherToTokenWithChange (KyberNetworkProxyInterface _kyberNetworkProxy, ERC20 token, address destAddress, uint maxDestQty, uint minRate) public payable{
        //note that this.balance has increased by msg.value before the execution of this function
        uint startEthBalance = this.balance;
        
        //send swapped tokens to dest address. change will be sent to this contract.
        _kyberNetworkProxy.trade.value(msg.value)(ETH_TOKEN_ADDRESS, msg.value, token, destAddress, maxDestQty, minRate, 0);
        
        //calculate contract starting ETH balance before receiving msg.value (startEthBalance - msg.value)
        //change = current balance after trade - starting ETH contract balance (this.balance - (startEthBalance - msg.value))
        uint change = this.balance - (startEthBalance - msg.value);
        SwapEtherChange(startEthBalance, this.balance, change);
        
        //return change to get_sender()
        get_sender().transfer(change); //get_sender()
    }

However, this gives a compile error : TypeError: Member "trade" not found or not visible after argument-dependent lookup in contract KyberNetworkProxyInterface

Indeed, when the KyberNetworkProxyInterface.sol contract is inspected, it does not have a trade() method, only a tradeWithHint() method.

Changing KyberNetworkProxyInterface to KyberNetworkProxy in ...swapEtherToTokenWithChange (KyberNetworkProxyInterface _kyberNetworkProxy,... does not result in a type error.

@andrewsource147
Copy link
Contributor

I doubt about that. You can check kyber smart contract in etherscan, It has trade function:
https://etherscan.io/address/0x818e6fecd516ecc3849daf6845e3ec868087b755#writeContract

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants