Last active
August 21, 2018 06:01
-
-
Save shingonu/e897edbeaeff7b9ceca418908b691f0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| owner = web3.eth.accounts[0] | |
| buyer = web3.eth.accounts[1] | |
| signer = web3.eth.accounts[3] // verified address that allows conversions with higher gas price | |
| defaultGasPriceLimit = 20000000000 | |
| // BancorNetwork init configuration= | |
| ContractRegistry.new().then(instance => contractRegistry = instance) | |
| ContractIds.new().then(instance => contractIds = instance) | |
| ContractFeatures.new().then(instance => contractFeatures = instance) | |
| contractFeaturesId = contractIds.CONTRACT_FEATURES.call() | |
| contractRegistry.registerAddress(contractFeaturesId, contractFeatures.address, owner) // Error: Invalid number of arguments to Solidity function | |
| BancorGasPriceLimit.new(defaultGasPriceLimit).then(instance => gasPriceLimit = instance) | |
| gasPriceLimitId = contractIds.BANCOR_GAS_PRICE_LIMIT.call() | |
| contractRegistry.registerAddress(gasPriceLimitId, gasPriceLimit.address, owner) // Error: Invalid number of arguments to Solidity function | |
| BancorFormula.new().then(instance => formula = instance) | |
| formulaId = contractIds.BANCOR_FORMULA.call() | |
| contractRegistry.registerAddress(formulaId, formula.address, owner) // Error: Invalid number of arguments to Solidity function | |
| BancorNetwork.new(contractRegistry.address).then(instance => bancorNetwork = instance) | |
| bancorNetworkId = contractIds.BANCOR_NETWORK.call() | |
| contractRegistry.registerAddress(bancorNetworkId, bancorNetwork.address, owner) // Error: Invalid number of arguments to Solidity function | |
| bancorNetwork.setSignerAddress(signer) | |
| // issue tokens | |
| EtherToken.new().then(instance => etherToken = instance) | |
| etherToken.deposit({from: owner, value: 10000000}) | |
| bancorNetwork.registerEtherToken(etherToken.address, true); | |
| SmartToken.new('Token1', 'TKN1', 2).then(instance => smartToken1 = instance) | |
| smartToken1.issue(owner, 1000000); | |
| SmartToken.new('Token2', 'TKN2', 2).then(instance => smartToken2 = instance) | |
| smartToken2.issue(owner, 2000000); | |
| SmartToken.new('Token3', 'TKN3', 2).then(instance => smartToken3 = instance) | |
| smartToken3.issue(owner, 3000000); | |
| SmartToken.new('Token4', 'TKN4', 2).then(instance => smartToken4 = instance) | |
| smartToken4.issue(owner, 2500000); | |
| TestERC20Token.new('ERC20Token', 'ERC5', 1000000).then(instance => erc20Token = instance) | |
| // make converter | |
| BancorConverter.new(smartToken1.address, contractRegistry.address, 0, etherToken.address, 250000).then(instance => converter1 = instance) | |
| BancorConverter.new(smartToken2.address, contractRegistry.address, 0, smartToken1.address, 300000).then(instance => converter2 = instance) | |
| converter2.addConnector(smartToken3.address, 150000, false); | |
| BancorConverter.new(smartToken3.address, contractRegistry.address, 0, smartToken4.address, 350000).then(instance => converter3 = instance) | |
| BancorConverter.new(smartToken4.address, contractRegistry.address, 0, etherToken.address, 150000).then(instance => converter4 = instance) | |
| converter4.addConnector(erc20Token.address, 220000, false); | |
| etherToken.transfer(converter1.address, 50000); | |
| smartToken1.transfer(converter2.address, 40000); | |
| smartToken3.transfer(converter2.address, 25000); | |
| smartToken4.transfer(converter3.address, 30000); | |
| etherToken.transfer(converter4.address, 20000); | |
| erc20Token.transfer(converter4.address, 35000); | |
| smartToken1.transferOwnership(converter1.address); | |
| converter1.acceptTokenOwnership(); | |
| smartToken2.transferOwnership(converter2.address); | |
| converter2.acceptTokenOwnership(); | |
| smartToken3.transferOwnership(converter3.address); | |
| converter3.acceptTokenOwnership(); | |
| smartToken4.transferOwnership(converter4.address); | |
| converter4.acceptTokenOwnership(); | |
| smartToken1QuickBuyPath = [etherToken.address, smartToken1.address, smartToken1.address]; | |
| smartToken2QuickBuyPath = [etherToken.address, smartToken1.address, smartToken1.address, smartToken2.address, smartToken2.address]; | |
| smartToken3QuickBuyPath = [etherToken.address, smartToken4.address, smartToken4.address, smartToken3.address, smartToken4.address]; | |
| smartToken4QuickBuyPath = [etherToken.address, smartToken4.address, smartToken4.address]; | |
| erc20QuickBuyPath = [etherToken.address, smartToken4.address, erc20Token.address]; | |
| converter1.setQuickBuyPath(smartToken1QuickBuyPath); | |
| converter2.setQuickBuyPath(smartToken2QuickBuyPath); | |
| converter3.setQuickBuyPath(smartToken3QuickBuyPath); | |
| converter4.setQuickBuyPath(smartToken4QuickBuyPath); | |
| smartToken1QuickSellPath = [smartToken1.address, smartToken1.address, etherToken.address]; | |
| smartToken2QuickSellPath = [smartToken2.address, smartToken2.address, smartToken1.address, smartToken1.address, etherToken.address]; | |
| prevBalance = smartToken1.balanceOf.call(buyer); | |
| converter1.quickConvert(smartToken1QuickBuyPath, 100, 1, { from: buyer, value: 100 }); | |
| newBalance = smartToken1.balanceOf.call(buyer); | |
| prevETHBalance = web3.eth.getBalance(owner); | |
| prevTokenBalance = smartToken1.balanceOf.call(owner); | |
| res = converter1.quickConvert(smartToken1QuickSellPath, 10000, 1); | |
| newETHBalance = web3.eth.getBalance(owner); | |
| newTokenBalance = smartToken1.balanceOf.call(owner); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment