Ejemplo n.º 1
0
 def setup_method(self):
     self.web3 = Web3(EthereumTesterProvider())
     self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
     self.our_address = Address(self.web3.eth.defaultAccount)
     self.other_address = Address(self.web3.eth.accounts[1])
     self.tx = TxManager.deploy(self.web3)
     self.token1 = DSToken.deploy(self.web3, 'ABC')
     self.token1.mint(Wad.from_number(1000000))
     self.token2 = DSToken.deploy(self.web3, 'DEF')
Ejemplo n.º 2
0
    def test_equals(self):
        # given
        token1 = DSToken.deploy(self.web3, 'ABC')
        token2 = DSToken.deploy(self.web3, 'DEF')
        token2b = ERC20Token(web3=self.web3, address=token2.address)

        # expect
        assert token1 == token1
        assert token2 == token2b
        assert not token1 == token2
        assert not token1 == token2b
Ejemplo n.º 3
0
 def setup_method(self):
     self.web3 = Web3(EthereumTesterProvider())
     self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
     self.our_address = Address(self.web3.eth.defaultAccount)
     self.second_address = Address(self.web3.eth.accounts[1])
     self.token = DSToken.deploy(self.web3, 'ABC')
     self.token.mint(Wad(1000000))
Ejemplo n.º 4
0
def new_sai() -> SaiDeployment:
    def deploy(web3, contract_name, args=None):
        contract_factory = web3.eth.contract(
            abi=json.loads(
                pkg_resources.resource_string('api.feed',
                                              f'abi/{contract_name}.abi')),
            bytecode=pkg_resources.resource_string('api.feed',
                                                   f'abi/{contract_name}.bin'))
        tx_hash = contract_factory.deploy(args=args)
        receipt = web3.eth.getTransactionReceipt(tx_hash)
        return receipt['contractAddress']

    web3 = Web3(EthereumTesterProvider())
    web3.eth.defaultAccount = web3.eth.accounts[0]
    our_address = Address(web3.eth.defaultAccount)
    sai = DSToken.deploy(web3, 'SAI')
    sin = DSToken.deploy(web3, 'SIN')
    gem = DSToken.deploy(web3, 'ETH')
    pip = DSValue.deploy(web3)
    skr = DSToken.deploy(web3, 'SKR')
    pot = DSVault.deploy(web3)
    pit = DSVault.deploy(web3)
    tip = deploy(web3, 'Tip')
    dad = DSGuard.deploy(web3)
    jug = deploy(web3, 'SaiJug', [sai.address.address, sin.address.address])
    jar = deploy(
        web3, 'SaiJar',
        [skr.address.address, gem.address.address, pip.address.address])

    tub = Tub.deploy(web3, Address(jar), Address(jug), pot.address,
                     pit.address, Address(tip))
    tap = Tap.deploy(web3, tub.address, pit.address)
    top = Top.deploy(web3, tub.address, tap.address)

    # set permissions
    dad.permit(DSGuard.ANY, DSGuard.ANY, DSGuard.ANY)
    for auth in [sai, sin, skr, pot, pit, tub, tap, top]:
        auth.set_authority(dad.address)

    # approve, mint some GEMs
    tub.approve(directly())
    gem.mint(Wad.from_number(1000000))

    web3.currentProvider.rpc_methods.evm_snapshot()
    return SaiDeployment(web3, our_address, gem, sai, skr, tub, tap, top)
parser.add_argument(
    "--step",
    help="Incremental step towards the maximum price (value between 0 and 1)",
    required=True,
    type=float)
args = parser.parse_args()

web3 = Web3(
    HTTPProvider(endpoint_uri=f"http://{args.rpc_host}:{args.rpc_port}"))
web3.eth.defaultAccount = args.eth_from  #TODO allow to use ETH_FROM env variable

config = Config(web3)

auction_manager_address = Address(
    config.get_contract_address("auctionManager"))
auction_manager = AuctionManager(web3=web3,
                                 address=auction_manager_address,
                                 is_splitting=True)
trader_address = Address(args.eth_from)
dai_address = ERC20Token.token_address_by_name("DAI")
dai_token = ERC20Token(web3=web3, address=dai_address)
mkr_address = ERC20Token.token_address_by_name("MKR")
mkr_token = DSToken(web3=web3, address=mkr_address)

strategy = BasicForwardAuctionStrategy(
    dai_token, mkr_token, args.mkr_dai_rate, args.step,
    Wad(args.minimal_mkr_bid * 1000000000000000000))
engine = AuctionEngine(auction_manager, trader_address, strategy,
                       args.frequency)
engine.start()
Ejemplo n.º 6
0
def setup_function():
    global token
    token = DSToken.deploy(web3, 'ABC')
Ejemplo n.º 7
0
 def setup_method(self):
     self.web3 = Web3(EthereumTesterProvider())
     self.web3.eth.defaultAccount = self.web3.eth.accounts[0]
     self.our_address = Address(self.web3.eth.defaultAccount)
     self.dstoken = DSToken.deploy(self.web3, 'ABC')