Esempio n. 1
0
    def coax(self, new_way: Ray) -> Transact:
        """Update the holder fee.

        Args:
            new_way: The new per-second value of the holder fee (`way`). `1.0` means no holder fee.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_way, Ray)
        return Transact(self, self.web3, self.abiTip, self.tip(), self._contractTip, 'coax', [new_way.value])
Esempio n. 2
0
    def cuff(self, new_mat: Ray) -> Transact:
        """Update the liquidation ratio.

        Args:
            new_mat: The new value of the liquidation ratio (`mat`). `1.5` means the liquidation ratio is 150%.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_mat, Ray)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'cuff', [new_mat.value])
Esempio n. 3
0
    def crop(self, new_tax: Ray) -> Transact:
        """Update the stability fee.

        Args:
            new_tax: The new per-second value of the stability fee (`tax`). `1.0` means no stability fee.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_tax, Ray)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'crop', [new_tax.value])
Esempio n. 4
0
    def cork(self, new_hat: Wad) -> Transact:
        """Update the debt ceiling.

        Args:
            new_hat: The new value of the debt ceiling (`hat`), in SAI.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_hat, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'cork', [new_hat.value])
Esempio n. 5
0
    def chop(self, new_axe: Ray) -> Transact:
        """Update the liquidation penalty.

        Args:
            new_axe: The new value of the liquidation penalty (`axe`). `1.0` means no penalty. `1.2` means 20% penalty.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_axe, Ray)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'chop', [new_axe.value])
Esempio n. 6
0
    def join(self, amount_in_gem: Wad) -> Transact:
        """Buy SKR for GEMs.

        Args:
            amount_in_gem: The amount of GEMs to buy SKR for.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(amount_in_gem, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'join', [amount_in_gem.value])
Esempio n. 7
0
    def jar_jump(self, new_gap: Wad) -> Transact:
        """Update the current spread (`gap`) for `join` and `exit`.

        Args:
            new_tax: The new value of the spread (`gap`). `1.0` means no spread, `1.01` means 1% spread.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_gap, Wad)
        return Transact(self, self.web3, self.abiJar, self.jar(), self._contractJar, 'jump', [new_gap.value])
Esempio n. 8
0
    def deposit(self, amount: Wad) -> Transact:
        """Deposits `amount` of raw ETH to EtherDelta.

        Args:
            amount: Amount of raw ETH to be deposited on EtherDelta.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert(isinstance(amount, Wad))
        return Transact(self, self.web3, self.abi, self.address, self._contract, 'deposit', [], {'value': amount.value})
Esempio n. 9
0
    def set_authority(self, address: Address) -> Transact:
        """Set the `authority` of a `DSAuth`-ed contract.

        Args:
            address: The address of the new `authority`.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert (isinstance(address, Address))
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'setAuthority', [address.address])
Esempio n. 10
0
File: sai.py Progetto: livnev/keeper
    def bust(self, amount_in_skr: Wad) -> Transact:
        """Sell some amount of SAI to process `woe` (bad debt).

        Args:
            amount_in_skr: The amount of SKR we want to receive in exchange for our SAI.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(amount_in_skr, Wad)
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'bust', [amount_in_skr.value])
Esempio n. 11
0
    def make(self,
             have_token: Address,
             have_amount: Wad,
             want_token: Address,
             want_amount: Wad,
             pos: int = None) -> Transact:
        """Create a new offer.

        The `have_amount` of `have_token` token will be taken from you on offer creation and deposited
        in the market contract. Allowance needs to be set first. Refer to the `approve()` method
        in the `ERC20Token` class.

        The `MatchingMarket` contract maintains an internal ordered linked list of offers, which allows the contract
        to do automated matching. Client placing a new offer can either let the contract find the correct
        position in the linked list (by passing `0` as the `pos` argument of `make`) or calculate the position
        itself and just pass the right value to the contract (this will happen if you omit the `pos`
        argument of `make`). The latter should always use less gas. If the client decides not to calculate the
        position or it does get it wrong and the number of open orders is high at the same time, the new offer
        may not even be placed at all as the attempt to calculate the position by the contract will likely fail
        due to high gas usage.

        Args:
            have_token: Address of the ERC20 token you want to put on sale.
            have_amount: Amount of the `have_token` token you want to put on sale.
            want_token: Address of the ERC20 token you want to be paid with.
            want_amount: Amount of the `want_token` you want to receive.
            pos: The position to insert the order at in the sorted list.
                If `None`, the optimal position will automatically get calculated.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert (isinstance(have_token, Address))
        assert (isinstance(have_amount, Wad))
        assert (isinstance(want_token, Address))
        assert (isinstance(want_amount, Wad))
        assert (isinstance(pos, int) or (pos is None))
        assert (have_amount > Wad(0))
        assert (want_amount > Wad(0))

        if pos is None:
            pos = self.position(have_token=have_token,
                                have_amount=have_amount,
                                want_token=want_token,
                                want_amount=want_amount)
        else:
            assert (pos >= 0)

        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'offer', [
                            have_amount.value, have_token.address,
                            want_amount.value, want_token.address, pos
                        ])
Esempio n. 12
0
File: sai.py Progetto: livnev/keeper
    def jump(self, new_gap: Wad) -> Transact:
        """Update the spread.

        Args:
            new_gap: The new value of the spread (`gap`). `1.0` means no spread. `1.02` means 2% spread.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(new_gap, Wad)
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'jump', [new_gap.value])
Esempio n. 13
0
    def execute(self, contract: bytes, calldata: bytes) -> Transact:
        """Create a new contract and call a function of it.

        Creates a new contract using the bytecode (`contract`). Then does _delegatecall_ to the function
        and arguments specified in the `calldata`.

        Args:
            contract: Contract bytecode.
            calldata: Calldata to pass to _delegatecall_.
        """
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'execute', [contract, calldata])
Esempio n. 14
0
File: sai.py Progetto: livnev/keeper
    def exit(self, amount_in_skr: Wad) -> Transact:
        """Sell SKR for GEMs.

        Args:
            amount_in_skr: The amount of SKR to sell for GEMs.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(amount_in_skr, Wad)
        return Transact(self, self.web3, self.abiTub, self.address,
                        self._contractTub, 'exit', [amount_in_skr.value])
Esempio n. 15
0
File: sai.py Progetto: livnev/keeper
    def bite(self, cup_id: int) -> Transact:
        """Initiate liquidation of an undercollateralized cup.

        Args:
            cup_id: Id of the cup to liquidate.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        return Transact(self, self.web3, self.abiTub, self.address,
                        self._contractTub, 'bite', [int_to_bytes32(cup_id)])
Esempio n. 16
0
    def set_buy_enabled(self, buy_enabled: bool) -> Transact:
        """Enables or disables direct buy.

        Args:
            buy_enabled: Whether direct buy should be enabled or disabled.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert (isinstance(buy_enabled, bool))
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'setBuyEnabled', [buy_enabled])
Esempio n. 17
0
File: sai.py Progetto: livnev/keeper
    def boom(self, amount_in_skr: Wad) -> Transact:
        """Buy some amount of SAI to process `joy` (surplus).

        Args:
            amount_in_skr: The amount of SKR we want to send in order to receive SAI.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(amount_in_skr, Wad)
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'boom', [amount_in_skr.value])
Esempio n. 18
0
    def withdraw(self, amount: Wad) -> Transact:
        """Withdraws `amount` of raw ETH from `DSEthToken`.

        The withdrawn ETH will get transferred to the calling account.

        Args:
            amount: Amount of raw ETH to be withdrawn from `DSEthToken`.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert(isinstance(amount, Wad))
        return Transact(self, self.web3, self.abi, self.address, self._contract, 'withdraw', [amount.value])
Esempio n. 19
0
    def poke(self, new_value: bytes) -> Transact:
        """Populates this instance with a new value.

        Args:
            new_value: A 32-byte array with the new value to be set.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert (isinstance(new_value, bytes))
        assert (len(new_value) == 32)
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'poke', [new_value])
Esempio n. 20
0
    def warp(self, seconds: int) -> Transact:
        """Move the SAI contracts forward in time.

        If the `seconds` parameter is equal to `0`, time travel will get permanently disabled
        and subsequent `warp()` calls will always fail.

        Args:
            seconds: Number of seconds to warp the time forward, or `0` to permanently disable time travel.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        return Transact(self, self.web3, self.abiTip, self.tip(), self._contractTip, 'warp', [seconds])
Esempio n. 21
0
    def set_matching_enabled(self, matching_enabled: bool) -> Transact:
        """Enables or disables order matching.

        Args:
            matching_enabled: Whether order matching should be enabled or disabled.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert (isinstance(matching_enabled, bool))
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'setMatchingEnabled',
                        [matching_enabled])
