Feature Tip: Add private address tag to any address under My Name Tag !
Source Code
Latest 25 from a total of 155 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Add Funds | 24398410 | 17 days ago | IN | 0 ETH | 0.00018618 | ||||
| Add Funds | 24328559 | 27 days ago | IN | 0 ETH | 0.00018358 | ||||
| Withdraw Funds | 24328478 | 27 days ago | IN | 0 ETH | 0.00017325 | ||||
| Add Funds | 24322314 | 28 days ago | IN | 0 ETH | 0.00017785 | ||||
| Add Funds | 24322143 | 28 days ago | IN | 0 ETH | 0.00017771 | ||||
| Add Funds | 24264667 | 36 days ago | IN | 0 ETH | 0.00001533 | ||||
| Add Funds | 24246613 | 38 days ago | IN | 0 ETH | 0.00000406 | ||||
| Add Funds | 24066442 | 63 days ago | IN | 0 ETH | 0.00000295 | ||||
| Add Funds | 24014691 | 71 days ago | IN | 0 ETH | 0.0000048 | ||||
| Add Funds | 24014660 | 71 days ago | IN | 0 ETH | 0.00000556 | ||||
| Add Funds | 23990455 | 74 days ago | IN | 0 ETH | 0.00018341 | ||||
| Add Funds | 23978105 | 76 days ago | IN | 0 ETH | 0.00019035 | ||||
| Add Funds | 23954543 | 79 days ago | IN | 0 ETH | 0.00000213 | ||||
| Withdraw Funds | 23954475 | 79 days ago | IN | 0 ETH | 0.00000249 | ||||
| Withdraw Funds | 23953661 | 79 days ago | IN | 0 ETH | 0.00000249 | ||||
| Add Funds | 23949477 | 80 days ago | IN | 0 ETH | 0.00000167 | ||||
| Withdraw Funds | 23949278 | 80 days ago | IN | 0 ETH | 0.00000176 | ||||
| Add Funds | 23938635 | 81 days ago | IN | 0 ETH | 0.00020043 | ||||
| Add Funds | 23938416 | 81 days ago | IN | 0 ETH | 0.00017529 | ||||
| Add Funds | 23938404 | 81 days ago | IN | 0 ETH | 0.00020031 | ||||
| Withdraw Funds | 23935616 | 82 days ago | IN | 0 ETH | 0.00000297 | ||||
| Add Funds | 23935261 | 82 days ago | IN | 0 ETH | 0.00000386 | ||||
| Withdraw Funds | 23935208 | 82 days ago | IN | 0 ETH | 0.00000304 | ||||
| Add Funds | 23934288 | 82 days ago | IN | 0 ETH | 0.00000706 | ||||
| Add Funds | 23934038 | 82 days ago | IN | 0 ETH | 0.00000489 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60a06040 | 22932316 | 222 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0xF8c0a63F...9Ba873bb8 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
SubscriptionCardWallet
Compiler Version
v0.8.25+commit.b61c2a91
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "../@galaxis/registries/contracts/Versionable/IVersionable.sol";
import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
import "../@galaxis/registries/contracts/CommunityList.sol";
import "../@galaxis/registries/contracts/CommunityRegistry.sol";
import {TokenRecord,CommunityTokensRegistry} from "../Community/CommunityTokensRegistry.sol";
import "../SubscriptionDeposit/DateTime.sol";
import {MembershipLevel} from "../SubscriptionDeposit/MembershipLevel.sol";
import "../CardWallet/ICardWalletGenericBalanceConsumer.sol";
import "../SubscriptionDeposit/RoyaltySplitterOverride.sol";
import "./TokenTransferSecurity.sol";
struct SubscriptionRecord {
uint256 updatedTo;
uint256 lastBalance;
uint256 periodCost;
uint256 membershipTierId;
bool annual;
bool enabled;
}
struct SubscriptionInfo {
uint256 projectedExpiryDate;
uint256 currentPeriodEnds;
uint256 currentBalance;
SubscriptionRecord storedData;
}
interface IERC721S {
function ownerOf(uint256 tokenId) external view returns (address owner);
}
/**
* @title SubscriptionCardWallet
* @author galaxis.xyz
* @notice This contract serves as a CardWallet and SubscriptionCardWallet for a given community.
*/
contract SubscriptionCardWallet is IVersionable, UsesGalaxisRegistry, TokenTransferSecurity {
using DateTime for uint256;
using Strings for uint256;
using SafeERC20 for IERC20;
using EnumerableSet for EnumerableSet.UintSet;
// Used to store subscription and token balance information for each membership card
mapping(uint256 => SubscriptionRecord) public subscriptions;
// ID of the community this SubscriptionCardWallet belongs to
uint32 public thisCommunityId;
// CommunityRegistry for this community
CommunityRegistry public thisCommunityRegistry;
// The token this SubscriptionCardWallet works with
IERC20 public paymentToken;
// Name of the payment token
bytes32 public paymentTokenName;
// The currency ID used to identify the payment token
// 0 - stable, 1 - galaxis, 2 - custom token
uint256 public currencyId;
// Address that will receive revenue from this contract
address public paymentAddress;
// The membership card contract used for this SubscriptionCardWallet
IERC721S public membershipCard;
// Indicates which membership level contract to look for
string public MembershipContractKey;
// Enumerable set to store subscriptions in the order they were created
EnumerableSet.UintSet private subscriptionOrder;
/////////////////////
/// EVENTS
/////////////////////
event SubscriptionStarted(
uint256 membershipCardId,
uint256 membershipTierId,
bool annual
);
event SubscriptionCancelled(
uint256 membershipCardId
);
event FundsAdded(
uint256 membershipCardId,
uint256 amount,
uint256 newBalance
);
event FundsWithdrawn(
uint256 membershipCardId,
uint256 amount,
uint256 newBalance
);
event FundsClaimed(
uint256 paymentReceiverAmount,
uint256 royaltyAmount
);
/////////////////////
// MODIFERS
/////////////////////
modifier onlyCardOwner(uint256 _cardId) {
require(msg.sender == membershipCard.ownerOf(_cardId),"SubscriptionCardWallet: You do not own this card");
_;
}
// Version of the contract
function version() public pure virtual returns (uint256) {
return 2025053101;
}
/**
*
* @param _galaxisRegistry Galaxis registry address
* @param _communityId Id of community this SubscriptionCardWallet belongs to
* @param _currencyId Used to identify the payment token, 0 - stable, 1 - galaxis, 2 - custom token
* @param _paymentAddress Address that will receive revenue from this contract
*/
constructor(
address _galaxisRegistry,
uint32 _communityId,
uint256 _currencyId,
address _paymentAddress
) UsesGalaxisRegistry(_galaxisRegistry) TokenTransferSecurity(_galaxisRegistry, _communityId){
if (_communityId == 0) return; // for goldens
// Validate the currency id provided
TokenRecord[] memory tr = CommunityTokensRegistry(
galaxisRegistry.getRegistryAddress("COMMUNITY_TOKEN_REGISTRY")
).getPaymentTokens(_communityId);
require(_currencyId < tr.length, "SubscriptionCardWallet: Invalid currency ID");
currencyId = _currencyId;
// Set up community registry
thisCommunityId = _communityId;
CommunityList communityList = CommunityList(galaxisRegistry.getRegistryAddress("COMMUNITY_LIST"));
(, address crAddr, ) = communityList.communities(_communityId);
require(crAddr != address(0), "SubscriptionCardWallet: Invalid community ID");
thisCommunityRegistry = CommunityRegistry( crAddr );
// Set up payment token
require(tr[_currencyId]._address != address(0), "SubscriptionCardWallet: Payment token missing");
paymentToken = IERC20(tr[_currencyId]._address);
paymentTokenName = tr[_currencyId]._name;
// Set up membership card contract
address membershipAddress = CommunityRegistry( crAddr ).getRegistryAddress("TOKEN_1");
require(membershipAddress != address(0), "SubscriptionCardWallet: Membership collection missing");
membershipCard = IERC721S(membershipAddress);
// Set up payment receiver
paymentAddress = _paymentAddress;
// Set membership contract key
if (_currencyId == 0) {
MembershipContractKey = "MEMBERSHIP_LEVELS_STABLE";
} else if (_currencyId == 1) {
MembershipContractKey = "MEMBERSHIP_LEVELS_GALAXIS";
} else if (_currencyId == 2) {
MembershipContractKey = "MEMBERSHIP_LEVELS_CUSTOM_TOKEN";
}
}
/**
* @notice Allows the owner of a membership card to top up their card with funds.
* @dev This assumes that the owner has already approved this contract to spend the specified amount of the payment token.
* @param membershipCardId The ID of the membership card.
* @param amount The amount of funds to add.
*/
function addFunds(
uint256 membershipCardId,
uint256 amount
) external onlyCardOwner(membershipCardId) {
paymentToken.safeTransferFrom(msg.sender,address(this),amount);
_addFunds(membershipCardId,amount);
}
/**
* @notice Internal function to add funds to a membership card.
* @dev This function updates the subscription record for the given membership card ID.
* @param membershipCardId The ID of the membership card.
* @param amount The amount of funds to add.
*/
function _addFunds(uint256 membershipCardId, uint256 amount) internal {
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCardId);
sendTokensHome(owing);
subRec.lastBalance = amount + balance;
setLastTxTime();
emit FundsAdded(membershipCardId, amount, subRec.lastBalance);
}
/**
* @notice Starts a subscription for a membership card.
* @param membershipCardId The ID of the membership card.
* @param membershipTierId The ID of the membership tier.
* @param annual true if the subscription should be paid annualy, false if it is monthly.
* @dev Immediately takes the payment for the first period(month or year)
*/
function startSubscription(
uint256 membershipCardId,
uint256 membershipTierId,
bool annual
) external onlyCardOwner(membershipCardId){
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoForUpdate(membershipCardId);
sendTokensHome(owing);
// Set up membership related information
address MembershipLevelContractAddress = thisCommunityRegistry.getRegistryAddress(MembershipContractKey);
require(MembershipLevelContractAddress != address(0),string.concat("SubscriptionCardWallet: Membership level contract not found : ", MembershipContractKey));
MembershipLevel MembershipLevelContract = MembershipLevel(MembershipLevelContractAddress);
subRec.annual = annual;
subRec.membershipTierId = membershipTierId;
if (annual) {
subRec.periodCost = MembershipLevelContract.getMembershipAmountTwelve(membershipTierId);
subRec.updatedTo = getTimeStamp().addYears(1);
}else {
subRec.periodCost = MembershipLevelContract.getMembershipAmountOne(membershipTierId);
subRec.updatedTo = getTimeStamp().addMonths(1);
}
// Makes sure first period can be baid
require(balance >= subRec.periodCost,"SubscriptionCardWallet: Insufficient funds to start subscription");
// Take payment for first period and activate subscription
subRec.lastBalance = balance - subRec.periodCost;
subRec.enabled = true;
sendTokensHome(subRec.periodCost);
subscriptionOrder.add(membershipCardId);
setLastTxTime();
emit SubscriptionStarted(membershipCardId, membershipTierId, annual);
}
/**
* @notice Sends tokens to the payment receiver and the royalty receiver
* @param amountToCollect The amount of tokens to collect and send.
* @dev This function splits the collected funds between the owner and the royalty receiver.
* @dev It uses the RoyaltySplitterOverride contract to get the split configuration.
*/
function sendTokensHome(uint256 amountToCollect) internal {
// Ignore if there is nothing to collect
if (amountToCollect == 0) return;
// Royalty splitting
RoyaltySplitterOverride SplitterConfigAddress = RoyaltySplitterOverride(galaxisRegistry.getRegistryAddress("GLOBAL_SUBSCRIPTION_SPLITTER_CONFIG"));
(uint256 millis, address receiverAddress) = SplitterConfigAddress.getSplitConfig(thisCommunityId);
// Calculate amounts to transfer
// millis = 100 means 1% royalty, millis = 10000 means 100% royalty
uint256 royaltyAmount = amountToCollect * millis / 10000;
uint256 ownerAmount = amountToCollect - royaltyAmount;
// transfer to owner
paymentToken.safeTransfer( paymentAddress, ownerAmount);
// transfer to royalty receiver
paymentToken.safeTransfer( receiverAddress, royaltyAmount);
emit FundsClaimed(ownerAmount, royaltyAmount);
}
/**
* @notice Allows the payment receiver to claim owed funds from a membership card.
* @param membershipCardId The ID of the membership card.
* @dev This function can only be called by the paymentAddress.
*/
function claimFunds(uint256 membershipCardId) external {
require(msg.sender == paymentAddress,"SubscriptionCardWallet: unauthorised");
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCardId);
sendTokensHome(owing);
subRec.lastBalance = balance;
setLastTxTime();
}
/**
* @notice Allows the payment receiver to bulk claim funds from multiple membership cards.
* @param membershipCards An array of membership card IDs.
* @dev This function can only be called by the paymentAddress.
*/
function bulkClaimFunds(uint256[] calldata membershipCards) external {
require(msg.sender == paymentAddress,"SubscriptionCardWallet: unauthorised");
uint256 totalOwing;
// Calculate the total claimable funds from the given membership cards
for (uint256 j = 0; j < membershipCards.length; j++) {
SubscriptionRecord storage subRec = subscriptions[membershipCards[j]];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCards[j]);
totalOwing += owing;
subRec.lastBalance = balance;
}
// Send the total amount in one transfer
sendTokensHome(totalOwing);
setLastTxTime();
}
/**
* @notice Cancels the subscription for a membership card.
* @param membershipCardId The ID of the membership card.
* @dev This function can only be called by the owner of the membership card.
* @dev The cancelled subscriptions will still be actived for the period they were paid for.
*/
function cancelSubscription(uint256 membershipCardId) external onlyCardOwner(membershipCardId) {
_disableSubscriptionFor(membershipCardId);
}
/**
* @notice Allows the payment receiver to bulk cancel subscriptions for multiple membership cards.
* @param membershipCardIds An array of membership card IDs.
* @dev The cancelled subscriptions will still be actived for the period they were paid for.
*/
function ownerBulkCancel(uint256[] calldata membershipCardIds) public {
require(msg.sender==paymentAddress,"SubscriptionCardWallet: unauthorised");
for(uint256 i = 0; i < membershipCardIds.length; i++) {
_disableSubscriptionFor(membershipCardIds[i]);
}
}
/**
* @notice Internal function to disable the subscription for a membership card.
* @param membershipCardId The ID of the membership card.
* @dev Updates the subscription record
*/
function _disableSubscriptionFor(uint256 membershipCardId) internal {
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCardId);
sendTokensHome(owing);
// Disable the subscription and update balance
subRec.enabled = false;
subRec.lastBalance = balance;
emit SubscriptionCancelled(membershipCardId);
}
/**
* @notice Allows the owner of a membership card to withdraw funds from their card.
* @param membershipCardId The ID of the membership card.
* @param amount The amount of funds to withdraw.
* @dev This function can only be called by the owner of the membership card.
*/
function withdrawFunds(uint256 membershipCardId, uint256 amount) external onlyCardOwner(membershipCardId) {
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCardId);
require(balance >= amount, "SubscriptionCardWallet: insufficient balance");
sendTokensHome(owing);
// Update balance and transfer funds
subRec.lastBalance = balance - amount;
paymentToken.safeTransfer(msg.sender,amount);
emit FundsWithdrawn(membershipCardId, amount, subRec.lastBalance);
}
/**
* @notice Allows the transfer of funds from one SubscriptionCardWallet to another.
* @param membershipCardId The ID of the membership card.
* @param destinationCardId The ID of the destination membership card.
* @param amount The amount of funds to transfer.
*/
function payToCard(uint256 membershipCardId, uint256 destinationCardId, uint256 amount) external onlyCardOwner(membershipCardId) {
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,) = _balanceInfoWithUpdate(membershipCardId);
require(balance >= amount, "SubscriptionCardWallet: insufficient balance");
// Checks if the destination card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRecD = subscriptions[destinationCardId];
(,uint256 owingD,) = _balanceInfoWithUpdate(destinationCardId);
sendTokensHome(owing+owingD);
RoyaltySplitterOverride SplitterConfigAddress = RoyaltySplitterOverride(galaxisRegistry.getRegistryAddress("GLOBAL_SUBSCRIPTION_SPLITTER_CONFIG"));
(uint256 millis, address receiverAddress) = SplitterConfigAddress.getSplitConfig(thisCommunityId);
// Calculate amounts to transfer
// millis = 100 means 1% royalty, millis = 10000 means 100% royalty
uint256 royaltyAmount = amount * millis / 10000;
uint256 ownerAmount = amount - royaltyAmount;
// update blances
subRec.lastBalance -= amount;
subRecD.lastBalance += ownerAmount;
// transfer to royalty receiver
paymentToken.safeTransfer( receiverAddress, royaltyAmount);
}
/**
* @notice Updates and returns the balance information for a given membership card.
* @param cardId The ID of the membership card.
* @return balance The available balance for the membership card.
* @return owing The amount of funds that are owed by the membership card.
* @return updateableDate The date when the subscription will end.
* @dev Uses _balanceInfoForUpdate to get the balance information and updates the subscription record.
* @dev It also cancel the subscription if it has expired.
*/
function _balanceInfoWithUpdate(uint256 cardId) internal returns (uint256 balance, uint256 owing, uint256 updateableDate) {
SubscriptionRecord storage subRec = subscriptions[cardId];
( balance, owing, updateableDate) = _balanceInfoForUpdate(cardId);
if (updateableDate < getTimeStamp()) {
subRec.updatedTo = getTimeStamp();
// subscription has expired
subRec.enabled = false;
} else {
subRec.updatedTo = updateableDate;
}
return (balance,owing,updateableDate);
}
// To allow time based testing with TestSubscriptionCardWallet
function setLastTxTime() virtual internal {}
/////////////////////
// CARD WALLET FEATURES
/////////////////////
/**
* @param membershipCardId The ID of the membership card.
* @param _tokenAddress The address of the token to take.
* @param _amount The amount of tokens to take.
* @param _userData Additional user data, should contain the community ID in bytes32 format.
* @dev Every contract that wants to intereact with SubcriptionEngine needs to impmenet ICardWalletGenericBalanceConsumer interface.
* @dev This function will transfer the funds to this contract and add them to the membership card balance of a given community card.
*/
function takeMyTokens(
uint256 membershipCardId,
address _tokenAddress,
uint256 _amount,
bytes calldata _userData
) external approvedSpender(msg.sender) {
require(_tokenAddress == address(paymentToken),"SubscriptionCardWallet: Invalid ERC20 transfer");
require(_getOwnerOfCard(membershipCardId) != address(0),"SubscriptionCardWallet: invalid card ID");
require(_userData.length == 32,"SubscriptionCardWallet : Invalid data length");
uint32 requestedCommunity = uint32(uint256(bytes32(_userData[0:32])));
require(requestedCommunity == thisCommunityId,"SubscriptionCardWallet: Invalid requested community");
// Contract takes tokens from msg.sender and adds them to the membership card balance
paymentToken.safeTransferFrom( msg.sender, address(this), _amount);
_addFunds(membershipCardId,_amount);
}
/**
* @param membershipCardId The ID of the membership card.
* @param destination The address of the destination contract.
* @param amount The amount of funds to approve for transfer.
* @param userData Additional user data to be passed to the destination contract.
* @dev This function can only be called by the owner of the membership card.
* @dev The destination contract must implement ICardWalletGenericBalanceConsumer interface.
* @dev This function allows the user to spend funds from their MembershipCard on apporved destination contracts.
* @dev The approved addresses can be set by community managers
*/
function approveAndCall(
uint256 membershipCardId,
address destination,
uint256 amount,
bytes calldata userData
) public onlyCardOwner(membershipCardId) approvedBuyer(destination) {
// Checks if the card is left behind with payments and takes tokens accordingly
SubscriptionRecord storage subRec = subscriptions[membershipCardId];
(uint256 balance, uint256 owing,uint256 updateableDate) = _balanceInfoForUpdate(membershipCardId);
sendTokensHome(owing);
require(balance >= amount, "SubscriptionCardWallet: Insufficent funds");
// Update subscription status
if (updateableDate < getTimeStamp()) {
subRec.updatedTo = getTimeStamp();
subRec.enabled = false;
// subscription has expired
} else {
subRec.updatedTo = updateableDate;
}
subRec.lastBalance = balance - amount;
setLastTxTime();
// allow destination to transfer balance from this contract
paymentToken.safeApprove(destination, amount);
// THEN tell destination to take it
// and then do something for it.
ICardWalletGenericBalanceConsumer(destination).takeMyTokens(
membershipCardId,
address(paymentToken),
amount,
userData
);
require( paymentToken.allowance(address(this), destination) == 0 ,"SubscriptionCardWallet: funds not taken") ;
}
/////////////////////
// VIEW FUNCTIONS
/////////////////////
/**
* @notice Returns the available balance for a given membership card.
* @param cardId The ID of the membership card.
* @return balance The available balance for the membership card.
* @dev The balance of a membership card is the amount of funds that can be used by the owner of the card
* @dev If a membership card has an active subscription, the balance available to the card owner
* is calculated based on the lastBalance and the cost of the unprocessed periods.
*/
function availableBalance(uint256 cardId) external view returns (uint256 balance) {
(balance,,) = _balanceInfoForUpdate(cardId);
}
/**
* @notice Checks if a subscription is active for a given membership card.
* @param cardId The ID of the membership card.
* @return bool indicating whether the subscription is active or not
* @dev A subscription is considered active if updateableDate is in the future
*/
function isSubscriptionActive(uint256 cardId) external view returns (bool) {
(,,uint256 updateableDate) = _balanceInfoForUpdate(cardId);
return (updateableDate > getTimeStamp());
}
/**
* @notice Returns the amount of funds that can be claimed from a membership card.
* @param cardId The ID of the membership card.
* @return owing The amount of funds that can be claimed.
* @dev This function calculates the amount of funds that can be claimed based on the subscription record
* @dev It returns the amount of funds that are owed by the membership card
*/
function fundsClaimable(uint256 cardId) external view returns (uint256 owing) {
(,owing,) = _balanceInfoForUpdate(cardId);
}
/**
* @notice Returns the balance information for a given membership card.
* @param cardId The ID of the membership card.
* @return balance The available balance for the membership card.
* @return owing The amount of funds that are owed by the membership card.
* @return updateableDate The date when the subscription will end.
* @dev Calculates the balance, owing amount, and updateable date for a given membership card.
* @dev If a membership card has an active subscription, the balance available to the card owner
* is calculated based on the lastBalance and the cost of the unprocessed periods.
*
*/
function _balanceInfoForUpdate(uint256 cardId) internal view returns (uint256 balance, uint256 owing, uint256 updateableDate) {
SubscriptionRecord memory rec = subscriptions[cardId];
// If the updateTo is in the future, no calcualtions are needed, up until that date all payments are settled
if (rec.updatedTo > getTimeStamp()) return (rec.lastBalance,0,rec.updatedTo);
// If the subscription is not active no calculations needed, all payments are settled
if (!rec.enabled) return (rec.lastBalance,0,getTimeStamp());
// Calculate how many periods have passed since the last update
uint256 periodsSinceUpdated;
if (rec.annual) {
periodsSinceUpdated = rec.updatedTo.diffYears(getTimeStamp()) + 1;
} else{
periodsSinceUpdated = rec.updatedTo.diffMonths(getTimeStamp() ) + 1;
}
// Check if more periods passed than can be paid for
// The funds owed will only be calculated until the point where the balance was able to cover the full cost of a subscription
// Any leftower will remain on the card and can be used for future payments
if (periodsSinceUpdated * rec.periodCost > rec.lastBalance) {
// Not enough funds to cover everything
uint256 paidPeriods = rec.lastBalance / rec.periodCost;
if (rec.annual) {
updateableDate = rec.updatedTo.addYears(paidPeriods);
} else {
updateableDate = rec.updatedTo.addMonths(paidPeriods );
}
owing = paidPeriods * rec.periodCost;
balance = rec.lastBalance - owing;
return (balance,owing,updateableDate);
}
// If there are enough funds to cover all the periods, calculate the balance and owing amount
owing = periodsSinceUpdated * rec.periodCost;
balance = rec.lastBalance - owing;
if (rec.annual) {
updateableDate = rec.updatedTo.addYears(periodsSinceUpdated);
} else{
updateableDate = rec.updatedTo.addMonths(periodsSinceUpdated );
}
return (balance,owing,updateableDate);
}
/**
* @notice Returns the current timestamp.
* @return uint256 The current block timestamp.
* @dev This function is used to get the current time in seconds since the Unix epoch based on the current block.
*/
function getTimeStamp() public view virtual returns (uint256) {
return block.timestamp;
}
/**
* @notice Returns the owner of a given card ID.
* @param cardId The ID of the card.
* @return address The address of the owner of the card.
*/
function _getOwnerOfCard(uint256 cardId) internal view returns (address){
return IERC721S(thisCommunityRegistry.getRegistryAddress("TOKEN_1")).ownerOf(cardId);
}
/**
* @notice Returns the number of currently active subscriptions
* @dev This number might be greater than the actualy number of subscriptions
* @dev It includes subscriptions that dont have enough funds remaining to pay for the current period but are not interacted with.
* @dev The above mentioned subscription will be removed on the next interaction with the card.
*/
function getSubscriptionRecordsLength() public view returns (uint256) {
return subscriptionOrder.length();
}
/**
* @notice Returns the subscription record for the given card IDs.
* @param recordIds The IDs of the membership cards.
* @return SubscriptionRecord array containing the subscription records for the given card IDs.
*/
function getSubscriptionRecordsFor(uint256[] memory recordIds) external view returns(SubscriptionInfo[] memory) {
uint256 limit = recordIds.length;
SubscriptionInfo[] memory results = new SubscriptionInfo[](limit);
for(uint256 i = 0; i < limit; i++) {
results[i].storedData = subscriptions[recordIds[i]];
(
results[i].currentBalance,
, // uint256 owing
results[i].currentPeriodEnds
) = _balanceInfoForUpdate(recordIds[i]);
if (
(results[i].currentPeriodEnds > getTimeStamp()) && results[i].storedData.enabled
) {
uint256 periods = results[i].currentBalance / results[i].storedData.periodCost;
results[i].projectedExpiryDate = results[i].storedData.annual ?
results[i].currentPeriodEnds.addYears(periods) :
results[i].currentPeriodEnds.addMonths(periods);
}
}
return results;
}
/**
* @notice Returns the card IDs from a given index range from subscriptionOrder
* @param start The starting index for the records.
* @param limit The maximum number of records to return.
* @return uint256 array containing card IDs
*/
function getSubscriptionRecordIds(uint256 start, uint256 limit) public view returns (uint256[] memory) {
uint256 max = subscriptionOrder.length();
uint256 end = start+limit;
if(end >= max) {
end = max;
}
uint256[] memory records = new uint[](end-start);
uint256 y = 0;
for(uint256 i = start; i < end; i++) {
records[y] = subscriptionOrder.at(i);
y++;
}
return records;
}
/**
* @notice Returns all active subscription ids for the community.
* @return SubscriptionInfo array containing all active subscription ids
* @dev This function might fail if there are too many subscription ids.
*/
function getActiveSubscriptionIds() external view returns (uint256[] memory) {
uint256 limit = subscriptionOrder.length();
uint256[] memory tempResults = new uint256[](limit);
uint256 y = 0;
for (uint256 i = 0; i < limit; i++) {
(, , uint256 currentPeriodEnds) = _balanceInfoForUpdate(subscriptionOrder.at(i));
if (currentPeriodEnds > getTimeStamp()) {
tempResults[y] = subscriptionOrder.at(i);
y++;
}
}
uint256[] memory results = new uint256[](y);
for (uint256 i = 0; i < y; i++) {
results[i] = tempResults[i];
}
return results;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) {
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) {
return _roleMembers[role].length();
}
/**
* @dev Overload {_grantRole} to track enumerable memberships
*/
function _grantRole(bytes32 role, address account) internal virtual override {
super._grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {_revokeRole} to track enumerable memberships
*/
function _revokeRole(bytes32 role, address account) internal virtual override {
super._revokeRole(role, account);
_roleMembers[role].remove(account);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable is IAccessControl {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(
address from,
address to,
uint256 amount
) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(
address from,
address to,
uint256 amount
) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
}
_balances[to] += amount;
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 amount
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/structs/EnumerableSet.sol)
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.
*
* ```
* 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) {
return _values(set._inner);
}
// 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 on 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;
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "./Versionable/IVersionable.sol";
contract CommunityList is AccessControlEnumerable, IVersionable {
function version() external pure returns (uint256) {
return 2024040301;
}
bytes32 public constant CONTRACT_ADMIN = keccak256("CONTRACT_ADMIN");
uint256 public numberOfEntries;
struct community_entry {
string name;
address registry;
uint32 id;
}
mapping(uint32 => community_entry) public communities; // community_id => record
mapping(uint256 => uint32) public index; // entryNumber => community_id for enumeration
event CommunityAdded(uint256 pos, string community_name, address community_registry, uint32 community_id);
constructor() {
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(CONTRACT_ADMIN,msg.sender);
}
function addCommunity(uint32 community_id, string memory community_name, address community_registry) external onlyRole(CONTRACT_ADMIN) {
uint256 pos = numberOfEntries++;
index[pos] = community_id;
communities[community_id] = community_entry(community_name, community_registry, community_id);
emit CommunityAdded(pos, community_name, community_registry, community_id);
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./Versionable/IVersionable.sol";
import "./UsesGalaxisRegistry.sol";
contract CommunityRegistry is AccessControlEnumerable, UsesGalaxisRegistry, IVersionable {
function version() virtual external pure returns(uint256) {
return 2024040401;
}
bytes32 public constant COMMUNITY_REGISTRY_ADMIN = keccak256("COMMUNITY_REGISTRY_ADMIN");
uint32 public community_id;
string public community_name;
mapping(bytes32 => address) addresses;
mapping(bytes32 => uint256) uints;
mapping(bytes32 => bool) booleans;
mapping(bytes32 => string) strings;
mapping (uint => string) public addressEntries;
mapping (uint => string) public uintEntries;
mapping (uint => string) public boolEntries;
mapping (uint => string) public stringEntries;
uint public numberOfAddresses;
uint public numberOfUINTs;
uint public numberOfBooleans;
uint public numberOfStrings;
bool initialised;
bool public independant;
event IndependanceDay(bool gain_independance);
modifier onlyAdmin() {
require(
isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender)
,"CommunityRegistry : Unauthorised");
_;
}
modifier onlyPropertyAdmin() {
require(
isUserCommunityAdmin(COMMUNITY_REGISTRY_ADMIN,msg.sender) ||
hasRole(COMMUNITY_REGISTRY_ADMIN,msg.sender)
,"CommunityRegistry : Unauthorised");
_;
}
function isUserCommunityAdmin(bytes32 role, address user) public view returns (bool) {
if (hasRole(DEFAULT_ADMIN_ROLE,user) ) return true; // community_admin can do anything
if (independant){
return(
hasRole(role,user)
);
} else { // for Factories
return(roleManager().hasRole(role,user));
}
}
function roleManager() internal view returns (IAccessControlEnumerable) {
address addr = galaxisRegistry.getRegistryAddress("ROLE_MANAGER"); // universal
if (addr != address(0)) return IAccessControlEnumerable(addr);
addr = galaxisRegistry.getRegistryAddress("MAINNET_CHAIN_IMPLEMENTER"); // mainnet
if (addr != address(0)) return IAccessControlEnumerable(addr);
addr = galaxisRegistry.getRegistryAddress("L2_RECEIVER"); // mainnet
require(addr != address(0),"CommunityRegistry : no higher authority found");
return IAccessControlEnumerable(addr);
}
function grantRole(bytes32 key, address user) public override(AccessControl,IAccessControl) onlyAdmin {
_grantRole(key,user); // need to be able to grant it
}
constructor (
address _galaxisRegistry,
uint32 _community_id,
address _community_admin,
string memory _community_name
) UsesGalaxisRegistry(_galaxisRegistry){
_init(_community_id,_community_admin,_community_name);
}
function init(
uint32 _community_id,
address _community_admin,
string memory _community_name
) external {
_init(_community_id,_community_admin,_community_name);
}
function _init(
uint32 _community_id,
address _community_admin,
string memory _community_name
) internal {
require(!initialised,"This can only be called once");
initialised = true;
community_id = _community_id;
community_name = _community_name;
_setupRole(DEFAULT_ADMIN_ROLE, _community_admin); // default admin = launchpad
}
event AdminUpdated(address user, bool isAdmin);
event AppAdminChanged(address app,address user,bool state);
//===
event AddressChanged(string key, address value);
event UintChanged(string key, uint256 value);
event BooleanChanged(string key, bool value);
event StringChanged(string key, string value);
function setIndependant(bool gain_independance) external onlyAdmin {
if (independant != gain_independance) {
independant = gain_independance;
emit IndependanceDay(gain_independance);
}
}
function setAdmin(address user,bool status ) external onlyAdmin {
if (status)
_grantRole(COMMUNITY_REGISTRY_ADMIN,user);
else
_revokeRole(COMMUNITY_REGISTRY_ADMIN,user);
}
function hash(string memory field) internal pure returns (bytes32) {
return keccak256(abi.encode(field));
}
function setRegistryAddress(string memory fn, address value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
addresses[hf] = value;
addressEntries[numberOfAddresses++] = fn;
emit AddressChanged(fn,value);
}
function setRegistryBool(string memory fn, bool value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
booleans[hf] = value;
boolEntries[numberOfBooleans++] = fn;
emit BooleanChanged(fn,value);
}
function setRegistryString(string memory fn, string memory value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
strings[hf] = value;
stringEntries[numberOfStrings++] = fn;
emit StringChanged(fn,value);
}
function setRegistryUINT(string memory fn, uint value) external onlyPropertyAdmin {
bytes32 hf = hash(fn);
uints[hf] = value;
uintEntries[numberOfUINTs++] = fn;
emit UintChanged(fn,value);
}
function getRegistryAddress(string memory key) external view returns (address) {
return addresses[hash(key)];
}
function getRegistryBool(string memory key) external view returns (bool) {
return booleans[hash(key)];
}
function getRegistryUINT(string memory key) external view returns (uint256) {
return uints[hash(key)];
}
function getRegistryString(string memory key) external view returns (string memory) {
return strings[hash(key)];
}
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
interface IRegistry {
function setRegistryAddress(string memory fn, address value) external ;
function setRegistryBool(string memory fn, bool value) external ;
function setRegistryUINT(string memory key) external returns (uint256) ;
function setRegistryString(string memory fn, string memory value) external ;
function setAdmin(address user,bool status ) external;
function setAppAdmin(address app, address user, bool state) external;
function getRegistryAddress(string memory key) external view returns (address) ;
function getRegistryBool(string memory key) external view returns (bool);
function getRegistryUINT(string memory key) external view returns (uint256) ;
function getRegistryString(string memory key) external view returns (string memory) ;
function isAdmin(address user) external view returns (bool) ;
function isAppAdmin(address app, address user) external view returns (bool);
function numberOfAddresses() external view returns(uint256);
function addressEntries(uint256) external view returns(string memory);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.25;
import "./IRegistry.sol";
contract UsesGalaxisRegistry {
IRegistry immutable public galaxisRegistry;
constructor(address _galaxisRegistry) {
galaxisRegistry = IRegistry(_galaxisRegistry);
}
}//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
import "./IVersionable.sol";
/**
* @title IGenericVersionable
* @dev Interface for generic versionable contracts extending IVersionable.
*/
interface IGenericVersionable is IVersionable {
/**
* @notice Get the base version of the contract.
* @return The base version.
*/
function baseVersion() external pure returns (uint256);
}//SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.25;
/**
* @title IVersionable
* @dev Interface for versionable contracts.
*/
interface IVersionable {
/**
* @notice Get the current version of the contract.
* @return The current version.
*/
function version() external pure returns (uint256);
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
interface ICardWalletGenericBalanceConsumer {
function takeMyTokens(
uint256 membershipCardId,
address _tokenAddress,
uint256 _amount,
bytes calldata _userData
) external;
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
import "../@galaxis/registries/contracts/CommunityList.sol";
import "../@galaxis/registries/contracts/CommunityRegistry.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./ICommunityTokensRegistry.sol";
contract CommunityTokensRegistry is AccessControlEnumerable, IGenericVersionable, UsesGalaxisRegistry {
using SafeERC20 for IERC20;
mapping(uint256 => TokenRecord) public TokenRecords;
IERC20 public paymentToken;
uint256 public accessFee;
address public paymentReceiver;
address communityListAddress;
function baseVersion() public pure virtual returns (uint256) {
return 2025040101;
}
function version() public pure virtual returns (uint256) {
return 2025040101;
}
event CommunityTokenUpdated(uint32 communityId);
constructor(
address _galaxisRegistry,
address _adminSafe,
uint256 _accessFee,
address _paymentReceiver
) UsesGalaxisRegistry(_galaxisRegistry) {
paymentToken = IERC20(IRegistry(_galaxisRegistry).getRegistryAddress("GALAXIS_TOKEN"));
accessFee = _accessFee;
paymentReceiver = _paymentReceiver;
communityListAddress = IRegistry(_galaxisRegistry).getRegistryAddress("COMMUNITY_LIST");
_setupRole(DEFAULT_ADMIN_ROLE, _adminSafe);
}
function payAccessFee(
uint32 _communityId,
bytes32 _name,
address _address
) public {
TokenRecord storage thisCommunityRecords = TokenRecords[_communityId];
require(thisCommunityRecords._address == address(0), "CommunityTokensRegistry - Community already paid access fee");
require(isCommunityAdmin(msg.sender, _communityId), "CommunityTokensRegistry - Only community admins can pay access fee");
thisCommunityRecords._name = _name;
thisCommunityRecords._address = _address;
emit CommunityTokenUpdated(_communityId);
paymentToken.safeTransferFrom(msg.sender, paymentReceiver, accessFee);
}
function getPaymentTokens(uint32 communityId) public view returns (TokenRecord[] memory) {
TokenRecord[] memory results = new TokenRecord[](3);
results[0]._address = galaxisRegistry.getRegistryAddress("SUBSCRIPTION_PAYMENT_TOKEN");
results[0]._name = bytes32(bytes( ERC20(results[0]._address).symbol() ));
results[1]._address = galaxisRegistry.getRegistryAddress("GALAXIS_TOKEN");
results[1]._name = "Galaxis";
results[2]._address = TokenRecords[communityId]._address;
results[2]._name = TokenRecords[communityId]._name;
return results;
}
/// ADMIN FUNCTIONS
function setAccessFee(uint256 _accessFee) external onlyRole(DEFAULT_ADMIN_ROLE) {
accessFee = _accessFee;
}
function setPaymentReceiver(address _paymentReceiver) external onlyRole(DEFAULT_ADMIN_ROLE) {
paymentReceiver = _paymentReceiver;
}
function setPaymentToken(address _paymentToken) external onlyRole(DEFAULT_ADMIN_ROLE) {
paymentToken = IERC20(_paymentToken);
}
/// @dev only used by galaxis admins in case a user pays the fee and gives the wrong token address
function setForCommunity(
uint32 _communityId,
bytes32 _name,
address _address
) public onlyRole(DEFAULT_ADMIN_ROLE){
TokenRecord storage thisCommunityRecords = TokenRecords[_communityId];
thisCommunityRecords._name = _name;
thisCommunityRecords._address = _address;
emit CommunityTokenUpdated(_communityId);
}
/// HELPER FUNCTIONS
function isCommunityAdmin(address sender, uint32 communityId) internal view returns (bool) {
(,address _communityRegistry,) = CommunityList(communityListAddress).communities(communityId);
CommunityRegistry communityRegistry = CommunityRegistry(_communityRegistry);
return communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, sender);
}
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
struct TokenRecord {
bytes32 _name;
address _address;
}
interface ICommunityTokensRegistry {
function getPaymentTokens(uint32 communityId) external view returns (TokenRecord[] memory);
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "../@galaxis/registries/contracts/IRegistry.sol";
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
import "./TokenTransferSecurityCentre.sol";
/**
* @title TokenTransferSecurity
* @author galaxis.xyz
* @notice This contract serves as a security layer to manage and validate
* token transfer destinations for SubscriptionCardWallet contracts.
*/
contract TokenTransferSecurity {
IRegistry private galaxisRegistry;
// Bytes32 representation of roles
bytes32 public constant COMMUNITY_REGISTRY_ADMIN = keccak256("COMMUNITY_REGISTRY_ADMIN");
// Enumerable set of addresses where tokens can be transfered to.
EnumerableSet.AddressSet private validTokenTransfers;
uint32 private communityId;
// Check if tokens can be sent to the destination address - used in approveAndCall
modifier approvedBuyer(address destination) {
require(TSC().isValidBuyer(communityId,destination),"TokenTransferSecurity : destination not allowed to receive tokens");
_;
}
// Check if sender is allowed to send us tokens - used in takeMyTokens
modifier approvedSpender(address destination) {
require(TSC().isValidSpender(communityId,destination),"TokenTransferSecurity : source cannot buy with tokens");
_;
}
constructor(address _galaxisRegistry,uint32 _communityId) {
// Initialize role manager contract
galaxisRegistry = IRegistry(_galaxisRegistry);
communityId = _communityId;
}
function TSC() internal view returns (TokenTransferSecurityCentre) {
return TokenTransferSecurityCentre(galaxisRegistry.getRegistryAddress("TOKEN_SECURITY_CENTRE"));
}
/**
* @notice Gets the number of valid addresses for token transfers.
* @return The number of addresses that are valid for token transfers.
*/
function numberOfValidBuyers() external view returns (uint256) {
return TSC().numberOfValidBuyers(communityId);
}
function numberOfValidSpenders() external view returns (uint256) {
return TSC().numberOfValidSpenders(communityId);
}
/**
* @notice Returns a list of all valid token transfer addresses.
* @return An array of addresses that are valid for token transfers.
*/
function allValidBuyers() external view returns (address[] memory) {
return TSC().allValidBuyers(communityId);
}
function allValidSpenders() external view returns (address[] memory) {
return TSC().allValidSpenders(communityId);
}
/**
* @notice Lists valid token transfer addresses in a paginated manner.
* @param start The starting index for pagination.
* @param count The number of addresses to return.
* @return An array of addresses that are valid for token transfers.
* @dev listTokenTransfers is used if there are too mant token Transfers.
* This is highly unlikely in this application but here for safety
*/
function listValidBuyers(uint256 start, uint256 count) external view returns (address[] memory) {
return TSC().listValidBuyers(communityId,start,count);
}
function listValidSpenders(uint256 start, uint256 count) external view returns (address[] memory) {
return TSC().listValidSpenders(communityId,start,count);
}
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/IAccessControl.sol";
import "../@galaxis/registries/contracts/IRegistry.sol";
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
/**
* @title TokenTransferSecurityCentre
* @author galaxis.xyz
* @notice This contract serves as a security layer to manage and validate
* token transfer destinations for SubscriptionCardWallet contracts.
*/
contract TokenTransferSecurityCentre {
using EnumerableSet for EnumerableSet.AddressSet;
// Bytes32 representation of roles
bytes32 public constant COMMUNITY_REGISTRY_ADMIN = keccak256("COMMUNITY_REGISTRY_ADMIN");
// Enumerable set of valid spenders and buyers for each community
mapping(uint32 => EnumerableSet.AddressSet) private validSpenders;
mapping(uint32 => EnumerableSet.AddressSet) private validBuyers;
// Role manager interface to check permissions
IAccessControl private roleManager;
////////////////
/// EVENTS
////////////////
event ValidSpenderUpdated(uint32 communityId, address spender, bool enabled);
event ValidBuyerUpdated(uint32 communityId, address spender, bool enabled);
// Checks if the caller is COMMUNITY_REGISTRY_ADMIN
// This means admin of the CommunityRegistry contract, not admin for a given community
modifier approvedTransferSetter() {
require(roleManager.hasRole(COMMUNITY_REGISTRY_ADMIN,msg.sender),"TokenTransferSecurity : unauthorised");
_;
}
// CONSTRUCTOR
constructor(address _galaxisRegistry) {
// Initialize role manager contract
address roleManagerAddress = IRegistry(_galaxisRegistry).getRegistryAddress("ROLE_MANAGER");
require(roleManagerAddress != address(0),"TokenTransferSecurity : ROLE MANAGER not set");
roleManager = IAccessControl(roleManagerAddress);
}
/**
* @notice Adds or removes an address from the list of valid spenders
* @param target The address to be added or removed.
* @param enabled If true, adds the address; if false, removes it.
* @dev This function can only be called by an address with the COMMUNITY_REGISTRY_ADMIN role.
*/
function manageSpendAddress(uint32 _communityId,address target, bool enabled) external approvedTransferSetter {
_manageAddress(validSpenders,_communityId,target,enabled);
emit ValidSpenderUpdated(_communityId, target, enabled);
}
/**
* @notice Adds or removes an address from the list of valid buyers
* @param target The address to be added or removed.
* @param enabled If true, adds the address; if false, removes it.
* @dev This function can only be called by an address with the COMMUNITY_REGISTRY_ADMIN role.
*/
function manageBuyAddress(uint32 _communityId,address target, bool enabled) external approvedTransferSetter {
_manageAddress(validBuyers,_communityId, target,enabled);
emit ValidBuyerUpdated(_communityId, target, enabled);
}
/**
* @notice Helper function to set validSpenders and validBuyers
* @param validTokenTransfers The mapping in which we want to set values
* @param _communityId The community ID for which to manage the address.
* @param target The address to be added or removed.
* @param enabled If true, adds the address; if false, removes it.
*/
function _manageAddress(mapping(uint32 => EnumerableSet.AddressSet) storage validTokenTransfers, uint32 _communityId,address target, bool enabled) internal {
if (enabled)
validTokenTransfers[_communityId].add(target);
else
validTokenTransfers[_communityId].remove(target);
}
/**
* @notice Gets the number of valid spenders
* @return The number of addresses that are valid for token transfers.
*/
function numberOfValidSpenders(uint32 _communityId) external view returns (uint256) {
return validSpenders[_communityId].length();
}
/**
* @notice Gets the number of valid buyers
* @return The number of addresses that are valid for token transfers.
*/
function numberOfValidBuyers(uint32 _communityId) external view returns (uint256) {
return validBuyers[_communityId].length();
}
/**
* @notice Returns a list of all valid token transfer addresses.
* @return An array of addresses that are valid for token transfers.
*/
function allValidBuyers(uint32 _communityId) external view returns(address[] memory) {
return allValidTokenTransfers(validBuyers,_communityId);
}
/**
* @notice Returns a list of all valid spenders.
*/
function allValidSpenders(uint32 _communityId) external view returns(address[] memory) {
return allValidTokenTransfers(validSpenders,_communityId);
}
/**
@notice Helper function to return valid spenders or buyers
*/
function allValidTokenTransfers(mapping(uint32 => EnumerableSet.AddressSet) storage validTokenTransfers, uint32 _communityId) internal view returns (address[] memory) {
return validTokenTransfers[_communityId].values();
}
/**
* @notice Lists valid token transfer addresses in a paginated manner.
* @param start The starting index for pagination.
* @param count The number of addresses to return.
* @return An array of addresses that are valid buyers
* @dev listTokenTransfers is used if there are too many token Transfers.
* This is highly unlikely in this application but here for safety
*/
function listValidBuyers(uint32 _communityId, uint256 start, uint256 count) external view returns (address[] memory) {
return listValidTokenTransfers(validBuyers,_communityId,start,count);
}
/**
* @notice Lists valid spenders in a paginated manner.
* @param start The starting index for pagination.
* @param count The number of addresses to return.
* @return An array of addresses that are valid spenders
* @dev listTokenTransfers is used if there are too many token Transfers.
* This is highly unlikely in this application but here for safety
*/
function listValidSpenders(uint32 _communityId, uint256 start, uint256 count) external view returns (address[] memory) {
return listValidTokenTransfers(validSpenders,_communityId,start,count);
}
/**
* @notice Helper function to list valid token transfers.
* @param validTokenTransfers The mapping of valid token transfers.
* @param _communityId The community ID for which to list valid transfers.
* @param start The starting index for pagination.
* @param count The number of addresses to return.
* @return An array of addresses that are valid token transfers.
*/
function listValidTokenTransfers(mapping(uint32 => EnumerableSet.AddressSet) storage validTokenTransfers, uint32 _communityId, uint256 start, uint256 count) internal view returns (address[] memory) {
uint256 length = validTokenTransfers[_communityId].length();
if (start >= length) {
return new address[](0);
}
if (start + count > length) {
count = length - start;
}
address[] memory results = new address[](count);
for (uint256 j = 0; j < count; j++) {
results[j] = validTokenTransfers[_communityId].at(start + j);
}
return results;
}
// Check if address is a valid spender
function isValidSpender(uint32 _communityId, address _destination) external view returns (bool) {
return validSpenders[_communityId].contains(_destination);
}
// Check if address is a valid buyer
function isValidBuyer(uint32 _communityId, address _destination) external view returns (bool) {
return validBuyers[_communityId].contains(_destination);
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// ----------------------------------------------------------------------------
// DateTime Library v2.0
//
// A gas-efficient Solidity date and time library
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
// Tested date range 1970/01/01 to 2345/12/31
//
// Conventions:
// Unit | Range | Notes
// :-------- |:-------------:|:-----
// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC
// year | 1970 ... 2345 |
// month | 1 ... 12 |
// day | 1 ... 31 |
// hour | 0 ... 23 |
// minute | 0 ... 59 |
// second | 0 ... 59 |
// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday
//
//
// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------
library DateTime {
uint256 constant SECONDS_PER_DAY = 24 * 60 * 60;
uint256 constant SECONDS_PER_HOUR = 60 * 60;
uint256 constant SECONDS_PER_MINUTE = 60;
int256 constant OFFSET19700101 = 2440588;
uint256 constant DOW_MON = 1;
uint256 constant DOW_TUE = 2;
uint256 constant DOW_WED = 3;
uint256 constant DOW_THU = 4;
uint256 constant DOW_FRI = 5;
uint256 constant DOW_SAT = 6;
uint256 constant DOW_SUN = 7;
// ------------------------------------------------------------------------
// Calculate the number of days from 1970/01/01 to year/month/day using
// the date conversion algorithm from
// http://aa.usno.navy.mil/faq/docs/JD_Formula.php
// and subtracting the offset 2440588 so that 1970/01/01 is day 0
//
// days = day
// - 32075
// + 1461 * (year + 4800 + (month - 14) / 12) / 4
// + 367 * (month - 2 - (month - 14) / 12 * 12) / 12
// - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
// - offset
// ------------------------------------------------------------------------
function _daysFromDate(uint256 year, uint256 month, uint256 day) internal pure returns (uint256 _days) {
require(year >= 1970);
int256 _year = int256(year);
int256 _month = int256(month);
int256 _day = int256(day);
int256 __days = _day - 32075 + (1461 * (_year + 4800 + (_month - 14) / 12)) / 4
+ (367 * (_month - 2 - ((_month - 14) / 12) * 12)) / 12
- (3 * ((_year + 4900 + (_month - 14) / 12) / 100)) / 4 - OFFSET19700101;
_days = uint256(__days);
}
// ------------------------------------------------------------------------
// Calculate year/month/day from the number of days since 1970/01/01 using
// the date conversion algorithm from
// http://aa.usno.navy.mil/faq/docs/JD_Formula.php
// and adding the offset 2440588 so that 1970/01/01 is day 0
//
// int L = days + 68569 + offset
// int N = 4 * L / 146097
// L = L - (146097 * N + 3) / 4
// year = 4000 * (L + 1) / 1461001
// L = L - 1461 * year / 4 + 31
// month = 80 * L / 2447
// dd = L - 2447 * month / 80
// L = month / 11
// month = month + 2 - 12 * L
// year = 100 * (N - 49) + year + L
// ------------------------------------------------------------------------
function _daysToDate(uint256 _days) internal pure returns (uint256 year, uint256 month, uint256 day) {
unchecked {
int256 __days = int256(_days);
int256 L = __days + 68569 + OFFSET19700101;
int256 N = (4 * L) / 146097;
L = L - (146097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1461001;
L = L - (1461 * _year) / 4 + 31;
int256 _month = (80 * L) / 2447;
int256 _day = L - (2447 * _month) / 80;
L = _month / 11;
_month = _month + 2 - 12 * L;
_year = 100 * (N - 49) + _year + L;
year = uint256(_year);
month = uint256(_month);
day = uint256(_day);
}
}
function timestampFromDate(uint256 year, uint256 month, uint256 day) internal pure returns (uint256 timestamp) {
timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;
}
function timestampFromDateTime(
uint256 year,
uint256 month,
uint256 day,
uint256 hour,
uint256 minute,
uint256 second
)
internal
pure
returns (uint256 timestamp)
{
timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR
+ minute * SECONDS_PER_MINUTE + second;
}
function timestampToDate(uint256 timestamp) internal pure returns (uint256 year, uint256 month, uint256 day) {
unchecked {
(year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
}
}
function timestampToDateTime(uint256 timestamp)
internal
pure
returns (uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, uint256 second)
{
unchecked {
(year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
uint256 secs = timestamp % SECONDS_PER_DAY;
hour = secs / SECONDS_PER_HOUR;
secs = secs % SECONDS_PER_HOUR;
minute = secs / SECONDS_PER_MINUTE;
second = secs % SECONDS_PER_MINUTE;
}
}
function isValidDate(uint256 year, uint256 month, uint256 day) internal pure returns (bool valid) {
if (year >= 1970 && month > 0 && month <= 12) {
uint256 daysInMonth = _getDaysInMonth(year, month);
if (day > 0 && day <= daysInMonth) {
valid = true;
}
}
}
function isValidDateTime(uint256 year, uint256 month, uint256 day, uint256 hour, uint256 minute, uint256 second)
internal
pure
returns (bool valid)
{
if (isValidDate(year, month, day)) {
if (hour < 24 && minute < 60 && second < 60) {
valid = true;
}
}
}
function isLeapYear(uint256 timestamp) internal pure returns (bool leapYear) {
(uint256 year,,) = _daysToDate(timestamp / SECONDS_PER_DAY);
leapYear = _isLeapYear(year);
}
function _isLeapYear(uint256 year) internal pure returns (bool leapYear) {
leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
}
function isWeekDay(uint256 timestamp) internal pure returns (bool weekDay) {
weekDay = getDayOfWeek(timestamp) <= DOW_FRI;
}
function isWeekEnd(uint256 timestamp) internal pure returns (bool weekEnd) {
weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;
}
function getDaysInMonth(uint256 timestamp) internal pure returns (uint256 daysInMonth) {
(uint256 year, uint256 month,) = _daysToDate(timestamp / SECONDS_PER_DAY);
daysInMonth = _getDaysInMonth(year, month);
}
function _getDaysInMonth(uint256 year, uint256 month) internal pure returns (uint256 daysInMonth) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
daysInMonth = 31;
} else if (month != 2) {
daysInMonth = 30;
} else {
daysInMonth = _isLeapYear(year) ? 29 : 28;
}
}
// 1 = Monday, 7 = Sunday
function getDayOfWeek(uint256 timestamp) internal pure returns (uint256 dayOfWeek) {
uint256 _days = timestamp / SECONDS_PER_DAY;
dayOfWeek = ((_days + 3) % 7) + 1;
}
function getYear(uint256 timestamp) internal pure returns (uint256 year) {
(year,,) = _daysToDate(timestamp / SECONDS_PER_DAY);
}
function getMonth(uint256 timestamp) internal pure returns (uint256 month) {
(, month,) = _daysToDate(timestamp / SECONDS_PER_DAY);
}
function getDay(uint256 timestamp) internal pure returns (uint256 day) {
(,, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
}
function getHour(uint256 timestamp) internal pure returns (uint256 hour) {
uint256 secs = timestamp % SECONDS_PER_DAY;
hour = secs / SECONDS_PER_HOUR;
}
function getMinute(uint256 timestamp) internal pure returns (uint256 minute) {
uint256 secs = timestamp % SECONDS_PER_HOUR;
minute = secs / SECONDS_PER_MINUTE;
}
function getSecond(uint256 timestamp) internal pure returns (uint256 second) {
second = timestamp % SECONDS_PER_MINUTE;
}
function addYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {
(uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY);
year += _years;
uint256 daysInMonth = _getDaysInMonth(year, month);
if (day > daysInMonth) {
day = daysInMonth;
}
newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY);
require(newTimestamp >= timestamp);
}
function addMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {
(uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY);
month += _months;
year += (month - 1) / 12;
month = ((month - 1) % 12) + 1;
uint256 daysInMonth = _getDaysInMonth(year, month);
if (day > daysInMonth) {
day = daysInMonth;
}
newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY);
require(newTimestamp >= timestamp);
}
function addDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp + _days * SECONDS_PER_DAY;
require(newTimestamp >= timestamp);
}
function addHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
require(newTimestamp >= timestamp);
}
function addMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
require(newTimestamp >= timestamp);
}
function addSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp + _seconds;
require(newTimestamp >= timestamp);
}
function subYears(uint256 timestamp, uint256 _years) internal pure returns (uint256 newTimestamp) {
(uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY);
year -= _years;
uint256 daysInMonth = _getDaysInMonth(year, month);
if (day > daysInMonth) {
day = daysInMonth;
}
newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY);
require(newTimestamp <= timestamp);
}
function subMonths(uint256 timestamp, uint256 _months) internal pure returns (uint256 newTimestamp) {
(uint256 year, uint256 month, uint256 day) = _daysToDate(timestamp / SECONDS_PER_DAY);
uint256 yearMonth = year * 12 + (month - 1) - _months;
year = yearMonth / 12;
month = (yearMonth % 12) + 1;
uint256 daysInMonth = _getDaysInMonth(year, month);
if (day > daysInMonth) {
day = daysInMonth;
}
newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + (timestamp % SECONDS_PER_DAY);
require(newTimestamp <= timestamp);
}
function subDays(uint256 timestamp, uint256 _days) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp - _days * SECONDS_PER_DAY;
require(newTimestamp <= timestamp);
}
function subHours(uint256 timestamp, uint256 _hours) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
require(newTimestamp <= timestamp);
}
function subMinutes(uint256 timestamp, uint256 _minutes) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
require(newTimestamp <= timestamp);
}
function subSeconds(uint256 timestamp, uint256 _seconds) internal pure returns (uint256 newTimestamp) {
newTimestamp = timestamp - _seconds;
require(newTimestamp <= timestamp);
}
function diffYears(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _years) {
require(fromTimestamp <= toTimestamp);
(uint256 fromYear,,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
(uint256 toYear,,) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
_years = toYear - fromYear;
}
function diffMonths(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _months) {
require(fromTimestamp <= toTimestamp);
(uint256 fromYear, uint256 fromMonth,) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
(uint256 toYear, uint256 toMonth,) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
_months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
}
function diffDays(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _days) {
require(fromTimestamp <= toTimestamp);
_days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
}
function diffHours(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _hours) {
require(fromTimestamp <= toTimestamp);
_hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
}
function diffMinutes(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _minutes) {
require(fromTimestamp <= toTimestamp);
_minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
}
function diffSeconds(uint256 fromTimestamp, uint256 toTimestamp) internal pure returns (uint256 _seconds) {
require(fromTimestamp <= toTimestamp);
_seconds = toTimestamp - fromTimestamp;
}
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
import "../@galaxis/registries/contracts/CommunityList.sol";
import "../@galaxis/registries/contracts/CommunityRegistry.sol";
import "../Community/ICommunityTokensRegistry.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
struct MembershipLevelStoredData {
bytes32 name;
uint256 amountOne;
uint256 amountTwelve;
bytes metadata;
bool isActive;
}
struct MembershipLevelInfo {
uint256 order;
uint256 position;
bytes32 name;
uint256 amountOne;
uint256 amountTwelve;
bytes metadata;
bool isActive;
}
contract MembershipLevel is IGenericVersionable, UsesGalaxisRegistry {
function baseVersion() public pure virtual returns (uint256) {
return 2025040601;
}
function version() public pure virtual returns (uint256) {
return 2025040601;
}
uint256 public communityId;
CommunityRegistry public communityRegistry;
IERC20 public PaymentToken;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
uint256 public lastOrderId = 1;
uint256 public levelCount = 0;
mapping(uint256 => MembershipLevelStoredData) public data;
mapping(uint256 => uint256) public ordering;
event MembershipLevelCreated(uint256 id, bytes32 name, uint256 amountOne, uint256 amountTwelve);
event MembershipLevelUpdated(uint256 id, bytes32 name, uint256 amountOne, uint256 amountTwelve);
event MembershipLevelStatusChanged(uint256 position, bool isActive);
constructor(
address _galaxisRegistry,
uint32 _communityId,
uint8 _paymentTokenId
) UsesGalaxisRegistry(_galaxisRegistry) {
if (_communityId == 0) return; // for deploying goldens
communityId = _communityId;
CommunityList communityList = CommunityList(galaxisRegistry.getRegistryAddress("COMMUNITY_LIST"));
(, address crAddr, ) = communityList.communities(_communityId);
require(crAddr != address(0), "MembershipLevel: Invalid community id");
communityRegistry = CommunityRegistry( crAddr );
ICommunityTokensRegistry ComunityTokenRegistry = ICommunityTokensRegistry(
galaxisRegistry.getRegistryAddress("COMMUNITY_TOKEN_REGISTRY")
);
TokenRecord[] memory PaymentTokenAddresses = ComunityTokenRegistry.getPaymentTokens(_communityId);
PaymentToken = IERC20(PaymentTokenAddresses[_paymentTokenId]._address);
}
function addLevel(
bytes32[] memory name,
uint256[] memory amountOne,
uint256[] memory amountTwelve,
bytes[] memory metadata
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: addLevel DEFAULT_ADMIN_ROLE required");
for(uint8 i = 0; i < name.length; i++) {
data[lastOrderId] = MembershipLevelStoredData(name[i], amountOne[i], amountTwelve[i], metadata[i],true);
ordering[lastOrderId] = lastOrderId;
lastOrderId++;
levelCount++;
emit MembershipLevelCreated(lastOrderId - 1, name[i], amountOne[i], amountTwelve[i]);
}
}
function updateLevel(
uint256 position,
bytes32 name,
uint256 amountOne,
uint256 amountTwelve,
bytes memory metadata
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateLevel DEFAULT_ADMIN_ROLE required");
bool isActive = data[position].isActive;
data[position] = MembershipLevelStoredData(name, amountOne, amountTwelve, metadata,isActive);
emit MembershipLevelUpdated(position, name, amountOne, amountTwelve);
}
function setLevelStatus(uint256 position, bool isActive) public {
require(data[position].isActive != isActive, "MembershipLevel: Level is already in the desired state");
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateLevel DEFAULT_ADMIN_ROLE required");
data[position].isActive = isActive;
emit MembershipLevelStatusChanged(position, isActive);
}
function updateOrdering(
uint256[] memory positions,
uint256[] memory ids
) public {
require(communityRegistry.hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "MembershipLevel: updateOrdering DEFAULT_ADMIN_ROLE required");
for(uint8 i = 0; i < ids.length; i++) {
ordering[positions[i]] = ids[i];
}
}
function getMembershipLevels() public view returns (MembershipLevelInfo[] memory) {
MembershipLevelInfo[] memory results = new MembershipLevelInfo[](levelCount);
for(uint8 i = 1; i <= levelCount; i++) {
MembershipLevelStoredData storage stored = data[ordering[i]];
results[i-1] = MembershipLevelInfo(
i,
ordering[i],
stored.name,
stored.amountOne,
stored.amountTwelve,
stored.metadata,
stored.isActive
);
}
return results;
}
function getMembershipData(uint256 index) public view returns (MembershipLevelStoredData memory) {
return data[index];
}
function getMembershipAmountOne(uint256 index) public view returns (uint256) {
require(data[index].isActive,"MembershipLevel : level not active");
return data[index].amountOne;
}
function getMembershipAmountTwelve(uint256 index) public view returns (uint256) {
require(data[index].isActive,"MembershipLevel : level not active");
return data[index].amountTwelve;
}
}// SPDX-License-Identifier: UNLICENCED
pragma solidity 0.8.25;
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "../@galaxis/registries/contracts/Versionable/IGenericVersionable.sol";
import "../@galaxis/registries/contracts/UsesGalaxisRegistry.sol";
contract RoyaltySplitterOverride is AccessControlEnumerable, IGenericVersionable, UsesGalaxisRegistry {
function baseVersion() public pure virtual returns (uint256) {
return 2025270101;
}
function version() public pure virtual returns (uint256) {
return 2025270101;
}
struct configItem {
bool enabled;
uint256 value;
}
mapping(uint256 => configItem) splitterConfig;
uint256 public globalSplitterConfig = 500; // 5%
address public globalSplitterAddress ; // 5%
constructor(
address _galaxisRegistry,
address _adminSafe,
address _outputSafe
) UsesGalaxisRegistry(_galaxisRegistry) {
_setupRole(DEFAULT_ADMIN_ROLE, _adminSafe);
globalSplitterAddress = _outputSafe;
}
function getSplitConfig(uint256 _communityId) public view returns (uint256, address) {
uint256 retVal;
configItem storage item = splitterConfig[_communityId];
if(item.enabled) {
retVal = item.value;
} else {
retVal = globalSplitterConfig;
}
return (retVal, globalSplitterAddress);
}
function overrideDefault(uint256 _communityId, bool _enabled, uint256 _millis) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_millis >= 0 && _millis <= 10000, "RoyaltySplitterOverride: millis has to be 0 to 10000");
configItem storage item = splitterConfig[_communityId];
item.enabled = _enabled;
item.value = _millis;
}
function setGlobalMillis(uint256 _millis) public onlyRole(DEFAULT_ADMIN_ROLE) {
require(_millis >= 0 && _millis <= 10000, "RoyaltySplitterOverride: millis has to be 0 to 10000");
globalSplitterConfig = _millis;
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_galaxisRegistry","type":"address"},{"internalType":"uint32","name":"_communityId","type":"uint32"},{"internalType":"uint256","name":"_currencyId","type":"uint256"},{"internalType":"address","name":"_paymentAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"FundsAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"paymentReceiverAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"name":"FundsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"FundsWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"membershipCardId","type":"uint256"}],"name":"SubscriptionCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"membershipTierId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"annual","type":"bool"}],"name":"SubscriptionStarted","type":"event"},{"inputs":[],"name":"COMMUNITY_REGISTRY_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MembershipContractKey","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"addFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"allValidBuyers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allValidSpenders","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"address","name":"destination","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"userData","type":"bytes"}],"name":"approveAndCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"cardId","type":"uint256"}],"name":"availableBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"membershipCards","type":"uint256[]"}],"name":"bulkClaimFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"}],"name":"cancelSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"}],"name":"claimFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currencyId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cardId","type":"uint256"}],"name":"fundsClaimable","outputs":[{"internalType":"uint256","name":"owing","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"galaxisRegistry","outputs":[{"internalType":"contract IRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getActiveSubscriptionIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"getSubscriptionRecordIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"recordIds","type":"uint256[]"}],"name":"getSubscriptionRecordsFor","outputs":[{"components":[{"internalType":"uint256","name":"projectedExpiryDate","type":"uint256"},{"internalType":"uint256","name":"currentPeriodEnds","type":"uint256"},{"internalType":"uint256","name":"currentBalance","type":"uint256"},{"components":[{"internalType":"uint256","name":"updatedTo","type":"uint256"},{"internalType":"uint256","name":"lastBalance","type":"uint256"},{"internalType":"uint256","name":"periodCost","type":"uint256"},{"internalType":"uint256","name":"membershipTierId","type":"uint256"},{"internalType":"bool","name":"annual","type":"bool"},{"internalType":"bool","name":"enabled","type":"bool"}],"internalType":"struct SubscriptionRecord","name":"storedData","type":"tuple"}],"internalType":"struct SubscriptionInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSubscriptionRecordsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTimeStamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cardId","type":"uint256"}],"name":"isSubscriptionActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"count","type":"uint256"}],"name":"listValidBuyers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"count","type":"uint256"}],"name":"listValidSpenders","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"membershipCard","outputs":[{"internalType":"contract IERC721S","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfValidBuyers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numberOfValidSpenders","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"membershipCardIds","type":"uint256[]"}],"name":"ownerBulkCancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"uint256","name":"destinationCardId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"payToCard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paymentAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentTokenName","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"uint256","name":"membershipTierId","type":"uint256"},{"internalType":"bool","name":"annual","type":"bool"}],"name":"startSubscription","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"subscriptions","outputs":[{"internalType":"uint256","name":"updatedTo","type":"uint256"},{"internalType":"uint256","name":"lastBalance","type":"uint256"},{"internalType":"uint256","name":"periodCost","type":"uint256"},{"internalType":"uint256","name":"membershipTierId","type":"uint256"},{"internalType":"bool","name":"annual","type":"bool"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_userData","type":"bytes"}],"name":"takeMyTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"thisCommunityId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"thisCommunityRegistry","outputs":[{"internalType":"contract CommunityRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"membershipCardId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawFunds","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
0x60a060405234801561001057600080fd5b506040516143e83803806143e883398101604081905261002f916106c3565b6001600160a01b0384166080819052600080546001600160a01b03191690911790556003805463ffffffff191663ffffffff85169081179091551561068a57608051604051631d2e660b60e21b815260206004820152601860248201527f434f4d4d554e4954595f544f4b454e5f5245474953545259000000000000000060448201526000916001600160a01b0316906374b9982c90606401602060405180830381865afa1580156100e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101099190610710565b6040516288128f60e41b815263ffffffff861660048201526001600160a01b03919091169063088128f090602401600060405180830381865afa158015610154573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261017c91908101906107a0565b9050805183106101d55760405162461bcd60e51b815260206004820152602b60248201526000805160206143c883398151915260448201526a18dd5c9c995b98de48125160aa1b60648201526084015b60405180910390fd5b60088390556005805463ffffffff191663ffffffff8616179055608051604051631d2e660b60e21b815260206004820152600e60248201526d10d3d353555392551657d31254d560921b60448201526000916001600160a01b0316906374b9982c90606401602060405180830381865afa158015610257573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061027b9190610710565b60405163d0f4a53760e01b815263ffffffff871660048201529091506000906001600160a01b0383169063d0f4a53790602401600060405180830381865afa1580156102cb573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526102f39190810190610874565b509150506001600160a01b0381166103505760405162461bcd60e51b815260206004820152602c60248201526000805160206143c883398151915260448201526b18dbdb5b5d5b9a5d1e48125160a21b60648201526084016101cc565b60058054600160201b600160c01b0319166401000000006001600160a01b03841602179055825160009084908790811061038c5761038c610940565b6020026020010151602001516001600160a01b0316036104045760405162461bcd60e51b815260206004820152602d60248201527f537562736372697074696f6e4361726457616c6c65743a205061796d656e742060448201526c746f6b656e206d697373696e6760981b60648201526084016101cc565b82858151811061041657610416610940565b602002602001015160200151600660006101000a8154816001600160a01b0302191690836001600160a01b0316021790555082858151811061045a5761045a610940565b602090810291909101015151600755604051631d2e660b60e21b81526000906001600160a01b038316906374b9982c906104b290600401602080825260079082015266544f4b454e5f3160c81b604082015260600190565b602060405180830381865afa1580156104cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f39190610710565b90506001600160a01b0381166105715760405162461bcd60e51b815260206004820152603560248201527f537562736372697074696f6e4361726457616c6c65743a204d656d626572736860448201527f697020636f6c6c656374696f6e206d697373696e67000000000000000000000060648201526084016101cc565b600a80546001600160a01b038084166001600160a01b031992831617909255600980549288169290911691909117905560008690036105f15760408051808201909152601881527f4d454d424552534849505f4c4556454c535f535441424c4500000000000000006020820152600b906105eb90826109e1565b50610685565b8560010361063a5760408051808201909152601981527f4d454d424552534849505f4c4556454c535f47414c41584953000000000000006020820152600b906105eb90826109e1565b856002036106855760408051808201909152601e81527f4d454d424552534849505f4c4556454c535f435553544f4d5f544f4b454e00006020820152600b9061068390826109e1565b505b505050505b50505050610aa0565b80516001600160a01b03811681146106aa57600080fd5b919050565b805163ffffffff811681146106aa57600080fd5b600080600080608085870312156106d957600080fd5b6106e285610693565b93506106f0602086016106af565b92506040850151915061070560608601610693565b905092959194509250565b60006020828403121561072257600080fd5b61072b82610693565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b038111828210171561076a5761076a610732565b60405290565b604051601f8201601f191681016001600160401b038111828210171561079857610798610732565b604052919050565b600060208083850312156107b357600080fd5b82516001600160401b03808211156107ca57600080fd5b818501915085601f8301126107de57600080fd5b8151818111156107f0576107f0610732565b6107fe848260051b01610770565b818152848101925060069190911b83018401908782111561081e57600080fd5b928401925b81841015610869576040848903121561083c5760008081fd5b610844610748565b84518152610853868601610693565b8187015283526040939093019291840191610823565b979650505050505050565b60008060006060848603121561088957600080fd5b83516001600160401b03808211156108a057600080fd5b818601915086601f8301126108b457600080fd5b8151818111156108c6576108c6610732565b602091506108dc601f8201601f19168301610770565b81815288838386010111156108f057600080fd5b60005b8281101561090e5784810184015182820185015283016108f3565b5060008383830101528096505050610927818701610693565b93505050610937604085016106af565b90509250925092565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061096a57607f821691505b60208210810361098a57634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156109dc576000816000526020600020601f850160051c810160208610156109b95750805b601f850160051c820191505b818110156109d8578281556001016109c5565b5050505b505050565b81516001600160401b038111156109fa576109fa610732565b610a0e81610a088454610956565b84610990565b602080601f831160018114610a435760008415610a2b5750858301515b600019600386901b1c1916600185901b1785556109d8565b600085815260208120601f198616915b82811015610a7257888601518255948401946001909101908401610a53565b5085821015610a905787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6080516138ff610ac96000396000818161044301528181610cf10152611f7401526138ff6000f3fe608060405234801561001057600080fd5b506004361061021c5760003560e01c8063665305bb11610125578063aa9b41e5116100ad578063db4542cb1161007c578063db4542cb1461050b578063e52531051461051e578063ee1fee4714610531578063f75b2b8014610556578063f7640fd51461056957600080fd5b8063aa9b41e5146104ca578063abddba1e146104d2578063ad7ed7da146104f2578063da235b221461050557600080fd5b806385f45250116100f457806385f452501461048c5780638ab1f97a1461049f5780639c402ff5146104a7578063a2ced936146104ba578063a3f23bce146104c257600080fd5b8063665305bb1461040e5780636ddc9597146104295780637671114d1461043e57806380cefab71461046557600080fd5b80632a8c5ad2116101a857806330f83cac1161017757806330f83cac1461039b578063399570a3146103bb57806354fd4d50146103ce57806357e2c0f5146103d8578063633423be146103fb57600080fd5b80632a8c5ad2146102e75780632d5bbf60146102fa5780632f2c7d5f146103755780633013ce291461038857600080fd5b80631d9c37b0116101ef5780631d9c37b0146102855780631feeece2146102a557806321235083146102ae5780632220b4c6146102c157806325263391146102d457600080fd5b806309e1f7031461022157806319b78c311461023d5780631b55e338146102685780631bd6e8481461027d575b600080fd5b61022a60075481565b6040519081526020015b60405180910390f35b600a54610250906001600160a01b031681565b6040516001600160a01b039091168152602001610234565b61027b610276366004612ea6565b610571565b005b61022a6105d9565b610298610293366004612ebf565b61065d565b6040516102349190612ee1565b61022a60085481565b61027b6102bc366004612ea6565b6106f7565b61022a6102cf366004612ea6565b6107a1565b6102986102e2366004612ebf565b6107b4565b61027b6102f5366004612f3a565b610804565b610344610308366004612ea6565b60046020819052600091825260409091208054600182015460028301546003840154939094015491939092909160ff8082169161010090041686565b60408051968752602087019590955293850192909252606084015215156080830152151560a082015260c001610234565b61027b610383366004612fd0565b610bcd565b600654610250906001600160a01b031681565b6103ae6103a9366004613067565b610e67565b60405161023491906130f2565b61022a6103c9366004612ea6565b611125565b6378b3dbad61022a565b6103eb6103e6366004612ea6565b611139565b6040519015158152602001610234565b600954610250906001600160a01b031681565b6005546102509064010000000090046001600160a01b031681565b610431611157565b60405161023491906131b4565b6102507f000000000000000000000000000000000000000000000000000000000000000081565b61022a7ffb3231be112a9810d87b6e307a1f4ba88b91ae1ffb1f669ad6f3832974c930bc81565b61027b61049a366004612ebf565b6111e5565b6102986112a9565b61027b6104b53660046131e7565b61132c565b61022a61138a565b6102986113cc565b61022a61140e565b6104e56104e0366004612ebf565b61141a565b604051610234919061325c565b61027b6105003660046132a2565b6114e7565b4261022a565b61027b6105193660046131e7565b61189b565b61027b61052c366004612ebf565b611950565b6005546105419063ffffffff1681565b60405163ffffffff9091168152602001610234565b61027b610564366004612f3a565b611aaa565b6104e5611d9f565b6009546001600160a01b031633146105a45760405162461bcd60e51b815260040161059b906132db565b60405180910390fd5b600081815260046020526040812090806105bd84611f03565b50915091506105cb81611f4f565b600183018290555b50505050565b60006105e36120fa565b6003546040516388a0f1bd60e01b815263ffffffff90911660048201526001600160a01b0391909116906388a0f1bd906024015b602060405180830381865afa158015610634573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610658919061331f565b905090565b60606106676120fa565b60035460405163df8cfb3360e01b815263ffffffff909116600482015260248101859052604481018490526001600160a01b03919091169063df8cfb33906064015b600060405180830381865afa1580156106c6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106ee9190810190613338565b90505b92915050565b600a546040516331a9108f60e11b81526004810183905282916001600160a01b031690636352211e90602401602060405180830381865afa158015610740573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076491906133c7565b6001600160a01b0316336001600160a01b0316146107945760405162461bcd60e51b815260040161059b906133e4565b61079d8261218d565b5050565b60006107ac82612201565b509392505050565b60606107be6120fa565b600354604051633b0e887360e11b815263ffffffff909116600482015260248101859052604481018490526001600160a01b03919091169063761d10e6906064016106a9565b600a546040516331a9108f60e11b81526004810187905286916001600160a01b031690636352211e90602401602060405180830381865afa15801561084d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087191906133c7565b6001600160a01b0316336001600160a01b0316146108a15760405162461bcd60e51b815260040161059b906133e4565b846108aa6120fa565b60035460405163a00ff6e560e01b815263ffffffff90911660048201526001600160a01b038381166024830152919091169063a00ff6e590604401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190613434565b6109a25760405162461bcd60e51b815260206004820152604160248201527f546f6b656e5472616e736665725365637572697479203a2064657374696e617460448201527f696f6e206e6f7420616c6c6f77656420746f207265636569766520746f6b656e6064820152607360f81b608482015260a40161059b565b60008781526004602052604081209080806109bc8b612201565b9250925092506109cb82611f4f565b88831015610a2d5760405162461bcd60e51b815260206004820152602960248201527f537562736372697074696f6e4361726457616c6c65743a20496e737566666963604482015268656e742066756e647360b81b606482015260840161059b565b42811015610a4a5742845560048401805461ff0019169055610a4e565b8084555b610a588984613467565b6001850155600654610a74906001600160a01b03168b8b6123c0565b896001600160a01b031663f75b2b808c600660009054906101000a90046001600160a01b03168c8c8c6040518663ffffffff1660e01b8152600401610abd95949392919061347a565b600060405180830381600087803b158015610ad757600080fd5b505af1158015610aeb573d6000803e3d6000fd5b5050600654604051636eb1769f60e11b81523060048201526001600160a01b038e81166024830152909116925063dd62ed3e9150604401602060405180830381865afa158015610b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b63919061331f565b15610bc05760405162461bcd60e51b815260206004820152602760248201527f537562736372697074696f6e4361726457616c6c65743a2066756e6473206e6f6044820152663a103a30b5b2b760c91b606482015260840161059b565b5050505050505050505050565b600a546040516331a9108f60e11b81526004810185905284916001600160a01b031690636352211e90602401602060405180830381865afa158015610c16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3a91906133c7565b6001600160a01b0316336001600160a01b031614610c6a5760405162461bcd60e51b815260040161059b906133e4565b60008481526004602052604081209080610c8387611f03565b509150915084821015610ca85760405162461bcd60e51b815260040161059b906134c9565b600086815260046020526040812090610cc088611f03565b509150610cd79050610cd28285613515565b611f4f565b604051631d2e660b60e21b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906374b9982c90610d2490600401613528565b602060405180830381865afa158015610d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6591906133c7565b6005546040516328e8b14f60e01b815263ffffffff909116600482015290915060009081906001600160a01b038416906328e8b14f906024016040805180830381865afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde919061356b565b90925090506000612710610df2848d61359b565b610dfc91906135c8565b90506000610e0a828d613467565b90508b8a6001016000828254610e209190613467565b9250508190555080876001016000828254610e3b9190613515565b9091555050600654610e57906001600160a01b03168484612508565b5050505050505050505050505050565b805160609060008167ffffffffffffffff811115610e8757610e87612ffc565b604051908082528060200260200182016040528015610ec057816020015b610ead612e44565b815260200190600190039081610ea55790505b50905060005b828110156107ac5760046000868381518110610ee457610ee46135dc565b6020908102919091018101518252818101929092526040908101600020815160c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004015460ff8082161515608084015261010090910416151560a08201528251839083908110610f6157610f616135dc565b602002602001015160600181905250610f92858281518110610f8557610f856135dc565b6020026020010151612201565b9050838381518110610fa657610fa66135dc565b6020026020010151604001848481518110610fc357610fc36135dc565b60209081029190910181015101919091525242828281518110610fe857610fe86135dc565b60200260200101516020015111801561101f575081818151811061100e5761100e6135dc565b60200260200101516060015160a001515b1561111d576000828281518110611038576110386135dc565b6020026020010151606001516040015183838151811061105a5761105a6135dc565b60200260200101516040015161107091906135c8565b9050828281518110611084576110846135dc565b602002602001015160600151608001516110cd576110c8818484815181106110ae576110ae6135dc565b60200260200101516020015161253890919063ffffffff16565b6110fd565b6110fd818484815181106110e3576110e36135dc565b60200260200101516020015161260f90919063ffffffff16565b83838151811061110f5761110f6135dc565b602090810291909101015152505b600101610ec6565b600061113082612201565b50909392505050565b60008061114583612201565b925050506111504290565b1092915050565b600b8054611164906135f2565b80601f0160208091040260200160405190810160405280929190818152602001828054611190906135f2565b80156111dd5780601f106111b2576101008083540402835291602001916111dd565b820191906000526020600020905b8154815290600101906020018083116111c057829003601f168201915b505050505081565b600a546040516331a9108f60e11b81526004810184905283916001600160a01b031690636352211e90602401602060405180830381865afa15801561122e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125291906133c7565b6001600160a01b0316336001600160a01b0316146112825760405162461bcd60e51b815260040161059b906133e4565b60065461129a906001600160a01b0316333085612643565b6112a4838361267b565b505050565b60606112b36120fa565b6003546040516391499f0f60e01b815263ffffffff90911660048201526001600160a01b0391909116906391499f0f906024015b600060405180830381865afa158015611304573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106589190810190613338565b6009546001600160a01b031633146113565760405162461bcd60e51b815260040161059b906132db565b60005b818110156112a457611382838383818110611376576113766135dc565b9050602002013561218d565b600101611359565b60006113946120fa565b60035460405163c74505ff60e01b815263ffffffff90911660048201526001600160a01b03919091169063c74505ff90602401610617565b60606113d66120fa565b6003546040516338e7d79960e21b815263ffffffff90911660048201526001600160a01b03919091169063e39f5e64906024016112e7565b6000610658600c6126fa565b60606000611428600c6126fa565b905060006114368486613515565b90508181106114425750805b600061144e8683613467565b67ffffffffffffffff81111561146657611466612ffc565b60405190808252806020026020018201604052801561148f578160200160208202803683370190505b5090506000865b838110156114db576114a9600c82612704565b8383815181106114bb576114bb6135dc565b6020908102919091010152816114d08161362c565b925050600101611496565b50909695505050505050565b600a546040516331a9108f60e11b81526004810185905284916001600160a01b031690636352211e90602401602060405180830381865afa158015611530573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155491906133c7565b6001600160a01b0316336001600160a01b0316146115845760405162461bcd60e51b815260040161059b906133e4565b6000848152600460205260408120908061159d87612201565b50915091506115ab81611f4f565b600554604051631d2e660b60e21b815260009164010000000090046001600160a01b0316906374b9982c906115e590600b90600401613645565b602060405180830381865afa158015611602573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162691906133c7565b6040519091506001600160a01b03821615159061164890600b906020016136d5565b604051602081830303815290604052906116755760405162461bcd60e51b815260040161059b91906131b4565b5060048401805460ff1916871580159190911790915560038501889055819061171857604051639ca1ca7560e01b8152600481018990526001600160a01b03821690639ca1ca7590602401602060405180830381865afa1580156116dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611701919061331f565b600286015561171142600161260f565b8555611794565b6040516350cb1aa560e11b8152600481018990526001600160a01b0382169063a196354a90602401602060405180830381865afa15801561175d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611781919061331f565b6002860155611791426001612538565b85555b8460020154841015611810576040805162461bcd60e51b81526020600482015260248101919091527f537562736372697074696f6e4361726457616c6c65743a20496e73756666696360448201527f69656e742066756e647320746f20737461727420737562736372697074696f6e606482015260840161059b565b600285015461181f9085613467565b600186015560048501805461ff001916610100179055600285015461184390611f4f565b61184e600c8a612710565b50604080518a8152602081018a90528815158183015290517f388e3efde44a5716a4ab145a371688610563b4d7a5648b0a72f4781906a612789181900360600190a1505050505050505050565b6009546001600160a01b031633146118c55760405162461bcd60e51b815260040161059b906132db565b6000805b82811015611946576000600460008686858181106118e9576118e96135dc565b9050602002013581526020019081526020016000209050600080611924878786818110611918576119186135dc565b90506020020135611f03565b5090925090506119348186613515565b600193840192909255509250016118c9565b506112a481611f4f565b600a546040516331a9108f60e11b81526004810184905283916001600160a01b031690636352211e90602401602060405180830381865afa158015611999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bd91906133c7565b6001600160a01b0316336001600160a01b0316146119ed5760405162461bcd60e51b815260040161059b906133e4565b60008381526004602052604081209080611a0686611f03565b509150915084821015611a2b5760405162461bcd60e51b815260040161059b906134c9565b611a3481611f4f565b611a3e8583613467565b6001840155600654611a5a906001600160a01b03163387612508565b60018301546040805188815260208101889052908101919091527fd5550c71ca14cc44783a664cd798ecb70dcefed6b3cfdf323041ce6d221f2d72906060015b60405180910390a1505050505050565b33611ab36120fa565b600354604051631fa3761960e31b815263ffffffff90911660048201526001600160a01b038381166024830152919091169063fd1bb0c890604401602060405180830381865afa158015611b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2f9190613434565b611b995760405162461bcd60e51b815260206004820152603560248201527f546f6b656e5472616e736665725365637572697479203a20736f757263652063604482015274616e6e6f7420627579207769746820746f6b656e7360581b606482015260840161059b565b6006546001600160a01b03868116911614611c0d5760405162461bcd60e51b815260206004820152602e60248201527f537562736372697074696f6e4361726457616c6c65743a20496e76616c69642060448201526d22a9219918103a3930b739b332b960911b606482015260840161059b565b6000611c188761271c565b6001600160a01b031603611c7e5760405162461bcd60e51b815260206004820152602760248201527f537562736372697074696f6e4361726457616c6c65743a20696e76616c69642060448201526618d85c9908125160ca1b606482015260840161059b565b60208214611ce35760405162461bcd60e51b815260206004820152602c60248201527f537562736372697074696f6e4361726457616c6c6574203a20496e76616c696460448201526b040c8c2e8c240d8cadccee8d60a31b606482015260840161059b565b6000611cf260208285876137a4565b611cfb916137ce565b60055490915063ffffffff808316911614611d745760405162461bcd60e51b815260206004820152603360248201527f537562736372697074696f6e4361726457616c6c65743a20496e76616c69642060448201527272657175657374656420636f6d6d756e69747960681b606482015260840161059b565b600654611d8c906001600160a01b0316333088612643565b611d96878661267b565b50505050505050565b60606000611dad600c6126fa565b905060008167ffffffffffffffff811115611dca57611dca612ffc565b604051908082528060200260200182016040528015611df3578160200160208202803683370190505b5090506000805b83811015611e68576000611e17611e12600c84612704565b612201565b92505050611e224290565b811115611e5f57611e34600c83612704565b848481518110611e4657611e466135dc565b602090810291909101015282611e5b8161362c565b9350505b50600101611dfa565b5060008167ffffffffffffffff811115611e8457611e84612ffc565b604051908082528060200260200182016040528015611ead578160200160208202803683370190505b50905060005b82811015611efa57838181518110611ecd57611ecd6135dc565b6020026020010151828281518110611ee757611ee76135dc565b6020908102919091010152600101611eb3565b50949350505050565b600081815260046020526040812081908190611f1e85612201565b9195509350915042821015611f425742815560048101805461ff0019169055611f46565b8181555b505b9193909250565b80600003611f5a5750565b604051631d2e660b60e21b81526000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906374b9982c90611fa790600401613528565b602060405180830381865afa158015611fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fe891906133c7565b6005546040516328e8b14f60e01b815263ffffffff909116600482015290915060009081906001600160a01b038416906328e8b14f906024016040805180830381865afa15801561203d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612061919061356b565b90925090506000612710612075848761359b565b61207f91906135c8565b9050600061208d8287613467565b6009546006549192506120ad916001600160a01b03908116911683612508565b6006546120c4906001600160a01b03168484612508565b60408051828152602081018490527ff5113038110e08c7fac91012f7b68c6010271f7653a75b250e714f6d1e2d75909101611a9a565b60008054604051631d2e660b60e21b8152602060048201526015602482015274544f4b454e5f53454355524954595f43454e54524560581b60448201526001600160a01b03909116906374b9982c90606401602060405180830381865afa158015612169573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065891906133c7565b600081815260046020526040812090806121a684611f03565b50915091506121b481611f4f565b60048301805461ff0019169055600183018290556040518481527fbd2bcea75d16a85f005cd83447e0de57341bf926fe7419e6d553663e91ab4da79060200160405180910390a150505050565b6000818152600460208181526040808420815160c08101835281548152600182015493810193909352600281015491830191909152600381015460608301529091015460ff8082161515608084015261010090910416151560a08201528190819042815111156122805760208101519051909350600092509050611f48565b8060a0015161229b5760200151925060009150429050611f48565b60008160800151156122c5576122b342835190612817565b6122be906001613515565b90506122df565b6122d142835190612869565b6122dc906001613515565b90505b602082015160408301516122f3908361359b565b11156123685760008260400151836020015161230f91906135c8565b905082608001511561232e578251612327908261260f565b935061233d565b825161233a9082612538565b93505b604083015161234c908261359b565b945084836020015161235e9190613467565b9550505050611f48565b6040820151612377908261359b565b93508382602001516123899190613467565b94508160800151156123a85781516123a1908261260f565b92506123b7565b81516123b49082612538565b92505b50509193909250565b80158061243a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612414573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612438919061331f565b155b6124a55760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161059b565b6040516001600160a01b0383166024820152604481018290526112a490849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526128eb565b6040516001600160a01b0383166024820152604481018290526112a490849063a9059cbb60e01b906064016124d1565b600080808061255261254d62015180886135c8565b6129bd565b919450925090506125638583613515565b9150600c612572600184613467565b61257c91906135c8565b6125869084613515565b9250600c612595600184613467565b61259f91906137ec565b6125aa906001613515565b915060006125b88484612a59565b9050808211156125c6578091505b6125d362015180886137ec565b620151806125e2868686612adf565b6125ec919061359b565b6125f69190613515565b94508685101561260557600080fd5b5050505092915050565b600080808061262461254d62015180886135c8565b919450925090506126358584613515565b925060006125b88484612a59565b6040516001600160a01b03808516602483015283166044820152606481018290526105d39085906323b872dd60e01b906084016124d1565b6000828152600460205260408120908061269485611f03565b50915091506126a281611f4f565b6126ac8285613515565b60018401819055604080518781526020810187905280820192909252517f62ee73c773b55504821f98bde7e07289174973e15c1715eb5b94d661bfcce4ce9181900360600190a15050505050565b60006106f1825490565b60006106ee8383612c1c565b60006106ee8383612c46565b600554604051631d2e660b60e21b8152602060048201526007602482015266544f4b454e5f3160c81b604482015260009164010000000090046001600160a01b0316906374b9982c90606401602060405180830381865afa158015612785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a991906133c7565b6001600160a01b0316636352211e836040518263ffffffff1660e01b81526004016127d691815260200190565b602060405180830381865afa1580156127f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906133c7565b60008183111561282657600080fd5b600061283861254d62015180866135c8565b505090506000612850620151808561254d91906135c8565b5050905081816128609190613467565b95945050505050565b60008183111561287857600080fd5b60008061288b61254d62015180876135c8565b5090925090506000806128a461254d62015180886135c8565b509092509050826128b685600c61359b565b826128c285600c61359b565b6128cc9190613515565b6128d69190613467565b6128e09190613467565b979650505050505050565b6000612940826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612c959092919063ffffffff16565b8051909150156112a4578080602001905181019061295e9190613434565b6112a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161059b565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f8460500281612a1a57612a1a6135b2565b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b60008160011480612a6a5750816003145b80612a755750816005145b80612a805750816007145b80612a8b5750816008145b80612a96575081600a145b80612aa1575081600c145b15612aae5750601f6106f1565b81600214612abe5750601e6106f1565b612ac783612cae565b612ad257601c612ad5565b601d5b60ff169392505050565b60006107b2841015612af057600080fd5b838383600062253d8c60046064600c612b0a600e88613800565b612b149190613827565b612b2088611324613855565b612b2a9190613855565b612b349190613827565b612b3f90600361387d565b612b499190613827565b600c80612b57600e88613800565b612b619190613827565b612b6c90600c61387d565b612b77600288613800565b612b819190613800565b612b8d9061016f61387d565b612b979190613827565b6004600c612ba6600e89613800565b612bb09190613827565b612bbc896112c0613855565b612bc69190613855565b612bd2906105b561387d565b612bdc9190613827565b612be8617d4b87613800565b612bf29190613855565b612bfc9190613855565b612c069190613800565b612c109190613800565b98975050505050505050565b6000826000018281548110612c3357612c336135dc565b9060005260206000200154905092915050565b6000818152600183016020526040812054612c8d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106f1565b5060006106f1565b6060612ca48484600085612cea565b90505b9392505050565b6000612cbb6004836137ec565b158015612cd15750612cce6064836137ec565b15155b806106f15750612ce3610190836137ec565b1592915050565b606082471015612d4b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161059b565b6001600160a01b0385163b612da25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161059b565b600080866001600160a01b03168587604051612dbe91906138ad565b60006040518083038185875af1925050503d8060008114612dfb576040519150601f19603f3d011682016040523d82523d6000602084013e612e00565b606091505b50915091506128e082828660608315612e1a575081612ca7565b825115612e2a5782518084602001fd5b8160405162461bcd60e51b815260040161059b91906131b4565b6040518060800160405280600081526020016000815260200160008152602001612ea16040518060c00160405280600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b905290565b600060208284031215612eb857600080fd5b5035919050565b60008060408385031215612ed257600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156114db5783516001600160a01b031683529284019291840191600101612efd565b6001600160a01b0381168114612f3757600080fd5b50565b600080600080600060808688031215612f5257600080fd5b853594506020860135612f6481612f22565b935060408601359250606086013567ffffffffffffffff80821115612f8857600080fd5b818801915088601f830112612f9c57600080fd5b813581811115612fab57600080fd5b896020828501011115612fbd57600080fd5b9699959850939650602001949392505050565b600080600060608486031215612fe557600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561303b5761303b612ffc565b604052919050565b600067ffffffffffffffff82111561305d5761305d612ffc565b5060051b60200190565b6000602080838503121561307a57600080fd5b823567ffffffffffffffff81111561309157600080fd5b8301601f810185136130a257600080fd5b80356130b56130b082613043565b613012565b81815260059190911b820183019083810190878311156130d457600080fd5b928401925b828410156128e0578335825292840192908401906130d9565b602080825282518282018190526000919060409081850190868401855b828110156131835781518051855286810151878601528581015186860152606090810151805182870152808801516080808801919091528188015160a0808901919091529282015160c0880152810151151560e087015201511515610100850152610120909301929085019060010161310f565b5091979650505050505050565b60005b838110156131ab578181015183820152602001613193565b50506000910152565b60208152600082518060208401526131d3816040850160208701613190565b601f01601f19169190910160400192915050565b600080602083850312156131fa57600080fd5b823567ffffffffffffffff8082111561321257600080fd5b818501915085601f83011261322657600080fd5b81358181111561323557600080fd5b8660208260051b850101111561324a57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156114db57835183529284019291840191600101613278565b8015158114612f3757600080fd5b6000806000606084860312156132b757600080fd5b833592506020840135915060408401356132d081613294565b809150509250925092565b60208082526024908201527f537562736372697074696f6e4361726457616c6c65743a20756e617574686f726040820152631a5cd95960e21b606082015260800190565b60006020828403121561333157600080fd5b5051919050565b6000602080838503121561334b57600080fd5b825167ffffffffffffffff81111561336257600080fd5b8301601f8101851361337357600080fd5b80516133816130b082613043565b81815260059190911b820183019083810190878311156133a057600080fd5b928401925b828410156128e05783516133b881612f22565b825292840192908401906133a5565b6000602082840312156133d957600080fd5b8151612ca781612f22565b60208082526030908201527f537562736372697074696f6e4361726457616c6c65743a20596f7520646f206e60408201526f1bdd081bdddb881d1a1a5cc818d85c9960821b606082015260800190565b60006020828403121561344657600080fd5b8151612ca781613294565b634e487b7160e01b600052601160045260246000fd5b818103818111156106f1576106f1613451565b8581526001600160a01b0385166020820152604081018490526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b6020808252602c908201527f537562736372697074696f6e4361726457616c6c65743a20696e73756666696360408201526b69656e742062616c616e636560a01b606082015260800190565b808201808211156106f1576106f1613451565b60208082526023908201527f474c4f42414c5f535542534352495054494f4e5f53504c49545445525f434f4e60408201526246494760e81b606082015260800190565b6000806040838503121561357e57600080fd5b82519150602083015161359081612f22565b809150509250929050565b80820281158282048414176106f1576106f1613451565b634e487b7160e01b600052601260045260246000fd5b6000826135d7576135d76135b2565b500490565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061360657607f821691505b60208210810361362657634e487b7160e01b600052602260045260246000fd5b50919050565b60006001820161363e5761363e613451565b5060010190565b6000602080835260008454613659816135f2565b806020870152604060018084166000811461367b5760018114613697576136c7565b60ff19851660408a0152604084151560051b8a010195506136c7565b89600052602060002060005b858110156136be5781548b82018601529083019088016136a3565b8a016040019650505b509398975050505050505050565b7f537562736372697074696f6e4361726457616c6c65743a204d656d62657273688152600060207f6970206c6576656c20636f6e7472616374206e6f7420666f756e64203a2000006020840152603e60008554613731816135f2565b60018281168015613749576001811461376457613796565b60ff198416603e8a0152603e83151584028a01019450613796565b89600052602060002060005b8481101561378b5781548b8201890152908301908801613770565b5050603e838a010194505b509298975050505050505050565b600080858511156137b457600080fd5b838611156137c157600080fd5b5050820193919092039150565b803560208310156106f157600019602084900360031b1b1692915050565b6000826137fb576137fb6135b2565b500690565b818103600083128015838313168383128216171561382057613820613451565b5092915050565b600082613836576138366135b2565b600160ff1b82146000198414161561385057613850613451565b500590565b808201828112600083128015821682158216171561387557613875613451565b505092915050565b80820260008212600160ff1b8414161561389957613899613451565b81810583148215176106f1576106f1613451565b600082516138bf818460208701613190565b919091019291505056fea2646970667358221220c09a8794c2582e2c31b32648231b0f9654ea72d9b7b4fc44dfd287d86e543a8c64736f6c63430008190033537562736372697074696f6e4361726457616c6c65743a20496e76616c696420000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae200000000000000000000000000000000000000000000000000000000000003e90000000000000000000000000000000000000000000000000000000000000002000000000000000000000000691bfc17cdff58a9ec9126403d2ff9b27512fec1
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061021c5760003560e01c8063665305bb11610125578063aa9b41e5116100ad578063db4542cb1161007c578063db4542cb1461050b578063e52531051461051e578063ee1fee4714610531578063f75b2b8014610556578063f7640fd51461056957600080fd5b8063aa9b41e5146104ca578063abddba1e146104d2578063ad7ed7da146104f2578063da235b221461050557600080fd5b806385f45250116100f457806385f452501461048c5780638ab1f97a1461049f5780639c402ff5146104a7578063a2ced936146104ba578063a3f23bce146104c257600080fd5b8063665305bb1461040e5780636ddc9597146104295780637671114d1461043e57806380cefab71461046557600080fd5b80632a8c5ad2116101a857806330f83cac1161017757806330f83cac1461039b578063399570a3146103bb57806354fd4d50146103ce57806357e2c0f5146103d8578063633423be146103fb57600080fd5b80632a8c5ad2146102e75780632d5bbf60146102fa5780632f2c7d5f146103755780633013ce291461038857600080fd5b80631d9c37b0116101ef5780631d9c37b0146102855780631feeece2146102a557806321235083146102ae5780632220b4c6146102c157806325263391146102d457600080fd5b806309e1f7031461022157806319b78c311461023d5780631b55e338146102685780631bd6e8481461027d575b600080fd5b61022a60075481565b6040519081526020015b60405180910390f35b600a54610250906001600160a01b031681565b6040516001600160a01b039091168152602001610234565b61027b610276366004612ea6565b610571565b005b61022a6105d9565b610298610293366004612ebf565b61065d565b6040516102349190612ee1565b61022a60085481565b61027b6102bc366004612ea6565b6106f7565b61022a6102cf366004612ea6565b6107a1565b6102986102e2366004612ebf565b6107b4565b61027b6102f5366004612f3a565b610804565b610344610308366004612ea6565b60046020819052600091825260409091208054600182015460028301546003840154939094015491939092909160ff8082169161010090041686565b60408051968752602087019590955293850192909252606084015215156080830152151560a082015260c001610234565b61027b610383366004612fd0565b610bcd565b600654610250906001600160a01b031681565b6103ae6103a9366004613067565b610e67565b60405161023491906130f2565b61022a6103c9366004612ea6565b611125565b6378b3dbad61022a565b6103eb6103e6366004612ea6565b611139565b6040519015158152602001610234565b600954610250906001600160a01b031681565b6005546102509064010000000090046001600160a01b031681565b610431611157565b60405161023491906131b4565b6102507f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae281565b61022a7ffb3231be112a9810d87b6e307a1f4ba88b91ae1ffb1f669ad6f3832974c930bc81565b61027b61049a366004612ebf565b6111e5565b6102986112a9565b61027b6104b53660046131e7565b61132c565b61022a61138a565b6102986113cc565b61022a61140e565b6104e56104e0366004612ebf565b61141a565b604051610234919061325c565b61027b6105003660046132a2565b6114e7565b4261022a565b61027b6105193660046131e7565b61189b565b61027b61052c366004612ebf565b611950565b6005546105419063ffffffff1681565b60405163ffffffff9091168152602001610234565b61027b610564366004612f3a565b611aaa565b6104e5611d9f565b6009546001600160a01b031633146105a45760405162461bcd60e51b815260040161059b906132db565b60405180910390fd5b600081815260046020526040812090806105bd84611f03565b50915091506105cb81611f4f565b600183018290555b50505050565b60006105e36120fa565b6003546040516388a0f1bd60e01b815263ffffffff90911660048201526001600160a01b0391909116906388a0f1bd906024015b602060405180830381865afa158015610634573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610658919061331f565b905090565b60606106676120fa565b60035460405163df8cfb3360e01b815263ffffffff909116600482015260248101859052604481018490526001600160a01b03919091169063df8cfb33906064015b600060405180830381865afa1580156106c6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106ee9190810190613338565b90505b92915050565b600a546040516331a9108f60e11b81526004810183905282916001600160a01b031690636352211e90602401602060405180830381865afa158015610740573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076491906133c7565b6001600160a01b0316336001600160a01b0316146107945760405162461bcd60e51b815260040161059b906133e4565b61079d8261218d565b5050565b60006107ac82612201565b509392505050565b60606107be6120fa565b600354604051633b0e887360e11b815263ffffffff909116600482015260248101859052604481018490526001600160a01b03919091169063761d10e6906064016106a9565b600a546040516331a9108f60e11b81526004810187905286916001600160a01b031690636352211e90602401602060405180830381865afa15801561084d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061087191906133c7565b6001600160a01b0316336001600160a01b0316146108a15760405162461bcd60e51b815260040161059b906133e4565b846108aa6120fa565b60035460405163a00ff6e560e01b815263ffffffff90911660048201526001600160a01b038381166024830152919091169063a00ff6e590604401602060405180830381865afa158015610902573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109269190613434565b6109a25760405162461bcd60e51b815260206004820152604160248201527f546f6b656e5472616e736665725365637572697479203a2064657374696e617460448201527f696f6e206e6f7420616c6c6f77656420746f207265636569766520746f6b656e6064820152607360f81b608482015260a40161059b565b60008781526004602052604081209080806109bc8b612201565b9250925092506109cb82611f4f565b88831015610a2d5760405162461bcd60e51b815260206004820152602960248201527f537562736372697074696f6e4361726457616c6c65743a20496e737566666963604482015268656e742066756e647360b81b606482015260840161059b565b42811015610a4a5742845560048401805461ff0019169055610a4e565b8084555b610a588984613467565b6001850155600654610a74906001600160a01b03168b8b6123c0565b896001600160a01b031663f75b2b808c600660009054906101000a90046001600160a01b03168c8c8c6040518663ffffffff1660e01b8152600401610abd95949392919061347a565b600060405180830381600087803b158015610ad757600080fd5b505af1158015610aeb573d6000803e3d6000fd5b5050600654604051636eb1769f60e11b81523060048201526001600160a01b038e81166024830152909116925063dd62ed3e9150604401602060405180830381865afa158015610b3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b63919061331f565b15610bc05760405162461bcd60e51b815260206004820152602760248201527f537562736372697074696f6e4361726457616c6c65743a2066756e6473206e6f6044820152663a103a30b5b2b760c91b606482015260840161059b565b5050505050505050505050565b600a546040516331a9108f60e11b81526004810185905284916001600160a01b031690636352211e90602401602060405180830381865afa158015610c16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c3a91906133c7565b6001600160a01b0316336001600160a01b031614610c6a5760405162461bcd60e51b815260040161059b906133e4565b60008481526004602052604081209080610c8387611f03565b509150915084821015610ca85760405162461bcd60e51b815260040161059b906134c9565b600086815260046020526040812090610cc088611f03565b509150610cd79050610cd28285613515565b611f4f565b604051631d2e660b60e21b81526000906001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216906374b9982c90610d2490600401613528565b602060405180830381865afa158015610d41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d6591906133c7565b6005546040516328e8b14f60e01b815263ffffffff909116600482015290915060009081906001600160a01b038416906328e8b14f906024016040805180830381865afa158015610dba573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dde919061356b565b90925090506000612710610df2848d61359b565b610dfc91906135c8565b90506000610e0a828d613467565b90508b8a6001016000828254610e209190613467565b9250508190555080876001016000828254610e3b9190613515565b9091555050600654610e57906001600160a01b03168484612508565b5050505050505050505050505050565b805160609060008167ffffffffffffffff811115610e8757610e87612ffc565b604051908082528060200260200182016040528015610ec057816020015b610ead612e44565b815260200190600190039081610ea55790505b50905060005b828110156107ac5760046000868381518110610ee457610ee46135dc565b6020908102919091018101518252818101929092526040908101600020815160c08101835281548152600182015493810193909352600281015491830191909152600381015460608301526004015460ff8082161515608084015261010090910416151560a08201528251839083908110610f6157610f616135dc565b602002602001015160600181905250610f92858281518110610f8557610f856135dc565b6020026020010151612201565b9050838381518110610fa657610fa66135dc565b6020026020010151604001848481518110610fc357610fc36135dc565b60209081029190910181015101919091525242828281518110610fe857610fe86135dc565b60200260200101516020015111801561101f575081818151811061100e5761100e6135dc565b60200260200101516060015160a001515b1561111d576000828281518110611038576110386135dc565b6020026020010151606001516040015183838151811061105a5761105a6135dc565b60200260200101516040015161107091906135c8565b9050828281518110611084576110846135dc565b602002602001015160600151608001516110cd576110c8818484815181106110ae576110ae6135dc565b60200260200101516020015161253890919063ffffffff16565b6110fd565b6110fd818484815181106110e3576110e36135dc565b60200260200101516020015161260f90919063ffffffff16565b83838151811061110f5761110f6135dc565b602090810291909101015152505b600101610ec6565b600061113082612201565b50909392505050565b60008061114583612201565b925050506111504290565b1092915050565b600b8054611164906135f2565b80601f0160208091040260200160405190810160405280929190818152602001828054611190906135f2565b80156111dd5780601f106111b2576101008083540402835291602001916111dd565b820191906000526020600020905b8154815290600101906020018083116111c057829003601f168201915b505050505081565b600a546040516331a9108f60e11b81526004810184905283916001600160a01b031690636352211e90602401602060405180830381865afa15801561122e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125291906133c7565b6001600160a01b0316336001600160a01b0316146112825760405162461bcd60e51b815260040161059b906133e4565b60065461129a906001600160a01b0316333085612643565b6112a4838361267b565b505050565b60606112b36120fa565b6003546040516391499f0f60e01b815263ffffffff90911660048201526001600160a01b0391909116906391499f0f906024015b600060405180830381865afa158015611304573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526106589190810190613338565b6009546001600160a01b031633146113565760405162461bcd60e51b815260040161059b906132db565b60005b818110156112a457611382838383818110611376576113766135dc565b9050602002013561218d565b600101611359565b60006113946120fa565b60035460405163c74505ff60e01b815263ffffffff90911660048201526001600160a01b03919091169063c74505ff90602401610617565b60606113d66120fa565b6003546040516338e7d79960e21b815263ffffffff90911660048201526001600160a01b03919091169063e39f5e64906024016112e7565b6000610658600c6126fa565b60606000611428600c6126fa565b905060006114368486613515565b90508181106114425750805b600061144e8683613467565b67ffffffffffffffff81111561146657611466612ffc565b60405190808252806020026020018201604052801561148f578160200160208202803683370190505b5090506000865b838110156114db576114a9600c82612704565b8383815181106114bb576114bb6135dc565b6020908102919091010152816114d08161362c565b925050600101611496565b50909695505050505050565b600a546040516331a9108f60e11b81526004810185905284916001600160a01b031690636352211e90602401602060405180830381865afa158015611530573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155491906133c7565b6001600160a01b0316336001600160a01b0316146115845760405162461bcd60e51b815260040161059b906133e4565b6000848152600460205260408120908061159d87612201565b50915091506115ab81611f4f565b600554604051631d2e660b60e21b815260009164010000000090046001600160a01b0316906374b9982c906115e590600b90600401613645565b602060405180830381865afa158015611602573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162691906133c7565b6040519091506001600160a01b03821615159061164890600b906020016136d5565b604051602081830303815290604052906116755760405162461bcd60e51b815260040161059b91906131b4565b5060048401805460ff1916871580159190911790915560038501889055819061171857604051639ca1ca7560e01b8152600481018990526001600160a01b03821690639ca1ca7590602401602060405180830381865afa1580156116dd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611701919061331f565b600286015561171142600161260f565b8555611794565b6040516350cb1aa560e11b8152600481018990526001600160a01b0382169063a196354a90602401602060405180830381865afa15801561175d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611781919061331f565b6002860155611791426001612538565b85555b8460020154841015611810576040805162461bcd60e51b81526020600482015260248101919091527f537562736372697074696f6e4361726457616c6c65743a20496e73756666696360448201527f69656e742066756e647320746f20737461727420737562736372697074696f6e606482015260840161059b565b600285015461181f9085613467565b600186015560048501805461ff001916610100179055600285015461184390611f4f565b61184e600c8a612710565b50604080518a8152602081018a90528815158183015290517f388e3efde44a5716a4ab145a371688610563b4d7a5648b0a72f4781906a612789181900360600190a1505050505050505050565b6009546001600160a01b031633146118c55760405162461bcd60e51b815260040161059b906132db565b6000805b82811015611946576000600460008686858181106118e9576118e96135dc565b9050602002013581526020019081526020016000209050600080611924878786818110611918576119186135dc565b90506020020135611f03565b5090925090506119348186613515565b600193840192909255509250016118c9565b506112a481611f4f565b600a546040516331a9108f60e11b81526004810184905283916001600160a01b031690636352211e90602401602060405180830381865afa158015611999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119bd91906133c7565b6001600160a01b0316336001600160a01b0316146119ed5760405162461bcd60e51b815260040161059b906133e4565b60008381526004602052604081209080611a0686611f03565b509150915084821015611a2b5760405162461bcd60e51b815260040161059b906134c9565b611a3481611f4f565b611a3e8583613467565b6001840155600654611a5a906001600160a01b03163387612508565b60018301546040805188815260208101889052908101919091527fd5550c71ca14cc44783a664cd798ecb70dcefed6b3cfdf323041ce6d221f2d72906060015b60405180910390a1505050505050565b33611ab36120fa565b600354604051631fa3761960e31b815263ffffffff90911660048201526001600160a01b038381166024830152919091169063fd1bb0c890604401602060405180830381865afa158015611b0b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b2f9190613434565b611b995760405162461bcd60e51b815260206004820152603560248201527f546f6b656e5472616e736665725365637572697479203a20736f757263652063604482015274616e6e6f7420627579207769746820746f6b656e7360581b606482015260840161059b565b6006546001600160a01b03868116911614611c0d5760405162461bcd60e51b815260206004820152602e60248201527f537562736372697074696f6e4361726457616c6c65743a20496e76616c69642060448201526d22a9219918103a3930b739b332b960911b606482015260840161059b565b6000611c188761271c565b6001600160a01b031603611c7e5760405162461bcd60e51b815260206004820152602760248201527f537562736372697074696f6e4361726457616c6c65743a20696e76616c69642060448201526618d85c9908125160ca1b606482015260840161059b565b60208214611ce35760405162461bcd60e51b815260206004820152602c60248201527f537562736372697074696f6e4361726457616c6c6574203a20496e76616c696460448201526b040c8c2e8c240d8cadccee8d60a31b606482015260840161059b565b6000611cf260208285876137a4565b611cfb916137ce565b60055490915063ffffffff808316911614611d745760405162461bcd60e51b815260206004820152603360248201527f537562736372697074696f6e4361726457616c6c65743a20496e76616c69642060448201527272657175657374656420636f6d6d756e69747960681b606482015260840161059b565b600654611d8c906001600160a01b0316333088612643565b611d96878661267b565b50505050505050565b60606000611dad600c6126fa565b905060008167ffffffffffffffff811115611dca57611dca612ffc565b604051908082528060200260200182016040528015611df3578160200160208202803683370190505b5090506000805b83811015611e68576000611e17611e12600c84612704565b612201565b92505050611e224290565b811115611e5f57611e34600c83612704565b848481518110611e4657611e466135dc565b602090810291909101015282611e5b8161362c565b9350505b50600101611dfa565b5060008167ffffffffffffffff811115611e8457611e84612ffc565b604051908082528060200260200182016040528015611ead578160200160208202803683370190505b50905060005b82811015611efa57838181518110611ecd57611ecd6135dc565b6020026020010151828281518110611ee757611ee76135dc565b6020908102919091010152600101611eb3565b50949350505050565b600081815260046020526040812081908190611f1e85612201565b9195509350915042821015611f425742815560048101805461ff0019169055611f46565b8181555b505b9193909250565b80600003611f5a5750565b604051631d2e660b60e21b81526000906001600160a01b037f000000000000000000000000dbd9608fbca959828c1615d29aeb3dc872d40ae216906374b9982c90611fa790600401613528565b602060405180830381865afa158015611fc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fe891906133c7565b6005546040516328e8b14f60e01b815263ffffffff909116600482015290915060009081906001600160a01b038416906328e8b14f906024016040805180830381865afa15801561203d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612061919061356b565b90925090506000612710612075848761359b565b61207f91906135c8565b9050600061208d8287613467565b6009546006549192506120ad916001600160a01b03908116911683612508565b6006546120c4906001600160a01b03168484612508565b60408051828152602081018490527ff5113038110e08c7fac91012f7b68c6010271f7653a75b250e714f6d1e2d75909101611a9a565b60008054604051631d2e660b60e21b8152602060048201526015602482015274544f4b454e5f53454355524954595f43454e54524560581b60448201526001600160a01b03909116906374b9982c90606401602060405180830381865afa158015612169573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065891906133c7565b600081815260046020526040812090806121a684611f03565b50915091506121b481611f4f565b60048301805461ff0019169055600183018290556040518481527fbd2bcea75d16a85f005cd83447e0de57341bf926fe7419e6d553663e91ab4da79060200160405180910390a150505050565b6000818152600460208181526040808420815160c08101835281548152600182015493810193909352600281015491830191909152600381015460608301529091015460ff8082161515608084015261010090910416151560a08201528190819042815111156122805760208101519051909350600092509050611f48565b8060a0015161229b5760200151925060009150429050611f48565b60008160800151156122c5576122b342835190612817565b6122be906001613515565b90506122df565b6122d142835190612869565b6122dc906001613515565b90505b602082015160408301516122f3908361359b565b11156123685760008260400151836020015161230f91906135c8565b905082608001511561232e578251612327908261260f565b935061233d565b825161233a9082612538565b93505b604083015161234c908261359b565b945084836020015161235e9190613467565b9550505050611f48565b6040820151612377908261359b565b93508382602001516123899190613467565b94508160800151156123a85781516123a1908261260f565b92506123b7565b81516123b49082612538565b92505b50509193909250565b80158061243a5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015612414573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612438919061331f565b155b6124a55760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b606482015260840161059b565b6040516001600160a01b0383166024820152604481018290526112a490849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526128eb565b6040516001600160a01b0383166024820152604481018290526112a490849063a9059cbb60e01b906064016124d1565b600080808061255261254d62015180886135c8565b6129bd565b919450925090506125638583613515565b9150600c612572600184613467565b61257c91906135c8565b6125869084613515565b9250600c612595600184613467565b61259f91906137ec565b6125aa906001613515565b915060006125b88484612a59565b9050808211156125c6578091505b6125d362015180886137ec565b620151806125e2868686612adf565b6125ec919061359b565b6125f69190613515565b94508685101561260557600080fd5b5050505092915050565b600080808061262461254d62015180886135c8565b919450925090506126358584613515565b925060006125b88484612a59565b6040516001600160a01b03808516602483015283166044820152606481018290526105d39085906323b872dd60e01b906084016124d1565b6000828152600460205260408120908061269485611f03565b50915091506126a281611f4f565b6126ac8285613515565b60018401819055604080518781526020810187905280820192909252517f62ee73c773b55504821f98bde7e07289174973e15c1715eb5b94d661bfcce4ce9181900360600190a15050505050565b60006106f1825490565b60006106ee8383612c1c565b60006106ee8383612c46565b600554604051631d2e660b60e21b8152602060048201526007602482015266544f4b454e5f3160c81b604482015260009164010000000090046001600160a01b0316906374b9982c90606401602060405180830381865afa158015612785573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127a991906133c7565b6001600160a01b0316636352211e836040518263ffffffff1660e01b81526004016127d691815260200190565b602060405180830381865afa1580156127f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f191906133c7565b60008183111561282657600080fd5b600061283861254d62015180866135c8565b505090506000612850620151808561254d91906135c8565b5050905081816128609190613467565b95945050505050565b60008183111561287857600080fd5b60008061288b61254d62015180876135c8565b5090925090506000806128a461254d62015180886135c8565b509092509050826128b685600c61359b565b826128c285600c61359b565b6128cc9190613515565b6128d69190613467565b6128e09190613467565b979650505050505050565b6000612940826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612c959092919063ffffffff16565b8051909150156112a4578080602001905181019061295e9190613434565b6112a45760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161059b565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f8460500281612a1a57612a1a6135b2565b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b60008160011480612a6a5750816003145b80612a755750816005145b80612a805750816007145b80612a8b5750816008145b80612a96575081600a145b80612aa1575081600c145b15612aae5750601f6106f1565b81600214612abe5750601e6106f1565b612ac783612cae565b612ad257601c612ad5565b601d5b60ff169392505050565b60006107b2841015612af057600080fd5b838383600062253d8c60046064600c612b0a600e88613800565b612b149190613827565b612b2088611324613855565b612b2a9190613855565b612b349190613827565b612b3f90600361387d565b612b499190613827565b600c80612b57600e88613800565b612b619190613827565b612b6c90600c61387d565b612b77600288613800565b612b819190613800565b612b8d9061016f61387d565b612b979190613827565b6004600c612ba6600e89613800565b612bb09190613827565b612bbc896112c0613855565b612bc69190613855565b612bd2906105b561387d565b612bdc9190613827565b612be8617d4b87613800565b612bf29190613855565b612bfc9190613855565b612c069190613800565b612c109190613800565b98975050505050505050565b6000826000018281548110612c3357612c336135dc565b9060005260206000200154905092915050565b6000818152600183016020526040812054612c8d575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556106f1565b5060006106f1565b6060612ca48484600085612cea565b90505b9392505050565b6000612cbb6004836137ec565b158015612cd15750612cce6064836137ec565b15155b806106f15750612ce3610190836137ec565b1592915050565b606082471015612d4b5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b606482015260840161059b565b6001600160a01b0385163b612da25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161059b565b600080866001600160a01b03168587604051612dbe91906138ad565b60006040518083038185875af1925050503d8060008114612dfb576040519150601f19603f3d011682016040523d82523d6000602084013e612e00565b606091505b50915091506128e082828660608315612e1a575081612ca7565b825115612e2a5782518084602001fd5b8160405162461bcd60e51b815260040161059b91906131b4565b6040518060800160405280600081526020016000815260200160008152602001612ea16040518060c00160405280600081526020016000815260200160008152602001600081526020016000151581526020016000151581525090565b905290565b600060208284031215612eb857600080fd5b5035919050565b60008060408385031215612ed257600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156114db5783516001600160a01b031683529284019291840191600101612efd565b6001600160a01b0381168114612f3757600080fd5b50565b600080600080600060808688031215612f5257600080fd5b853594506020860135612f6481612f22565b935060408601359250606086013567ffffffffffffffff80821115612f8857600080fd5b818801915088601f830112612f9c57600080fd5b813581811115612fab57600080fd5b896020828501011115612fbd57600080fd5b9699959850939650602001949392505050565b600080600060608486031215612fe557600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561303b5761303b612ffc565b604052919050565b600067ffffffffffffffff82111561305d5761305d612ffc565b5060051b60200190565b6000602080838503121561307a57600080fd5b823567ffffffffffffffff81111561309157600080fd5b8301601f810185136130a257600080fd5b80356130b56130b082613043565b613012565b81815260059190911b820183019083810190878311156130d457600080fd5b928401925b828410156128e0578335825292840192908401906130d9565b602080825282518282018190526000919060409081850190868401855b828110156131835781518051855286810151878601528581015186860152606090810151805182870152808801516080808801919091528188015160a0808901919091529282015160c0880152810151151560e087015201511515610100850152610120909301929085019060010161310f565b5091979650505050505050565b60005b838110156131ab578181015183820152602001613193565b50506000910152565b60208152600082518060208401526131d3816040850160208701613190565b601f01601f19169190910160400192915050565b600080602083850312156131fa57600080fd5b823567ffffffffffffffff8082111561321257600080fd5b818501915085601f83011261322657600080fd5b81358181111561323557600080fd5b8660208260051b850101111561324a57600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b818110156114db57835183529284019291840191600101613278565b8015158114612f3757600080fd5b6000806000606084860312156132b757600080fd5b833592506020840135915060408401356132d081613294565b809150509250925092565b60208082526024908201527f537562736372697074696f6e4361726457616c6c65743a20756e617574686f726040820152631a5cd95960e21b606082015260800190565b60006020828403121561333157600080fd5b5051919050565b6000602080838503121561334b57600080fd5b825167ffffffffffffffff81111561336257600080fd5b8301601f8101851361337357600080fd5b80516133816130b082613043565b81815260059190911b820183019083810190878311156133a057600080fd5b928401925b828410156128e05783516133b881612f22565b825292840192908401906133a5565b6000602082840312156133d957600080fd5b8151612ca781612f22565b60208082526030908201527f537562736372697074696f6e4361726457616c6c65743a20596f7520646f206e60408201526f1bdd081bdddb881d1a1a5cc818d85c9960821b606082015260800190565b60006020828403121561344657600080fd5b8151612ca781613294565b634e487b7160e01b600052601160045260246000fd5b818103818111156106f1576106f1613451565b8581526001600160a01b0385166020820152604081018490526080606082018190528101829052818360a0830137600081830160a090810191909152601f909201601f19160101949350505050565b6020808252602c908201527f537562736372697074696f6e4361726457616c6c65743a20696e73756666696360408201526b69656e742062616c616e636560a01b606082015260800190565b808201808211156106f1576106f1613451565b60208082526023908201527f474c4f42414c5f535542534352495054494f4e5f53504c49545445525f434f4e60408201526246494760e81b606082015260800190565b6000806040838503121561357e57600080fd5b82519150602083015161359081612f22565b809150509250929050565b80820281158282048414176106f1576106f1613451565b634e487b7160e01b600052601260045260246000fd5b6000826135d7576135d76135b2565b500490565b634e487b7160e01b600052603260045260246000fd5b600181811c9082168061360657607f821691505b60208210810361362657634e487b7160e01b600052602260045260246000fd5b50919050565b60006001820161363e5761363e613451565b5060010190565b6000602080835260008454613659816135f2565b806020870152604060018084166000811461367b5760018114613697576136c7565b60ff19851660408a0152604084151560051b8a010195506136c7565b89600052602060002060005b858110156136be5781548b82018601529083019088016136a3565b8a016040019650505b509398975050505050505050565b7f537562736372697074696f6e4361726457616c6c65743a204d656d62657273688152600060207f6970206c6576656c20636f6e7472616374206e6f7420666f756e64203a2000006020840152603e60008554613731816135f2565b60018281168015613749576001811461376457613796565b60ff198416603e8a0152603e83151584028a01019450613796565b89600052602060002060005b8481101561378b5781548b8201890152908301908801613770565b5050603e838a010194505b509298975050505050505050565b600080858511156137b457600080fd5b838611156137c157600080fd5b5050820193919092039150565b803560208310156106f157600019602084900360031b1b1692915050565b6000826137fb576137fb6135b2565b500690565b818103600083128015838313168383128216171561382057613820613451565b5092915050565b600082613836576138366135b2565b600160ff1b82146000198414161561385057613850613451565b500590565b808201828112600083128015821682158216171561387557613875613451565b505092915050565b80820260008212600160ff1b8414161561389957613899613451565b81810583148215176106f1576106f1613451565b600082516138bf818460208701613190565b919091019291505056fea2646970667358221220c09a8794c2582e2c31b32648231b0f9654ea72d9b7b4fc44dfd287d86e543a8c64736f6c63430008190033
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ 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.