bancorprotocol / contracts-solidity

Bancor Protocol Contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some BancorConverters are old and not compatible with getReturnByPath

k06a opened this issue · comments

For example STOX converter has no method connectors(address): https://etherscan.io/address/0x8606704880234178125b2d44cbbe190ccdbde015#code

Here you can see how connectors(address) call is handled in fallback to quickConvert and failed in getReturnByPath call:

Decoded call tree:
* [1] 0x0c8496cc(0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000000000000000005000000000000000000000000c0829421c1d260bd3cb3e0f06cfe2d52db2ce3150000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c0000000000000000000000001f573d6fb3f13d689ff844b4ce37794d79a7ff1c000000000000000000000000006bea43baa3f7a6f765f14f10a1a1b08334ef45000000000000000000000000006bea43baa3f7a6f765f14f10a1a1b08334ef45) { to: 0x24618ec3a496e576a65503a16afd3ccfcf613f96 }
    [2] registry():0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 { to: 0x6690819cb98c1211a8e38790d6cd48316ed518db }
    [3] getAddress((bytes32)(0x42616e636f72466f726d756c6100000000000000000000000000000000000000)):0xffd2de852b694f88656e91d9defa6b425c454742 { to: 0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 }
    [4] owner():0xcbc6a023eb975a1e2630223a7959988948e664f3 { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
    [5] totalSupply():0x3b264e5e1bf8dbb0598adb { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
    [6] connectors((address)(0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315)):0x4553e09afc773b36d7700000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001 { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
    [7] getConnectorBalance((address)(0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315)):0x4553e09afc773b36d77 { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
    [8] connectors((address)(0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315)):0x4553e09afc773b36d7700000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001 { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
    [9] calculatePurchaseReturn((uint256)(0x3b264e5e1bf8dbb0598adb),(uint256)(0x4553e09afc773b36d77),(uint32)(0x186a0),(uint256)(0xde0b6b3a7640000)):0x12f1b71ca6c0200498 { to: 0xffd2de852b694f88656e91d9defa6b425c454742 }
    [10] conversionFee():0x0 { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
    [11] totalSupply():0x3b264e5e1bf8dbb0598adb { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
    [12] owner():0x8606704880234178125b2d44cbbe190ccdbde015 { to: 0x006bea43baa3f7a6f765f14f10a1a1b08334ef45 }
    [13] totalSupply():0x2ecd7ad47ba1b593ae4222 { to: 0x006bea43baa3f7a6f765f14f10a1a1b08334ef45 }
  * [14] connectors((address)(0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c)) { to: 0x8606704880234178125b2d44cbbe190ccdbde015 }
      [15] quickConverter():0x6690819cb98c1211a8e38790d6cd48316ed518db { to: 0xf46002c37af6fb078ae1833fd447698a0c9012f7 }
      [16] transferFrom((address)(0x24618ec3a496e576a65503a16afd3ccfcf613f96),(address)(0x6690819cb98c1211a8e38790d6cd48316ed518db),(uint256)(0x0)):0x1 { to: 0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315 }
    * [17] convertFor((address[])(c0829421c1d260bd3cb3e0f06cfe2d52db2ce315,1f573d6fb3f13d689ff844b4ce37794d79a7ff1c,1f573d6fb3f13d689ff844b4ce37794d79a7ff1c,006bea43baa3f7a6f765f14f10a1a1b08334ef45,006bea43baa3f7a6f765f14f10a1a1b08334ef45),(uint256)(0x0),(uint256)(0x1),(address)(0x24618ec3a496e576a65503a16afd3ccfcf613f96)) { to: 0x6690819cb98c1211a8e38790d6cd48316ed518db }
        [18] addressOf((bytes32)(0x42616e636f7247617350726963654c696d697400000000000000000000000000)):0x607a5c47978e2eb6d59c6c6f51bc0bf411f4b85a { to: 0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 }
        [19] validateGasPrice((uint256)(0x2540be400)):0x0 { to: 0x607a5c47978e2eb6d59c6c6f51bc0bf411f4b85a }
        [20] addressOf((bytes32)(0x436f6e7472616374466561747572657300000000000000000000000000000000)):0x563172281800b139f69fb038cc2c08cad56ce699 { to: 0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 }
        [21] owner():0xcbc6a023eb975a1e2630223a7959988948e664f3 { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
        [22] isSupported((address)(0xcbc6a023eb975a1e2630223a7959988948e664f3),(uint256)(0x1)):0x1 { to: 0x563172281800b139f69fb038cc2c08cad56ce699 }
        [23] conversionWhitelist():0x0 { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
        [24] allowance((address)(0x6690819cb98c1211a8e38790d6cd48316ed518db),(address)(0xcbc6a023eb975a1e2630223a7959988948e664f3)):0x0 { to: 0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315 }
      * [25] change((address)(0xc0829421c1d260bd3cb3e0f06cfe2d52db2ce315),(address)(0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c),(uint256)(0x0),(uint256)(0x1)) { to: 0xcbc6a023eb975a1e2630223a7959988948e664f3 }
          [26] addressOf((bytes32)(0x42616e636f724e6574776f726b00000000000000000000000000000000000000)):0x6690819cb98c1211a8e38790d6cd48316ed518db { to: 0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 }
          [27] owner():0xcbc6a023eb975a1e2630223a7959988948e664f3 { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
          [28] totalSupply():0x3b264e5e1bf8dbb0598adb { to: 0x1f573d6fb3f13d689ff844b4ce37794d79a7ff1c }
          [29] addressOf((bytes32)(0x42616e636f72466f726d756c6100000000000000000000000000000000000000)):0xffd2de852b694f88656e91d9defa6b425c454742 { to: 0x52ae12abe5d8bd778bd5397f99ca900624cfadd4 }
          [30] calculatePurchaseReturn((uint256)(0x3b264e5e1bf8dbb0598adb),(uint256)(0x4553e09afc773b36d77),(uint32)(0x186a0),(uint256)(0x0)):0x0 { to: 0xffd2de852b694f88656e91d9defa6b425c454742 }

Just deployed my fixed version of BancorNetwork, where getReturnByPath handle 2 different returns of version to solve this issue: https://etherscan.io/address/0x7a9b986420d734bb3fe98439a2d945ab97757595#code

commented

@k06a you are an amazing human

The solution that we've used in order to resolve this problem (based on the solution proposed by @k06a), can be found at https://github.com/bancorprotocol/contracts/blob/master/solidity/contracts/BancorNetwork.sol#L362 (contract BancorNetwork / function getReturn).

The official network already supports it and is deployed for a while now.
The latest one is 0x0e936B11c2e7b601055e58c7E32417187aF4de4a.

Closing this thread.