Skip to content
Verified contractExactMIT

AdapterRegistry

Address0xea982b86c6b8a4dfb10ea128522567f02794b9b3
Balance

0 ETH

 

Transactions

1

 

Compiler

vyper 0.5.0b1

 

Same code

Only this contract

 

Details

Compiler
vyper 0.5.0b1+commit.577d2534
Language
vyper
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,385,345
Creation transaction
0x0c1c1ebba6…8ae825a062

contracts/burners/adapters/AdapterRegistry.vy

# pragma version 0.5.0b1
# pragma nonreentrancy on
# pragma evm-version cancun
# SPDX-License-Identifier: MIT
"""
@title AdapterRegistry
@author Curve Finance
@license MIT
@notice Governance-curated catalog of settlement adapters for Dutch auctions:
        an executor and an activation flag per adapter address, the list of
        registered adapters, and whether an executor is in use.
@dev An adapter is a settlement rail: any contract that sells auction
     inventory by its own rules. Its executor is the protocol contract that
     pulls sold tokens (can be the adapter itself): auctions approve it while
     is_executor_active(executor) (an active adapter references it), so
     listing an adapter is a custody-relevant act reviewed by the owner. The
     registry is the single management point. It holds no tokens, calls no
     external protocols, and never executes adapters.
@custom:kill The emergency owner can only disable_adapter, which immediately
             releases the executor reference and, for adapters reached
             through the ERC-1271 router, stops routing on every auction
             reading this registry. Activation and new entries require the
             owner. The registry stores no roles of its own: both are read
             live from the role source (the FeeCollector).
@custom:security Trust boundary is the owner: listing and activation are
                 owner-gated (the emergency owner can only disable), so
                 adapters cannot self-register. An adapter's runtime code
                 cannot change under its address — accounts cannot be
                 redeployed with different code since Cancun, and an adapter
                 behind a proxy must be treated as its proxy admin's code.
                 Activation is a separate owner call, so a set alone never
                 goes live; nothing prevents batching both in one
                 transaction. An unknown adapter reads
                 as a zeroed config (executor == empty(address)), which
                 routers must treat as invalid.
"""

from contracts.interfaces import IAdapterRegistry
from contracts.utils import constants as c
from contracts.utils import roles

implements: IAdapterRegistry
initializes: roles
exports: (
    roles.role_source,
    roles.owner,
    roles.emergency_owner,
)


error BadAdapter:
    pass


error UnknownAdapter:
    pass


error AlreadyActive:
    pass


error NotActive:
    pass


event AdapterSet:
    adapter: indexed(address)
    executor: indexed(address)


event AdapterActivated:
    adapter: indexed(address)


event AdapterDisabled:
    adapter: indexed(address)


configs: HashMap[address, IAdapterRegistry.AdapterConfig]
# Registered adapters (executor set), in no particular order.
adapters: DynArray[address, c.MAX_ADAPTERS]
# Active adapters per executor. Several adapters can share one executor (every
# permit2-family protocol pulls through Permit2 itself); auctions approve an
# executor while its count is positive.
executor_refcount: HashMap[address, uint256]


@deploy
def __init__(_role_source: roles.RoleSource):
    """
    @notice Pin the role source the registry reads its owners from.
    @param _role_source Contract exposing owner() and emergency_owner() views
           (the FeeCollector); must answer owner() with a nonzero address.
    """
    roles.__init__(_role_source)


# Adapter catalog


@external
@view
def get_adapter(_adapter: address) -> IAdapterRegistry.AdapterConfig:
    """
    @notice Read an adapter's config.
    @param _adapter Adapter contract.
    @return Stored config; zeroed (executor == empty(address)) when unknown.
    """
    return self.configs[_adapter]


@external
@view
def get_adapters() -> DynArray[address, c.MAX_ADAPTERS]:
    """
    @notice List every registered adapter, active or not.
    @return Registered adapter addresses, in no particular order.
    """
    return self.adapters


@external
@view
def is_executor_active(_executor: address) -> bool:
    """
    @notice Whether an active adapter references the executor; auctions keep
            their allowances toward it while this holds.
    @param _executor Executor contract.
    @return True while at least one active adapter references it.
    """
    return self.executor_refcount[_executor] > 0


@internal
def _remove_listing(_adapter: address):
    # Swap-remove: order is not part of the listing's contract.
    for i: uint256 in range(len(self.adapters), bound=c.MAX_ADAPTERS):
        if self.adapters[i] == _adapter:
            self.adapters[i] = self.adapters[len(self.adapters) - 1]
            self.adapters.pop()
            break


@external
def set_adapter(_adapter: address, _executor: address):
    """
    @notice Register an adapter, repoint an inactive one at a new executor,
            or remove it (executor == empty(address) reads as unknown and
            drops it from get_adapters). Entries are stored inactive:
            activation is a separate owner step, and an active adapter must
            be disabled first so executor references stay consistent.
    @param _adapter Adapter contract.
    @param _executor Protocol contract that pulls sold tokens; the approval
           target auctions grant while the adapter is active. Zero removes
           the entry.
    """
    roles._check_owner()
    assert _adapter != empty(address), BadAdapter()
    assert not self.configs[_adapter].active, AlreadyActive()

    if _executor == empty(address):
        self._remove_listing(_adapter)
    elif self.configs[_adapter].executor == empty(address):
        self.adapters.append(_adapter)  # dev: too many adapters
    self.configs[_adapter] = IAdapterRegistry.AdapterConfig(executor=_executor, active=False)
    log AdapterSet(adapter=_adapter, executor=_executor)


