ETH Price: $3,849.71 (+1.12%)

Contract

0x6903223578806940bd3ff0C51f87aa43968424c8
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Buy_dai187648072023-12-11 18:40:47360 days ago1702320047IN
Yearn: Buyback 2
0 ETH0.0088374671.37347221
Buy_dai178208372023-08-01 14:45:47492 days ago1690901147IN
Yearn: Buyback 2
0 ETH0.0042990636.12054857
Buy_dai173882862023-06-01 20:20:23553 days ago1685650823IN
Yearn: Buyback 2
0 ETH0.0042833937.50524158
Buy_dai161144422022-12-04 22:31:59732 days ago1670193119IN
Yearn: Buyback 2
0 ETH0.0015065312.17734971
Buy_dai160376572022-11-24 5:09:23742 days ago1669266563IN
Yearn: Buyback 2
0 ETH0.0016782612.33763323
Buy_dai155145602022-09-11 11:23:26816 days ago1662895406IN
Yearn: Buyback 2
0 ETH0.000728025.1691732
Buy_dai155118762022-09-11 0:45:28817 days ago1662857128IN
Yearn: Buyback 2
0 ETH0.000933626.62954208
Buy_dai149573662022-06-13 18:08:25906 days ago1655143705IN
Yearn: Buyback 2
0 ETH0.0070155156.70659855
Set_admin149538632022-06-13 3:42:42906 days ago1655091762IN
Yearn: Buyback 2
0 ETH0.0027582999.01611741
Set_treasury149538582022-06-13 3:41:22906 days ago1655091682IN
Yearn: Buyback 2
0 ETH0.00306926102.37724405

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Vyper_contract

Compiler Version
vyper:0.3.3

Optimization Enabled:
N/A

Other Settings:
default evmVersion, MIT license

Contract Source Code (Vyper language format)

# @version 0.3.3
"""
@title YFI Buyer
@license MIT
@author banteg
@notice
    Buy YFI for DAI at the current Chainlink price.

    New in v0.2.0
    - Accept and release a LlamaPay stream on buy
"""
from vyper.interfaces import ERC20

YFI: constant(address) = 0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e
DAI: constant(address) = 0x6B175474E89094C44Da98b954EedeAC495271d0F
YFI_USD: constant(address) = 0xA027702dbb89fbd58938e4324ac03B58d812b0E1
LLAMAPAY: constant(address) = 0x60c7B0c5B3a4Dc8C690b074727a17fF7aA287Ff2

STALE_AFTER: constant(uint256) = 3600

admin: public(address)
treasury: public(address)
rate: public(uint216)

struct ChainlinkRound:
    roundId: uint80
    answer: int256
    startedAt: uint256
    updatedAt: uint256
    answeredInRound: uint80

interface Chainlink:
    def latestRoundData() -> ChainlinkRound: view

struct Withdrawable:
    amount: uint256
    last_update: uint256
    owed: uint256

interface LlamaPay:
    def withdraw(source: address, target: address, rate: uint216): nonpayable
    def withdrawable(source: address, target: address, rate: uint216) -> Withdrawable: view

event Buyback:
    buyer: indexed(address)
    yfi: uint256
    dai: uint256

event UpdateAdmin:
    admin: indexed(address)

event UpdateTreasury:
    treasury: indexed(address)

event UpdateRate:
    rate: indexed(uint216)


@external
def __init__():
    self.admin = msg.sender
    self.treasury = msg.sender
    
    log UpdateAdmin(msg.sender)
    log UpdateTreasury(msg.sender)


@view
@internal
def withdrawable() -> uint256:
    if self.rate != 0:
        return LlamaPay(LLAMAPAY).withdrawable(self.admin, self, self.rate).amount
    return 0


@external
def buy_dai(yfi_amount: uint256):
    oracle: ChainlinkRound = Chainlink(YFI_USD).latestRoundData()
    assert oracle.updatedAt + STALE_AFTER > block.timestamp  # dev: stale oracle

    if self.rate != 0:
        LlamaPay(LLAMAPAY).withdraw(self.admin, self, self.rate)

    dai_amount: uint256 = convert(oracle.answer, uint256) * yfi_amount / 10 ** 8

    assert ERC20(YFI).transferFrom(msg.sender, self.treasury, yfi_amount)  # dev: no allowance
    assert ERC20(DAI).transfer(msg.sender, dai_amount)  # dev: not enough dai

    log Buyback(msg.sender, yfi_amount, dai_amount)


@view
@external
def price() -> uint256:
    oracle: ChainlinkRound = Chainlink(YFI_USD).latestRoundData()
    return convert(oracle.answer, uint256) * 10 ** 10


@view
@external
def total_dai() -> uint256:
    return ERC20(DAI).balanceOf(self) + self.withdrawable()


@view
@external
def max_amount() -> uint256:
    oracle: ChainlinkRound = Chainlink(YFI_USD).latestRoundData()
    amount: uint256 = ERC20(DAI).balanceOf(self) + self.withdrawable()
    return amount / convert(oracle.answer, uint256) * 10 ** 8


@external
def sweep(token: address, amount: uint256 = MAX_UINT256):
    assert msg.sender == self.admin
    value: uint256 = amount
    if value == MAX_UINT256:
        value = ERC20(token).balanceOf(self)
    
    assert ERC20(token).transfer(self.admin, value)


@external
def set_admin(proposed_admin: address):
    assert msg.sender == self.admin
    self.admin = proposed_admin

    log UpdateAdmin(proposed_admin)


@external
def set_treasury(new_treasury: address):
    assert msg.sender == self.admin
    self.treasury = new_treasury

    log UpdateTreasury(new_treasury)


@external
def set_rate(new_rate: uint216):
    assert msg.sender == self.admin
    self.rate = new_rate

    log UpdateRate(new_rate)

Contract Security Audit

Contract ABI

