예제 #1
0
    def ilk(self, name: str) -> Ilk:
        assert isinstance(name, str)

        b32_ilk = Ilk(name).toBytes()
        (art, rate, spot, line, dust) = self._contract.functions.ilks(b32_ilk).call()

        # We could get "ink" from the urn, but caller must provide an address.
        return Ilk(name, rate=Ray(rate), ink=Wad(0), art=Wad(art), spot=Ray(spot), line=Rad(line), dust=Rad(dust))
예제 #2
0
    def urn(self, ilk: Ilk, address: Address) -> Urn:
        assert isinstance(ilk, Ilk)
        assert isinstance(address, Address)

        (ink, art) = self._contract.functions.urns(ilk.toBytes(),
                                                   address.address).call()
        return Urn(address, ilk, Wad(ink), Wad(art))
예제 #3
0
    def frob(self, ilk: Ilk, urn_address: Address, dink: Wad, dart: Wad, collateral_owner=None, dai_recipient=None):
        """Adjust amount of collateral and reserved amount of Dai for the CDP

        Args:
            ilk: Identifies the type of collateral.
            urn_address: CDP holder (address of the Urn).
            dink: Amount of collateral to add/remove.
            dart: Adjust CDP debt (amount of Dai available for borrowing).
            collateral_owner: Holder of the collateral used to fund the CDP.
            dai_recipient: Party receiving the Dai.
        """
        assert isinstance(ilk, Ilk)
        assert isinstance(urn_address, Address)
        assert isinstance(dink, Wad)
        assert isinstance(dart, Wad)
        assert isinstance(collateral_owner, Address) or (collateral_owner is None)
        assert isinstance(dai_recipient, Address) or (dai_recipient is None)

        # Usually these addresses are the same as the account holding the urn
        v = collateral_owner or urn_address
        w = dai_recipient or urn_address
        assert isinstance(v, Address)
        assert isinstance(w, Address)

        self.validate_frob(ilk, urn_address, dink, dart)

        if v == urn_address and w == urn_address:
            logger.info(f"frobbing {ilk.name} urn {urn_address.address} with dink={dink}, dart={dart}")
        else:
            logger.info(f"frobbing {ilk.name} urn {urn_address.address} "
                        f"with dink={dink} from {v.address}, "
                        f"dart={dart} for {w.address}")

        return Transact(self, self.web3, self.abi, self.address, self._contract,
                        'frob', [ilk.toBytes(), urn_address.address, v.address, w.address, dink.value, dart.value])
예제 #4
0
    def bark(self, ilk: Ilk, urn: Urn, kpr: Address = None) -> Transact:
        """ Initiate liquidation of a vault, kicking off a flip auction

        Args:
            ilk: Identifies the type of collateral.
            urn: Address of the vault holder.
            kpr: Keeper address; leave empty to use web3 default.
        """
        assert isinstance(ilk, Ilk)
        assert isinstance(urn, Urn)
        if kpr:
            assert isinstance(kpr, Address)
        else:
            kpr = Address(self.web3.eth.defaultAccount)

        ilk = self.vat.ilk(ilk.name)
        urn = self.vat.urn(ilk, urn.address)
        rate = self.vat.ilk(ilk.name).rate
        logger.info(
            f'Barking {ilk.name} vault {urn.address.address} with ink={urn.ink} spot={ilk.spot} '
            f'art={urn.art} rate={rate}')

        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'bark',
                        [ilk.toBytes(), urn.address.address, kpr.address])
예제 #5
0
 def __init__(self, log):
     self.ilk = Ilk.fromBytes(log['args']['ilk'])
     self.urn = Urn(Address(log['args']['urn']))
     self.ink = Wad(log['args']['ink'])
     self.art = Wad(log['args']['art'])
     self.due = Rad(log['args']['due'])
     self.clip = Address(log['args']['clip'])
     self.id = int(log['args']['id'])
     self.raw = log
예제 #6
0
    def flux(self, ilk: Ilk, src: Address, dst: Address, wad: Wad) -> Transact:
        """Move Ilk balance in Vat from source address to destiny address

        Args:
            ilk: Identifies the type of collateral.
            src: Source of the collateral (address of the source).
            dst: Destiny of the collateral (address of the recipient).
            wad: Amount of collateral to move.
        """
        assert isinstance(ilk, Ilk)
        assert isinstance(src, Address)
        assert isinstance(dst, Address)
        assert isinstance(wad, Wad)

        flux_args = [ilk.toBytes(), src.address, dst.address, wad.value]
        return Transact(self, self.web3, self.abi, self.address, self._contract, 'flux', flux_args)
