Skip to content
Verified contractExact

LMCallback

Address0x327a74baf6ccb199d07642dcdfb4128f131c98ee
Balance

0 ETH

 

Transactions

2

 

Compiler

vyper 0.4.3

 

Same code

Only this contract

 

Details

Compiler
vyper 0.4.3+commit.bff19ea2
Language
vyper
EVM version
cancun
License
Not stated
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,273,867
Creation transaction
0xc9630ebc19…f92f4cc29c

curve_stablecoin/lm_callback/LMCallback.vy

# pragma version 0.4.3
"""
@title LlamaLend V2 LMCallback
@author Curve.Finance
@license Copyright (c) Curve.Finance, 2020-2026 - all rights reserved
@notice LM callback works like a gauge for collateral in LlamaLend/crvUSD AMMs
@dev Use this contract only on Ethereum Mainnet since CRV, GAUGE_CONTROLLER and MINTER addresses are hardcoded
@custom:security [email protected]
@custom:kill The factory owner can pause CRV rewards with set_killed(True);
             accounting and earned reward claims continue. False resumes rewards
             while attached but cannot clear permanent retirement. To retire:
             1. Checkpoint every borrower before detaching, or unsettled rewards
                will be lost.
             2. Detach via Configurator.set_callback, then call
                user_checkpoint(empty(address)) on this callback in the same
                transaction to record permanent retirement.
             Never reattach after missed AMM updates. is_killed() is only a view.
"""

from curve_std.interfaces import IERC20
from curve_stablecoin import constants as c
from curve_stablecoin.interfaces import IAMM
from curve_stablecoin.interfaces import ILMCallback
from curve_stablecoin.interfaces import ILMCallbackFactory

version: public(constant(String[5])) = "1.0.0"

implements: ILMCallback

interface ICRV20:
    def future_epoch_time_write() -> uint256: nonpayable
    def rate() -> uint256: view

interface IGaugeController:
    def gauge_relative_weight(addr: address, time: uint256) -> uint256: view
    def checkpoint_gauge(addr: address): nonpayable

interface IMinter:
    def minted(user: address, gauge: address) -> uint256: view


MAX_TICKS_UINT: constant(uint256) = c.MAX_TICKS_UINT
MAX_TICKS_INT: constant(int256) = c.MAX_TICKS
WEEK: constant(uint256) = 604800

CRV: constant(ICRV20) = ICRV20(0xD533a949740bb3306d119CC777fa900bA034cd52)
GAUGE_CONTROLLER: constant(IGaugeController) = IGaugeController(0x2F50D538606Fa9EDD2B11E2446BEb18C9D5846bB)
MINTER: constant(IMinter) = IMinter(0xd061D61a4d941c39E5453435B6345Dc261C2fcE0)

# Not public: gauges expose their factory as `factory()`, so the getter below
# carries that name instead of the `FACTORY()` a public immutable would give
_FACTORY: immutable(address)
AMM: public(immutable(IAMM))
COLLATERAL_TOKEN: public(immutable(IERC20))

# Set the first time this contract is seen as the AMM's configured callback
attached: public(bool)
# Latched when a callback that had gone live is no longer the AMM's configured
# callback. A detached callback reads `attached == True` and `detached == True`.
detached: public(bool)
rewards_killed: bool
collateral_per_share: public(HashMap[int256, uint256])

# Tracking of mining period
inflation_rate: public(uint256)
future_epoch_time: public(uint256)


# Running integrals
# ------------------
# Definitions:
#
# r - reward rate
# w - gauge relative weight
# s[i] - shares per band i
# cs[i] - collateral per share in band i
# s[u,i] - shares per user in band
#
# Reward rate per collateral:
# rrpc = (r * w) / sum(s[i] * cs[i])
#
# Rewards per collateral (integral):
# I_rpc = integral(rrpc * dt)
# t_rpc - time of the last I_rpc value

I_rpc: public(ILMCallback.IntegralRPC)

# Rewards per share:
# I_rps[i] = integral(cs[i] * rrpc * dt) = sum(cs[i] * delta(I_rpc))

I_rps: public(HashMap[int256, ILMCallback.IntegralRPS])

# Rewards per user:
# I_rpu[u,i] = sum(s[u,i] * delta(I_rps[i]))
# I_rpu[u] = sum_i(I_rpu[u,i])

I_rpu: public(HashMap[address, HashMap[int256, ILMCallback.IntegralRPU]])
integrate_fraction: public(HashMap[address, uint256])


@deploy
def __init__(_amm: IAMM):
    """
    @notice LMCallback constructor
    @param _amm The address of the AMM
    """
    _FACTORY = msg.sender
    AMM = _amm
    COLLATERAL_TOKEN = IERC20(staticcall AMM.coins(1))
    assert staticcall COLLATERAL_TOKEN.decimals() == 18, "collateral decimals must be 18"

    self.future_epoch_time = extcall CRV.future_epoch_time_write()
    self.inflation_rate = staticcall CRV.rate()
    self.I_rpc.t = block.timestamp


@external
@view
def factory() -> address:
    """
    @notice Address of the factory which deployed this callback
    @dev Named after the gauge convention. Set to `msg.sender` in the constructor,
         so on a callback deployed outside a factory it is just the deployer.
    @return Address of the LM Callback factory
    """
    return _FACTORY


@external
@view
def lp_token() -> address:
    """
    @notice Collateral token rewarded through the AMM callback
    """
    return COLLATERAL_TOKEN.address


@external
@view
def is_killed() -> bool:
    """
    @notice Whether new CRV accrual is paused or the callback is retired
    @dev False does not imply attachment, initialization, or positive emissions.
    """
    return self.rewards_killed or self.detached or (
        self.attached and (staticcall AMM.liquidity_mining_callback()).address != self
    )


@external
def set_killed(killed: bool):
    """
    @notice Pause or resume new CRV accrual without detaching the callback
    @param killed True to pause rewards; False to resume while still attached
    """
    assert msg.sender == staticcall ILMCallbackFactory(_FACTORY).owner(), "only owner"
    if not killed:
        assert self._attached(), "not attached"

    # Checkpoint under the old flag so resuming cannot backpay paused time.
    self._checkpoint_collateral_shares(0, [], 0)
    self.rewards_killed = killed
    log ILMCallback.SetKilled(killed=killed)


@internal
def _attached() -> bool:
    """
    @notice Whether this contract is currently the AMM's configured callback
    @dev Latches `detached` on a negative observation, but only once the callback
         has gone live - see `attached`. Both integrals are gated on this: while
         detached the AMM stops reporting band and user share changes, so
         `collateral_per_share` freezes while `total_collateral` keeps tracking
         `balanceOf(AMM)`, and deposits land with no `I_rpu` baseline. Accruing on
         either would mint more CRV than the gauge weight allows.
    @return True only while this contract is the AMM's live callback
    """
    if self.detached:
        return False

    if (staticcall AMM.liquidity_mining_callback()).address == self:
        if not self.attached:
            self.attached = True
            log ILMCallback.Attached()
        return True

    # Not the AMM's callback. Before going live that is just the deployment
    # window and must not set `detached`; after going live it is a detach.
    if self.attached:
        self.detached = True
        log ILMCallback.Detached()

    return False