Esempio n. 22
0
    def transfer(self, address: Address, value: Wad) -> Transact:
        """Transfers tokens to a specified address.

        Args:
            address: Destination address to transfer the tokens to.
            value: The value of tokens to transfer.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert(isinstance(address, Address))
        assert(isinstance(value, Wad))

        return Transact(self, self.web3, self.abi, self.address, self._contract, 'transfer', [address.address, value.value])
Esempio n. 23
0
    def lock(self, cup_id: int, amount_in_skr: Wad) -> Transact:
        """Post additional SKR collateral to a cup.

        Args:
            cup_id: Id of the cup to post the collateral into.
            amount_in_skr: The amount of collateral to post, in SKR.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        assert isinstance(amount_in_skr, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'lock',
                        [int_to_bytes32(cup_id), amount_in_skr.value])
Esempio n. 24
0
    def free(self, cup_id: int, amount_in_skr: Wad) -> Transact:
        """Remove excess SKR collateral from a cup.

        Args:
            cup_id: Id of the cup to remove the collateral from.
            amount_in_skr: The amount of collateral to remove, in SKR.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        assert isinstance(amount_in_skr, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'free',
                        [int_to_bytes32(cup_id), amount_in_skr.value])
Esempio n. 25
0
    def draw(self, cup_id: int, amount_in_sai: Wad) -> Transact:
        """Issue the specified amount of SAI stablecoins.

        Args:
            cup_id: Id of the cup to issue the SAI from.
            amount_in_sai: The amount SAI to be issued.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        assert isinstance(amount_in_sai, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'draw',
                        [int_to_bytes32(cup_id), amount_in_sai.value])
Esempio n. 26
0
    def wipe(self, cup_id: int, amount_in_sai: Wad) -> Transact:
        """Repay some portion of existing SAI debt.

        Args:
            cup_id: Id of the cup to repay the SAI to.
            amount_in_sai: The amount SAI to be repaid.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        assert isinstance(amount_in_sai, Wad)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'wipe',
                        [int_to_bytes32(cup_id), amount_in_sai.value])
Esempio n. 27
0
    def shut(self, cup_id: int) -> Transact:
        """Close a cup.

        Involves calling `wipe()` and `free()` internally in order to clear all remaining SAI debt and free
        all remaining SKR collateral.

        Args:
            cup_id: Id of the cup to close.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'shut', [int_to_bytes32(cup_id)])
Esempio n. 28
0
    def give(self, cup_id: int, new_lad: Address) -> Transact:
        """Transfer ownership of a cup.

        Args:
            cup_id: Id of the cup to transfer ownership of.
            new_lad: New owner of the cup.

        Returns:
            A `Transact` instance, which can be used to trigger the transaction.
        """
        assert isinstance(cup_id, int)
        assert isinstance(new_lad, Address)
        return Transact(self, self.web3, self.abiTub, self.address, self._contractTub, 'give',
                        [int_to_bytes32(cup_id), new_lad.address])
Esempio n. 29
0
    def kill(self, offer_id: int) -> Transact:
        """Cancels an existing offer.

        Offers can be cancelled only by their owners. In addition to that, in case of expiring markets,
        after the market has expired all orders can be cancelled by anyone.

        Args:
            offer_id: Id of the offer you want to cancel.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        return Transact(self, self.web3, self.abi, self.address,
                        self._contract, 'kill', [int_to_bytes32(offer_id)])
Esempio n. 30
0
    def withdraw_token(self, token: Address, amount: Wad) -> Transact:
        """Withdraws `amount` of ERC20 token `token` from EtherDelta.

        Tokens will get transferred to the calling account.

        Args:
            token: Address of the ERC20 token to be withdrawn.
            amount: Amount of token `token` to be withdrawn from EtherDelta.

        Returns:
            A :py:class:`keeper.api.Transact` instance, which can be used to trigger the transaction.
        """
        assert(isinstance(token, Address))
        assert(isinstance(amount, Wad))
        return Transact(self, self.web3, self.abi, self.address, self._contract, 'withdrawToken',
                        [token.address, amount.value])