[{"name":"Buyback","inputs":[{"name":"buyer","type":"address","indexed":true},{"name":"yfi","type":"uint256","indexed":false},{"name":"dai","type":"uint256","indexed":false}],"anonymous":false,"type":"event"},{"name":"UpdateAdmin","inputs":[{"name":"admin","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"UpdateTreasury","inputs":[{"name":"treasury","type":"address","indexed":true}],"anonymous":false,"type":"event"},{"name":"UpdateRate","inputs":[{"name":"rate","type":"uint216","indexed":true}],"anonymous":false,"type":"event"},{"stateMutability":"nonpayable","type":"constructor","inputs":[],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"buy_dai","inputs":[{"name":"yfi_amount","type":"uint256"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"price","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"total_dai","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"max_amount","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"nonpayable","type":"function","name":"sweep","inputs":[{"name":"token","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"sweep","inputs":[{"name":"token","type":"address"},{"name":"amount","type":"uint256"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_admin","inputs":[{"name":"proposed_admin","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_treasury","inputs":[{"name":"new_treasury","type":"address"}],"outputs":[]},{"stateMutability":"nonpayable","type":"function","name":"set_rate","inputs":[{"name":"new_rate","type":"uint216"}],"outputs":[]},{"stateMutability":"view","type":"function","name":"admin","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"treasury","inputs":[],"outputs":[{"name":"","type":"address"}]},{"stateMutability":"view","type":"function","name":"rate","inputs":[],"outputs":[{"name":"","type":"uint216"}]}]

3360005533600155337fbfc8d7754fec5096becc28e0816011e8d0adcfe752ffa1c88924a7f88b00a41d60006040a2337f1f54d231bb9d500b1923e4a1cb25e600f366a8368873d9af7c1c623814df19fc60006040a261081261006e6300000000396108126000016300000000f3600436101561000d5761079c565b60003560e01c3461080d5763776c6e8481186102915763feaf968c60e05260a060e0600460fc73a027702dbb89fbd58938e4324ac03b58d812b0e15afa610059573d600060003e3d6000fd5b60a03d1061080d5760e0518060501c61080d576101a052610100516101c052610120516101e0526101405161020052610160518060501c61080d57610220526101a0805160405260208101516060526040810151608052606081015160a052608081015160c052504260a051610e10818183011061080d5780820190509050111561080d5760006002541461014e576317a566e460e052600054610100523061012052600254610140527360c7b0c5b3a4dc8c690b074727a17ff7aa287ff23b1561080d5760006000606460fc60007360c7b0c5b3a4dc8c690b074727a17ff7aa287ff25af161014e573d600060003e3d6000fd5b606051806000811261080d57905060043580820282158284830414171561080d57905090506305f5e1008082049050905060e0526323b872dd61010052336101205260015461014052600435610160526020610100606461011c6000730bc529c00c6401aef6d220be8c6ea1667f6ad93e5af16101d0573d600060003e3d6000fd5b60203d1061080d57610100518060011c61080d5761018052610180511561080d5763a9059cbb61010052336101205260e051610140526020610100604461011c6000736b175474e89094c44da98b954eedeac495271d0f5af1610238573d600060003e3d6000fd5b60203d1061080d57610100518060011c61080d5761016052610160511561080d57337f2dcc2439519c7d06fca9f8ae01e07f4f3c6ca21b5cdf8eff42cb75cf34d223c96004356101005260e051610120526040610100a2005b63a035b1fe811861036b5763feaf968c60e05260a060e0600460fc73a027702dbb89fbd58938e4324ac03b58d812b0e15afa6102d2573d600060003e3d6000fd5b60a03d1061080d5760e0518060501c61080d576101a052610100516101c052610120516101e0526101405161020052610160518060501c61080d57610220526101a0805160405260208101516060526040810151608052606081015160a052608081015160c05250606051806000811261080d5790506402540be40080820282158284830414171561080d579050905060e052602060e0f35b63ce96204781186103e5576370a0823160c0523060e052602060c0602460dc736b175474e89094c44da98b954eedeac495271d0f5afa6103b0573d600060003e3d6000fd5b60203d1061080d5760c0516103c66101006107a2565b61010051818183011061080d5780820190509050610120526020610120f35b631a34fe8181186105455763feaf968c6101605260a0610160600461017c73a027702dbb89fbd58938e4324ac03b58d812b0e15afa610429573d600060003e3d6000fd5b60a03d1061080d57610160518060501c61080d576102205261018051610240526101a051610260526101c051610280526101e0518060501c61080d576102a052610220805160c052602081015160e052604081015161010052606081015161012052608081015161014052506370a0823161018052306101a0526020610180602461019c736b175474e89094c44da98b954eedeac495271d0f5afa6104d3573d600060003e3d6000fd5b60203d1061080d57610180516104ea6101c06107a2565b6101c051818183011061080d5780820190509050610160526101605160e051806000811261080d57905080801561080d578204905090506305f5e10080820282158284830414171561080d5790509050610180526020610180f35b6301681a628118610579577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60605261058b565b636ea056a9811861065c576024356060525b6004358060a01c61080d57604052600054331861080d576060516080527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60805118610608576370a0823160a0523060c052602060a0602460bc6040515afa6105f9573d600060003e3d6000fd5b60203d1061080d5760a0516080525b63a9059cbb60a05260005460c05260805160e052602060a0604460bc60006040515af161063a573d600060003e3d6000fd5b60203d1061080d5760a0518060011c61080d5761010052610100511561080d57005b63e9333fab81186106af576004358060a01c61080d57604052600054331861080d576040516000556040517fbfc8d7754fec5096becc28e0816011e8d0adcfe752ffa1c88924a7f88b00a41d60006060a2005b6330bcd67b8118610702576004358060a01c61080d57604052600054331861080d576040516001556040517f1f54d231bb9d500b1923e4a1cb25e600f366a8368873d9af7c1c623814df19fc60006060a2005b63ede911e88118610755576004358060d81c61080d57604052600054331861080d576040516002556040517fb206d5f618a83fae38b4ae56db2976072076e1e0c0708a51b6f1c060e78b7cc760006060a2005b63f851a440811861076c5760005460405260206040f35b6361d027b381186107835760015460405260206040f35b632c4e722e811861079a5760025460405260206040f35b505b60006000fd5b60006002541461080557633f053acd6040526000546060523060805260025460a052606060406064605c7360c7b0c5b3a4dc8c690b074727a17ff7aa287ff25afa6107f2573d600060003e3d6000fd5b60603d1061080d5760405181525061080b565b60008152505b565b600080fd

Deployed Bytecode

0x600436101561000d5761079c565b60003560e01c3461080d5763776c6e8481186102915763feaf968c60e05260a060e0600460fc73a027702dbb89fbd58938e4324ac03b58d812b0e15afa610059573d600060003e3d6000fd5b60a03d1061080d5760e0518060501c61080d576101a052610100516101c052610120516101e0526101405161020052610160518060501c61080d57610220526101a0805160405260208101516060526040810151608052606081015160a052608081015160c052504260a051610e10818183011061080d5780820190509050111561080d5760006002541461014e576317a566e460e052600054610100523061012052600254610140527360c7b0c5b3a4dc8c690b074727a17ff7aa287ff23b1561080d5760006000606460fc60007360c7b0c5b3a4dc8c690b074727a17ff7aa287ff25af161014e573d600060003e3d6000fd5b606051806000811261080d57905060043580820282158284830414171561080d57905090506305f5e1008082049050905060e0526323b872dd61010052336101205260015461014052600435610160526020610100606461011c6000730bc529c00c6401aef6d220be8c6ea1667f6ad93e5af16101d0573d600060003e3d6000fd5b60203d1061080d57610100518060011c61080d5761018052610180511561080d5763a9059cbb61010052336101205260e051610140526020610100604461011c6000736b175474e89094c44da98b954eedeac495271d0f5af1610238573d600060003e3d6000fd5b60203d1061080d57610100518060011c61080d5761016052610160511561080d57337f2dcc2439519c7d06fca9f8ae01e07f4f3c6ca21b5cdf8eff42cb75cf34d223c96004356101005260e051610120526040610100a2005b63a035b1fe811861036b5763feaf968c60e05260a060e0600460fc73a027702dbb89fbd58938e4324ac03b58d812b0e15afa6102d2573d600060003e3d6000fd5b60a03d1061080d5760e0518060501c61080d576101a052610100516101c052610120516101e0526101405161020052610160518060501c61080d57610220526101a0805160405260208101516060526040810151608052606081015160a052608081015160c05250606051806000811261080d5790506402540be40080820282158284830414171561080d579050905060e052602060e0f35b63ce96204781186103e5576370a0823160c0523060e052602060c0602460dc736b175474e89094c44da98b954eedeac495271d0f5afa6103b0573d600060003e3d6000fd5b60203d1061080d5760c0516103c66101006107a2565b61010051818183011061080d5780820190509050610120526020610120f35b631a34fe8181186105455763feaf968c6101605260a0610160600461017c73a027702dbb89fbd58938e4324ac03b58d812b0e15afa610429573d600060003e3d6000fd5b60a03d1061080d57610160518060501c61080d576102205261018051610240526101a051610260526101c051610280526101e0518060501c61080d576102a052610220805160c052602081015160e052604081015161010052606081015161012052608081015161014052506370a0823161018052306101a0526020610180602461019c736b175474e89094c44da98b954eedeac495271d0f5afa6104d3573d600060003e3d6000fd5b60203d1061080d57610180516104ea6101c06107a2565b6101c051818183011061080d5780820190509050610160526101605160e051806000811261080d57905080801561080d578204905090506305f5e10080820282158284830414171561080d5790509050610180526020610180f35b6301681a628118610579577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60605261058b565b636ea056a9811861065c576024356060525b6004358060a01c61080d57604052600054331861080d576060516080527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60805118610608576370a0823160a0523060c052602060a0602460bc6040515afa6105f9573d600060003e3d6000fd5b60203d1061080d5760a0516080525b63a9059cbb60a05260005460c05260805160e052602060a0604460bc60006040515af161063a573d600060003e3d6000fd5b60203d1061080d5760a0518060011c61080d5761010052610100511561080d57005b63e9333fab81186106af576004358060a01c61080d57604052600054331861080d576040516000556040517fbfc8d7754fec5096becc28e0816011e8d0adcfe752ffa1c88924a7f88b00a41d60006060a2005b6330bcd67b8118610702576004358060a01c61080d57604052600054331861080d576040516001556040517f1f54d231bb9d500b1923e4a1cb25e600f366a8368873d9af7c1c623814df19fc60006060a2005b63ede911e88118610755576004358060d81c61080d57604052600054331861080d576040516002556040517fb206d5f618a83fae38b4ae56db2976072076e1e0c0708a51b6f1c060e78b7cc760006060a2005b63f851a440811861076c5760005460405260206040f35b6361d027b381186107835760015460405260206040f35b632c4e722e811861079a5760025460405260206040f35b505b60006000fd5b60006002541461080557633f053acd6040526000546060523060805260025460a052606060406064605c7360c7b0c5b3a4dc8c690b074727a17ff7aa287ff25afa6107f2573d600060003e3d6000fd5b60603d1061080d5760405181525061080b565b60008152505b565b600080fd

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.