@external
def activate_adapter(_adapter: address):
    """
    @notice Activate a registered adapter and reference its executor;
            auction allowances follow through their sync_executor_approvals.
    @param _adapter Adapter to activate; must exist and be inactive.
    """
    roles._check_owner()
    config: IAdapterRegistry.AdapterConfig = self.configs[_adapter]
    assert config.executor != empty(address), UnknownAdapter()
    assert not config.active, AlreadyActive()

    self.configs[_adapter].active = True
    self.executor_refcount[config.executor] += 1
    log AdapterActivated(adapter=_adapter)


# Emergency


@external
def disable_adapter(_adapter: address):
    """
    @notice Disable an active adapter and release its executor reference.
            Faster than activation on purpose: the emergency owner can kill an
            adapter without being able to add one.
    @dev Does not touch auction allowances: batch with each auction's
         sync_executor_approvals once the executor is no longer active.
    @param _adapter Adapter to disable; must be active.
    """
    roles._check_owner_or_emergency()
    config: IAdapterRegistry.AdapterConfig = self.configs[_adapter]
    assert config.active, NotActive()

    self.configs[_adapter].active = False
    self.executor_refcount[config.executor] -= 1
    log AdapterDisabled(adapter=_adapter)

contracts/interfaces/IAdapterRegistry.vyi

"""
@title IAdapterRegistry
@author Curve Finance
@license MIT
@notice Read surface only of the settlement adapter catalog: adapter configs,
        the list of registered adapters, and whether an executor is in use.
        Management (set_adapter, activate_adapter, disable_adapter) is on the
        AdapterRegistry contract ABI and not shared through this interface.
@dev An adapter is a settlement rail selling auction inventory by its own
     rules (the ERC-1271 router is one way in: it routes signatures prefixed
     with an active adapter's address to it); the executor is the protocol
     contract that pulls sold tokens, which auctions approve while
     is_executor_active(executor). An unknown adapter returns the zeroed
     config (executor == empty(address)).
"""

from contracts.utils import constants as c


struct AdapterConfig:
    executor: address
    active: bool


@external
@view
def get_adapter(_adapter: address) -> AdapterConfig:
    ...


@external
@view
def get_adapters() -> DynArray[address, c.MAX_ADAPTERS]:
    ...


@external
@view
def is_executor_active(_executor: address) -> bool:
    ...

contracts/utils/constants.vy

# pragma version 0.5.0b1
# SPDX-License-Identifier: MIT
"""
@title Shared protocol constants
@author Curve Finance
@license MIT
@notice Protocol-wide scales, bounds, and interface ids shared across the
        burner stack.
@dev Stateless constants-only module; import as `constants as c`.
"""

# transfer/exchange batch bound.
MAX_COINS: constant(uint256) = 64
# Fixed-point percentage scale: 100% = 10**18.
WAD: constant(uint256) = 10**18
# Bound of the AdapterRegistry catalog.
MAX_ADAPTERS: constant(uint256) = 32

# ERC-165 interface ids (XOR of the interface's selectors).
ERC165_INTERFACE_ID: constant(bytes4) = method_id("supportsInterface(bytes4)", output_type=bytes4)
# FeeCollector burner interface:
#   ^ burn(address[],address) 0x72a436a8
#   ^ push_target() 0x2eb078cd
#   ^ VERSION() 0xffa1ad74
BURNER_INTERFACE_ID: constant(bytes4) = 0xa3b5e311

# ERC-1271: the single-selector interface id doubles as the magic return value.
ERC1271_MAGIC_VALUE: constant(bytes4) = method_id(
    "isValidSignature(bytes32,bytes)", output_type=bytes4
)  # 0x1626ba7e

contracts/utils/roles.vy

# pragma version 0.5.0b1
# SPDX-License-Identifier: MIT
"""
@title Role source module
@author Curve Finance
@license MIT
@notice Live protocol roles read from a pinned role source (e.g. FeeCollector).
@dev The module stores no roles of its own — both are staticcall'ed from the
     role source on every read, so governance always matches the protocol's
     current owner and emergency owner and needs no commit/accept plumbing
     here. The importing contract initializes the module with its role source
     and reuses _check_owner/_check_owner_or_emergency for authorization.
"""


interface RoleSource:
    def owner() -> address: view
    def emergency_owner() -> address: view


error BadRoleSource:
    pass


error OnlyOwner:
    pass


error OnlyOwnerOrEmergency:
    pass


role_source: public(immutable(RoleSource))


@deploy
def __init__(_role_source: RoleSource):
    """
    @notice Pin the role source the roles are read from.
    @param _role_source Contract exposing owner() and emergency_owner() views;
        must answer owner() with a nonzero address.
    """
    assert staticcall _role_source.owner() != empty(address), BadRoleSource()
    self.role_source = _role_source


@internal
@view
def _owner() -> address:
    return staticcall self.role_source.owner()


@internal
@view
def _emergency_owner() -> address:
    return staticcall self.role_source.emergency_owner()


@internal
@view
def _check_owner():
    assert msg.sender == self._owner(), OnlyOwner()


@internal
@view
def _check_owner_or_emergency():
    assert msg.sender in [self._owner(), self._emergency_owner()], OnlyOwnerOrEmergency()


@external
@view
def owner() -> address:
    """
    @notice Governance owner.
    @return Owner read live from the role source.
    """
    return self._owner()


@external
@view
def emergency_owner() -> address:
    """
    @notice Emergency role owner.
    @return Emergency owner read live from the role source.
    """
    return self._emergency_owner()
Compiler settingsShow
{
  "search_paths": [
    "."
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.