def test_direct_approval_should_not_approve_if_already_approved():
    # given
    global web3, our_address, second_address, token
    token.approve(second_address, Wad(2**248 + 17))

    # when
    directly()(token, second_address, "some-name")

    # then
    assert token.allowance_of(our_address, second_address) == Wad(2**248 + 17)
示例#2
0
    def cups(self, cup_id: int) -> Cup:
        """Get the cup details.

        Args:
            cup_id: Id of the cup to get the details of.

        Returns:
            Class encapsulating cup details.
        """
        assert isinstance(cup_id, int)
        array = self._contractTub.call().cups(int_to_bytes32(cup_id))
        return Cup(cup_id, Address(array[0]), Wad(array[1]), Wad(array[2]))
def test_via_tx_manager_approval_should_not_approve_if_already_approved():
    # given
    global web3, our_address, second_address, token
    tx = TxManager.deploy(web3)
    tx.execute([], [
        Invocation(token.address,
                   token.approve_calldata(second_address, Wad(2**248 + 19)))
    ])

    # when
    via_tx_manager(tx)(token, second_address, "some-name")

    # then
    assert token.allowance_of(tx.address, second_address) == Wad(2**248 + 19)
    def test_approve(self):
        # given
        assert self.token1.allowance_of(self.our_address,
                                        self.tx.address) == Wad(0)
        assert self.token2.allowance_of(self.our_address,
                                        self.tx.address) == Wad(0)

        # when
        self.tx.approve([self.token1, self.token2], directly())

        # then
        assert self.token1.allowance_of(self.our_address,
                                        self.tx.address) == Wad(2**256 - 1)
        assert self.token2.allowance_of(self.our_address,
                                        self.tx.address) == Wad(2**256 - 1)
示例#5
0
    def jar_gap(self) -> Wad:
        """Get the current spread for `join` and `exit`.

        Returns:
            The current spread for `join` and `exit`. `1.0` means no spread, `1.01` means 1% spread.
        """
        return Wad(self._contractJar.call().gap())
示例#6
0
    def air(self) -> Wad:
        """Get the amount of backing collateral.

        Returns:
            The amount of backing collateral in SKR.
        """
        return Wad(self._contractTub.call().air())
示例#7
0
    def pie(self) -> Wad:
        """Get the amount of raw collateral.

        Returns:
            The amount of raw collateral in GEM.
        """
        return Wad(self._contractTub.call().pie())
示例#8
0
    def ice(self) -> Wad:
        """Get the amount of good debt.

        Returns:
            The amount of good debt in SAI.
        """
        return Wad(self._contractTub.call().ice())
示例#9
0
    def hat(self) -> Wad:
        """Get the debt ceiling.

        Returns:
            The debt ceiling in SAI.
        """
        return Wad(self._contractTub.call().hat())
示例#10
0
    def fog(self) -> Wad:
        """Get the amount of SKR pending liquidation.

        Returns:
            The amount of SKR pending liquidation, in SKR.
        """
        return Wad(self._contract.call().fog())
示例#11
0
    def pie(self) -> Wad:
        """Get the total pool value (in ref).

        Returns:
            The the total pool value (in ref).
        """
        return Wad(self._contract.call().pie())
示例#12
0
    def gap(self) -> Wad:
        """Get the spread, charged on `take()`.

        Returns:
            The current value of the spread. `1.0` means no spread. `1.02` means 2% spread.
        """
        return Wad(self._contract.call().gap())
示例#13
0
    def bid(self) -> Wad:
        """Get the current price of SKR in SAI for `boom`.

        Returns:
            The SKR in SAI price that will be used on `boom()`.
        """
        return Wad(self._contract.call().bid())
示例#14
0
    def ask(self) -> Wad:
        """Get the current price of SKR in SAI for `bust`.

        Returns:
            The SKR in SAI price that will be used on `bust()`.
        """
        return Wad(self._contract.call().ask())
示例#15
0
    def gap(self) -> Wad:
        """Get the current spread for `boom` and `bust`.

        Returns:
            The current spread for `boom` and `bust`. `1.0` means no spread, `1.01` means 1% spread.
        """
        return Wad(self._contract.call().gap())
示例#16
0
    def s2s(self) -> Wad:
        """Get the current SKR per SAI rate (for `boom` and `bust`).

        Returns:
            The current SKR per SAI rate.
        """
        return Wad(self._contract.call().s2s())
示例#17
0
    def woe(self) -> Wad:
        """Get the amount of bad debt.

        Returns:
            The amount of bad debt in SAI.
        """
        return Wad(self._contract.call().woe())
def test_direct_approval():
    # given
    global web3, our_address, second_address, token

    # when
    directly()(token, second_address, "some-name")

    # then
    assert token.allowance_of(our_address, second_address) == Wad(2**256 - 1)
示例#19
0
    def tag(self) -> Wad:
        """Get the current price (refs per alt).

        The price is read from the price feed (`tip()`) every time this method gets called.

        Returns:
            The current price (refs per alt).
        """
        return Wad(self._contract.call().tag())
示例#20
0
    def joy(self) -> Wad:
        """Get the amount of surplus SAI.

        Surplus SAI can be processed using `boom()`.

        Returns:
            The amount of surplus SAI accumulated in the Tub.
        """
        return Wad(self._contract.call().joy())
def test_via_tx_manager_approval():
    # given
    global web3, our_address, second_address, token
    tx = TxManager.deploy(web3)

    # when
    via_tx_manager(tx)(token, second_address, "some-name")

    # then
    assert token.allowance_of(tx.address, second_address) == Wad(2**256 - 1)
示例#22
0
    def tag(self) -> Wad:
        """Get the reference price (REF per SKR).

        The price is read from the price feed (`tip()`) every time this method gets called.
        Its value is actually the value from the feed (REF per GEM) multiplied by `per()` (GEM per SKR).

        Returns:
            The reference price (REF per SKR).
        """
        return Wad(self._contractJar.call().tag())
示例#23
0
    def par(self) -> Wad:
        """Get the accrued holder fee (REF per SAI).

        Every invocation of this method calls `prod()` internally, so the value you receive is always up-to-date.
        But as calling it doesn't result in an Ethereum transaction, the actual `_par` value in the smart
        contract storage does not get updated.

        Returns:
            The accrued holder fee.
        """
        return Wad(self._contractTip.call().par())
示例#24
0
    def ink(self, cup_id: int) -> Wad:
        """Get the amount of SKR collateral locked in a cup.

        Args:
            cup_id: Id of the cup.

        Returns:
            Amount of SKR collateral locked in the cup, in SKR.
        """
        assert isinstance(cup_id, int)
        return Wad(self._contractTub.call().ink(int_to_bytes32(cup_id)))
示例#25
0
    def tab(self, cup_id: int) -> Wad:
        """Get the amount of debt in a cup.

        Args:
            cup_id: Id of the cup.

        Returns:
            Amount of debt in the cup, in SAI.
        """
        assert isinstance(cup_id, int)
        return Wad(self._contractTub.call().tab(int_to_bytes32(cup_id)))
示例#26
0
 def eth_balance(self, address: Address) -> Wad:
     assert (isinstance(address, Address))
     return Wad(self.web3.eth.getBalance(address.address))