Ejemplo n.º 1
0
    def __init__(self):
        super().__init__()
        self.tub_address = Address(self.config.get_contract_address("saiTub"))
        self.tub = Tub(web3=self.web3, address=self.tub_address)
        self.tap_address = Address(self.config.get_contract_address("saiTap"))
        self.tap = Tap(web3=self.web3, address=self.tap_address)
        self.top_address = Address(self.config.get_contract_address("saiTop"))
        self.top = Top(web3=self.web3, address=self.top_address)
        self.otc_address = Address(self.config.get_contract_address("otc"))
        self.otc = SimpleMarket(web3=self.web3, address=self.otc_address)

        self.skr = ERC20Token(web3=self.web3, address=self.tub.skr())
        self.sai = ERC20Token(web3=self.web3, address=self.tub.sai())
        self.gem = DSEthToken(web3=self.web3, address=self.tub.gem())
        ERC20Token.register_token(self.tub.skr(), 'SKR')
        ERC20Token.register_token(self.tub.sai(), 'SAI')
        ERC20Token.register_token(self.tub.gem(), 'WETH')
Ejemplo n.º 2
0
 def __init__(self, tub: Tub):
     self.tub = tub
     super().__init__(
         source_token=self.tub.skr(),
         target_token=self.tub.gem(),
         rate=tub.jar_bid(),
         max_source_amount=Wad.from_number(
             1000000),  #1 mio SKR = infinity ;)
         method="tub.exit()")
Ejemplo n.º 3
0
 def __init__(self, tub: Tub):
     self.tub = tub
     super().__init__(
         source_token=self.tub.gem(),
         target_token=self.tub.skr(),
         rate=(Ray.from_number(1) / tub.jar_ask()),
         max_source_amount=Wad.from_number(
             1000000),  #1 mio ETH = infinity ;)
         method="tub.join()")
Ejemplo n.º 4
0
class SaiKeeper(Keeper):
    def __init__(self):
        super().__init__()
        self.tub = Tub(web3=self.web3,
                       address=Address(
                           self.config.get_contract_address("saiTub")))
        self.tap = Tap(web3=self.web3,
                       address=Address(
                           self.config.get_contract_address("saiTap")))
        self.top = Top(web3=self.web3,
                       address=Address(
                           self.config.get_contract_address("saiTop")))
        self.otc = MatchingMarket(web3=self.web3,
                                  address=Address(
                                      self.config.get_contract_address("otc")))

        self.skr = ERC20Token(web3=self.web3, address=self.tub.skr())
        self.sai = ERC20Token(web3=self.web3, address=self.tub.sai())
        self.gem = DSEthToken(web3=self.web3, address=self.tub.gem())
        ERC20Token.register_token(self.tub.skr(), 'SKR')
        ERC20Token.register_token(self.tub.sai(), 'SAI')
        ERC20Token.register_token(self.tub.gem(), 'WETH')

    def startup(self):
        # implemented only to avoid IntelliJ IDEA warning
        super().startup()
Ejemplo n.º 5
0
def new_sai() -> SaiDeployment:
    def deploy(web3, contract_name, args=None):
        contract_factory = web3.eth.contract(
            abi=json.loads(
                pkg_resources.resource_string('keeper.api.feed',
                                              f'abi/{contract_name}.abi')),
            bytecode=pkg_resources.resource_string('keeper.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).transact()
    tub.set_authority(dad.address)
    for auth in [sai, sin, skr, pot, pit, tap, top]:
        auth.set_authority(dad.address).transact()

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

    web3.currentProvider.rpc_methods.evm_snapshot()
    return SaiDeployment(web3, our_address, gem, sai, sin, skr, tub, tap, top)