Socket
Socket
Sign inDemoInstall

@bancor/contracts-solidity

Package Overview
Dependencies
Maintainers
5
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bancor/contracts-solidity - npm Package Compare versions

Comparing version 0.6.8 to 0.6.9

solidity/test/LiquidityPoolV2ConverterStateless.js

5

CHANGELOG.md

@@ -0,1 +1,6 @@

### 0.6.9 (2020-08-07)
LiquidityPoolV2Converter
* Upgraded dynamic fee mechanism
### 0.6.8 (2020-07-31)

@@ -2,0 +7,0 @@ Converters

2

package.json
{
"name": "@bancor/contracts-solidity",
"version": "0.6.8",
"version": "0.6.9",
"description": "The solidity version of the Bancor smart contracts is composed of many different components that work together to create the Bancor Network deployment.",

@@ -5,0 +5,0 @@ "repository": {

[
{"operation": "newPool", "amp": 20, "fee": 1000, "mainToken": "TKN", "sideToken": "BNT", "numOfUsers": 3, "initialAmount": 1000000},
{"operation": "newPool", "amp": 20, "fee": 1000, "factor": 10000, "mainToken": "TKN", "sideToken": "BNT", "numOfUsers": 3, "initialAmount": 1000000},
{"operation": "setRates", "mainRate": 1, "sideRate": 1},

@@ -4,0 +4,0 @@ {"operation": "addLiquidity", "token": "TKN", "user": "user1", "amount": 100000},

@@ -141,6 +141,10 @@ const fs = require('fs');

// main contracts
const contractRegistryAddress = '0x52Ae12ABe5D8BD778BD5397F99cA900624CfADD4';
const contractRegistry = await web3Func(deploy, 'contractRegistry', 'ContractRegistry', []);
const converterFactory = await web3Func(deploy, 'converterFactory', 'ConverterFactory', []);
const bancorFormula = await web3Func(deploy, 'bancorFormula', 'BancorFormula', []);
const converterUpgrader = await web3Func(deploy, 'converterUpgrader', 'ConverterUpgrader', [contractRegistryAddress, addresses.ETH]);
const bancorNetwork = await web3Func(deploy, 'bancorNetwork', 'BancorNetwork', [contractRegistry._address]);
const conversionPathFinder = await web3Func(deploy, 'conversionPathFinder', 'ConversionPathFinder', [contractRegistry._address]);
const converterUpgrader = await web3Func(deploy, 'converterUpgrader', 'ConverterUpgrader', [contractRegistry._address, addresses.ETH]);
const converterRegistry = await web3Func(deploy, 'converterRegistry', 'ConverterRegistry', [contractRegistry._address]);
const converterRegistryData = await web3Func(deploy, 'converterRegistryData', 'ConverterRegistryData', [contractRegistry._address]);
const liquidTokenConverterFactory = await web3Func(deploy, 'liquidTokenConverterFactory', 'LiquidTokenConverterFactory', []);

@@ -151,4 +155,3 @@ const liquidityPoolV1ConverterFactory = await web3Func(deploy, 'liquidityPoolV1ConverterFactory', 'LiquidityPoolV1ConverterFactory', []);

const liquidityPoolV2ConverterCustomFactory = await web3Func(deploy, 'liquidityPoolV2ConverterCustomFactory', 'LiquidityPoolV2ConverterCustomFactory', []);
await web3Func(deploy, 'oracleWhitelist', 'Whitelist', []);
await web3Func(deploy, 'ethToEthOracle', 'ChainlinkETHToETHOracle', []);
const oracleWhitelist = await web3Func(deploy, 'oracleWhitelist', 'Whitelist', []);

@@ -162,6 +165,17 @@ // contract deployment for etherscan verification only

await web3Func(deploy, 'priceOracle', 'PriceOracle', [smartToken._address, smartToken2._address, chainlinkOracle1._address, chainlinkOracle2._address]);
await web3Func(deploy, 'liquidTokenConverter', 'LiquidTokenConverter', [smartToken._address, contractRegistryAddress, 1000]);
await web3Func(deploy, 'liquidityPoolV1Converter', 'LiquidityPoolV1Converter', [smartToken2._address, contractRegistryAddress, 1000]);
await web3Func(deploy, 'liquidityPoolV2Converter', 'LiquidityPoolV2Converter', [poolTokensContainer._address, contractRegistryAddress, 1000]);
await web3Func(deploy, 'liquidTokenConverter', 'LiquidTokenConverter', [smartToken._address, contractRegistry._address, 1000]);
await web3Func(deploy, 'liquidityPoolV1Converter', 'LiquidityPoolV1Converter', [smartToken2._address, contractRegistry._address, 1000]);
await web3Func(deploy, 'liquidityPoolV2Converter', 'LiquidityPoolV2Converter', [poolTokensContainer._address, contractRegistry._address, 1000]);
// initialize contract registry
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('ContractRegistry'), contractRegistry._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('ConverterFactory'), converterFactory._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BancorFormula'), bancorFormula._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BancorNetwork'), bancorNetwork._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('ConversionPathFinder'), conversionPathFinder._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BancorConverterUpgrader'), converterUpgrader._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BancorConverterRegistry'), converterRegistry._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BancorConverterRegistryData'), converterRegistryData._address));
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('ChainlinkOracleWhitelist'), oracleWhitelist._address));
// initialize converter factory

@@ -174,2 +188,73 @@ await execute(converterFactory.methods.registerTypedConverterFactory(liquidTokenConverterFactory._address));

for (const reserve of getConfig().reserves) {
if (reserve.address) {
addresses[reserve.symbol] = reserve.address;
tokenDecimals[reserve.symbol] = reserve.decimals;
continue;
}
const name = reserve.symbol + ' ERC20 Token';
const symbol = reserve.symbol;
const decimals = reserve.decimals;
const supply = decimalToInteger(reserve.supply, decimals);
const token = await web3Func(deploy, 'erc20Token' + symbol, 'ERC20Token', [name, symbol, decimals, supply]);
addresses[reserve.symbol] = token._address;
tokenDecimals[reserve.symbol] = reserve.decimals;
}
for (const converter of getConfig().converters) {
const type = converter.type;
const name = converter.symbol + (type == 0 ? ' Liquid Token' : ' Liquidity Pool');
const symbol = converter.symbol;
const decimals = converter.decimals;
const fee = percentageToPPM(converter.fee);
const tokens = converter.reserves.map(reserve => addresses[reserve.symbol]);
const weights = converter.reserves.map(reserve => percentageToPPM(reserve.weight));
const amounts = converter.reserves.map(reserve => decimalToInteger(reserve.balance, tokenDecimals[reserve.symbol]));
const value = amounts[converter.reserves.findIndex(reserve => reserve.symbol === 'ETH')];
await execute(converterRegistry.methods.newConverter(type, name, symbol, decimals, '1000000', tokens, weights));
const anchor = deployed(web3, 'IConverterAnchor', (await converterRegistry.methods.getAnchors().call()).slice(-1)[0]);
const converterBase = deployed(web3, 'ConverterBase', await anchor.methods.owner().call());
await execute(converterBase.methods.setConversionFee(fee));
await execute(converterBase.methods.acceptOwnership());
if (type !== 0 && amounts.every(amount => amount > 0)) {
for (let i = 0; i < converter.reserves.length; i++) {
const reserve = converter.reserves[i];
if (reserve.symbol !== 'ETH') {
await execute(deployed(web3, 'ERC20Token', tokens[i]).methods.approve(converterBase._address, amounts[i]));
}
if (type == 2) {
if (!reserve.oracle) {
// can be used to deploy test (static) oracles
/*
const chainlinkPriceOracle = await web3Func(deploy, 'chainlinkPriceOracle' + converter.symbol + reserve.symbol, 'ChainlinkETHToETHOracle', []);
reserve.oracle = chainlinkPriceOracle._address;
*/
}
await execute(oracleWhitelist.methods.addAddress(reserve.oracle));
}
}
if (type == 1) {
await execute(deployed(web3, 'LiquidityPoolV1Converter', converterBase._address).methods.addLiquidity(tokens, amounts, 1), value);
}
else if (type == 2) {
const deployedConverter = deployed(web3, 'LiquidityPoolV2Converter', converterBase._address);
await execute(deployedConverter.methods.activate(tokens[0], converter.reserves[0].oracle, converter.reserves[1].oracle));
for (let i = 0; i < converter.reserves.length; i++) {
await execute(deployedConverter.methods.addLiquidity(tokens[i], amounts[i], 1), value);
}
}
}
addresses[converter.symbol] = anchor._address;
}
await execute(contractRegistry.methods.registerAddress(Web3.utils.asciiToHex('BNTToken'), addresses.BNT));
await execute(conversionPathFinder.methods.setAnchorToken(addresses.BNT));
await execute(bancorFormula.methods.init());

@@ -182,2 +267,2 @@

run();
run();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc