Skip to content

Commit fc69b7b

Browse files
committed
refactoring DSS deployment continued
1 parent e012d0c commit fc69b7b

17 files changed

+2565
-19
lines changed

chief_keeper/chief_keeper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
from chief_keeper.database import SimpleDatabase
3232
from chief_keeper.spell import DSSSpell
3333

34-
from .utils.keeper_lifecycle import Lifecycle
35-
from. utils.register_keys import register_keys
36-
from .utils.blockchain import initialize_blockchain_connection
34+
from chief_keeper.utils.keeper_lifecycle import Lifecycle
35+
36+
from chief_keeper.utils.blockchain import initialize_blockchain_connection
3737

3838
# from pymaker import Address, web3_via_http
3939
# from pymaker.util import is_contract_at

chief_keeper/database.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525

2626
from chief_keeper.spell import DSSSpell
2727

28-
from pymaker import Address
29-
from pymaker.util import is_contract_at
28+
from chief_keeper.utils.address import Address
29+
from chief_keeper.utils.address import Address
30+
from chief_keeper.utils.utils import is_contract_at
3031
from pymaker.deployment import DssDeployment
3132

3233

chief_keeper/makerdao_utils/auctions.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@
2929
from chief_keeper.utils.address import Address
3030
from chief_keeper.utils.contract import Contract
3131
from chief_keeper.utils.transact import Transact
32+
from chief_keeper.utils.big_number import Wad, Rad, Ray
3233

34+
from chief_keeper.makerdao_utils.dss import Dog, Vat
35+
from chief_keeper.makerdao_utils.token import ERC20Token
3336

34-
from pymaker.dss import Dog, Vat
3537
from pymaker.logging import LogNote
36-
from pymaker.numeric import Wad, Rad, Ray
37-
from pymaker.token import ERC20Token
38+
3839

3940

4041
def toBytes(string: str):
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This file is part of Maker Keeper Framework.
2+
#
3+
# Copyright (C) 2019-2021 EdNoepel
4+
#
5+
# This program is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU Affero General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Affero General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU Affero General Public License
16+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
18+
import logging
19+
20+
from chief_keeper.utils.address import Address
21+
from chief_keeper.utils.contract import Contract
22+
23+
from chief_keeper.makerdao_utils.auctions import AuctionContract, Clipper, Flipper
24+
from chief_keeper.makerdao_utils.join import GemJoin
25+
from chief_keeper.makerdao_utils.token import ERC20Token
26+
27+
from pymaker.approval import directly, hope_directly
28+
29+
from pymaker.ilk import Ilk
30+
from pymaker.gas import DefaultGasPrice
31+
32+
33+
34+
logger = logging.getLogger()
35+
36+
37+
class Collateral:
38+
"""The `Collateral` object wraps accounting information in the Ilk with token-wide artifacts shared across
39+
multiple collateral types for the same token. For example, ETH-A and ETH-B are represented by different Ilks,
40+
but will share the same gem (WETH token), GemJoin instance, and Flipper contract.
41+
"""
42+
43+
def __init__(self, ilk: Ilk, gem: ERC20Token, adapter: GemJoin, auction: AuctionContract, pip, vat: Contract):
44+
assert isinstance(ilk, Ilk)
45+
assert isinstance(gem, ERC20Token)
46+
assert isinstance(adapter, GemJoin)
47+
assert isinstance(auction, AuctionContract)
48+
assert isinstance(vat, Contract)
49+
50+
self.ilk = ilk
51+
self.gem = gem
52+
self.adapter = adapter
53+
if isinstance(auction, Flipper):
54+
self.flipper = auction
55+
self.clipper = None
56+
elif isinstance(auction, Clipper):
57+
self.flipper = None
58+
self.clipper = auction
59+
# Points to `median` for official deployments, `DSValue` for testing purposes.
60+
# Users generally have no need to interact with the pip.
61+
self.pip = pip
62+
self.vat = vat
63+
64+
def approve(self, usr: Address, **kwargs):
65+
"""
66+
Allows the user to move this collateral into and out of their CDP.
67+
68+
Args
69+
usr: User making transactions with this collateral
70+
"""
71+
gas_strategy = kwargs['gas_strategy'] if 'gas_strategy' in kwargs else DefaultGasPrice()
72+
self.adapter.approve(hope_directly(from_address=usr, gas_strategy=gas_strategy), self.vat.address)
73+
self.adapter.approve_token(directly(from_address=usr, gas_strategy=gas_strategy))

0 commit comments

Comments
 (0)