@internal
def _checkpoint_collateral_shares(n_start: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT], size: int256):
    """
    @notice Checkpoint for shares in a set of bands
    @dev Updates the CRV emission shares are entitled to receive
    @param n_start Index of the first band to checkpoint
    @param collateral_per_share Collateral per share ratio by bands
    @param size The number of bands to checkpoint starting from `n_start`
    """
    if not self._attached():
        return

    # Read current and new rate; update the new rate if needed
    I_rpc: ILMCallback.IntegralRPC = self.I_rpc
    rate: uint256 = self.inflation_rate
    new_rate: uint256 = rate
    prev_future_epoch: uint256 = self.future_epoch_time
    if block.timestamp >= prev_future_epoch:
        self.future_epoch_time = extcall CRV.future_epoch_time_write()
        new_rate = staticcall CRV.rate()
        self.inflation_rate = new_rate
        log ILMCallback.UpdateInflationRate(new_rate=new_rate, future_epoch_time=self.future_epoch_time)

    # Keep rate caching and AMM accounting live; zero only effective rates.
    if self.rewards_killed:
        rate = 0
        new_rate = 0

    # Transfers from/to AMM always happen after LM Callback calls, so this value is taken BEFORE the action
    total_collateral: uint256 = staticcall COLLATERAL_TOKEN.balanceOf(AMM.address)
    delta_rpc: uint256 = 0

    if total_collateral > 0 and block.timestamp > I_rpc.t:
        extcall GAUGE_CONTROLLER.checkpoint_gauge(self)
        prev_week_time: uint256 = I_rpc.t
        week_time: uint256 = min(unsafe_div(prev_week_time + WEEK, WEEK) * WEEK, block.timestamp)

        for week_iter: uint256 in range(500):
            w: uint256 = staticcall GAUGE_CONTROLLER.gauge_relative_weight(self, prev_week_time)

            if prev_future_epoch >= prev_week_time and prev_future_epoch < week_time:
                # If we went across one or multiple epochs, apply the rate
                # of the first epoch until it ends, and then the rate of
                # the last epoch.
                # If more than one epoch is crossed - the gauge gets less,
                # but that'd mean it wasn't called for more than 1 year
                delta_rpc += unsafe_div(rate * w * unsafe_sub(prev_future_epoch, prev_week_time), total_collateral)
                rate = new_rate
                delta_rpc += unsafe_div(rate * w * unsafe_sub(week_time, prev_future_epoch), total_collateral)
            else:
                delta_rpc += unsafe_div(rate * w * unsafe_sub(week_time, prev_week_time), total_collateral)
            # On precisions of the calculation
            # rate ~= 10e18
            # last_weight > 0.01 * 1e18 = 1e16 (if pool weight is 1%)
            # total_collateral ~= TVL * 1e18 ~= 1e26 ($100M for example)
            # The largest loss is at dt = 1
            # Loss is 1e-9 - acceptable

            if week_time == block.timestamp:
                break
            prev_week_time = week_time
            week_time = min(week_time + WEEK, block.timestamp)

    # * Record the collateral per share values
    # * Record integrals of rewards per share
    I_rpc.t = block.timestamp
    I_rpc.rpc += delta_rpc
    self.I_rpc = I_rpc
    log ILMCallback.CheckpointRPC(rpc=I_rpc.rpc, t=I_rpc.t)

    for i: int256 in range(size, bound=MAX_TICKS_INT):
        _n: int256 = n_start + i

        old_cps: uint256 = self.collateral_per_share[_n]
        if len(collateral_per_share) > 0:
            self.collateral_per_share[_n] = collateral_per_share[i]

        I_rps: ILMCallback.IntegralRPS = self.I_rps[_n]
        I_rps.rps += unsafe_div(old_cps * unsafe_sub(I_rpc.rpc, I_rps.rpc), 10**18)
        I_rps.rpc = I_rpc.rpc
        self.I_rps[_n] = I_rps
        log ILMCallback.CheckpointBand(n=_n, rps=I_rps.rps, collateral_per_share=old_cps)


@internal
def _checkpoint_user_shares(user: address, n_start: int256, old_user_shares: DynArray[uint256, MAX_TICKS_UINT], size: int256):
    """
    @notice Checkpoint for user's shares in a set of bands
    @dev Updates the CRV emissions a user is entitled to receive
    @param user The address of the user
    @param n_start Index of the first band to checkpoint
    @param old_user_shares User's shares by bands taken BEFORE the action
    @param size The number of bands to checkpoint starting from `n_start`
    """
    if not self._attached():
        return

    rpu: uint256 = self.integrate_fraction[user]
    for i: int256 in range(size, bound=MAX_TICKS_INT):
        _n: int256 = n_start + i

        old_user_shares_i: uint256 = 0
        if len(old_user_shares) > 0:
            old_user_shares_i = old_user_shares[i]

        I_rpu: ILMCallback.IntegralRPU = self.I_rpu[user][_n]
        I_rps: uint256 = self.I_rps[_n].rps
        d_rpu: uint256 = unsafe_div(old_user_shares_i * unsafe_sub(I_rps, I_rpu.rps), 10**18)
        I_rpu.rpu += d_rpu
        I_rpu.rps = I_rps
        self.I_rpu[user][_n] = I_rpu
        rpu += d_rpu

    self.integrate_fraction[user] = rpu
    log ILMCallback.CheckpointUser(user=user, integrate_fraction=rpu)


@external
@view
def total_collateral() -> uint256:
    """
    @return Total collateral amount in LlamaLend/crvUSD AMM
    """
    return staticcall COLLATERAL_TOKEN.balanceOf(AMM.address)


@external
@view
def user_collateral(user: address) -> uint256:
    """
    @param user The address of the user
    @return User's collateral amount in LlamaLend/crvUSD AMM
    """
    return (staticcall AMM.get_sum_xy(user))[1]


@external
def callback_collateral_shares(n_start: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT], size: uint256):
    """
    @notice Checkpoint for shares in a set of bands
    @dev Updates the CRV emission shares are entitled to receive.
         Can be called only be the corresponding AMM.
         It is important that this callback is called every time before callback_user_shares.
    @param n_start Index of the first band to checkpoint
    @param collateral_per_share Collateral per share ratio by bands
    @param size The number of bands to checkpoint starting from `n_start`
    """
    # It is important that this callback is called every time before callback_user_shares
    assert msg.sender == AMM.address
    self._checkpoint_collateral_shares(n_start, collateral_per_share, convert(size, int256))


@external
def callback_user_shares(user: address, n_start: int256, old_user_shares: DynArray[uint256, MAX_TICKS_UINT], size: uint256):
    """
    @notice Checkpoint for user's shares in a set of bands.
    @dev Updates the CRV emissions a user is entitled to receive.
         Can be called only be the corresponding AMM.
    @param user The address of the user
    @param n_start Index of the first band to checkpoint
    @param old_user_shares User's shares by bands taken BEFORE the action
    @param size The number of bands to checkpoint starting from `n_start`
    """
    assert msg.sender == AMM.address
    self._checkpoint_user_shares(user, n_start, old_user_shares, convert(size, int256))


@internal
def _user_checkpoint(addr: address):
    """
    @notice Record a checkpoint for `addr`
    @param addr User address
    """
    ns: int256[2] = staticcall AMM.read_user_tick_numbers(addr)
    user_shares: DynArray[uint256, MAX_TICKS_UINT] = staticcall AMM.read_user_ticks(addr)
    self._checkpoint_collateral_shares(ns[0], [], ns[1] - ns[0] + 1)
    if len(user_shares) > 0 and user_shares[0] > 0:
        self._checkpoint_user_shares(addr, ns[0], user_shares, ns[1] - ns[0] + 1)


@external
def user_checkpoint(addr: address) -> bool:
    """
    @notice Record a checkpoint for `addr`
    @param addr User address
    @return Always True
    """
    self._user_checkpoint(addr)

    return True


@external
def claimable_tokens(addr: address) -> uint256:
    """
    @notice Get the number of claimable tokens per user
    @dev This function should be manually changed to "view" in the ABI
    @param addr User address
    @return uint256 number of claimable tokens per user
    """
    self._user_checkpoint(addr)

    return self.integrate_fraction[addr] - staticcall MINTER.minted(addr, self)

curve_stablecoin/constants.vy

__version__: constant(String[5]) = "2.0.0"
MAX_TICKS: constant(int256) = 50
MAX_TICKS_UINT: constant(uint256) = 50
MIN_TICKS: constant(int256) = 4
MIN_TICKS_UINT: constant(uint256) = 4
MAX_SKIP_TICKS: constant(int256) = 1024
MAX_SKIP_TICKS_UINT: constant(uint256) = 1024

DEAD_SHARES: constant(uint256) = 1000
WAD: constant(uint256) = 10**18
SWAD: constant(int256) = 10**18

CALLDATA_MAX_SIZE: constant(uint256) = 32 * 300

# Sentinel values used in `configure` methods.
# We use an arbitrary high value that is unlikely to be used as a real value (can't use zero address as it might be intentional)

# keccak("SKIP_CONFIG") in decimal
SKIP_CONFIG_UINT256: constant(uint256) = 34683848501677104821777960696933802007602333377339998839659032476042327981902
# Last 20 bytes of keccak("SKIP_CONFIG_ADDRESS"), used as a nonzero sentinel for address config params
SKIP_CONFIG_ADDRESS: constant(address) = 0xEE97C47b4665063dD362c127B31a2d463BDFf91c

curve_stablecoin/interfaces/IAMM.vyi

from curve_stablecoin.interfaces import ILMCallback
from curve_stablecoin.interfaces import IPriceOracle
# Structs

struct UserTicks:
    ns: int256
    ticks: uint256[25]


struct DetailedTrade:
    in_amount: uint256
    out_amount: uint256
    n1: int256
    n2: int256
    ticks_in: DynArray[uint256, 50]
    last_tick_j: uint256


# Events

event TokenExchange:
    buyer: indexed(address)
    sold_id: uint256
    tokens_sold: uint256
    bought_id: uint256
    tokens_bought: uint256


event Deposit:
    provider: indexed(address)
    amount: uint256
    n1: int256
    n2: int256


event Withdraw:
    provider: indexed(address)
    amount_borrowed: uint256
    amount_collateral: uint256


event SetRate:
    rate: uint256
    rate_mul: uint256
    time: uint256


# Functions

@external
def set_admin(_admin: address):
    ...


@view
@external
def coins(i: uint256) -> address:
    ...


@view
@external
def price_oracle() -> uint256:
    ...


@view
@external
def get_rate_mul() -> uint256:
    ...


@view
@external
def get_base_price() -> uint256:
    ...


@view
@external
def p_current_up(n: int256) -> uint256:
    ...


@view
@external
def p_current_down(n: int256) -> uint256:
    ...


@view
@external
def p_oracle_up(n: int256) -> uint256:
    ...


@view
@external
def p_oracle_down(n: int256) -> uint256:
    ...


@view
@external
def get_p() -> uint256:
    ...


@view
@external
def read_user_tick_numbers(user: address) -> int256[2]:
    ...


@view
@external
def read_user_ticks(user: address) -> DynArray[uint256, 50]:
    ...


@view
@external
def can_skip_bands(n_end: int256) -> bool:
    ...


@view
@external
def active_band_with_skip() -> int256:
    ...


@view
@external
def has_liquidity(user: address) -> bool:
    ...


@external
def deposit_range(user: address, amount: uint256, n1: int256, n2: int256):
    ...


@external
def withdraw(user: address, frac: uint256) -> uint256[2]:
    ...


@view
@external
def get_dy(i: uint256, j: uint256, in_amount: uint256) -> uint256:
    ...


@view
@external
def get_dxdy(i: uint256, j: uint256, in_amount: uint256) -> (uint256, uint256):
    ...


@view
@external
def get_dx(i: uint256, j: uint256, out_amount: uint256) -> uint256:
    ...


@view
@external
def get_dydx(i: uint256, j: uint256, out_amount: uint256) -> (uint256, uint256):
    ...


@external
def exchange(i: uint256, j: uint256, in_amount: uint256, min_amount: uint256, _for: address) -> uint256[2]:
    ...


@external
def exchange_dy(i: uint256, j: uint256, out_amount: uint256, max_amount: uint256, _for: address) -> uint256[2]:
    ...


@view
@external
def get_y_up(user: address) -> uint256:
    ...


@view
@external
def get_x_down(user: address) -> uint256:
    ...


@view
@external
def get_sum_xy(user: address) -> uint256[2]:
    ...


@view
@external
def get_xy(user: address) -> DynArray[uint256, 50][2]:
    ...


@view
@external
def get_amount_for_price(p: uint256) -> (uint256, bool):
    ...


@external
def set_rate(rate: uint256) -> uint256:
    ...


@external
def set_fee(fee: uint256):
    ...


@external
def set_callback(liquidity_mining_callback: ILMCallback):
    ...


@external
def set_price_oracle(_price_oracle: IPriceOracle):
    ...


@view
@external
def admin() -> address:
    ...


@view
@external
def A() -> uint256:
    ...


@view
@external
def fee() -> uint256:
    ...


@view
@external
def rate() -> uint256:
    ...


@view
@external
def active_band() -> int256:
    ...


@view
@external
def min_band() -> int256:
    ...


@view
@external
def max_band() -> int256:
    ...


@view
@external
def price_oracle_contract() -> IPriceOracle:
    ...


@view
@external
def bands_x(arg0: int256) -> uint256:
    ...


@view
@external
def bands_y(arg0: int256) -> uint256:
    ...



@view
@external
def liquidity_mining_callback() -> ILMCallback:
    ...

curve_stablecoin/interfaces/ILMCallback.vyi

from curve_stablecoin import constants as c
MAX_TICKS_UINT: constant(uint256) = c.MAX_TICKS_UINT


event Attached:
    pass

event Detached:
    pass

event SetKilled:
    killed: bool

event UpdateInflationRate:
    new_rate: uint256
    future_epoch_time: uint256

event CheckpointRPC:
    rpc: uint256
    t: uint256

event CheckpointUser:
    user: indexed(address)
    integrate_fraction: uint256

event CheckpointBand:
    n: indexed(int256)
    rps: uint256
    collateral_per_share: uint256


struct IntegralRPC:
    rpc: uint256
    t: uint256

struct IntegralRPS:
    rps: uint256
    rpc: uint256

struct IntegralRPU:
    rpu: uint256
    rps: uint256


# Immutables. Typed as plain addresses rather than IAMM/ILMCallbackFactory/IERC20
# so that this interface stays free of imports that would cycle back into it.
@view
@external
def AMM() -> address:
    ...


@view
@external
def COLLATERAL_TOKEN() -> address:
    ...


@view
@external
def lp_token() -> address:
    ...


# Lowercase to follow the gauge convention, which pairs with the factory's
# `is_valid_gauge()` - see the getter's docstring in `LMCallback.vy`
@view
@external
def factory() -> address:
    ...


@view
@external
def version() -> String[5]:
    ...


@view
@external
def attached() -> bool:
    ...


@view
@external
def detached() -> bool:
    ...


@view
@external
def is_killed() -> bool:
    ...


@external
def set_killed(killed: bool):
    ...


@view
@external
def collateral_per_share(_n: int256) -> uint256:
    ...


@view
@external
def inflation_rate() -> uint256:
    ...


@view
@external
def future_epoch_time() -> uint256:
    ...


@view
@external
def I_rpc() -> IntegralRPC:
    ...


@view
@external
def I_rps(_n: int256) -> IntegralRPS:
    ...


@view
@external
def I_rpu(_user: address, _n: int256) -> IntegralRPU:
    ...


@view
@external
def integrate_fraction(_user: address) -> uint256:
    ...


@view
@external
def total_collateral() -> uint256:
    ...


@view
@external
def user_collateral(user: address) -> uint256:
    ...


@external
def callback_collateral_shares(n: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT], size: uint256):
    ...


@external
def callback_user_shares(user: address, n: int256, user_shares: DynArray[uint256, MAX_TICKS_UINT], size: uint256):
    ...


@external
def user_checkpoint(addr: address) -> bool:
    ...


# Not a view: it checkpoints before returning (see the note on the implementation)
@external
def claimable_tokens(addr: address) -> uint256:
    ...

curve_stablecoin/interfaces/ILMCallbackFactory.vyi

from curve_stablecoin.interfaces import IAMM

event DeployedLMCallback:
    amm: indexed(address)
    deployer: indexed(address)
    blueprint: indexed(address)
    lm_callback: address


event UpdateLMCallbackBlueprint:
    old_blueprint: address
    new_blueprint: address


@view
@external
def owner() -> address:
    ...


@external
def transfer_ownership(new_owner: address):
    ...


@external
def deploy_lm_callback(_amm: IAMM) -> address:
    ...


@view
@external
def lm_callback_blueprint() -> address:
    ...


@view
@external
def is_valid_gauge(_lm_callback: address) -> bool:
    ...


@view
@external
def get_lm_callback(_i: uint256) -> address:
    ...


@view
@external
def get_lm_callback_by_amm(_amm: address) -> address:
    ...


@view
@external
def get_blueprint_by_lm_callback(_lm_callback: address) -> address:
    ...


@view
@external
def get_lm_callback_count() -> uint256:
    ...


@external
def pause():
    ...


@external
def unpause():
    ...


@view
@external
def paused() -> bool:
    ...


@external
def set_blueprint(_blueprint: address):
    ...


@view
@external
def version() -> String[5]:
    ...

curve_stablecoin/interfaces/IPriceOracle.vyi

@view
def price() -> uint256:
    ...

def price_w() -> uint256:
    ...

curve_std/interfaces/IERC20.vyi

# pragma version 0.4.3
# See https://github.com/vyperlang/vyper/pull/4349 for rationale

SYMBOL_MAX_LEN: constant(uint256) = 32
NAME_MAX_LEN: constant(uint256) = 64

# Events
event Transfer:
    sender: indexed(address)
    receiver: indexed(address)
    value: uint256


event Approval:
    owner: indexed(address)
    spender: indexed(address)
    value: uint256


# Functions
@view
def totalSupply() -> uint256:
    ...


@view
def balanceOf(_owner: address) -> uint256:
    ...


@view
def allowance(_owner: address, _spender: address) -> uint256:
    ...


def transfer(_to: address, _value: uint256) -> bool:
    ...


def transferFrom(_from: address, _to: address, _value: uint256) -> bool:
    ...


def approve(_spender: address, _value: uint256) -> bool:
    ...


@view
def name() -> String[NAME_MAX_LEN]:
    ...


@view
def symbol() -> String[SYMBOL_MAX_LEN]:
    ...


@view
def decimals() -> uint8:
    ...
Compiler settingsShow
{
  "evmVersion": "cancun"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.