Address: 0x338244E0e3dE1ee377370c2D5Cc3a2496C2b5f35
Balance (XRP): 0 XRP
Bytecode: 0x608060405234801561001057600080fd5b506004361061018e5760003560e01c806386ac6928116100de5780639bc2faef11610097578063d2e1f80611610071578063d2e1f8061461037b578063f2fde38b1461038e578063f3da762c146103a1578063fccf4a28146103b457600080fd5b80639bc2faef14610342578063ab97848314610355578063bc6584a81461036857600080fd5b806386ac6928146102d257806389a686a6146102e55780638da5cb5b146102f857806392334d36146103095780639567ac421461031c578063979517941461032f57600080fd5b806359db63761161014b5780636e4f88c8116101255780636e4f88c814610282578063715018a6146102975780637b2ee3bc1461029f5780638123e80c146102bf57600080fd5b806359db63761461024957806361e17dca1461025c5780636b313b1f1461026f57600080fd5b8063150b7a02146101935780631966a83f146101d057806348046ca3146101e55780634c6e98a3146101f857806352245dc11461020b57806359a9c7441461021e575b600080fd5b6101b26101a1366004611e65565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b6101e36101de366004611f00565b6103c7565b005b6101e36101f3366004611f19565b610599565b6101e3610206366004611f19565b61061c565b6101e3610219366004611f00565b61069f565b600554610231906001600160a01b031681565b6040516001600160a01b0390911681526020016101c7565b6101e3610257366004611f19565b6108aa565b600254610231906001600160a01b031681565b6101e361027d366004611f00565b61093e565b61028a610af5565b6040516101c79190611f34565b6101e3610b06565b6102b26102ad366004611f19565b610b1a565b6040516101c79190611fbc565b6101e36102cd366004611f00565b610c7c565b600754610231906001600160a01b031681565b6101e36102f336600461206c565b610e2d565b6000546001600160a01b0316610231565b600354610231906001600160a01b031681565b6101e361032a366004611f19565b611388565b600854610231906001600160a01b031681565b6101e3610350366004611f19565b611415565b600454610231906001600160a01b031681565b600654610231906001600160a01b031681565b6101e361038936600461206c565b611498565b6101e361039c366004611f19565b61187c565b6101e36103af366004611f19565b6118f2565b6101e36103c2366004611f19565b611975565b6103cf611a09565b600081116104245760405162461bcd60e51b815260206004820181905260248201527f4d757374207769746864726177206d6f7265207468616e203020746f6b656e7360448201526064015b60405180910390fd5b336000908152600a60205260409020548111156104835760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e74207374616b656420616d6f756e74000000000000604482015260640161041b565b60035460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156104d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f8919061209c565b50336000908152600a6020526040812080548392906105189084906120d4565b90915550610527905033611a62565b336001600160a01b03167fb80d46a1fcb96f3896e038df66c1242504a8e49effecd0bf2473574707ca012182604051610585918152604060208201819052600b908201526a0524f4f542f5a5250204c560ac1b606082015260800190565b60405180910390a261059660018055565b50565b6105a1611b80565b6003546001600160a01b0316156105fa5760405162461bcd60e51b815260206004820152601d60248201527f524f4f542f5a5250204c5020746f6b656e20616c726561647920736574000000604482015260640161041b565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b610624611b80565b6002546001600160a01b03161561067d5760405162461bcd60e51b815260206004820152601c60248201527f5852502f5a5250204c5020746f6b656e20616c72656164792073657400000000604482015260640161041b565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6106a7611a09565b6002546001600160a01b03166106fa5760405162461bcd60e51b81526020600482015260186024820152771614940bd69494081314081d1bdad95b881b9bdd081cd95d60421b604482015260640161041b565b6000811161074a5760405162461bcd60e51b815260206004820181905260248201527f4d757374207769746864726177206d6f7265207468616e203020746f6b656e73604482015260640161041b565b336000908152600960205260409020548111156107a95760405162461bcd60e51b815260206004820152601a60248201527f496e73756666696369656e74207374616b656420616d6f756e74000000000000604482015260640161041b565b60025460405163a9059cbb60e01b8152336004820152602481018390526001600160a01b039091169063a9059cbb906044016020604051808303816000875af11580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e919061209c565b50336000908152600960205260408120805483929061083e9084906120d4565b9091555061084d905033611a62565b336001600160a01b03167fb80d46a1fcb96f3896e038df66c1242504a8e49effecd0bf2473574707ca012182604051610585918152604060208201819052600a908201526905852502f5a5250204c560b41b606082015260800190565b6108b2611b80565b6007546001600160a01b03161561091c5760405162461bcd60e51b815260206004820152602860248201527f5a6572706d6f6e20547261696e6572732045766f6c766564204e465420616c726044820152671958591e481cd95d60c21b606482015260840161041b565b600780546001600160a01b0319166001600160a01b0392909216919091179055565b610946611a09565b6003546001600160a01b031661099e5760405162461bcd60e51b815260206004820152601960248201527f524f4f542f5a5250204c5020746f6b656e206e6f742073657400000000000000604482015260640161041b565b600081116109ee5760405162461bcd60e51b815260206004820152601d60248201527f4d757374207374616b65206d6f7265207468616e203020746f6b656e73000000604482015260640161041b565b6003546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610a22903390309086906004016120e7565b6020604051808303816000875af1158015610a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a65919061209c565b50336000908152600a602052604081208054839290610a8590849061210b565b90915550610a969050601033611bda565b50336001600160a01b03167f78a806bb7699c94c8bf510c6ae4c7d16f8a7465865bee03d1a5d2c572f7c128b82604051610585918152604060208201819052600b908201526a0524f4f542f5a5250204c560ac1b606082015260800190565b6060610b016010611bf8565b905090565b610b0e611b80565b610b186000611c0c565b565b610b5a6040518060e00160405280600081526020016000815260200160608152602001606081526020016060815260200160608152602001606081525090565b610b9a6040518060e00160405280600081526020016000815260200160608152602001606081526020016060815260200160608152602001606081525090565b6001600160a01b0383166000818152600960209081526040808320548552838352600a82528083205485830152928252600b905220610bd890611bf8565b6040808301919091526001600160a01b0384166000908152600c60205220610bff90611bf8565b60608201526001600160a01b0383166000908152600d60205260409020610c2590611bf8565b60808201526001600160a01b0383166000908152600e60205260409020610c4b90611bf8565b60a08201526001600160a01b0383166000908152600f60205260409020610c7190611bf8565b60c082015292915050565b610c84611a09565b6002546001600160a01b0316610cd75760405162461bcd60e51b81526020600482015260186024820152771614940bd69494081314081d1bdad95b881b9bdd081cd95d60421b604482015260640161041b565b60008111610d275760405162461bcd60e51b815260206004820152601d60248201527f4d757374207374616b65206d6f7265207468616e203020746f6b656e73000000604482015260640161041b565b6002546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610d5b903390309086906004016120e7565b6020604051808303816000875af1158015610d7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9e919061209c565b503360009081526009602052604081208054839290610dbe90849061210b565b90915550610dcf9050601033611bda565b50336001600160a01b03167f78a806bb7699c94c8bf510c6ae4c7d16f8a7465865bee03d1a5d2c572f7c128b82604051610585918152604060208201819052600a908201526905852502f5a5250204c560b41b606082015260800190565b610e35611a09565b6000826004811115610e4957610e4961211e565b03610f2b576004546001600160a01b0316610ea65760405162461bcd60e51b815260206004820152601b60248201527f5a6572706d6f6e2047656e65736973204e4654206e6f74207365740000000000604482015260640161041b565b60048054604051632142170760e11b81526001600160a01b03909116916342842e0e91610ed991339130918791016120e7565b600060405180830381600087803b158015610ef357600080fd5b505af1158015610f07573d6000803e3d6000fd5b5050336000908152600b60205260409020610f259250905082611c5c565b50611309565b6001826004811115610f3f57610f3f61211e565b0361101c576005546001600160a01b0316610f9c5760405162461bcd60e51b815260206004820152601b60248201527f5a6572706d6f6e2045766f6c766564204e4654206e6f74207365740000000000604482015260640161041b565b600554604051632142170760e11b81526001600160a01b03909116906342842e0e90610fd0903390309086906004016120e7565b600060405180830381600087803b158015610fea57600080fd5b505af1158015610ffe573d6000803e3d6000fd5b5050336000908152600c60205260409020610f259250905082611c5c565b60028260048111156110305761103061211e565b03611119576006546001600160a01b03166110995760405162461bcd60e51b8152602060048201526024808201527f5a6572706d6f6e20547261696e6572732047656e65736973204e4654206e6f74604482015263081cd95d60e21b606482015260840161041b565b600654604051632142170760e11b81526001600160a01b03909116906342842e0e906110cd903390309086906004016120e7565b600060405180830381600087803b1580156110e757600080fd5b505af11580156110fb573d6000803e3d6000fd5b5050336000908152600d60205260409020610f259250905082611c5c565b600382600481111561112d5761112d61211e565b03611216576007546001600160a01b03166111965760405162461bcd60e51b8152602060048201526024808201527f5a6572706d6f6e20547261696e6572732045766f6c766564204e4654206e6f74604482015263081cd95d60e21b606482015260840161041b565b600754604051632142170760e11b81526001600160a01b03909116906342842e0e906111ca903390309086906004016120e7565b600060405180830381600087803b1580156111e457600080fd5b505af11580156111f8573d6000803e3d6000fd5b5050336000908152600e60205260409020610f259250905082611c5c565b600482600481111561122a5761122a61211e565b03611309576008546001600160a01b03166112875760405162461bcd60e51b815260206004820152601d60248201527f5a6572706d6f6e2045717569706d656e74204e4654206e6f7420736574000000604482015260640161041b565b600854604051632142170760e11b81526001600160a01b03909116906342842e0e906112bb903390309086906004016120e7565b600060405180830381600087803b1580156112d557600080fd5b505af11580156112e9573d6000803e3d6000fd5b5050336000908152600f602052604090206113079250905082611c5c565b505b611314601033611bda565b50336001600160a01b03167f78a806bb7699c94c8bf510c6ae4c7d16f8a7465865bee03d1a5d2c572f7c128b82604051611373918152604060208201819052600b908201526a16995c9c1b5bdb8813919560aa1b606082015260800190565b60405180910390a261138460018055565b5050565b611390611b80565b6008546001600160a01b0316156113f35760405162461bcd60e51b815260206004820152602160248201527f5a6572706d6f6e2045717569706d656e74204e465420616c72656164792073656044820152601d60fa1b606482015260840161041b565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b61141d611b80565b6005546001600160a01b0316156114765760405162461bcd60e51b815260206004820152601f60248201527f5a6572706d6f6e2045766f6c766564204e465420616c72656164792073657400604482015260640161041b565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6114a0611a09565b60008260048111156114b4576114b461211e565b0361157257336000908152600b602052604090206114d29082611c68565b6114ee5760405162461bcd60e51b815260040161041b90612134565b336000908152600b602052604090206115079082611c80565b5060048054604051632142170760e11b81526001600160a01b03909116916342842e0e9161153b91309133918791016120e7565b600060405180830381600087803b15801561155557600080fd5b505af1158015611569573d6000803e3d6000fd5b50505050611815565b60018260048111156115865761158661211e565b0361160e57336000908152600c602052604090206115a49082611c68565b6115c05760405162461bcd60e51b815260040161041b90612134565b336000908152600c602052604090206115d99082611c80565b50600554604051632142170760e11b81526001600160a01b03909116906342842e0e9061153b903090339086906004016120e7565b60028260048111156116225761162261211e565b036116aa57336000908152600d602052604090206116409082611c68565b61165c5760405162461bcd60e51b815260040161041b90612134565b336000908152600d602052604090206116759082611c80565b50600654604051632142170760e11b81526001600160a01b03909116906342842e0e9061153b903090339086906004016120e7565b60038260048111156116be576116be61211e565b0361174657336000908152600e602052604090206116dc9082611c68565b6116f85760405162461bcd60e51b815260040161041b90612134565b336000908152600e602052604090206117119082611c80565b50600754604051632142170760e11b81526001600160a01b03909116906342842e0e9061153b903090339086906004016120e7565b600482600481111561175a5761175a61211e565b0361181557336000908152600f602052604090206117789082611c68565b6117945760405162461bcd60e51b815260040161041b90612134565b336000908152600f602052604090206117ad9082611c80565b50600854604051632142170760e11b81526001600160a01b03909116906342842e0e906117e2903090339086906004016120e7565b600060405180830381600087803b1580156117fc57600080fd5b505af1158015611810573d6000803e3d6000fd5b505050505b61181e33611a62565b336001600160a01b03167fb80d46a1fcb96f3896e038df66c1242504a8e49effecd0bf2473574707ca012182604051611373918152604060208201819052600b908201526a16995c9c1b5bdb8813919560aa1b606082015260800190565b611884611b80565b6001600160a01b0381166118e95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161041b565b61059681611c0c565b6118fa611b80565b6004546001600160a01b0316156119535760405162461bcd60e51b815260206004820152601f60248201527f5a6572706d6f6e2047656e65736973204e465420616c72656164792073657400604482015260640161041b565b600480546001600160a01b0319166001600160a01b0392909216919091179055565b61197d611b80565b6006546001600160a01b0316156119e75760405162461bcd60e51b815260206004820152602860248201527f5a6572706d6f6e20547261696e6572732047656e65736973204e465420616c726044820152671958591e481cd95d60c21b606482015260840161041b565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b600260015403611a5b5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161041b565b6002600155565b6001600160a01b038116600090815260096020526040902054158015611a9e57506001600160a01b0381166000908152600a6020526040902054155b8015611ac857506001600160a01b0381166000908152600b60205260409020611ac690611c8c565b155b8015611af257506001600160a01b0381166000908152600c60205260409020611af090611c8c565b155b8015611b1c57506001600160a01b0381166000908152600d60205260409020611b1a90611c8c565b155b8015611b4657506001600160a01b0381166000908152600e60205260409020611b4490611c8c565b155b8015611b7057506001600160a01b0381166000908152600f60205260409020611b6e90611c8c565b155b1561059657611384601082611c96565b6000546001600160a01b03163314610b185760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161041b565b6000611bef836001600160a01b038416611cab565b90505b92915050565b60606000611c0583611cfa565b9392505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611bef8383611cab565b60008181526001830160205260408120541515611bef565b6000611bef8383611d56565b6000611bf2825490565b6000611bef836001600160a01b038416611d56565b6000818152600183016020526040812054611cf257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611bf2565b506000611bf2565b606081600001805480602002602001604051908101604052809291908181526020018280548015611d4a57602002820191906000526020600020905b815481526020019060010190808311611d36575b50505050509050919050565b60008181526001830160205260408120548015611e3f576000611d7a6001836120d4565b8554909150600090611d8e906001906120d4565b9050818114611df3576000866000018281548110611dae57611dae61215c565b9060005260206000200154905080876000018481548110611dd157611dd161215c565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611e0457611e04612172565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611bf2565b6000915050611bf2565b80356001600160a01b0381168114611e6057600080fd5b919050565b600080600080600060808688031215611e7d57600080fd5b611e8686611e49565b9450611e9460208701611e49565b935060408601359250606086013567ffffffffffffffff80821115611eb857600080fd5b818801915088601f830112611ecc57600080fd5b813581811115611edb57600080fd5b896020828501011115611eed57600080fd5b9699959850939650602001949392505050565b600060208284031215611f1257600080fd5b5035919050565b600060208284031215611f2b57600080fd5b611bef82611e49565b6020808252825182820181905260009190848201906040850190845b81811015611f755783516001600160a01b031683529284019291840191600101611f50565b50909695505050505050565b600081518084526020808501945080840160005b83811015611fb157815187529582019590820190600101611f95565b509495945050505050565b6020815281516020820152602082015160408201526000604083015160e06060840152611fed610100840182611f81565b90506060840151601f198085840301608086015261200b8383611f81565b925060808601519150808584030160a08601526120288383611f81565b925060a08601519150808584030160c08601526120458383611f81565b925060c08601519150808584030160e0860152506120638282611f81565b95945050505050565b6000806040838503121561207f57600080fd5b82356005811061208e57600080fd5b946020939093013593505050565b6000602082840312156120ae57600080fd5b81518015158114611c0557600080fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115611bf257611bf26120be565b6001600160a01b039384168152919092166020820152604081019190915260600190565b80820180821115611bf257611bf26120be565b634e487b7160e01b600052602160045260246000fd5b6020808252600e908201526d139195081b9bdd081cdd185ad95960921b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fdfea26469706673582212206f4c1cc24c7b2a2f0154cc1068f62dfd63fdf1416d731fb13f58bf90b001340664736f6c63430008110033
Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
ReentrancyGuard.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == _ENTERED; } }
IERC20.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
EnumerableSet.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
ZerpmonStaking.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; /// @title ZerpmonStaking /// @notice Contract for staking XRP/ZRP and ROOT/ZRP LP tokens, Zerpmon NFTs, and Zerpmon Equipment NFTs contract ZerpmonStaking is Ownable, ReentrancyGuard, IERC721Receiver { using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.UintSet; enum NftCollection { ZerpmonGenesis, ZerpmonEvolved, ZerpmonTrainersGenesis, ZerpmonTrainersEvolved, ZerpmonEquipment } /// @notice XRP/ZRP Liquidity Pool token IERC20 public xrpZrpLpToken; /// @notice ROOT/ZRP Liquidity Pool token IERC20 public rootZrpLpToken; /// @notice Zerpmon Genesis NFT IERC721 public zerpmonGenesisNft; /// @notice Zerpmon Evolved NFT IERC721 public zerpmonEvolvedNft; /// @notice Zerpmon Trainers Genesis NFT IERC721 public zerpmonTrainersGenesisNft; /// @notice Zerpmon Trainers Evolved NFT IERC721 public zerpmonTrainersEvolvedNft; /// @notice Zerpmon Equipment NFT IERC721 public zerpmonEquipmentNft; /// @notice Mapping of address to amount of XRP/ZRP LP tokens staked mapping(address => uint256) private xrpZrpLpStakes; /// @notice Mapping of address to amount of ROOT/ZRP LP tokens staked mapping(address => uint256) private rootZrpLpStakes; /// @notice Mapping of Zerpmon Genesis NFT ID to address of staker mapping(address => EnumerableSet.UintSet) private zerpmonGenesisNftStakes; /// @notice Mapping of Zerpmon Evolved NFT ID to address of staker mapping(address => EnumerableSet.UintSet) private zerpmonEvolvedNftStakes; /// @notice Mapping of Zerpmon Trainers Genesis NFT ID to address of staker mapping(address => EnumerableSet.UintSet) private zerpmonTrainersGenesisNftStakes; /// @notice Mapping of Zerpmon Trainers Evolved NFT ID to address of staker mapping(address => EnumerableSet.UintSet) private zerpmonTrainersEvolvedNftStakes; /// @notice Mapping of Zerpmon Equipment NFT ID to address of staker mapping(address => EnumerableSet.UintSet) private zerpmonEquipmentNftStakes; /// @notice All stakers enumerable set EnumerableSet.AddressSet private stakers; /// @notice Event emitted when a user stakes assets event Staked(address indexed user, uint256 amount, string assetType); /// @notice Event emitted when a user withdraws assets event Withdrawn(address indexed user, uint256 amount, string assetType); constructor() Ownable() {} /// @notice Function for staking XRP/ZRP LP tokens /// @param amount Amount of XRP/ZRP LP tokens to stake function stakeXrpZrpLpTokens(uint256 amount) external nonReentrant { require(address(xrpZrpLpToken) != address(0), "XRP/ZRP LP token not set"); require(amount > 0, "Must stake more than 0 tokens"); xrpZrpLpToken.transferFrom(msg.sender, address(this), amount); xrpZrpLpStakes[msg.sender] += amount; stakers.add(msg.sender); emit Staked(msg.sender, amount, "XRP/ZRP LP"); } /// @notice Function for withdrawing XRP/ZRP LP tokens /// @param amount Amount of XRP/ZRP LP tokens to withdraw function withdrawXrpZrpLpTokens(uint256 amount) external nonReentrant { require(address(xrpZrpLpToken) != address(0), "XRP/ZRP LP token not set"); require(amount > 0, "Must withdraw more than 0 tokens"); require(xrpZrpLpStakes[msg.sender] >= amount, "Insufficient staked amount"); xrpZrpLpToken.transfer(msg.sender, amount); xrpZrpLpStakes[msg.sender] -= amount; checkAndRemoveStaker(msg.sender); emit Withdrawn(msg.sender, amount, "XRP/ZRP LP"); } /// @notice Function for staking ROOT/ZRP LP tokens /// @param amount Amount of ROOT/ZRP LP tokens to stake function stakeRootZrpLpTokens(uint256 amount) external nonReentrant { require(address(rootZrpLpToken) != address(0), "ROOT/ZRP LP token not set"); require(amount > 0, "Must stake more than 0 tokens"); rootZrpLpToken.transferFrom(msg.sender, address(this), amount); rootZrpLpStakes[msg.sender] += amount; stakers.add(msg.sender); emit Staked(msg.sender, amount, "ROOT/ZRP LP"); } /// @notice Function for withdrawing ROOT/ZRP LP tokens /// @param amount Amount of ROOT/ZRP LP tokens to withdraw function withdrawRootZrpLpTokens(uint256 amount) external nonReentrant { require(amount > 0, "Must withdraw more than 0 tokens"); require(rootZrpLpStakes[msg.sender] >= amount, "Insufficient staked amount"); rootZrpLpToken.transfer(msg.sender, amount); rootZrpLpStakes[msg.sender] -= amount; checkAndRemoveStaker(msg.sender); emit Withdrawn(msg.sender, amount, "ROOT/ZRP LP"); } /// @notice Function for staking Zerpmon NFTs /// @param collection Collection of the Zerpmon NFT /// @param nftId ID of the Zerpmon Genesis NFT to stake /// @dev 0 Zerpmon Genesis, 1 Zerpmon Evolved, 2 Zerpmon Trainers Genesis, 3 Zerpmon Trainers Evolved, 4 Zerpmon Equipment function stakeZerpmonNft(NftCollection collection, uint256 nftId) external nonReentrant { if (collection == NftCollection.ZerpmonGenesis) { require(address(zerpmonGenesisNft) != address(0), "Zerpmon Genesis NFT not set"); zerpmonGenesisNft.safeTransferFrom(msg.sender, address(this), nftId); zerpmonGenesisNftStakes[msg.sender].add(nftId); } else if (collection == NftCollection.ZerpmonEvolved) { require(address(zerpmonEvolvedNft) != address(0), "Zerpmon Evolved NFT not set"); zerpmonEvolvedNft.safeTransferFrom(msg.sender, address(this), nftId); zerpmonEvolvedNftStakes[msg.sender].add(nftId); } else if (collection == NftCollection.ZerpmonTrainersGenesis) { require(address(zerpmonTrainersGenesisNft) != address(0), "Zerpmon Trainers Genesis NFT not set"); zerpmonTrainersGenesisNft.safeTransferFrom(msg.sender, address(this), nftId); zerpmonTrainersGenesisNftStakes[msg.sender].add(nftId); } else if (collection == NftCollection.ZerpmonTrainersEvolved) { require(address(zerpmonTrainersEvolvedNft) != address(0), "Zerpmon Trainers Evolved NFT not set"); zerpmonTrainersEvolvedNft.safeTransferFrom(msg.sender, address(this), nftId); zerpmonTrainersEvolvedNftStakes[msg.sender].add(nftId); } else if (collection == NftCollection.ZerpmonEquipment) { require(address(zerpmonEquipmentNft) != address(0), "Zerpmon Equipment NFT not set"); zerpmonEquipmentNft.safeTransferFrom(msg.sender, address(this), nftId); zerpmonEquipmentNftStakes[msg.sender].add(nftId); } stakers.add(msg.sender); emit Staked(msg.sender, nftId, "Zerpmon NFT"); } /// @notice Function for withdrawing Zerpmon NFTs /// @param collection Collection of the Zerpmon NFT /// @param nftId ID of the Zerpmon Genesis NFT to withdraw /// @dev 0 Zerpmon Genesis, 1 Zerpmon Evolved, 2 Zerpmon Trainers Genesis, 3 Zerpmon Trainers Evolved, 4 Zerpmon Equipment function withdrawZerpmonNft(NftCollection collection, uint256 nftId) external nonReentrant { if (collection == NftCollection.ZerpmonGenesis) { require(zerpmonGenesisNftStakes[msg.sender].contains(nftId), "NFT not staked"); zerpmonGenesisNftStakes[msg.sender].remove(nftId); zerpmonGenesisNft.safeTransferFrom(address(this), msg.sender, nftId); } else if (collection == NftCollection.ZerpmonEvolved) { require(zerpmonEvolvedNftStakes[msg.sender].contains(nftId), "NFT not staked"); zerpmonEvolvedNftStakes[msg.sender].remove(nftId); zerpmonEvolvedNft.safeTransferFrom(address(this), msg.sender, nftId); } else if (collection == NftCollection.ZerpmonTrainersGenesis) { require(zerpmonTrainersGenesisNftStakes[msg.sender].contains(nftId), "NFT not staked"); zerpmonTrainersGenesisNftStakes[msg.sender].remove(nftId); zerpmonTrainersGenesisNft.safeTransferFrom(address(this), msg.sender, nftId); } else if (collection == NftCollection.ZerpmonTrainersEvolved) { require(zerpmonTrainersEvolvedNftStakes[msg.sender].contains(nftId), "NFT not staked"); zerpmonTrainersEvolvedNftStakes[msg.sender].remove(nftId); zerpmonTrainersEvolvedNft.safeTransferFrom(address(this), msg.sender, nftId); } else if (collection == NftCollection.ZerpmonEquipment) { require(zerpmonEquipmentNftStakes[msg.sender].contains(nftId), "NFT not staked"); zerpmonEquipmentNftStakes[msg.sender].remove(nftId); zerpmonEquipmentNft.safeTransferFrom(address(this), msg.sender, nftId); } checkAndRemoveStaker(msg.sender); emit Withdrawn(msg.sender, nftId, "Zerpmon NFT"); } /// @notice Function to check if a user has any remaining assets staked and remove from stakers list if not /// @param staker Address of the staker function checkAndRemoveStaker(address staker) internal { if ( xrpZrpLpStakes[staker] == 0 && rootZrpLpStakes[staker] == 0 && zerpmonGenesisNftStakes[staker].length() == 0 && zerpmonEvolvedNftStakes[staker].length() == 0 && zerpmonTrainersGenesisNftStakes[staker].length() == 0 && zerpmonTrainersEvolvedNftStakes[staker].length() == 0 && zerpmonEquipmentNftStakes[staker].length() == 0 ) { stakers.remove(staker); } } /// @notice Function to get the list of addresses of all stakers function getAllStakers() external view returns (address[] memory) { return stakers.values(); } struct StakerAssets { uint256 xrpZrpLp; uint256 rootZrpLp; uint256[] zerpmonGenesisNftIds; uint256[] zerpmonEvolvedNftIds; uint256[] zerpmonTrainersGenesisNftIds; uint256[] zerpmonTrainersEvolvedNftIds; uint256[] zerpmonEquipmentNftIds; } /// @notice Function to get staked assets of a user address /// @param staker Address of the staker function getStakedAssets(address staker) external view returns (StakerAssets memory) { StakerAssets memory assets; assets.xrpZrpLp = xrpZrpLpStakes[staker]; assets.rootZrpLp = rootZrpLpStakes[staker]; assets.zerpmonGenesisNftIds = zerpmonGenesisNftStakes[staker].values(); assets.zerpmonEvolvedNftIds = zerpmonEvolvedNftStakes[staker].values(); assets.zerpmonTrainersGenesisNftIds = zerpmonTrainersGenesisNftStakes[staker].values(); assets.zerpmonTrainersEvolvedNftIds = zerpmonTrainersEvolvedNftStakes[staker].values(); assets.zerpmonEquipmentNftIds = zerpmonEquipmentNftStakes[staker].values(); return assets; } /// @notice Function to change the XRP/ZRP LP token /// @param _xrpZrpLpToken New XRP/ZRP LP token function changeXrpZrpLpToken(address _xrpZrpLpToken) external onlyOwner { require(address(xrpZrpLpToken) == address(0), "XRP/ZRP LP token already set"); xrpZrpLpToken = IERC20(_xrpZrpLpToken); } /// @notice Function to change the ROOT/ZRP LP token /// @param _rootZrpLpToken New ROOT/ZRP LP token function changeRootZrpLpToken(address _rootZrpLpToken) external onlyOwner { require(address(rootZrpLpToken) == address(0), "ROOT/ZRP LP token already set"); rootZrpLpToken = IERC20(_rootZrpLpToken); } /// @notice Function to change the Zerpmon Genesis NFT /// @param _zerpmonGenesisNft New Zerpmon Genesis NFT function changeZerpmonGenesisNft(address _zerpmonGenesisNft) external onlyOwner { require(address(zerpmonGenesisNft) == address(0), "Zerpmon Genesis NFT already set"); zerpmonGenesisNft = IERC721(_zerpmonGenesisNft); } /// @notice Function to change the Zerpmon Evolved NFT /// @param _zerpmonEvolvedNft New Zerpmon Evolved NFT function changeZerpmonEvolvedNft(address _zerpmonEvolvedNft) external onlyOwner { require(address(zerpmonEvolvedNft) == address(0), "Zerpmon Evolved NFT already set"); zerpmonEvolvedNft = IERC721(_zerpmonEvolvedNft); } /// @notice Function to change the Zerpmon Trainers Genesis NFT /// @param _zerpmonTrainersGenesisNft New Zerpmon Trainers Genesis NFT function changeZerpmonTrainersGenesisNft(address _zerpmonTrainersGenesisNft) external onlyOwner { require(address(zerpmonTrainersGenesisNft) == address(0), "Zerpmon Trainers Genesis NFT already set"); zerpmonTrainersGenesisNft = IERC721(_zerpmonTrainersGenesisNft); } /// @notice Function to change the Zerpmon Trainers Evolved NFT /// @param _zerpmonTrainersEvolvedNft New Zerpmon Trainers Evolved NFT function changeZerpmonTrainersEvolvedNft(address _zerpmonTrainersEvolvedNft) external onlyOwner { require(address(zerpmonTrainersEvolvedNft) == address(0), "Zerpmon Trainers Evolved NFT already set"); zerpmonTrainersEvolvedNft = IERC721(_zerpmonTrainersEvolvedNft); } /// @notice Function to change the Zerpmon Equipment NFT /// @param _zerpmonEquipmentNft New Zerpmon Equipment NFT function changeZerpmonEquipmentNft(address _zerpmonEquipmentNft) external onlyOwner { require(address(zerpmonEquipmentNft) == address(0), "Zerpmon Equipment NFT already set"); zerpmonEquipmentNft = IERC721(_zerpmonEquipmentNft); } /// @notice Function to receive ERC721 tokens /// @param operator Address which called the function /// @param from Address from which the token is transferred /// @param tokenId ID of the token /// @param data Additional data function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external override returns (bytes4) { return this.onERC721Received.selector; } }
Gas Token: