def run(logger):
    module = Contract('ModelDataSource')

    setter = module.setter()
    getter = module.getter()
    tester = module.tester()

    mLen = len(str(len(intervalLists)))
    nLen = max([len(str(len(intervalList))) for intervalList in intervalLists])

    totalGas = 0
    logger.info('Setting intervals...')
    for m in range(len(intervalLists)):
        for n in range(len(intervalLists[m])):
            gas = tester.setInterval(m, n, *intervalLists[m][n])
            setter.setInterval(m, n, *intervalLists[m][n])
            assert getter.getInterval(m, n) == intervalLists[m][n]
            logger.debug('Set interval {0:{1}} {2:{3}}: gas = {4}'.format(
                m, mLen, n, nLen, gas))
            totalGas += gas
    logger.info('Total gas = {}'.format(totalGas))

    setter.lock()
    try:
        setter.setInterval(0, 0, *intervalLists[0][0])
        logger.error('Lock failure')
    except ValueError:
        logger.info('Lock success')
def run(numOfTestsPerInterval,logger,conversionHandler,distributionFunc):
    intervals  = [[minN,maxN,minR,maxR,alpha,beta] for minN,maxN,minR,maxR,alpha,beta in sum(intervalLists,[])]
    numOfTests = numOfTestsPerInterval*len(intervals)
    testCount  = 0

    module1 = conversionHandler(FixedPoint)
    module2 = conversionHandler(Contract('ModelCalculator').getter())

    logger.info('Starting {} tests...'.format(numOfTests))
    for minN,maxN,minR,maxR,alpha,beta in intervals:
        module1.SetIntervalTypeInternally(alpha,beta)
        module2.SetIntervalTypeInternally(alpha,beta)
        minV,maxV = conversionHandler.inputRange(minN,maxN,minR,maxR)
        for newV in distributionFunc(minV,maxV,numOfTestsPerInterval):
            testCount += 1
            output1 = module1.outputFunc(newV,minN,maxN,minR,maxR,alpha,beta)
            output2 = module2.outputFunc(newV,minN,maxN,minR,maxR,alpha,beta)
            logger.periodic(testCount,numOfTests,'python = {}, solidity = {}'.format(output1,output2))
            if output1 != output2:
                logger.error('Emulation error:')
                logger.error('minN  = {}'.format(minN ))
                logger.error('maxN  = {}'.format(maxN ))
                logger.error('minR  = {}'.format(minR ))
                logger.error('maxR  = {}'.format(maxR ))
                logger.error('alpha = {}'.format(alpha))
                logger.error('beta  = {}'.format(beta ))
                logger.error('newV  = {}'.format(newV ))
                return
    logger.info('Done')
Пример #3
0
def run(fileName, logger):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            monetaryModelState, monetaryModel = init(logger,
                                                     command['timeout'])
        elif command['operation'] == 'buy':
            Contract.jump(command['elapsed'])
            sdrAmount = dec2wei(command['amount'])
            sgaAmount = Contract.decode(monetaryModel.setter().buy(sdrAmount),
                                        0, eventParams)['output']
            logger.debug('buy: {:.2f} SDR ==> {:.2f} SGA'.format(
                wei2dec(sdrAmount), wei2dec(sgaAmount)))
        elif command['operation'] == 'sell':
            Contract.jump(command['elapsed'])
            sgaAmount = dec2wei(command['amount'])
            sdrAmount = Contract.decode(monetaryModel.setter().sell(sgaAmount),
                                        0, eventParams)['output']
            logger.debug('sell: {:.2f} SGA ==> {:.2f} SDR'.format(
                wei2dec(sgaAmount), wei2dec(sdrAmount)))
        elif command['operation'] == 'info':
            logger.debug('SDR = {:.2f}'.format(
                wei2dec(monetaryModelState.getter().getSdrTotal())))
            logger.debug('SGA = {:.2f}'.format(
                wei2dec(monetaryModelState.getter().getSgaTotal())))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')
Пример #4
0
def run(fileName, logger):
    logger.info('Executing sequence...')
    for command in load(fileName):
        if command['operation'] == 'init':
            sgaToken = init(logger, command['timeout'])
        elif command['operation'] == 'buy':
            Contract.jump(command['elapsed'])
            ethAmount = dec2wei(command['amount'])
            sgaAmount = Contract.decode(
                sgaToken.setter({
                    'value': ethAmount
                }).exchange(), 2, eventParams)['output']
            logger.debug('buy: {:.2f} ETH ==> {:.2f} SGA'.format(
                wei2dec(ethAmount), wei2dec(sgaAmount)))
        elif command['operation'] == 'sell':
            Contract.jump(command['elapsed'])
            sgaAmount = dec2wei(command['amount'])
            ethAmount = Contract.decode(
                sgaToken.setter().transfer(sgaToken.address, sgaAmount), 2,
                eventParams)['output']
            logger.debug('sell: {:.2f} SGA ==> {:.2f} ETH'.format(
                wei2dec(sgaAmount), wei2dec(ethAmount)))
        elif command['operation'] == 'info':
            logger.debug('ETH = {:.2f}'.format(wei2dec(sgaToken.balance())))
            logger.debug('SGA = {:.2f}'.format(
                wei2dec(sgaToken.getter().totalSupply())))
        else:
            logger.debug('Undefined operation')
    logger.info('Done')
def run(numOfTestsPerInterval,logger,conversionHandler,distributionFunc):
    intervals  = [[minN,maxN,minR,maxR,alpha,beta] for minN,maxN,minR,maxR,alpha,beta in sum(intervalLists,[])]
    numOfTests = numOfTestsPerInterval*len(intervals)
    testCount  = 0

    maxGas = 0
    module = conversionHandler(Contract('ModelCalculator').tester())

    logger.info('Starting {} tests...'.format(numOfTests))
    for minN,maxN,minR,maxR,alpha,beta in intervals:
        module.SetIntervalTypeExternally(FixedPoint,alpha,beta)
        minV,maxV = conversionHandler.inputRange(minN,maxN,minR,maxR)
        for newV in distributionFunc(minV,maxV,numOfTestsPerInterval):
            testCount += 1
            curGas = module.outputFunc(newV,minN,maxN,minR,maxR,alpha,beta)
            maxGas = max(maxGas,curGas)
            logger.periodic(testCount,numOfTests,'curGas = {}, maxGas = {}'.format(curGas,maxGas))
    logger.info('Done:  maxGas = {}'.format(maxGas))
def run(logger):
    contractAddressLocatorProxy = Contract('ContractAddressLocatorProxy',[                                   ])
    modelCalculator             = Contract('ModelCalculator'            ,[                                   ])
    priceBandCalculator            = Contract('PriceBandCalculator'           ,[                                   ])
    reconciliationAdjuster           = Contract('ReconciliationAdjuster'          ,[                                   ])
    ethConverter        = Contract('ETHConverter'       ,[contractAddressLocatorProxy.address])
    rateApprover        = Contract('RateApprover'       ,[contractAddressLocatorProxy.address])
    modelDataSource                  = Contract('ModelDataSource'                 ,[                                   ])
    monetaryModel                   = Contract('MonetaryModel'                  ,[contractAddressLocatorProxy.address])
    transactionLimiter          = Contract('TransactionLimiter'         ,[contractAddressLocatorProxy.address])
    transactionManager          = Contract('TransactionManager'         ,[contractAddressLocatorProxy.address])
    authorizationDataSource     = Contract('AuthorizationDataSource'    ,[                                   ])
    sgaAuthorizationManager     = Contract('SGAAuthorizationManager'    ,[contractAddressLocatorProxy.address])
    walletsTradingDataSource           = Contract('WalletsTradingDataSource'          ,[contractAddressLocatorProxy.address])
    walletsTradingLimiterValueConverter            = Contract('WalletsTradingLimiterValueConverter'           ,[                                   ])
    tradingClasses              = Contract('TradingClasses'             ,[                                   ])
    sgaWalletsTradingLimiter              = Contract('SGAWalletsTradingLimiter'             ,[contractAddressLocatorProxy.address        ])
    reserveManager              = Contract('ReserveManager'             ,[contractAddressLocatorProxy.address])
    paymentManager                 = Contract('PaymentManager'                ,[contractAddressLocatorProxy.address])
    paymentQueue                   = Contract('PaymentQueue'                  ,[contractAddressLocatorProxy.address])
    redButton                   = Contract('RedButton'                  ,[                                   ])
    sgaTokenManager             = Contract('SGATokenManager'            ,[contractAddressLocatorProxy.address])

    initialize(modelDataSource.setter(),logger)

    walletsTradingLimiterValueConverter.setter().accept(Contract.owner)
    ethConverter.setter().accept(Contract.owner)
    authorizationDataSource.setter().accept(Contract.owner)
    authorizationDataSource.setter().upsertOne(Contract.owner,1,True,2**256-1,2**256-1,0)

    testCount  = 0
    numOfTests = len(CONSTANTS)**4
    logger.info('Starting {} tests...'.format(numOfTests))

    for factorN in CONSTANTS:
        for factorD in CONSTANTS:
            for priceN in CONSTANTS:
                for priceD in CONSTANTS:
                    testCount += 1
                    mintingPointTimersManager            = Contract('MintingPointTimersManager'           ,[contractAddressLocatorProxy.address,2**255])
                    mintManager            = Contract('MintManager'           ,[contractAddressLocatorProxy.address       ])
                    intervalIterator       = Contract('IntervalIterator'      ,[contractAddressLocatorProxy.address       ])
                    monetaryModelState         = Contract('MonetaryModelState'        ,[contractAddressLocatorProxy.address       ])
                    sgaToken               = Contract('SGAToken'              ,[contractAddressLocatorProxy.address       ])
                    contractAddressLocator = Contract('ContractAddressLocator',unzip([
                        ['IModelCalculator'        ,modelCalculator        .address],
                        ['IPriceBandCalculator'       ,priceBandCalculator       .address],
                        ['IReconciliationAdjuster'      ,reconciliationAdjuster      .address],
                        ['IETHConverter'   ,ethConverter   .address],
                        ['IModelDataSource'             ,modelDataSource             .address],
                        ['IMintingPointTimersManager'            ,mintingPointTimersManager            .address],
                        ['IMintManager'            ,mintManager            .address],
                        ['IIntervalIterator'       ,intervalIterator       .address],
                        ['IMonetaryModelState'         ,monetaryModelState         .address],
                        ['IMonetaryModel'              ,monetaryModel              .address],
                        ['ITransactionLimiter'     ,transactionLimiter     .address],
                        ['ITransactionManager'     ,transactionManager     .address],
                        ['ISGAToken'               ,sgaToken               .address],
                        ['IAuthorizationDataSource',authorizationDataSource.address],
                        ['ISGAAuthorizationManager',sgaAuthorizationManager.address],
                        ['IWalletsTradingDataSource'      ,walletsTradingDataSource      .address],
                        ['IWalletsTLValueConverter'       ,walletsTradingLimiterValueConverter       .address],
                        ['ITradingClasses'         ,tradingClasses         .address],
                        ['WalletsTLSGATokenManager'         ,sgaWalletsTradingLimiter         .address],
                        ['IReserveManager'         ,reserveManager         .address],
                        ['IPaymentManager'            ,paymentManager            .address],
                        ['IPaymentQueue'              ,paymentQueue              .address],
                        ['IRedButton'              ,redButton              .address],
                        ['ISGATokenManager'        ,sgaTokenManager        .address],
                        ["IRateApprover"           , rateApprover               .address],
                    ]))
                    contractAddressLocatorProxy.setter().upgrade(contractAddressLocator.address)
                    rateApprover.setter().setRateBounds(1, 0x10000000000000000,1,1,0x10000000000000000)
                    walletsTradingLimiterValueConverter.setter().setPrice(testCount,1,1)

                    reconciliationAdjuster.setter().setFactor(testCount,factorN,factorD)
                    ethConverter.setter().setPrice(testCount,priceN,priceD,priceN,priceD)
                    sdrInput     = reconciliationAdjuster.getter().adjustSell(MAX_SDR_AMOUNT)
                    ethInput     = ethConverter.getter().toEthAmount(sdrInput)
                    b_sgaOutput  = Contract.decode(sgaToken.setter({'value':ethInput}).exchange(),2,eventParams)['output']
                    b_sdrInModel = monetaryModelState.getter().getSdrTotal()
                    b_sgaInModel = monetaryModelState.getter().getSgaTotal()
                    b_sgaInToken = sgaToken.getter().totalSupply()
                    b_ethInToken = sgaToken.balance()
                    s_ethOutput  = Contract.decode(sgaToken.setter().transfer(sgaToken.address,b_sgaOutput),2,eventParams)['output']
                    s_sdrInModel = monetaryModelState.getter().getSdrTotal()
                    s_sgaInModel = monetaryModelState.getter().getSgaTotal()
                    s_sgaInToken = sgaToken.getter().totalSupply()
                    s_ethInToken = sgaToken.balance()
                    logger.periodic(testCount,numOfTests,'factorN      = {}'.format(int(factorN     )))
                    logger.periodic(testCount,numOfTests,'factorD      = {}'.format(int(factorD     )))
                    logger.periodic(testCount,numOfTests,'priceN       = {}'.format(int(priceN      )))
                    logger.periodic(testCount,numOfTests,'priceD       = {}'.format(int(priceD      )))
                    logger.periodic(testCount,numOfTests,'sdrInput     = {}'.format(int(sdrInput    )))
                    logger.periodic(testCount,numOfTests,'ethInput     = {}'.format(int(ethInput    )))
                    logger.periodic(testCount,numOfTests,'b_sgaOutput  = {}'.format(int(b_sgaOutput )))
                    logger.periodic(testCount,numOfTests,'b_sdrInModel = {}'.format(int(b_sdrInModel)))
                    logger.periodic(testCount,numOfTests,'b_sgaInModel = {}'.format(int(b_sgaInModel)))
                    logger.periodic(testCount,numOfTests,'b_sgaInToken = {}'.format(int(b_sgaInToken)))
                    logger.periodic(testCount,numOfTests,'b_ethInToken = {}'.format(int(b_ethInToken)))
                    logger.periodic(testCount,numOfTests,'s_ethOutput  = {}'.format(int(s_ethOutput )))
                    logger.periodic(testCount,numOfTests,'s_sdrInModel = {}'.format(int(s_sdrInModel)))
                    logger.periodic(testCount,numOfTests,'s_sgaInModel = {}'.format(int(s_sgaInModel)))
                    logger.periodic(testCount,numOfTests,'s_sgaInToken = {}'.format(int(s_sgaInToken)))
                    logger.periodic(testCount,numOfTests,'s_ethInToken = {}'.format(int(s_ethInToken)))
Пример #7
0
def init(logger, timeout):
    contractAddressLocatorProxy = Contract('ContractAddressLocatorProxy', [])
    modelCalculator = Contract('ModelCalculator', [])
    priceBandCalculator = Contract('PriceBandCalculator', [])
    modelDataSource = Contract('ModelDataSource', [])
    mintingPointTimersManager = Contract(
        'MintingPointTimersManager',
        [contractAddressLocatorProxy.address, timeout])
    mintManager = Contract('MintManager',
                           [contractAddressLocatorProxy.address])
    intervalIterator = Contract('IntervalIterator',
                                [contractAddressLocatorProxy.address])
    monetaryModelState = Contract('MonetaryModelState',
                                  [contractAddressLocatorProxy.address])
    monetaryModel = Contract('MonetaryModel',
                             [contractAddressLocatorProxy.address])
    contractAddressLocator = Contract(
        'ContractAddressLocator',
        unzip([
            ['IModelCalculator', modelCalculator.address],
            ['IPriceBandCalculator', priceBandCalculator.address],
            ['IModelDataSource', modelDataSource.address],
            ['IMintingPointTimersManager', mintingPointTimersManager.address],
            ['IMintManager', mintManager.address],
            ['IIntervalIterator', intervalIterator.address],
            ['IMonetaryModelState', monetaryModelState.address],
            ['IMonetaryModel', monetaryModel.address],
            ['ITransactionManager', Contract.owner],
        ]))

    contractAddressLocatorProxy.setter().upgrade(
        contractAddressLocator.address)

    initialize(modelDataSource.setter(), logger)

    return monetaryModelState, monetaryModel
Пример #8
0
def init(logger, timeout):
    contractAddressLocatorProxy = Contract('ContractAddressLocatorProxy', [])
    modelCalculator = Contract('ModelCalculator', [])
    priceBandCalculator = Contract('PriceBandCalculator', [])
    reconciliationAdjuster = Contract('ReconciliationAdjuster', [])
    ethConverter = Contract('ETHConverter',
                            [contractAddressLocatorProxy.address])
    modelDataSource = Contract('ModelDataSource', [])
    mintingPointTimersManager = Contract(
        'MintingPointTimersManager',
        [contractAddressLocatorProxy.address, timeout])
    mintManager = Contract('MintManager',
                           [contractAddressLocatorProxy.address])
    intervalIterator = Contract('IntervalIterator',
                                [contractAddressLocatorProxy.address])
    monetaryModelState = Contract('MonetaryModelState',
                                  [contractAddressLocatorProxy.address])
    monetaryModel = Contract('MonetaryModel',
                             [contractAddressLocatorProxy.address])
    transactionLimiter = Contract('TransactionLimiter',
                                  [contractAddressLocatorProxy.address])
    transactionManager = Contract('TransactionManager',
                                  [contractAddressLocatorProxy.address])
    sgaToken = Contract('SGAToken', [contractAddressLocatorProxy.address])
    authorizationDataSource = Contract('AuthorizationDataSource', [])
    sgaAuthorizationManager = Contract('SGAAuthorizationManager',
                                       [contractAddressLocatorProxy.address])
    walletsTradingDataSource = Contract('WalletsTradingDataSource',
                                        [contractAddressLocatorProxy.address])
    walletsTradingLimiterValueConverter = Contract(
        'WalletsTradingLimiterValueConverter', [])
    tradingClasses = Contract('TradingClasses', [])
    sgaWalletsTradingLimiter = Contract('SGAWalletsTradingLimiter',
                                        [contractAddressLocatorProxy.address])
    reserveManager = Contract('ReserveManager',
                              [contractAddressLocatorProxy.address])
    paymentManager = Contract('PaymentManager',
                              [contractAddressLocatorProxy.address])
    paymentQueue = Contract('PaymentQueue',
                            [contractAddressLocatorProxy.address])
    redButton = Contract('RedButton', [])
    sgaTokenManager = Contract('SGATokenManager',
                               [contractAddressLocatorProxy.address])
    contractAddressLocator = Contract(
        'ContractAddressLocator',
        unzip([
            ['IModelCalculator', modelCalculator.address],
            ['IPriceBandCalculator', priceBandCalculator.address],
            ['IReconciliationAdjuster', reconciliationAdjuster.address],
            ['IETHConverter', ethConverter.address],
            ['IModelDataSource', modelDataSource.address],
            ['IMintingPointTimersManager', mintingPointTimersManager.address],
            ['IMintManager', mintManager.address],
            ['IIntervalIterator', intervalIterator.address],
            ['IMonetaryModelState', monetaryModelState.address],
            ['IMonetaryModel', monetaryModel.address],
            ['ITransactionLimiter', transactionLimiter.address],
            ['ITransactionManager', transactionManager.address],
            ['ISGAToken', sgaToken.address],
            ['IAuthorizationDataSource', authorizationDataSource.address],
            ['ISGAAuthorizationManager', sgaAuthorizationManager.address],
            ['IWalletsTradingDataSource', walletsTradingDataSource.address],
            [
                'IWalletsTradingLimiterValueConverter',
                walletsTradingLimiterValueConverter.address
            ],
            ['ITradingClasses', tradingClasses.address],
            ['IWalletsTradingLimiter', sgaWalletsTradingLimiter.address],
            ['IReserveManager', reserveManager.address],
            ['IPaymentManager', paymentManager.address],
            ['IPaymentQueue', paymentQueue.address],
            ['IRedButton', redButton.address],
            ['ISGATokenManager', sgaTokenManager.address],
        ]))

    contractAddressLocatorProxy.setter().upgrade(
        contractAddressLocator.address)

    initialize(modelDataSource.setter(), logger)

    authorizationDataSource.setter().accept(Contract.owner)
    authorizationDataSource.setter().upsertOne(Contract.owner, 1, True,
                                               2**256 - 1, 2**256 - 1, 0)

    return sgaToken
def run(logger):
    contractAddressLocatorProxy = Contract('ContractAddressLocatorProxy', [])
    aggregatorInterfaceMockup = Contract('AggregatorInterfaceMockup', [])
    modelCalculator = Contract('ModelCalculator', [])
    priceBandCalculator = Contract('PriceBandCalculator', [])
    reconciliationAdjuster = Contract('ReconciliationAdjuster', [])
    ethConverter = Contract('ETHConverter',
                            [contractAddressLocatorProxy.address])
    rateApprover = Contract('OracleRateApprover', [
        contractAddressLocatorProxy.address, aggregatorInterfaceMockup.address,
        10000
    ])
    modelDataSource = Contract('ModelDataSource', [])
    monetaryModel = Contract('MonetaryModel',
                             [contractAddressLocatorProxy.address])
    transactionLimiter = Contract('TransactionLimiter',
                                  [contractAddressLocatorProxy.address])
    transactionManager = Contract('TransactionManager',
                                  [contractAddressLocatorProxy.address])
    authorizationDataSource = Contract('AuthorizationDataSource', [])
    sgrAuthorizationManager = Contract('SGRAuthorizationManager',
                                       [contractAddressLocatorProxy.address])
    buyWalletsTradingDataSource = Contract(
        'WalletsTradingDataSource', [contractAddressLocatorProxy.address])
    sellWalletsTradingDataSource = Contract(
        'WalletsTradingDataSource', [contractAddressLocatorProxy.address])
    sgrBuyWalletsTradingLimiter = Contract(
        'SGRBuyWalletsTradingLimiter', [contractAddressLocatorProxy.address])
    sgrSellWalletsTradingLimiter = Contract(
        'SGRSellWalletsTradingLimiter', [contractAddressLocatorProxy.address])
    walletsTradingLimiterValueConverter = Contract(
        'WalletsTradingLimiterValueConverter', [])
    tradingClasses = Contract('TradingClasses', [])

    reserveManager = Contract('ReserveManager',
                              [contractAddressLocatorProxy.address])
    paymentManager = Contract('PaymentManager',
                              [contractAddressLocatorProxy.address])
    paymentQueue = Contract('PaymentQueue',
                            [contractAddressLocatorProxy.address])
    redButton = Contract('RedButton', [])
    sgrTokenManager = Contract('SGRTokenManager',
                               [contractAddressLocatorProxy.address])

    initialize(modelDataSource.setter(), logger)

    walletsTradingLimiterValueConverter.setter().accept(Contract.owner)
    ethConverter.setter().accept(Contract.owner)
    authorizationDataSource.setter().accept(Contract.owner)
    buyWalletsTradingDataSource.setter().setAuthorizedExecutorsIdentifier([
        Web3.toHex(text='BuyWalletsTLSGRTokenManager'),
        Web3.toHex(text='WalletsTLSGNTokenManager')
    ])
    sellWalletsTradingDataSource.setter().setAuthorizedExecutorsIdentifier(
        [Web3.toHex(text='SellWalletsTLSGRTokenManager')])

    authorizationDataSource.setter().upsertOne(Contract.owner, 1, True,
                                               2**256 - 1, 2**256 - 1,
                                               2**256 - 1, 0)

    testCount = 0
    numOfTests = len(CONSTANTS)**4
    logger.info('Starting {} tests...'.format(numOfTests))

    for factorN in CONSTANTS:
        for factorD in CONSTANTS:
            for priceN in CONSTANTS:
                for priceD in CONSTANTS:
                    testCount += 1
                    mintingPointTimersManager = Contract(
                        'MintingPointTimersManager',
                        [contractAddressLocatorProxy.address, 2**255])
                    mintManager = Contract(
                        'MintManager', [contractAddressLocatorProxy.address])
                    intervalIterator = Contract(
                        'IntervalIterator',
                        [contractAddressLocatorProxy.address])
                    monetaryModelState = Contract(
                        'MonetaryModelState',
                        [contractAddressLocatorProxy.address])
                    sgrToken = Contract('SGRToken',
                                        [contractAddressLocatorProxy.address])
                    contractAddressLocator = Contract(
                        'ContractAddressLocator',
                        unzip([
                            ['IModelCalculator', modelCalculator.address],
                            [
                                'IPriceBandCalculator',
                                priceBandCalculator.address
                            ],
                            [
                                'IReconciliationAdjuster',
                                reconciliationAdjuster.address
                            ],
                            ['IETHConverter', ethConverter.address],
                            ['IModelDataSource', modelDataSource.address],
                            [
                                'IMintingPointTimersManager',
                                mintingPointTimersManager.address
                            ],
                            ['IMintManager', mintManager.address],
                            ['IIntervalIterator', intervalIterator.address],
                            [
                                'IMonetaryModelState',
                                monetaryModelState.address
                            ],
                            ['IMonetaryModel', monetaryModel.address],
                            [
                                'ITransactionLimiter',
                                transactionLimiter.address
                            ],
                            [
                                'ITransactionManager',
                                transactionManager.address
                            ],
                            ['ISGRToken', sgrToken.address],
                            [
                                'IAuthorizationDataSource',
                                authorizationDataSource.address
                            ],
                            [
                                'ISGRAuthorizationManager',
                                sgrAuthorizationManager.address
                            ],
                            [
                                'IWalletsTLValueConverter',
                                walletsTradingLimiterValueConverter.address
                            ],
                            ['ITradingClasses', tradingClasses.address],
                            [
                                "BuyWalletsTLSGRTokenManager",
                                sgrBuyWalletsTradingLimiter.address
                            ],
                            [
                                "SellWalletsTLSGRTokenManager",
                                sgrSellWalletsTradingLimiter.address
                            ],
                            [
                                'BuyWalletsTradingDataSource',
                                buyWalletsTradingDataSource.address
                            ],
                            [
                                'SellWalletsTradingDataSource',
                                sellWalletsTradingDataSource.address
                            ],
                            ['IReserveManager', reserveManager.address],
                            ['IPaymentManager', paymentManager.address],
                            ['IPaymentQueue', paymentQueue.address],
                            ['IRedButton', redButton.address],
                            ['ISGRTokenManager', sgrTokenManager.address],
                            ["IRateApprover", rateApprover.address],
                        ]))

                    price = int((priceN / priceD) * 100000000)
                    tooLowPrice = price == 0

                    try:
                        contractAddressLocatorProxy.setter().upgrade(
                            contractAddressLocator.address)

                        aggregatorInterfaceMockup.setter().setLatestAnswer(
                            price)

                        walletsTradingLimiterValueConverter.setter().setPrice(
                            testCount, 1, 1)

                        reconciliationAdjuster.setter().setFactor(
                            testCount, factorN, factorD)
                        ethConverter.setter().setPrice(testCount, priceN,
                                                       priceD, priceN, priceD)
                        sdrInput = reconciliationAdjuster.getter().adjustSell(
                            MAX_SDR_AMOUNT)
                        ethInput = ethConverter.getter().toEthAmount(sdrInput)
                        b_sgrOutput = Contract.decode(
                            sgrToken.setter({
                                'value': ethInput
                            }).exchange(), 2, eventParams)['output']
                        b_sdrInModel = monetaryModelState.getter().getSdrTotal(
                        )
                        b_sgrInModel = monetaryModelState.getter().getSgrTotal(
                        )
                        b_sgrInToken = sgrToken.getter().totalSupply()
                        b_ethInToken = sgrToken.balance()
                        s_ethOutput = Contract.decode(
                            sgrToken.setter().transfer(sgrToken.address,
                                                       b_sgrOutput), 2,
                            eventParams)['output']
                        s_sdrInModel = monetaryModelState.getter().getSdrTotal(
                        )
                        s_sgrInModel = monetaryModelState.getter().getSgrTotal(
                        )
                        s_sgrInToken = sgrToken.getter().totalSupply()
                        s_ethInToken = sgrToken.balance()
                        logger.periodic(
                            testCount, numOfTests,
                            'factorN      = {}'.format(int(factorN)))
                        logger.periodic(
                            testCount, numOfTests,
                            'factorD      = {}'.format(int(factorD)))
                        logger.periodic(
                            testCount, numOfTests,
                            'priceN       = {}'.format(int(priceN)))
                        logger.periodic(
                            testCount, numOfTests,
                            'priceD       = {}'.format(int(priceD)))
                        logger.periodic(
                            testCount, numOfTests,
                            'sdrInput     = {}'.format(int(sdrInput)))
                        logger.periodic(
                            testCount, numOfTests,
                            'ethInput     = {}'.format(int(ethInput)))
                        logger.periodic(
                            testCount, numOfTests,
                            'b_sgrOutput  = {}'.format(int(b_sgrOutput)))
                        logger.periodic(
                            testCount, numOfTests,
                            'b_sdrInModel = {}'.format(int(b_sdrInModel)))
                        logger.periodic(
                            testCount, numOfTests,
                            'b_sgrInModel = {}'.format(int(b_sgrInModel)))
                        logger.periodic(
                            testCount, numOfTests,
                            'b_sgrInToken = {}'.format(int(b_sgrInToken)))
                        logger.periodic(
                            testCount, numOfTests,
                            'b_ethInToken = {}'.format(int(b_ethInToken)))
                        logger.periodic(
                            testCount, numOfTests,
                            's_ethOutput  = {}'.format(int(s_ethOutput)))
                        logger.periodic(
                            testCount, numOfTests,
                            's_sdrInModel = {}'.format(int(s_sdrInModel)))
                        logger.periodic(
                            testCount, numOfTests,
                            's_sgrInModel = {}'.format(int(s_sgrInModel)))
                        logger.periodic(
                            testCount, numOfTests,
                            's_sgrInToken = {}'.format(int(s_sgrInToken)))
                        logger.periodic(
                            testCount, numOfTests,
                            's_ethInToken = {}'.format(int(s_ethInToken)))

                    except Exception as e:
                        if (tooLowPrice):
                            logger.periodic(
                                testCount, numOfTests,
                                'tooLowPrice priceN {} priceD {} price {}'.
                                format(priceN, priceD, price))
                        else:
                            raise e