예제 #7
0
    def bite(self, ilk: Ilk, urn: Urn) -> Transact:
        """ Initiate liquidation of a vault, kicking off a flip auction

        Args:
            ilk: Identifies the type of collateral.
            urn: Address of the vault holder.
        """
        assert isinstance(ilk, Ilk)
        assert isinstance(urn, Urn)

        ilk = self.vat.ilk(ilk.name)
        urn = self.vat.urn(ilk, urn.address)
        rate = self.vat.ilk(ilk.name).rate
        logger.info(f'Biting {ilk.name} vault {urn.address.address} with ink={urn.ink} spot={ilk.spot} '
                    f'art={urn.art} rate={rate}')

        return Transact(self, self.web3, self.abi, self.address, self._contract,
                        'bite', [ilk.toBytes(), urn.address.address])
예제 #8
0
    def fork(self, ilk: Ilk, src: Address, dst: Address, dink: Wad, dart: Wad) -> Transact:
        """Split a Vault - binary approval or splitting/merging Vault's

        Args:
            ilk: Identifies the type of collateral.
            src: Address of the source Urn.
            dst: Address of the destiny Urn.
            dink: Amount of collateral to exchange.
            dart: Amount of stable coin debt to exchange.
        """
        assert isinstance(ilk, Ilk)
        assert isinstance(src, Address)
        assert isinstance(dst, Address)
        assert isinstance(dink, Wad)
        assert isinstance(dart, Wad)

        fork_args = [ilk.toBytes(), src.address, dst.address, dink.value, dart.value]
        return Transact(self, self.web3, self.abi, self.address, self._contract, 'fork', fork_args)
예제 #9
0
    def flipper(self, ilk: Ilk) -> Address:
        assert isinstance(ilk, Ilk)

        (flip, chop, dunk) = self._contract.functions.ilks(ilk.toBytes()).call()
        return Address(flip)
예제 #10
0
    def dunk(self, ilk: Ilk) -> Rad:
        assert isinstance(ilk, Ilk)

        (flip, chop, dunk) = self._contract.functions.ilks(ilk.toBytes()).call()
        return Rad(dunk)
예제 #11
0
    def rho(self, ilk: Ilk) -> int:
        assert isinstance(ilk, Ilk)

        return Web3.toInt(self._contract.functions.ilks(ilk.toBytes()).call()[1])
예제 #12
0
    def duty(self, ilk: Ilk) -> Ray:
        assert isinstance(ilk, Ilk)

        return Ray(self._contract.functions.ilks(ilk.toBytes()).call()[0])
예제 #13
0
    def mat(self, ilk: Ilk) -> Ray:
        assert isinstance(ilk, Ilk)
        (pip, mat) = self._contract.functions.ilks(ilk.toBytes()).call()

        return Ray(mat)
예제 #14
0
    def gem(self, ilk: Ilk, urn: Address) -> Wad:
        assert isinstance(ilk, Ilk)
        assert isinstance(urn, Address)

        return Wad(self._contract.functions.gem(ilk.toBytes(), urn.address).call())
예제 #15
0
    def clipper(self, ilk: Ilk) -> Address:
        assert isinstance(ilk, Ilk)

        (clip, chop, hole, dirt) = self._contract.functions.ilks(ilk.toBytes()).call()
        return Address(clip)
예제 #16
0
    def drip(self, ilk: Ilk) -> Transact:
        assert isinstance(ilk, Ilk)

        return Transact(self, self.web3, self.abi, self.address, self._contract, 'drip', [ilk.toBytes()])
예제 #17
0
 def dirt(self, ilk: Ilk) -> Rad:
     assert isinstance(ilk, Ilk)
     (clip, chop, hole, dirt) = self._contract.functions.ilks(ilk.toBytes()).call()
     return Rad(dirt)
예제 #18
0
파일: join.py 프로젝트: mtyou/pymaker
 def ilk(self):
     return Ilk.fromBytes(self._contract.functions.ilk().call())