Contract

0xfeE899CF3Ef6FCf338Da86453c334973e015c236

Overview

S Balance

Sonic LogoSonic LogoSonic Logo42.99216391503287629 S

S Value

-

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Add Fees Token9118772024-12-20 17:50:1312 hrs ago1734717013IN
0xfeE899CF...3e015c236
0 S0.000545122.01
Add Fees Token9108522024-12-20 17:40:5212 hrs ago1734716452IN
0xfeE899CF...3e015c236
0 S0.000298731.11
Start Sync Syste...9032102024-12-20 16:29:5913 hrs ago1734712199IN
0xfeE899CF...3e015c236
0 S0.000303671.11
Add Fees Token9027512024-12-20 16:24:4413 hrs ago1734711884IN
0xfeE899CF...3e015c236
0 S0.000304461.11
Start Sync Syste...8876652024-12-20 14:25:3715 hrs ago1734704737IN
0xfeE899CF...3e015c236
0 S0.00012081.11
Start Sync Syste...8827352024-12-20 13:50:5816 hrs ago1734702658IN
0xfeE899CF...3e015c236
0 S0.000402851.11
Set Swap To Wrap...8744022024-12-20 12:51:2117 hrs ago1734699081IN
0xfeE899CF...3e015c236
0 S0.000035731.11
Add Fees Token8738412024-12-20 12:48:0317 hrs ago1734698883IN
0xfeE899CF...3e015c236
0 S0.000298731.11
Add Fees Token8737102024-12-20 12:47:1617 hrs ago1734698836IN
0xfeE899CF...3e015c236
0 S0.000298651.11
Add Fees Token8736282024-12-20 12:46:4917 hrs ago1734698809IN
0xfeE899CF...3e015c236
0 S0.00029871.11
Add Fees Token8735362024-12-20 12:46:1717 hrs ago1734698777IN
0xfeE899CF...3e015c236
0 S0.000298651.11
Add Fees Token8734732024-12-20 12:45:5617 hrs ago1734698756IN
0xfeE899CF...3e015c236
0 S0.000298731.11
Add Fees Token8733992024-12-20 12:45:2917 hrs ago1734698729IN
0xfeE899CF...3e015c236
0 S0.000298741.11
Add Fees Token8732032024-12-20 12:44:2317 hrs ago1734698663IN
0xfeE899CF...3e015c236
0 S0.001248651.11
Transfer8727802024-12-20 12:41:5717 hrs ago1734698517IN
0xfeE899CF...3e015c236
43 S0.000024551.11

Latest 12 internal transactions

Parent Transaction Hash Block From To
9882912024-12-21 4:40:021 hr ago1734756002
0xfeE899CF...3e015c236
0.0005638 S
9877572024-12-21 4:30:171 hr ago1734755417
0xfeE899CF...3e015c236
0.00071868 S
9877522024-12-21 4:30:151 hr ago1734755415
0xfeE899CF...3e015c236
0.00081291 S
9877522024-12-21 4:30:151 hr ago1734755415
0xfeE899CF...3e015c236
0.00080846 S
9877522024-12-21 4:30:151 hr ago1734755415
0xfeE899CF...3e015c236
0.0006247 S
9877522024-12-21 4:30:151 hr ago1734755415
0xfeE899CF...3e015c236
0.0008141 S
9877512024-12-21 4:30:141 hr ago1734755414
0xfeE899CF...3e015c236
0.00081411 S
9877512024-12-21 4:30:141 hr ago1734755414
0xfeE899CF...3e015c236
0.00082252 S
9877492024-12-21 4:30:131 hr ago1734755413
0xfeE899CF...3e015c236
0.00038471 S
9877382024-12-21 4:30:011 hr ago1734755401
0xfeE899CF...3e015c236
0.00052015 S
8869522024-12-20 14:21:0115 hrs ago1734704461
0xfeE899CF...3e015c236
0.00043173 S
8854342024-12-20 14:11:0016 hrs ago1734703860
0xfeE899CF...3e015c236
0.00052015 S
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SilverFees

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 10 runs

Other Settings:
paris EvmVersion
File 1 of 26 : SilverFees.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "contracts/Libraries/TransferHelper.sol";

import "contracts/Integrations/Gelato/AutomateTaskCreator.sol";

import "contracts/SilverFees/SilverFeesGiveaway.sol";

struct ExactInputParams {
	bytes path;
	address recipient;
	uint256 deadline;
	uint256 amountIn;
	uint256 amountOutMinimum;
}

interface IAlgebraSwapRouter {
	function exactInput(ExactInputParams memory data) external payable returns (uint256);
}

interface IAlgebraCommunityVault {
	function withdraw(address token, uint256 amount) external;
	function algebraFee() external view returns (uint16);
}

interface IAlgebraPool {
	function communityVault() external view returns (address);
}

interface IAlgebraNFTPositionManager {
	function balanceOf(address owner) external view returns (uint256);
}

// Fees redistribution data
struct FeesRedistributionData {
	uint256 agWeeklyGiveawayAmount;
	uint256 wrappedTokenWeeklyGiveawayAmount;
	uint256 agFlareAmount;
	uint256 wrappedTokenFlareAmount;
	uint256 agSnatchAmount;
	uint256 wrappedTokenSnatchAmount;
}

// Fees management
struct FeesManagementData {
	uint256 teamFees;
	uint256 weeklyGiveawayFees;
	uint256 buybackFees;
	FeesRedistributionData redistributionData;
	mapping (address => bool) flareWhitelistedTokens;
	address[] flareTokenToUnwhitelist;
	uint256 flareProgramPercentage;
	address bannedFlareUser;
	bool flareEnded;
	bool snatchEnded;
	string flareCID;
	string snatchCID;
	bool swapChanged;
	bool swapToWrappedToken;
	uint256 firstExecution;
	uint256 lastExecution;
	bytes32 taskId;
}

// Sync fees management
struct SyncFeesManagementData {
	uint256 time;
	uint256 lastSync;
	uint256 nextSync;
	bytes32 taskId;
}

// Fees converter
struct FeesTokenData {
	mapping(address => bytes32) taskId;
	string scriptCID;
}

// Bid data
struct BidData {
	uint256 amount;
	uint256 timestamp;
}

// Flare datas
struct FlareData {
	address user;
	uint256 bidAmount;
	address buybackToken;
	mapping (address=>BidData) lastBid;
	bytes32 taskId;
}

// Snatch datas
struct SnatchPerPoolData {
	address user;
	uint256 bidAmount;
}

struct SnatchData {
	SnatchPerPoolData perPoolData;
	mapping (address=>BidData) lastBid;
	uint256 lastExecution;
	address bannedUser;
	bytes32 taskId;
}

/// @title SilverFees
/// @author github.com/SifexPro
/// @notice Contract for the fees management of Silver
contract SilverFees is AutomateTaskCreator, Ownable2Step {
	SilverFeesGiveaway public silverFeesGiveaway;

	// Utils variables
	IERC20 public silverToken;
	IERC20 public wrappedToken;
	address public burnAddress;
	address public flareProgramAddress;
	address public teamMultisig;
	IAlgebraSwapRouter public swapRouter;
	IAlgebraCommunityVault public communityVault;
	IAlgebraNFTPositionManager public nftPositionManager;

	// All datas structures
	FeesManagementData public feesManagementData;
	SyncFeesManagementData public syncFeesManagementData;
	FeesTokenData public feesTokenData;
	FlareData public flareData;
	mapping (address => SnatchData) public snatchData;
	mapping(address => bool) public snatchIsPoolBided;
	address[] public snatchPoolsBids;

	// Events
	event FeesManagementExecuted(uint256 forTeam, uint256 forWeeklyGiveaway, uint256 forBuyback);
	event SyncFeesStarted();
	event SyncFeesManagement(uint256 indexed timestamp);
	event TokensBurned(uint256 amount);

	event FeesTokenAdded(address indexed token, bytes32 taskId);
	event FeesTokenRemoved(address indexed token);
	event FeesTokenSwapped(address indexed token, uint256 amountIn, uint256 amountOut);

	event FlareAuction(address indexed user, uint256 auctionAmount);
	event FlareExecution(address indexed user, uint256 buybackAmount, uint256 programAmount);
	event FlareBuyback(address indexed token, uint256 amount);

	event SnatchAuction(address indexed user, address indexed poolToSteal, uint256 auctionAmount);
	event SnatchExecution(address indexed user, address indexed poolToSteal);
	event SnatchSteal(address indexed user, address indexed rewardsPool, address rewardsToken, uint256 rewardsAmount);

	// Events for misc
	event SwapToWrappedToken(bool swapToWrappedToken);
	event SwapTypeChanged();
	event WithdrawnNative(address indexed to, uint256 amount);
	event WithdrawnToken(address indexed token, address to, uint256 amount);
	event EditedTeamMultisig(address indexed teamMultisig);
	event EditedFees(uint256 teamFees, uint256 weeklyGiveawayFees, uint256 buybackFees);

	// Gelato events
	event GelatoTaskCreated(bytes32 id);
	event GelatoTaskCanceled(bytes32 id);
	event GelatoTaskCancelFailed(bytes32 id);
	event GelatoFeesCheck(uint256 fees, address token);
	
	// Constructor
	constructor(address _silver, address _silverFeesGiveaway, address _burnAddress, address _flareProgramAddress, address _swapRouter, address _nftPositionManager, address _communityVault, address _teamMultisig, address _automate, address _wrappedToken, string memory _flareCID, string memory _snatchCID, string memory _feesTokenCID) AutomateTaskCreator(_automate) Ownable(msg.sender) {
		silverToken = IERC20(payable(_silver));
		wrappedToken = IERC20(payable(_wrappedToken));
		burnAddress = _burnAddress;
		flareProgramAddress = _flareProgramAddress;
		teamMultisig = _teamMultisig;
		swapRouter = IAlgebraSwapRouter(payable(_swapRouter));
		communityVault = IAlgebraCommunityVault(payable(_communityVault));
		nftPositionManager = IAlgebraNFTPositionManager(payable(_nftPositionManager));

		silverFeesGiveaway = SilverFeesGiveaway(payable(_silverFeesGiveaway));
		
		feesManagementData.teamFees = 12; // 12% for team
		feesManagementData.weeklyGiveawayFees = 3; // 3% for weekly giveaway
		feesManagementData.buybackFees = 85; // 85% for buyback

		feesManagementData.flareProgramPercentage = 0;

		feesManagementData.flareCID = _flareCID;
		feesManagementData.snatchCID = _snatchCID;
		
		feesManagementData.swapToWrappedToken = true;

		feesTokenData.scriptCID = _feesTokenCID;
    }


	// Fees management

	/**
	 * @dev Main function (to manage the fees) scheduled with Gelato by the sync system (10 min after the last sync) 
	 */
	function executeFeesManagement() public onlyDedicatedMsgSender {
		require(block.timestamp >= feesManagementData.lastExecution + syncFeesManagementData.time - 5 minutes, "Too early");

		// Balance
		uint256 balance;
		if (feesManagementData.swapToWrappedToken)
			balance = tokenAmount(address(wrappedToken)) - feesManagementData.redistributionData.wrappedTokenWeeklyGiveawayAmount - feesManagementData.redistributionData.wrappedTokenFlareAmount - feesManagementData.redistributionData.wrappedTokenSnatchAmount;
		else
			balance = tokenAmount(address(silverToken)) - feesManagementData.redistributionData.agWeeklyGiveawayAmount - feesManagementData.redistributionData.agFlareAmount - feesManagementData.redistributionData.agSnatchAmount;

		// Fees
		uint256 teamFees = (balance * feesManagementData.teamFees) / 100;
		uint256 weeklyGiveawayFees = (balance * feesManagementData.weeklyGiveawayFees) / 100;
		uint256 buybackFees = balance - teamFees - weeklyGiveawayFees;

		uint256 flareFees = buybackFees / 2;
		uint256 snatchFees = buybackFees - flareFees;

		// Redistribution
		if (feesManagementData.swapToWrappedToken) {
			SafeERC20.safeTransfer(wrappedToken, teamMultisig, teamFees);
			feesManagementData.redistributionData.wrappedTokenWeeklyGiveawayAmount += weeklyGiveawayFees;
			feesManagementData.redistributionData.wrappedTokenFlareAmount += flareFees;
			feesManagementData.redistributionData.wrappedTokenSnatchAmount += snatchFees;
		} else {
			SafeERC20.safeTransfer(silverToken, teamMultisig, teamFees);
			feesManagementData.redistributionData.agWeeklyGiveawayAmount += weeklyGiveawayFees;
			feesManagementData.redistributionData.agFlareAmount += flareFees;
			feesManagementData.redistributionData.agSnatchAmount += snatchFees;
		}

		// Giveaway
		if (silverFeesGiveaway.checkExecuteGiveaway())
			drawWinner();

		// Flare
		if (feesManagementData.flareEnded && flareData.user != address(0))
			executeFlare();
		feesManagementData.flareEnded = false;

		// Snatch
		if (feesManagementData.snatchEnded && snatchPoolsBids.length > 0)
		{
			for (uint256 i = 0; i < snatchPoolsBids.length; i++)
			{
				executeSnatch(snatchPoolsBids[i]);
				snatchIsPoolBided[snatchPoolsBids[i]] = false;
			}
			delete snatchPoolsBids;
		}
		feesManagementData.snatchEnded = false;

		// Fees management data update
		if (feesManagementData.swapChanged) {
			feesManagementData.swapChanged = false;
			feesManagementData.swapToWrappedToken = !feesManagementData.swapToWrappedToken;
			emit SwapToWrappedToken(feesManagementData.swapToWrappedToken);
		}
		feesManagementData.lastExecution = block.timestamp;

		// Gelato fees
		(uint256 fee, address feeToken) = _getFeeDetails();

		_transfer(fee, feeToken);
		emit GelatoFeesCheck(fee, feeToken);

		feesManagementData.taskId = bytes32("");
		emit FeesManagementExecuted(teamFees, weeklyGiveawayFees, buybackFees);
	}


	// Sync fees management

	/**
	 * @dev Sync the fees management 
	 */
	function syncFeesManagement() public onlyDedicatedMsgSender {
		silverFeesGiveaway.syncGiveaway(); // Sync the giveaway 

		if (flareData.user != address(0))
			feesManagementData.flareEnded = true; // End the flare auction
		if (snatchPoolsBids.length > 0)
			feesManagementData.snatchEnded = true; // End the snatch auction

		syncFeesManagementData.lastSync = block.timestamp;
		syncFeesManagementData.nextSync = block.timestamp + syncFeesManagementData.time;

		createTaskFeesManagement(); // Create the task for executeFeesManagement() (10 min)

		// Gelato fees
		(uint256 fee, address feeToken) = _getFeeDetails();

		_transfer(fee, feeToken);
		emit GelatoFeesCheck(fee, feeToken);

		emit SyncFeesManagement(block.timestamp);
	}

	/**
	 * @dev Start the sync system
	 * @param time Time between each sync
	 * @notice The sync system will execute the syncFeesManagement() function every time seconds (12 hours by default)
	 */
	function startSyncSystem(uint256 time) public onlyOwner {
		require(time == 0 || time >= 1200, "Time too low");

		syncFeesManagementData.time = time;
		syncFeesManagementData.lastSync = block.timestamp;
		syncFeesManagementData.nextSync = block.timestamp + time;

		feesManagementData.firstExecution = block.timestamp;
		feesManagementData.lastExecution = block.timestamp;
		
		cancelTask(flareData.taskId);

		cancelTask(feesManagementData.taskId);
		cancelTask(syncFeesManagementData.taskId);

		delete flareData;
		for (uint256 i = 0; i < snatchPoolsBids.length; i++)
		{
			cancelTaskSnatch(snatchPoolsBids[i]);
			delete snatchData[snatchPoolsBids[i]].perPoolData;
			snatchData[snatchPoolsBids[i]].lastExecution = 0;
			snatchIsPoolBided[snatchPoolsBids[i]] = false;
		}
		delete snatchPoolsBids;

		feesManagementData.flareEnded = false;
		feesManagementData.snatchEnded = false;

		if (time != 0) {
			silverFeesGiveaway.startSyncGiveaway();
			createTaskSyncSystem();
		}

		emit SyncFeesStarted();
	}

	function syncFeesTime() public view returns (uint256) {
		return syncFeesManagementData.time;
	}

	function syncFeesLastSync() public view returns (uint256) {
		return syncFeesManagementData.lastSync;
	}


	// Tokens fees converter

	/**
	 * @dev Swap the fees token to WrappedToken or $AG
	 * @param tokenAddress Token to swap
	 * @param swapArgs Swap arguments
	 * @notice Executed by a gelato task when SyncFeesManagement event is emitted
	 */
	function swapFeesToken(address tokenAddress, ExactInputParams memory swapArgs) public onlyDedicatedMsgSender {
		uint256 amountIn;
		uint256 amountOut;
		uint256 balanceBefore;
		uint256 balanceAfter;

		if (feesManagementData.swapToWrappedToken)
			balanceBefore = tokenAmount(address(wrappedToken));
		else
			balanceBefore = tokenAmount(address(silverToken));

		communityVault.withdraw(tokenAddress, swapArgs.amountIn);

		if (!(feesManagementData.swapToWrappedToken && tokenAddress == address(wrappedToken) || !feesManagementData.swapToWrappedToken && tokenAddress == address(silverToken))) 
		{
			swapArgs.recipient = payable(address(this));
			swapArgs.amountIn = tokenAmount(tokenAddress);

			TransferHelper.safeApprove(address(tokenAddress), address(swapRouter), swapArgs.amountIn);

			swapRouter.exactInput(swapArgs);
		}

		if (feesManagementData.swapToWrappedToken)
			balanceAfter = tokenAmount(address(wrappedToken));
		else
			balanceAfter = tokenAmount(address(silverToken));

		amountIn = swapArgs.amountIn;
		amountOut = balanceAfter - balanceBefore;

		// Gelato fees
		(uint256 fee, address feeToken) = _getFeeDetails();

		_transfer(fee, feeToken);
		emit GelatoFeesCheck(fee, feeToken);

		emit FeesTokenSwapped(tokenAddress, amountIn, amountOut);
	}

	/**
	 * @dev Add a token to the fees converter system 
	 * @param tokenAddress Token to add
	 * @notice The token must be in the community vault
	 */
	function addFeesToken(address tokenAddress) public onlyOwner {
		require(feesTokenData.taskId[tokenAddress] == bytes32(""), "Already added");

		createTaskFeesToken(tokenAddress);

		bytes32 taskId = feesTokenData.taskId[tokenAddress];
		emit FeesTokenAdded(tokenAddress, taskId);
	}

	function removeFeesToken(address tokenAddress) public onlyOwner {
		require(feesTokenData.taskId[tokenAddress] != bytes32(""), "Not added");

		_cancelTask(feesTokenData.taskId[tokenAddress]);
		feesTokenData.taskId[tokenAddress] = bytes32("");

		emit FeesTokenRemoved(tokenAddress);
	}

	function tokenAmountVault(address tokenAddress) public view returns (uint256) {
		IERC20 token = IERC20(tokenAddress);
        uint256 balance = token.balanceOf(address(communityVault));
        
		return (balance);
	}

	function tokenAmount(address tokenAddress) public view returns (uint256) {
		IERC20 token = IERC20(tokenAddress);
        uint256 balance = token.balanceOf(address(this));
        
		return (balance);
	}

	function isSwapToWrappedToken() public view returns (bool) {
		return (feesManagementData.swapToWrappedToken);
	}

	function feesTokenTaskId(address tokenAddress) public view returns (bytes32) {
		return feesTokenData.taskId[tokenAddress];
	}


	// Weekly giveaway

	/**
	 * @dev Buy tickets for the weekly giveaway
	 * @param _amount Amount in $AG of tickets to buy, by default 1 ticket = 1 $AG
	 */
	function buyTickets(uint256 _amount) public onlyLpUser {
		silverFeesGiveaway.buyTickets(_amount, msg.sender);
	}

	/**
	 * @dev Draw the winner of the weekly giveaway
	 * @notice The winner will receive the weekly giveaway amount
	 */
	function drawWinner() public onlyDedicatedMsgSender {
		bool _isSwapToWrappedToken = feesManagementData.swapToWrappedToken;
		uint256 weeklyGiveawayAmount;

		if (_isSwapToWrappedToken) {
			weeklyGiveawayAmount = feesManagementData.redistributionData.wrappedTokenWeeklyGiveawayAmount;
			feesManagementData.redistributionData.wrappedTokenWeeklyGiveawayAmount = 0;
			TransferHelper.safeApprove(address(wrappedToken), address(silverFeesGiveaway), weeklyGiveawayAmount);
		}
		else {
			weeklyGiveawayAmount = feesManagementData.redistributionData.agWeeklyGiveawayAmount;
			feesManagementData.redistributionData.agWeeklyGiveawayAmount = 0;
			TransferHelper.safeApprove(address(silverToken), address(silverFeesGiveaway), weeklyGiveawayAmount);
		}
		silverFeesGiveaway.executeGiveaway(_isSwapToWrappedToken, weeklyGiveawayAmount);
	}
	
	function buyTicketsBurn(address _user, uint256 _amount) external {
		require(msg.sender == address(silverFeesGiveaway), "Only FeesGiveaway");

		bool success = silverToken.transferFrom(_user, address(this), _amount);
		require(success, "Transfer failed");

		burnTokens(_amount);
	}


	// Flare

	/**
	 * @dev Flare auction
	 * @param _amountToBurn Amount of $AG to burn
	 * @param buybackToken Token to buyback
	 */
	function flare(uint256 _amountToBurn, address buybackToken) public onlyLpUser {
		require(!feesManagementData.flareEnded, "Ended");
		require(feesManagementData.bannedFlareUser != msg.sender, "Banned");
		require(flareIsWhitelistedToken(buybackToken), "Not whitelisted token");

		uint256 rounding = 1 ether / 10;
		uint256 roundAmount = _amountToBurn / rounding;
		uint256 amountToBurn = roundAmount * rounding;

		require(amountToBurn > flareData.bidAmount, "Bid too low");
		require(amountToBurn >= rounding, "< 0.1 $AG");

		uint256 balance = silverToken.balanceOf(msg.sender);
		require(balance >= amountToBurn, "Not enough balance");

		uint256 allowance = silverToken.allowance(msg.sender, address(this));
		require(allowance >= amountToBurn, "Not enough allowance");

		flareData.user = msg.sender;
		flareData.bidAmount = amountToBurn;
		flareData.buybackToken = buybackToken;
		flareData.lastBid[msg.sender] = BidData(amountToBurn, block.timestamp);
		
		emit FlareAuction(msg.sender, amountToBurn);
	}

	/**
	 * @dev Flare's execute function
	 */
	function executeFlare() public onlyDedicatedMsgSender {
		require(feesManagementData.flareEnded, "Too early");

		address user = flareData.user;
		uint256 amountToBurn = flareData.bidAmount;

		uint256 balance = silverToken.balanceOf(user);
		uint256 allowance = silverToken.allowance(user, address(this));
		if (balance < amountToBurn || allowance < amountToBurn) {
			feesManagementData.bannedFlareUser = user;
			delete flareData;
			return;
		}

		bool success = silverToken.transferFrom(user, address(this), amountToBurn);
		require(success, "Transfer failed");
		
		burnTokens(amountToBurn);

		uint256 flareAmountBuyback;
		uint256 flareAmountProgram;
		if (feesManagementData.swapToWrappedToken) {
			flareAmountProgram = (feesManagementData.redistributionData.wrappedTokenFlareAmount * feesManagementData.flareProgramPercentage) / 100;
			flareAmountBuyback = feesManagementData.redistributionData.wrappedTokenFlareAmount - flareAmountProgram;
			
			feesManagementData.redistributionData.wrappedTokenFlareAmount = 0;

			if (flareAmountProgram > 0)
				SafeERC20.safeTransfer(wrappedToken, flareProgramAddress, flareAmountProgram);
		} 
		else {
			flareAmountProgram = (feesManagementData.redistributionData.agFlareAmount * feesManagementData.flareProgramPercentage) / 100;
			flareAmountBuyback = feesManagementData.redistributionData.agFlareAmount - flareAmountProgram;
			
			feesManagementData.redistributionData.agFlareAmount = 0;

			if (flareAmountProgram > 0)
				SafeERC20.safeTransfer(silverToken, flareProgramAddress, flareAmountProgram);
		}
		feesManagementData.bannedFlareUser = address(0);

		address buybackToken = flareData.buybackToken;
		delete flareData;

		createTaskFlareBuyback(buybackToken, flareAmountBuyback);

		emit FlareExecution(user, flareAmountBuyback, flareAmountProgram);
	}

	/**
	 * @dev Flare's buyback function (after the auction when executeFeeManagement is called)
	 * @param tokenToSwap Token to swap
	 * @param swapArgs Swap arguments
	 */
	function flareBuyback(address tokenToSwap, address tokenAddress, ExactInputParams memory swapArgs) public onlyDedicatedMsgSender {
		if (swapArgs.amountIn != 0 && tokenToSwap != tokenAddress && flareIsWhitelistedToken(tokenAddress)) {
			swapArgs.recipient = payable(teamMultisig);

			TransferHelper.safeApprove(address(tokenToSwap), address(swapRouter), swapArgs.amountIn);

			swapRouter.exactInput(swapArgs);
		}
		else if (swapArgs.amountIn != 0 && tokenToSwap == tokenAddress && flareIsWhitelistedToken(tokenAddress)) {
			bool success = IERC20(tokenToSwap).transfer(teamMultisig, swapArgs.amountIn);
			require(success, "Transfer failed");
		}

		for (uint256 i = 0; i < feesManagementData.flareTokenToUnwhitelist.length && i < 10; i++)
			feesManagementData.flareWhitelistedTokens[feesManagementData.flareTokenToUnwhitelist[i]] = false;
		delete feesManagementData.flareTokenToUnwhitelist;

		// Gelato fees
		(uint256 fee, address feeToken) = _getFeeDetails();

		_transfer(fee, feeToken);
		emit GelatoFeesCheck(fee, feeToken);

		flareData.taskId = bytes32("");
		emit FlareBuyback(tokenToSwap, swapArgs.amountIn);
	}

	function flareAddWhitelistedToken(address token) public onlyOwner {
		require(!flareIsWhitelistedToken(token), "Already whitelisted");
		feesManagementData.flareWhitelistedTokens[token] = true;
	}

	function flareRemoveWhitelistedToken(address token) public onlyOwner {
		require(flareIsWhitelistedToken(token), "Not whitelisted");
		if (flareData.buybackToken == token)
			feesManagementData.flareTokenToUnwhitelist.push(token);
		else
			feesManagementData.flareWhitelistedTokens[token] = false;
	}

	function flareIsWhitelistedToken(address token) public view returns (bool) {
		return feesManagementData.flareWhitelistedTokens[token];
	}

	function flareLastBid(address user) public view returns (uint256) {
		if (flareData.lastBid[user].timestamp > feesManagementData.lastExecution)
			return flareData.lastBid[user].amount;
		return 0;
	}


	// Snatch 

	/**
	 * @dev Snatch auction
	 * @param _amountToBurn Amount of $AG to burn
	 * @param poolToSteal Pool to steal 50% of swap fees
	 */
	function snatch(uint256 _amountToBurn, address poolToSteal) public onlyLpUser {
		require(!feesManagementData.snatchEnded, "Ended");
		require(snatchData[poolToSteal].bannedUser != msg.sender, "Banned");
		require(IAlgebraPool(poolToSteal).communityVault() == address(communityVault), "Invalid pool");

		uint256 rounding = 1 ether / 10;
		uint256 roundAmount = _amountToBurn / rounding;
		uint256 amountToBurn = roundAmount * rounding;

		require(amountToBurn > snatchData[poolToSteal].perPoolData.bidAmount, "Bid too low");
		require(amountToBurn >= rounding, "< 0.1 $AG");

		uint256 balance = silverToken.balanceOf(msg.sender);
		require(balance >= amountToBurn, "Not enough balance");

		uint256 allowance = silverToken.allowance(msg.sender, address(this));
		require(allowance >= amountToBurn, "Not enough allowance");

		if (!snatchIsPoolBided[poolToSteal])
		{
			snatchPoolsBids.push(poolToSteal);
			snatchIsPoolBided[poolToSteal] = true;
		}

		if (snatchData[poolToSteal].lastExecution == 0)
			snatchData[poolToSteal].lastExecution = feesManagementData.firstExecution;
		snatchData[poolToSteal].perPoolData.user = msg.sender;
		snatchData[poolToSteal].perPoolData.bidAmount = amountToBurn;
		snatchData[poolToSteal].lastBid[msg.sender] = BidData(amountToBurn, block.timestamp);
		
		emit SnatchAuction(msg.sender, poolToSteal, amountToBurn);
	}

	/**
	 * @dev Snatch's execute function
	 */
	function executeSnatch(address poolToSteal) public onlyDedicatedMsgSender {
		require(feesManagementData.snatchEnded, "Too early");

		address user = snatchData[poolToSteal].perPoolData.user;
		uint256 amountToBurn = snatchData[poolToSteal].perPoolData.bidAmount;

		uint256 balance = silverToken.balanceOf(user);
		uint256 allowance = silverToken.allowance(user, address(this));
		if (balance < amountToBurn || allowance < amountToBurn) {
			snatchData[poolToSteal].bannedUser = user;
			delete snatchData[poolToSteal].perPoolData;
			return;
		}

		bool success = silverToken.transferFrom(user, address(this), amountToBurn);
		require(success, "Transfer failed");
		
		burnTokens(amountToBurn);

		snatchData[poolToSteal].bannedUser = address(0);
		delete snatchData[poolToSteal].perPoolData;

		createTaskSnatchSteal(user, poolToSteal);

		emit SnatchExecution(user, poolToSteal);
	}
	
	/**
	 * @dev Snatch's steal function (after the auction when executeFeeManagement is called)
	 * @param user User to send the rewards
	 * @param rewardsPool Pool to steal
	 * @param rewardsToken Token to send
	 * @param rewardsAmount Amount to send
	 */
	function snatchSteal(address user, address rewardsPool, address rewardsToken, uint256 rewardsAmount) public onlyDedicatedMsgSender {
		if (rewardsToken == address(wrappedToken))
		{
			require(wrappedToken.transfer(user, rewardsAmount), "Transfer failed");
			if (rewardsAmount > feesManagementData.redistributionData.wrappedTokenSnatchAmount)
				feesManagementData.redistributionData.wrappedTokenSnatchAmount = 0;
			else
				feesManagementData.redistributionData.wrappedTokenSnatchAmount -= rewardsAmount;
		}
		else if (rewardsToken == address(silverToken))
		{
			require(silverToken.transfer(user, rewardsAmount), "Transfer failed");
			if (rewardsAmount > feesManagementData.redistributionData.agSnatchAmount)
				feesManagementData.redistributionData.agSnatchAmount = 0;
			else
				feesManagementData.redistributionData.agSnatchAmount -= rewardsAmount;
		}

		snatchData[rewardsPool].lastExecution = block.timestamp;
		snatchData[rewardsPool].taskId = bytes32("");

		// Gelato fees
		(uint256 fee, address feeToken) = _getFeeDetails();

		_transfer(fee, feeToken);
		emit GelatoFeesCheck(fee, feeToken);

		emit SnatchSteal(user, rewardsPool, rewardsToken, rewardsAmount);
	}

	function snatchLastBid(address user, address pool) public view returns (uint256) {
		if (snatchData[pool].lastBid[user].timestamp > feesManagementData.lastExecution)
			return snatchData[pool].lastBid[user].amount;
		return 0;
	}


	// Get allowance

	/**
	 * @dev Get all bids of a user
	 * @param user User to check
	 * @return totalBids Total bids of the user
	 * @notice Include Flare and Snatch bids
	 */
	function getAllBids(address user) public view returns (uint256) {
		uint256 totalBids;

		totalBids += flareLastBid(user);
		for (uint256 i = 0; i < snatchPoolsBids.length; i++)
			totalBids += snatchLastBid(user, snatchPoolsBids[i]);

		return totalBids;
	} 


	// Burn function

	/**
	 * @dev Burn the Silver tokens (send to burn contract)
	 * @param _amount Amount of $AG to burn
	 */
	function burnTokens(uint256 _amount) private {
		require(silverToken.transfer(burnAddress, _amount), "Burn failed");
		
		emit TokensBurned(_amount);
	}


	// Gelato functions

	/**
	 * @dev Create a task for the sync system 
	 * @notice The task will be executed every syncFeesManagementData.time seconds
	 */
	function createTaskSyncSystem() private {
		bytes memory execData = abi.encodeCall(this.syncFeesManagement, ());

		ModuleData memory moduleData = ModuleData({
			modules: new Module[](2),
			args: new bytes[](2)
		});

		moduleData.modules[0] = Module.PROXY;
		moduleData.modules[1] = Module.TRIGGER;
	
		moduleData.args[0] = _proxyModuleArg();
		
		moduleData.args[1] = _timeTriggerModuleArg(
			uint128(syncFeesManagementData.nextSync) * 1000,
			uint128(syncFeesManagementData.time) * 1000
		);

		bytes32 taskId = _createTask(address(this), execData, moduleData, ETH);
	
		syncFeesManagementData.taskId = taskId;
		
		emit GelatoTaskCreated(taskId);
	}
	
	/**
	 * @dev Create task for executeFeesManagement function (SINGLE_EXEC)
	 * @notice Created by the sync system
	 * @notice The task will be executed 10 min after the last sync
	 */
	function createTaskFeesManagement() private {
		uint256 execTime = 10 minutes;
		
		bytes memory execData = abi.encodeCall(this.executeFeesManagement, ());

		ModuleData memory moduleData = ModuleData({
			modules: new Module[](3),
			args: new bytes[](3)
		});

		moduleData.modules[0] = Module.PROXY;
		moduleData.modules[1] = Module.SINGLE_EXEC;
		moduleData.modules[2] = Module.TRIGGER;
	
		moduleData.args[0] = _proxyModuleArg();
		moduleData.args[1] = _singleExecModuleArg();
		moduleData.args[2] = _timeTriggerModuleArg(
			uint128(syncFeesManagementData.lastSync + execTime) * 1000, 
			uint128(execTime) * 1000
		);

		bytes32 taskId = _createTask(address(this), execData, moduleData, ETH);
	
		feesManagementData.taskId = taskId;
		
		emit GelatoTaskCreated(taskId);
	}

	/**
	 * @dev Create task for convert fees token to WrappedToken or $AG
	 * @param tokenAddress Token to convert
	 * @notice Executed by a gelato task when SyncFeesManagement event is emitted
	 */
	function createTaskFeesToken(address tokenAddress) private {
		bytes memory execData = abi.encode( 
			Strings.toHexString(uint256(uint160(address(this))), 20),			// contract address
			Strings.toHexString(uint256(uint160(tokenAddress)), 20),			// tokenAddress
			Strings.toString(ERC20(tokenAddress).decimals()),					// tokenDecimals
			Strings.toHexString(uint256(uint160(address(silverToken))), 20),	// agAddress
			Strings.toHexString(uint256(uint160(address(wrappedToken))), 20),	// wrappedTokenAddress
			Strings.toString(block.chainid)										// network
		);

		ModuleData memory moduleData = ModuleData({
			modules: new Module[](3),
			args: new bytes[](3)
		});

		moduleData.modules[0] = Module.PROXY;
		moduleData.modules[1] = Module.WEB3_FUNCTION;
		moduleData.modules[2] = Module.TRIGGER;
	
		moduleData.args[0] = _proxyModuleArg();
		moduleData.args[1] = _web3FunctionModuleArg(
			feesTokenData.scriptCID,
			execData
		);
		bytes32[][] memory topics = new bytes32[][](1);
		topics[0] = new bytes32[](1);
		topics[0][0] = keccak256("SyncFeesManagement(uint256)");

		moduleData.args[2] = _eventTriggerModuleArg(
			address(this),
           	topics,
			7
		);

		bytes32 taskId = _createTask(address(this), execData, moduleData, ETH);
	
		feesTokenData.taskId[tokenAddress] = taskId;
		
		emit GelatoTaskCreated(taskId);
	}

	/**
	 * @dev Create task for buyback function (after the auction)
	 * @param tokenAddress Token to swap
	 * @param buybackAmount Amount to buyback
	 * @notice Task created when executeFlare is called and executed right after
	 */
	function createTaskFlareBuyback(address tokenAddress, uint256 buybackAmount) private {
		address addressToSwap;
		if (feesManagementData.swapToWrappedToken)
			addressToSwap = address(wrappedToken);
		else
			addressToSwap = address(silverToken);
		
		bytes memory execData = abi.encode( 
			Strings.toHexString(uint256(uint160(address(this))), 20),			// contract address
			Strings.toHexString((uint256(uint160(teamMultisig))), 20), 		 	// teamMultisig
			Strings.toHexString((uint256(uint160(tokenAddress))), 20),			// tokenAddress
			Strings.toString(ERC20(tokenAddress).decimals()),					// tokenDecimals
			Strings.toString(buybackAmount),									// buybackAmount
			Strings.toHexString(uint256(uint160(address(addressToSwap))), 20), 	// addressToSwap
			Strings.toString(block.chainid)										// network
		);

		ModuleData memory moduleData = ModuleData({
			modules: new Module[](3),
			args: new bytes[](3)
		});

		moduleData.modules[0] = Module.PROXY;
		moduleData.modules[1] = Module.SINGLE_EXEC;
		moduleData.modules[2] = Module.WEB3_FUNCTION;
	
		moduleData.args[0] = _proxyModuleArg();
		moduleData.args[1] = _singleExecModuleArg();
		moduleData.args[2] = _web3FunctionModuleArg(
			feesManagementData.flareCID,
			execData
		);

		bytes32 taskId = _createTask(address(this), execData, moduleData, ETH);
	
		flareData.taskId = taskId;
		
		emit GelatoTaskCreated(taskId);
	}

	/**
     * @dev Create task for snatchSteal function (after the auction)
     * @param user User that steal the fees
     * @param poolToSteal Pool from which to steal 50% of swap fees
     * @notice Task is executed right after creation
     */
	function createTaskSnatchSteal(address user, address poolToSteal) private {
		address rewardsToken;
		uint256 timeToSteal = block.timestamp - snatchData[poolToSteal].lastExecution;
		
		if (feesManagementData.swapToWrappedToken)
			rewardsToken = address(wrappedToken);
		else
			rewardsToken = address(silverToken);

		bytes memory execData = abi.encode( 
			Strings.toHexString(uint256(uint160(address(this))), 20),			// contract address
			Strings.toHexString((uint256(uint160(user))), 20), 		 			// userAddress
			Strings.toString(timeToSteal),										// timeToSteal
			Strings.toHexString((uint256(uint160(poolToSteal))), 20),			// poolToSteal
			Strings.toHexString(uint256(uint160(address(rewardsToken))), 20), 	// rewardsToken
			Strings.toString(block.chainid)										// network
		);

		ModuleData memory moduleData = ModuleData({
			modules: new Module[](3),
			args: new bytes[](3)
		});

		moduleData.modules[0] = Module.PROXY;
		moduleData.modules[1] = Module.SINGLE_EXEC;
		moduleData.modules[2] = Module.WEB3_FUNCTION;
	
		moduleData.args[0] = _proxyModuleArg();
		moduleData.args[1] = _singleExecModuleArg();
		moduleData.args[2] = _web3FunctionModuleArg(
			feesManagementData.snatchCID,
			execData
		);

		bytes32 taskId = _createTask(address(this), execData, moduleData, ETH);
	
		snatchData[poolToSteal].taskId = taskId;
		
		emit GelatoTaskCreated(taskId);
	}

	function cancelTaskCall(bytes32 taskId) public {
		require(msg.sender == address(this));
		_cancelTask(taskId);
	}

	/**
	 * @dev Cancel a gelato task
	 * @param taskId Task id to cancel
	 */
	function cancelTask(bytes32 taskId) public onlyOwner {
		if (taskId == bytes32(""))
			return;

		(bool success, ) = address(this).call(
            abi.encodeWithSignature("cancelTaskCall(bytes32)", taskId)
        );

		if (success)
			emit GelatoTaskCanceled(taskId);
		else
			emit GelatoTaskCancelFailed(taskId);

		if (taskId == syncFeesManagementData.taskId)
			syncFeesManagementData.taskId = bytes32("");
		else if (taskId == feesManagementData.taskId)
			feesManagementData.taskId = bytes32("");
		else if (taskId == flareData.taskId)
			flareData.taskId = bytes32("");
	}

	/**
	 * @dev Cancel a gelato task
	 * @param pool Pool to cancel
	 */
	function cancelTaskSnatch(address pool) public onlyOwner {
		bytes32 taskId = snatchData[pool].taskId;
		if (taskId == bytes32(""))
			return;

		(bool success, ) = address(this).call(
            abi.encodeWithSignature("cancelTaskCall(bytes32)", taskId)
        );

		if (success)
			emit GelatoTaskCanceled(taskId);
		else
			emit GelatoTaskCancelFailed(taskId);
			
		snatchData[pool].taskId = bytes32("");
	}

	// Internal functions

	/**
	 * @dev Change the swap fees to WrappedToken or $AG
	 * @param swapToWrappedToken True if swap to WrappedToken, false if swap to $AG
	 * @notice The change is not immediate, it will be applied at the next fees management
	 */
	function setSwapToWrappedToken(bool swapToWrappedToken) public onlyOwner {
		if (feesManagementData.swapToWrappedToken == swapToWrappedToken)
			feesManagementData.swapChanged = false;
		else
			feesManagementData.swapChanged = true;
		
		emit SwapTypeChanged();
	}

	function withdrawNative(address _to) public onlyOwner {
		uint256 balance = address(this).balance;
        require(balance > 0, "No Native to withdraw");

		address payable _tresory = payable(_to);
		(bool success, ) = _tresory.call{value:balance}("");
		require(success, "Transaction failed");

		emit WithdrawnNative(_tresory, balance);
	}

	function withdrawToken(address _token, address _to) public onlyOwner {
		IERC20 token = IERC20(_token);
		uint256 balance = token.balanceOf(address(this));

		SafeERC20.safeTransfer(token, _to, balance);

		emit WithdrawnToken(_token, _to, balance);
	}
	
	function editMultisig(address _teamMultisig) public onlyMultisig {
		teamMultisig = _teamMultisig;

		emit EditedTeamMultisig(_teamMultisig);
	}

	function editSilver(address _silver) public onlyOwner {
		silverToken = IERC20(payable(_silver));
	}

	function editSilverFeesGiveaway(address _silverFeesGiveaway) public onlyOwner {
		silverFeesGiveaway = SilverFeesGiveaway(payable(_silverFeesGiveaway));
	}

	function editwrappedToken(address _wrappedToken) public onlyOwner {
		wrappedToken = IERC20(payable(_wrappedToken));
	}

	function editFlareProgramAddress(address _flareProgramAddress) public onlyOwner {
		flareProgramAddress = _flareProgramAddress;
	}

	function editAlgebraSwapRouter(address _swapRouter) public onlyOwner {
		swapRouter = IAlgebraSwapRouter(payable(_swapRouter));
	}

	function editCommunityVault(address _communityVault) public onlyOwner {
		communityVault = IAlgebraCommunityVault(payable(_communityVault));
	}

	function editNftPositionManager(address _nftPositionManager) public onlyOwner {
		nftPositionManager = IAlgebraNFTPositionManager(payable(_nftPositionManager));
	}

	function editFees(uint256 teamFees, uint256 weeklyGiveawayFees, uint256 buybackFees) public onlyOwner {
		require(teamFees + weeklyGiveawayFees + buybackFees == 100, "Invalid fees");

		feesManagementData.teamFees = teamFees;
		feesManagementData.weeklyGiveawayFees = weeklyGiveawayFees;
		feesManagementData.buybackFees = buybackFees;

		emit EditedFees(teamFees, weeklyGiveawayFees, buybackFees);
	}

	function editFlareProgramPercentage(uint256 flareProgramPercentage) public onlyOwner {
		require(flareProgramPercentage <= 100);
		
		feesManagementData.flareProgramPercentage = flareProgramPercentage;
	}

	function editFlareCID(string memory flareCID) public onlyOwner {
		feesManagementData.flareCID = flareCID;
	}

	function editSnatchCID(string memory snatchCID) public onlyOwner {
		feesManagementData.snatchCID = snatchCID;
	}

	function editFeesTokenCID(string memory scriptCID) public onlyOwner {
		feesTokenData.scriptCID = scriptCID;
	}


	// Modifiers 

	modifier onlyLpUser() {
		require(nftPositionManager.balanceOf(msg.sender) > 0, "Not LP user");
		_;
	}

	modifier onlyMultisig() {
		require(msg.sender == teamMultisig, "Not authorized");
		_;
	}


	// Receive function (to receive Native)

	receive() external payable {}
}

File 2 of 26 : ConfirmedOwner.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ConfirmedOwnerWithProposal} from "./ConfirmedOwnerWithProposal.sol";

/// @title The ConfirmedOwner contract
/// @notice A contract with helpers for basic contract ownership.
contract ConfirmedOwner is ConfirmedOwnerWithProposal {
  constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {}
}

File 3 of 26 : ConfirmedOwnerWithProposal.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IOwnable} from "../interfaces/IOwnable.sol";

/// @title The ConfirmedOwner contract
/// @notice A contract with helpers for basic contract ownership.
contract ConfirmedOwnerWithProposal is IOwnable {
  address private s_owner;
  address private s_pendingOwner;

  event OwnershipTransferRequested(address indexed from, address indexed to);
  event OwnershipTransferred(address indexed from, address indexed to);

  constructor(address newOwner, address pendingOwner) {
    // solhint-disable-next-line gas-custom-errors
    require(newOwner != address(0), "Cannot set owner to zero");

    s_owner = newOwner;
    if (pendingOwner != address(0)) {
      _transferOwnership(pendingOwner);
    }
  }

  /// @notice Allows an owner to begin transferring ownership to a new address.
  function transferOwnership(address to) public override onlyOwner {
    _transferOwnership(to);
  }

  /// @notice Allows an ownership transfer to be completed by the recipient.
  function acceptOwnership() external override {
    // solhint-disable-next-line gas-custom-errors
    require(msg.sender == s_pendingOwner, "Must be proposed owner");

    address oldOwner = s_owner;
    s_owner = msg.sender;
    s_pendingOwner = address(0);

    emit OwnershipTransferred(oldOwner, msg.sender);
  }

  /// @notice Get the current owner
  function owner() public view override returns (address) {
    return s_owner;
  }

  /// @notice validate, transfer ownership, and emit relevant events
  function _transferOwnership(address to) private {
    // solhint-disable-next-line gas-custom-errors
    require(to != msg.sender, "Cannot transfer to self");

    s_pendingOwner = to;

    emit OwnershipTransferRequested(s_owner, to);
  }

  /// @notice validate access
  function _validateOwnership() internal view {
    // solhint-disable-next-line gas-custom-errors
    require(msg.sender == s_owner, "Only callable by owner");
  }

  /// @notice Reverts if called by anyone other than the contract owner.
  modifier onlyOwner() {
    _validateOwnership();
    _;
  }
}

File 4 of 26 : IOwnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOwnable {
  function owner() external returns (address);

  function transferOwnership(address recipient) external;

  function acceptOwnership() external;
}

File 5 of 26 : LinkTokenInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// solhint-disable-next-line interface-starts-with-i
interface LinkTokenInterface {
  function allowance(address owner, address spender) external view returns (uint256 remaining);

  function approve(address spender, uint256 value) external returns (bool success);

  function balanceOf(address owner) external view returns (uint256 balance);

  function decimals() external view returns (uint8 decimalPlaces);

  function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);

  function increaseApproval(address spender, uint256 subtractedValue) external;

  function name() external view returns (string memory tokenName);

  function symbol() external view returns (string memory tokenSymbol);

  function totalSupply() external view returns (uint256 totalTokensIssued);

  function transfer(address to, uint256 value) external returns (bool success);

  function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);

  function transferFrom(address from, address to, uint256 value) external returns (bool success);
}

File 6 of 26 : VRFV2WrapperInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// solhint-disable-next-line interface-starts-with-i
interface VRFV2WrapperInterface {
  /**
   * @return the request ID of the most recent VRF V2 request made by this wrapper. This should only
   * be relied option within the same transaction that the request was made.
   */
  function lastRequestId() external view returns (uint256);

  /**
   * @notice Calculates the price of a VRF request with the given callbackGasLimit at the current
   * @notice block.
   *
   * @dev This function relies on the transaction gas price which is not automatically set during
   * @dev simulation. To estimate the price at a specific gas price, use the estimatePrice function.
   *
   * @param _callbackGasLimit is the gas limit used to estimate the price.
   */
  function calculateRequestPrice(uint32 _callbackGasLimit) external view returns (uint256);

  /**
   * @notice Estimates the price of a VRF request with a specific gas limit and gas price.
   *
   * @dev This is a convenience function that can be called in simulation to better understand
   * @dev pricing.
   *
   * @param _callbackGasLimit is the gas limit used to estimate the price.
   * @param _requestGasPriceWei is the gas price in wei used for the estimation.
   */
  function estimateRequestPrice(uint32 _callbackGasLimit, uint256 _requestGasPriceWei) external view returns (uint256);
}

File 7 of 26 : VRFV2WrapperConsumerBase.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {LinkTokenInterface} from "../shared/interfaces/LinkTokenInterface.sol";
import {VRFV2WrapperInterface} from "./interfaces/VRFV2WrapperInterface.sol";

/** *******************************************************************************
 * @notice Interface for contracts using VRF randomness through the VRF V2 wrapper
 * ********************************************************************************
 * @dev PURPOSE
 *
 * @dev Create VRF V2 requests without the need for subscription management. Rather than creating
 * @dev and funding a VRF V2 subscription, a user can use this wrapper to create one off requests,
 * @dev paying up front rather than at fulfillment.
 *
 * @dev Since the price is determined using the gas price of the request transaction rather than
 * @dev the fulfillment transaction, the wrapper charges an additional premium on callback gas
 * @dev usage, in addition to some extra overhead costs associated with the VRFV2Wrapper contract.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFV2WrapperConsumerBase. The consumer must be funded
 * @dev with enough LINK to make the request, otherwise requests will revert. To request randomness,
 * @dev call the 'requestRandomness' function with the desired VRF parameters. This function handles
 * @dev paying for the request based on the current pricing.
 *
 * @dev Consumers must implement the fullfillRandomWords function, which will be called during
 * @dev fulfillment with the randomness result.
 */
abstract contract VRFV2WrapperConsumerBase {
  // solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i
  LinkTokenInterface internal immutable LINK;
  // solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i
  VRFV2WrapperInterface internal immutable VRF_V2_WRAPPER;

  /**
   * @param _link is the address of LinkToken
   * @param _vrfV2Wrapper is the address of the VRFV2Wrapper contract
   */
  constructor(address _link, address _vrfV2Wrapper) {
    LINK = LinkTokenInterface(_link);
    VRF_V2_WRAPPER = VRFV2WrapperInterface(_vrfV2Wrapper);
  }

  /**
   * @dev Requests randomness from the VRF V2 wrapper.
   *
   * @param _callbackGasLimit is the gas limit that should be used when calling the consumer's
   *        fulfillRandomWords function.
   * @param _requestConfirmations is the number of confirmations to wait before fulfilling the
   *        request. A higher number of confirmations increases security by reducing the likelihood
   *        that a chain re-org changes a published randomness outcome.
   * @param _numWords is the number of random words to request.
   *
   * @return requestId is the VRF V2 request ID of the newly created randomness request.
   */
  // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
  function requestRandomness(
    uint32 _callbackGasLimit,
    uint16 _requestConfirmations,
    uint32 _numWords
  ) internal returns (uint256 requestId) {
    LINK.transferAndCall(
      address(VRF_V2_WRAPPER),
      VRF_V2_WRAPPER.calculateRequestPrice(_callbackGasLimit),
      abi.encode(_callbackGasLimit, _requestConfirmations, _numWords)
    );
    return VRF_V2_WRAPPER.lastRequestId();
  }

  /**
   * @notice fulfillRandomWords handles the VRF V2 wrapper response. The consuming contract must
   * @notice implement it.
   *
   * @param _requestId is the VRF V2 request ID.
   * @param _randomWords is the randomness result.
   */
  // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore
  function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal virtual;

  function rawFulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) external {
    // solhint-disable-next-line gas-custom-errors
    require(msg.sender == address(VRF_V2_WRAPPER), "only VRF V2 wrapper can fulfill");
    fulfillRandomWords(_requestId, _randomWords);
  }
}

File 8 of 26 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

File 9 of 26 : Ownable2Step.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)

pragma solidity ^0.8.20;

import {Ownable} from "./Ownable.sol";

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

    event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Returns the address of the pending owner.
     */
    function pendingOwner() public view virtual returns (address) {
        return _pendingOwner;
    }

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}

File 10 of 26 : draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

File 11 of 26 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * 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.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * 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 returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual 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 default value returned by this function, unless
     * it's 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 returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual 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 `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` 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 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        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 `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` 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.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` 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.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     * ```
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

File 12 of 26 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
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);
}

File 13 of 26 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @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.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
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].
     *
     * CAUTION: See Security Considerations above.
     */
    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);
}

File 14 of 26 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

File 15 of 26 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../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;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @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);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 16 of 26 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @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 or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * 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.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @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`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // 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 FailedInnerCall();
        }
    }
}

File 17 of 26 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 18 of 26 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 19 of 26 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 20 of 26 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        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_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        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);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

File 21 of 26 : AutomateModuleHelper.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.14;

import "./Types.sol";

abstract contract AutomateModuleHelper {
    function _resolverModuleArg(
        address _resolverAddress,
        bytes memory _resolverData
    ) internal pure returns (bytes memory) {
        return abi.encode(_resolverAddress, _resolverData);
    }

    function _proxyModuleArg() internal pure returns (bytes memory) {
        return bytes("");
    }

    function _singleExecModuleArg() internal pure returns (bytes memory) {
        return bytes("");
    }

    function _web3FunctionModuleArg(
        string memory _web3FunctionHash,
        bytes memory _web3FunctionArgsHex
    ) internal pure returns (bytes memory) {
        return abi.encode(_web3FunctionHash, _web3FunctionArgsHex);
    }

    function _timeTriggerModuleArg(uint128 _start, uint128 _interval)
        internal
        pure
        returns (bytes memory)
    {
        bytes memory triggerConfig = abi.encode(_start, _interval);

        return abi.encode(TriggerType.TIME, triggerConfig);
    }

    function _cronTriggerModuleArg(string memory _expression)
        internal
        pure
        returns (bytes memory)
    {
        bytes memory triggerConfig = abi.encode(_expression);

        return abi.encode(TriggerType.CRON, triggerConfig);
    }

    function _eventTriggerModuleArg(
        address _address,
        bytes32[][] memory _topics,
        uint256 _blockConfirmations
    ) internal pure returns (bytes memory) {
        bytes memory triggerConfig = abi.encode(
            _address,
            _topics,
            _blockConfirmations
        );

        return abi.encode(TriggerType.EVENT, triggerConfig);
    }

    function _blockTriggerModuleArg() internal pure returns (bytes memory) {
        bytes memory triggerConfig = abi.encode(bytes(""));

        return abi.encode(TriggerType.BLOCK, triggerConfig);
    }
}

File 22 of 26 : AutomateReady.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.14;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./Types.sol";

/**
 * @dev Inherit this contract to allow your smart contract to
 * - Make synchronous fee payments.
 * - Have call restrictions for functions to be automated.
 */
// solhint-disable private-vars-leading-underscore
abstract contract AutomateReady {
    IAutomate public immutable automate;
    address public immutable dedicatedMsgSender;
    address private immutable feeCollector;
    address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    /**
     * @dev
     * Only tasks created by _taskCreator defined in constructor can call
     * the functions with this modifier.
     */
    modifier onlyDedicatedMsgSender() {
        require(msg.sender == dedicatedMsgSender, "Only dedicated msg.sender");
        _;
    }

    /**
     * @dev
     * _taskCreator is the address which will create tasks for this contract.
     */
    constructor(address _automate, address _taskCreator) {
        automate = IAutomate(_automate);
        IGelato gelato = IGelato(IAutomate(_automate).gelato());

        feeCollector = gelato.feeCollector();

        address proxyModuleAddress = IAutomate(_automate).taskModuleAddresses(
            Module.PROXY
        );

        address opsProxyFactoryAddress = IProxyModule(proxyModuleAddress)
            .opsProxyFactory();

        (dedicatedMsgSender, ) = IOpsProxyFactory(opsProxyFactoryAddress)
            .getProxyOf(_taskCreator);
    }

    /**
     * @dev
     * Transfers fee to gelato for synchronous fee payments.
     *
     * _fee & _feeToken should be queried from IAutomate.getFeeDetails()
     */
    function _transfer(uint256 _fee, address _feeToken) internal {
        if (_feeToken == ETH) {
            (bool success, ) = feeCollector.call{value: _fee}("");
            require(success, "_transfer: ETH transfer failed");
        } else {
            SafeERC20.safeTransfer(IERC20(_feeToken), feeCollector, _fee);
        }
    }

    function _getFeeDetails()
        internal
        view
        returns (uint256 fee, address feeToken)
    {
        (fee, feeToken) = automate.getFeeDetails();
    }
}

File 23 of 26 : AutomateTaskCreator.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.14;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./AutomateReady.sol";
import {AutomateModuleHelper} from "./AutomateModuleHelper.sol";

/**
 * @dev Inherit this contract to allow your smart contract
 * to be a task creator and create tasks.
 */
//solhint-disable const-name-snakecase
//solhint-disable no-empty-blocks
abstract contract AutomateTaskCreator is AutomateModuleHelper, AutomateReady {
    using SafeERC20 for IERC20;

    IGelato1Balance public constant gelato1Balance =
        IGelato1Balance(0x7506C12a824d73D9b08564d5Afc22c949434755e);

    constructor(address _automate) AutomateReady(_automate, address(this)) {}

    function _depositFunds1Balance(
        uint256 _amount,
        address _token,
        address _sponsor
    ) internal {
        if (_token == ETH) {
            ///@dev Only deposit ETH on goerli for now.
            require(block.chainid == 5, "Only deposit ETH on goerli");
            gelato1Balance.depositNative{value: _amount}(_sponsor);
        } else {
            ///@dev Only deposit USDC on polygon for now.
            require(
                block.chainid == 137 &&
                    _token ==
                    address(0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174),
                "Only deposit USDC on polygon"
            );
            IERC20(_token).approve(address(gelato1Balance), _amount);
            gelato1Balance.depositToken(_sponsor, _token, _amount);
        }
    }

    function _createTask(
        address _execAddress,
        bytes memory _execDataOrSelector,
        ModuleData memory _moduleData,
        address _feeToken
    ) internal returns (bytes32) {
        return
            automate.createTask(
                _execAddress,
                _execDataOrSelector,
                _moduleData,
                _feeToken
            );
    }

    function _cancelTask(bytes32 _taskId) internal {
        automate.cancelTask(_taskId);
    }
}

File 24 of 26 : Types.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.12;

enum Module {
    RESOLVER,
    DEPRECATED_TIME,
    PROXY,
    SINGLE_EXEC,
    WEB3_FUNCTION,
    TRIGGER
}

enum TriggerType {
    TIME,
    CRON,
    EVENT,
    BLOCK
}

struct ModuleData {
    Module[] modules;
    bytes[] args;
}

interface IAutomate {
    function createTask(
        address execAddress,
        bytes calldata execDataOrSelector,
        ModuleData calldata moduleData,
        address feeToken
    ) external returns (bytes32 taskId);

    function cancelTask(bytes32 taskId) external;

    function getFeeDetails() external view returns (uint256, address);

    function gelato() external view returns (address payable);

    function taskModuleAddresses(Module) external view returns (address);
}

interface IProxyModule {
    function opsProxyFactory() external view returns (address);
}

interface IOpsProxyFactory {
    function getProxyOf(address account) external view returns (address, bool);
}

interface IGelato1Balance {
    function depositNative(address _sponsor) external payable;

    function depositToken(
        address _sponsor,
        address _token,
        uint256 _amount
    ) external;
}

interface IGelato {
    function feeCollector() external view returns (address);
}

File 25 of 26 : TransferHelper.sol
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.6.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';

/// @dev Credit to Uniswap Labs under GPL-2.0-or-later license:
/// https://github.com/Uniswap/v3-periphery
library TransferHelper {
    /// @notice Transfers tokens from the targeted address to the given destination
    /// @notice Errors with 'STF' if transfer fails
    /// @param token The contract address of the token to be transferred
    /// @param from The originating address from which the tokens will be transferred
    /// @param to The destination address of the transfer
    /// @param value The amount to be transferred
    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(
            abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value)
        );
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF');
    }

    /// @notice Transfers tokens from msg.sender to a recipient
    /// @dev Errors with ST if transfer fails
    /// @param token The contract address of the token which will be transferred
    /// @param to The recipient of the transfer
    /// @param value The value of the transfer
    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST');
    }

    /// @notice Approves the stipulated contract to spend the given allowance in the given token
    /// @dev Errors with 'SA' if transfer fails
    /// @param token The contract address of the token to be approved
    /// @param to The target of the approval
    /// @param value The amount of the given token the target will be allowed to spend
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value));
        require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA');
    }

    /// @notice Transfers NativeToken to the recipient address
    /// @dev Fails with `STE`
    /// @param to The destination of the transfer
    /// @param value The value to be transferred
    function safeTransferNative(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'STE');
    }
}

File 26 of 26 : SilverFeesGiveaway.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";

import "@chainlink/contracts/src/v0.8/vrf/VRFV2WrapperConsumerBase.sol";
import "@chainlink/contracts/src/v0.8/shared/access/ConfirmedOwner.sol";

import 'contracts/SilverFees/SilverFees.sol';

// User's tickets
struct UserTickets {
	uint256 tickets;
	uint256 timestamp;
}

// User's tickets data
struct GiveawayTicketsData {
	mapping(address => UserTickets) userTickets;
	uint256 lastExecution;
}

// Weekly giveaway
struct GiveawayData {
	address[] giveawayParticipants;
	uint256 numberOfParticipants;
	bool participationEnded;
	uint256 giveawayEndTime;
}

// Giveaway settings
struct GiveawaySettings {
	bool isGiveawayActive;
	uint256 ticketPrice;
	uint256 giveawayTime;
	bool editedActive;
	uint256 editedTicketPrice;
	uint256 editedGiveawayTime;
}

// Chainlink VRF datas
struct RequestStatus {
	uint256 paid;
	bool fulfilled;
	uint256[] randomWords;
}

// Chainlink VRF inputs
struct RequestInput {
	uint32 callbackGasLimit;
	uint16 requestConfirmations;
	uint32 numWords;
}

/// @title SilverFeesGiveaway
/// @author github.com/SifexPro
/// @notice This contract take care of the weekly giveaway
contract SilverFeesGiveaway is Ownable2Step, VRFV2WrapperConsumerBase {
	SilverFees public silverFees;

	GiveawayData public giveawayData;
	GiveawayTicketsData public giveawayTicketsData;

	GiveawaySettings public giveawaySettings;

	RequestStatus public s_request;
	RequestInput public s_input;
    uint256 private requestId;

	event GiveawaySyncStarted(uint256 ticketPrice, uint256 giveawayEndTime);
	event GiveawaySynced();

	event GiveawayExecuted(bool isGiveawayActive, uint256 weeklyGiveawayAmount);
	event BuyTickets(address indexed account, uint256 amount, uint256 tickets);
	event DrawWinner(address indexed winner, uint256 amount, uint256 randomIndex);

	event RequestSent(uint256 requestId, uint32 numWords);
    event RequestFulfilled(uint256 requestId, uint256[] randomWords, uint256 payment);

	event EditedSilverFees(address silverFees);
	event EditedGiveawayTicketPrice(uint256 ticketPrice);
	event EditedGiveawayTime(uint256 giveawayTime);
	event EditedGiveawayActive(bool isGiveawayActive);
	event StartedGiveaway(uint256 ticketPrice, uint256 giveawayEndTime);
	event StoppedGiveaway();

	event WithdrawnToken(address indexed token, address to, uint256 amount);


	constructor(address _link, address _wrapper) Ownable(msg.sender) VRFV2WrapperConsumerBase(_link, _wrapper) {
		s_input.callbackGasLimit = 500000;
    	s_input.requestConfirmations = 7;
    	s_input.numWords = 1;

		giveawaySettings = GiveawaySettings(true, 1 ether, 1 weeks, false, 0, 0);
	}


	// Fees management

	/**
	 * @dev Check if the giveaway can be executed
	 * @notice Will return true : if the giveaway is over and s_request is fulfilled, or if the giveaway is not active
	 */
	function checkExecuteGiveaway() external onlySilverFees view returns (bool) {
		return ((giveawayData.participationEnded && s_request.fulfilled) || !giveawaySettings.isGiveawayActive);
	}

	/**
	 * @dev Execute the giveaway
	 * @param isSwapToWrappedToken If the giveaway is in wrapped native token
	 * @param weeklyGiveawayAmount Amount to giveaway
	 * @notice Will draw a winner if the giveaway is active, otherwise will transfer the amount to the contract
	 */
	function executeGiveaway(bool isSwapToWrappedToken, uint256 weeklyGiveawayAmount) external onlySilverFees {
		if (giveawaySettings.isGiveawayActive && s_request.fulfilled)
			drawWinner(isSwapToWrappedToken, weeklyGiveawayAmount);
		else if (!giveawaySettings.isGiveawayActive) {
			bool success;
			if (isSwapToWrappedToken)
				success = silverFees.wrappedToken().transferFrom(address(silverFees), address(this), weeklyGiveawayAmount);
			else
				success = silverFees.silverToken().transferFrom(address(silverFees), address(this), weeklyGiveawayAmount);
			require(success, "Transfer failed");
		}

		if (!giveawaySettings.isGiveawayActive || (giveawaySettings.isGiveawayActive && s_request.fulfilled))
			applyEditedSettings();

		emit GiveawayExecuted(giveawaySettings.isGiveawayActive, weeklyGiveawayAmount);
	}


	// Sync Fees Management 

	/**
	 * @dev Start the giveaway sync
	 */
	function startSyncGiveaway() public onlySilverFees {
		applyEditedSettings();

		giveawayData = GiveawayData(new address[](0), 0, false, silverFees.syncFeesLastSync() + giveawaySettings.giveawayTime);
		
		emit GiveawaySyncStarted(giveawaySettings.ticketPrice, giveawayData.giveawayEndTime);
	}

	/**
	 * @dev Sync the giveaway
	 */
	function syncGiveaway() external onlySilverFees {
		if (!giveawaySettings.isGiveawayActive) return;
		uint256 syncTime = silverFees.syncFeesTime();
		uint256 giveawayTime = giveawaySettings.giveawayTime;

		bool giveawayTimeCheck = block.timestamp + (syncTime / 2) >= giveawayData.giveawayEndTime;
		if (giveawayTimeCheck && giveawayData.numberOfParticipants > 0 && requestId == 0) { // Check if the giveaway is over and no request is sent
			requestRandomWords();
			giveawayData.participationEnded = true;
		} else if (giveawayTimeCheck && giveawayData.numberOfParticipants == 0) { // Check if the giveaway is over and no participants
			giveawaySettings.editedGiveawayTime = giveawayTime;
			applyEditedSettings();
		} else if (giveawayTimeCheck && giveawayData.participationEnded && block.timestamp > giveawayData.giveawayEndTime + (2 * syncTime)) { // Check if the giveaway is over and still not executed after 2 sync 
			clearRequest();
			giveawayData.participationEnded = false;

			giveawaySettings.editedGiveawayTime = giveawayTime;
			applyEditedSettings();
		}

		emit GiveawaySynced();
	}


	// Weekly giveaway

	/**
	 * @dev Buy tickets for the giveaway
	 * @param _amount Amount of tokens to buy tickets
	 * @param user Address of the user
	 * @notice Will buy tickets for the user if the giveaway is active and not ended
	 */
	function buyTickets(uint256 _amount, address user) external onlySilverFees {
		require(giveawaySettings.isGiveawayActive, "Giveaway not active");
		require(!giveawayData.participationEnded, "Ended");
		require(_amount >= giveawaySettings.ticketPrice, "Price too low");
		
		uint256 amount = _amount;
		uint256 tokenAmountIn = _amount / giveawaySettings.ticketPrice;
		if (_amount > giveawaySettings.ticketPrice) {
			amount = tokenAmountIn * giveawaySettings.ticketPrice;
		}

		uint256 balance = silverFees.silverToken().balanceOf(user);
		require(balance >= amount, "Not enough balance");

		uint256 allowance = silverFees.silverToken().allowance(user, address(silverFees));
		require(allowance >= amount, 'Not enough allowance');

		silverFees.buyTicketsBurn(user, amount);

		for (uint256 i = 0; i < tokenAmountIn; i++)
			giveawayData.giveawayParticipants.push(user);
		giveawayData.numberOfParticipants = giveawayData.giveawayParticipants.length;

		giveawayTicketsData.userTickets[user] = UserTickets(userTickets(user) + tokenAmountIn, block.timestamp);

		emit BuyTickets(user, amount, tokenAmountIn);
	}

	/**
	 * @dev Draw a winner for the giveaway
	 * @param isSwapToWrappedToken If the giveaway is in wrapped native token
	 * @param weeklyGiveawayAmount Amount to giveaway
	 * @notice Will draw a winner if the giveaway is active and ended
	 */
	function drawWinner(bool isSwapToWrappedToken, uint256 weeklyGiveawayAmount) private {
		require(giveawayData.participationEnded, "Too early");
		require(giveawayData.numberOfParticipants > 0, "0 participants");

		uint256 winnerIndex = getRandomIndex(giveawayData.numberOfParticipants);
		address winner = giveawayData.giveawayParticipants[winnerIndex];
		uint256 giveawayAmount = weeklyGiveawayAmount;
		
		bool success;
		if (isSwapToWrappedToken)
			success = silverFees.wrappedToken().transferFrom(address(silverFees), winner, giveawayAmount);
		else
			success = silverFees.silverToken().transferFrom(address(silverFees), winner, giveawayAmount);
		require(success, "Transfer failed");

		// Reset giveaway
		giveawayData.participationEnded = false;
		giveawayData.giveawayEndTime = silverFees.syncFeesLastSync() + giveawaySettings.giveawayTime;
		giveawayData.giveawayParticipants = new address[](0);
		giveawayData.numberOfParticipants = 0;
		clearRequest();

		giveawayTicketsData.lastExecution = block.timestamp;

		emit DrawWinner(winner, giveawayAmount, winnerIndex);
	}

	function getRandomIndex(uint256 lenght) private view returns (uint256 _randomWords) {
        uint256 randomWords = s_request.randomWords[0] % lenght;
		return (randomWords);
    }


	// User tickets

	/**
	 * @dev Get the user's tickets
	 * @param user Address of the user
	 * @return Number of tickets
	 */
	function userTickets(address user) public view returns (uint256) {
		if (giveawayTicketsData.userTickets[user].timestamp > giveawayTicketsData.lastExecution && giveawaySettings.isGiveawayActive)
			return giveawayTicketsData.userTickets[user].tickets;
		return 0;
	}


	// Internal functions

	function withdrawToken(address _token, address _to) public onlyOwner {
		IERC20 token = IERC20(_token);
		uint256 balance = token.balanceOf(address(this));

		SafeERC20.safeTransfer(token, _to, balance);

		emit WithdrawnToken(_token, _to, balance);
	}

	function applyEditedSettings() private {
		if (giveawaySettings.editedTicketPrice != 0)
		{
			giveawaySettings.ticketPrice = giveawaySettings.editedTicketPrice;
			giveawaySettings.editedTicketPrice = 0;
		}

		if (giveawaySettings.editedGiveawayTime != 0)
		{
			giveawayData.giveawayEndTime = silverFees.syncFeesLastSync() + giveawaySettings.editedGiveawayTime;
			giveawaySettings.giveawayTime = giveawaySettings.editedGiveawayTime;
			giveawaySettings.editedGiveawayTime = 0;
		}

		if (giveawaySettings.editedActive)
		{
			giveawaySettings.isGiveawayActive = !giveawaySettings.isGiveawayActive;
			giveawaySettings.editedActive = false;

			if (giveawaySettings.isGiveawayActive)
			{
				giveawayData.giveawayEndTime = silverFees.syncFeesLastSync() + giveawaySettings.giveawayTime;
				emit StartedGiveaway(giveawaySettings.ticketPrice, giveawayData.giveawayEndTime);
			}
			else 
				emit StoppedGiveaway();
		}
	}

	function editSilverFees(address _silverFees) public onlyOwner {
		silverFees = SilverFees(payable(_silverFees));
		
		emit EditedSilverFees(_silverFees);
	}

	function editGiveawayTicketPrice(uint256 _ticketPrice) public onlyOwner {
		giveawaySettings.editedTicketPrice = _ticketPrice;
		
		emit EditedGiveawayTicketPrice(_ticketPrice);
	}

	function editGiveawayTime(uint256 _giveawayTime) public onlyOwner {
		giveawaySettings.editedGiveawayTime = _giveawayTime;
		
		emit EditedGiveawayTime(_giveawayTime);
	}

	function setActiveGiveaway(bool _giveawayActive) public onlyOwner {
		if (giveawaySettings.isGiveawayActive == _giveawayActive)
			giveawaySettings.editedActive = false;
		else
			giveawaySettings.editedActive = true;

		emit EditedGiveawayActive(_giveawayActive);
	}


	// Chainlink VRF

	function requestRandomWords() private returns (uint256 _requestId) {
		require(requestId == 0, "already sent");
        requestId = requestRandomness(s_input.callbackGasLimit, s_input.requestConfirmations, s_input.numWords);
        s_request = RequestStatus({
            paid: VRF_V2_WRAPPER.calculateRequestPrice(s_input.callbackGasLimit),
            randomWords: new uint256[](0),
            fulfilled: false
        });
        emit RequestSent(requestId, s_input.numWords);
        return requestId;
    }

    function fulfillRandomWords(uint256 _requestId, uint256[] memory _randomWords) internal override {
        require(s_request.paid > 0, "request not found");
		require(_requestId == requestId, "request id mismatch");
        s_request.fulfilled = true;
        s_request.randomWords = _randomWords;
        emit RequestFulfilled(_requestId, _randomWords, s_request.paid);
    }

	function clearRequest() private {
		requestId = 0;
		s_request = RequestStatus({
			paid: 0,
			randomWords: new uint256[](0),
			fulfilled: false
		});
	}


	// Modifiers 

	modifier onlySilverFees() {
		require(msg.sender == address(silverFees), 'Only SilverFees');
		_;
	}
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": true,
    "runs": 10
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_silver","type":"address"},{"internalType":"address","name":"_silverFeesGiveaway","type":"address"},{"internalType":"address","name":"_burnAddress","type":"address"},{"internalType":"address","name":"_flareProgramAddress","type":"address"},{"internalType":"address","name":"_swapRouter","type":"address"},{"internalType":"address","name":"_nftPositionManager","type":"address"},{"internalType":"address","name":"_communityVault","type":"address"},{"internalType":"address","name":"_teamMultisig","type":"address"},{"internalType":"address","name":"_automate","type":"address"},{"internalType":"address","name":"_wrappedToken","type":"address"},{"internalType":"string","name":"_flareCID","type":"string"},{"internalType":"string","name":"_snatchCID","type":"string"},{"internalType":"string","name":"_feesTokenCID","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"StringsInsufficientHexLength","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"teamFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"weeklyGiveawayFees","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"buybackFees","type":"uint256"}],"name":"EditedFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"teamMultisig","type":"address"}],"name":"EditedTeamMultisig","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"forTeam","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"forWeeklyGiveaway","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"forBuyback","type":"uint256"}],"name":"FeesManagementExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bytes32","name":"taskId","type":"bytes32"}],"name":"FeesTokenAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"}],"name":"FeesTokenRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"}],"name":"FeesTokenSwapped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"auctionAmount","type":"uint256"}],"name":"FlareAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FlareBuyback","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"buybackAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"programAmount","type":"uint256"}],"name":"FlareExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"fees","type":"uint256"},{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"GelatoFeesCheck","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"GelatoTaskCancelFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"GelatoTaskCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"GelatoTaskCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"poolToSteal","type":"address"},{"indexed":false,"internalType":"uint256","name":"auctionAmount","type":"uint256"}],"name":"SnatchAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"poolToSteal","type":"address"}],"name":"SnatchExecution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"rewardsPool","type":"address"},{"indexed":false,"internalType":"address","name":"rewardsToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardsAmount","type":"uint256"}],"name":"SnatchSteal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"swapToWrappedToken","type":"bool"}],"name":"SwapToWrappedToken","type":"event"},{"anonymous":false,"inputs":[],"name":"SwapTypeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"SyncFeesManagement","type":"event"},{"anonymous":false,"inputs":[],"name":"SyncFeesStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TokensBurned","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnNative","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnToken","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"addFeesToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"automate","outputs":[{"internalType":"contract IAutomate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"burnAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"buyTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"buyTicketsBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"name":"cancelTask","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"name":"cancelTaskCall","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pool","type":"address"}],"name":"cancelTaskSnatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"communityVault","outputs":[{"internalType":"contract IAlgebraCommunityVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dedicatedMsgSender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"drawWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_swapRouter","type":"address"}],"name":"editAlgebraSwapRouter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_communityVault","type":"address"}],"name":"editCommunityVault","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"teamFees","type":"uint256"},{"internalType":"uint256","name":"weeklyGiveawayFees","type":"uint256"},{"internalType":"uint256","name":"buybackFees","type":"uint256"}],"name":"editFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"scriptCID","type":"string"}],"name":"editFeesTokenCID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"flareCID","type":"string"}],"name":"editFlareCID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_flareProgramAddress","type":"address"}],"name":"editFlareProgramAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"flareProgramPercentage","type":"uint256"}],"name":"editFlareProgramPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_teamMultisig","type":"address"}],"name":"editMultisig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftPositionManager","type":"address"}],"name":"editNftPositionManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_silver","type":"address"}],"name":"editSilver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_silverFeesGiveaway","type":"address"}],"name":"editSilverFeesGiveaway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"snatchCID","type":"string"}],"name":"editSnatchCID","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wrappedToken","type":"address"}],"name":"editwrappedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"executeFeesManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"executeFlare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"poolToSteal","type":"address"}],"name":"executeSnatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feesManagementData","outputs":[{"internalType":"uint256","name":"teamFees","type":"uint256"},{"internalType":"uint256","name":"weeklyGiveawayFees","type":"uint256"},{"internalType":"uint256","name":"buybackFees","type":"uint256"},{"components":[{"internalType":"uint256","name":"agWeeklyGiveawayAmount","type":"uint256"},{"internalType":"uint256","name":"wrappedTokenWeeklyGiveawayAmount","type":"uint256"},{"internalType":"uint256","name":"agFlareAmount","type":"uint256"},{"internalType":"uint256","name":"wrappedTokenFlareAmount","type":"uint256"},{"internalType":"uint256","name":"agSnatchAmount","type":"uint256"},{"internalType":"uint256","name":"wrappedTokenSnatchAmount","type":"uint256"}],"internalType":"struct FeesRedistributionData","name":"redistributionData","type":"tuple"},{"internalType":"uint256","name":"flareProgramPercentage","type":"uint256"},{"internalType":"address","name":"bannedFlareUser","type":"address"},{"internalType":"bool","name":"flareEnded","type":"bool"},{"internalType":"bool","name":"snatchEnded","type":"bool"},{"internalType":"string","name":"flareCID","type":"string"},{"internalType":"string","name":"snatchCID","type":"string"},{"internalType":"bool","name":"swapChanged","type":"bool"},{"internalType":"bool","name":"swapToWrappedToken","type":"bool"},{"internalType":"uint256","name":"firstExecution","type":"uint256"},{"internalType":"uint256","name":"lastExecution","type":"uint256"},{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feesTokenData","outputs":[{"internalType":"string","name":"scriptCID","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"feesTokenTaskId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToBurn","type":"uint256"},{"internalType":"address","name":"buybackToken","type":"address"}],"name":"flare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"flareAddWhitelistedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenToSwap","type":"address"},{"internalType":"address","name":"tokenAddress","type":"address"},{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct ExactInputParams","name":"swapArgs","type":"tuple"}],"name":"flareBuyback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flareData","outputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"bidAmount","type":"uint256"},{"internalType":"address","name":"buybackToken","type":"address"},{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"flareIsWhitelistedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"flareLastBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flareProgramAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"flareRemoveWhitelistedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gelato1Balance","outputs":[{"internalType":"contract IGelato1Balance","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getAllBids","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isSwapToWrappedToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftPositionManager","outputs":[{"internalType":"contract IAlgebraNFTPositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"removeFeesToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"swapToWrappedToken","type":"bool"}],"name":"setSwapToWrappedToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"silverFeesGiveaway","outputs":[{"internalType":"contract SilverFeesGiveaway","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"silverToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToBurn","type":"uint256"},{"internalType":"address","name":"poolToSteal","type":"address"}],"name":"snatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"snatchData","outputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"bidAmount","type":"uint256"}],"internalType":"struct SnatchPerPoolData","name":"perPoolData","type":"tuple"},{"internalType":"uint256","name":"lastExecution","type":"uint256"},{"internalType":"address","name":"bannedUser","type":"address"},{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"snatchIsPoolBided","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"pool","type":"address"}],"name":"snatchLastBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"snatchPoolsBids","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"rewardsPool","type":"address"},{"internalType":"address","name":"rewardsToken","type":"address"},{"internalType":"uint256","name":"rewardsAmount","type":"uint256"}],"name":"snatchSteal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"startSyncSystem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"components":[{"internalType":"bytes","name":"path","type":"bytes"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"uint256","name":"amountOutMinimum","type":"uint256"}],"internalType":"struct ExactInputParams","name":"swapArgs","type":"tuple"}],"name":"swapFeesToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract IAlgebraSwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"syncFeesLastSync","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"syncFeesManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"syncFeesManagementData","outputs":[{"internalType":"uint256","name":"time","type":"uint256"},{"internalType":"uint256","name":"lastSync","type":"uint256"},{"internalType":"uint256","name":"nextSync","type":"uint256"},{"internalType":"bytes32","name":"taskId","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"syncFeesTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"teamMultisig","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"tokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"tokenAmountVault","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"withdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60e060405234620009a757620060af8038038091620000208260e0620009ac565b60e03960e0016101a060e0820312620009a7576200003f60e0620009d0565b906200004d610100620009d0565b6200005a610120620009d0565b9062000068610140620009d0565b62000075610160620009d0565b9062000083610180620009d0565b91620000916101a0620009d0565b916200009f6101c0620009d0565b90620000ad6101e0620009d0565b96620000bb610200620009d0565b610220516001600160401b038111620009a7578a620000dd9160e001620009e5565b61024051909b906001600160401b038111620009a7578b620001029160e001620009e5565b61026051909b6001600160401b038211620009a757620001259160e001620009e5565b6001600160a01b038b16608081905260405163573ea57560e01b8152919b9190602090829060049082905afa908115620008765760009162000959575b506040516331056e5760e21b815290602090829060049082906001600160a01b03165afa908115620008765760009162000910575b5060c05260405163cd3d4fb960e01b81526002600482015290602090829060249082906001600160a01b03165afa9081156200087657600091620008c9575b50604051632e8743fd60e21b815290602090829060049082906001600160a01b03165afa908115620008765760009162000882575b50604080516337b6269f60e21b815230600482015291829060249082906001600160a01b03165afa908115620008765760009162000823575b5060a05233156200080a57600180546001600160a01b03199081169091556000805433928116831782556001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a3600380546001600160a01b03199081166001600160a01b03938416178255600480548216948416949094179093556005805484169483169490941790935560068054831694821694909417909355600780548216948416949094179093556008805484169483169490941790935560098054831694821694909417909355600a80548216948416949094179093556002805490931693909116929092179055600c600b819055556055600d55600060165582516001600160401b0381116200061857601854600181811c91168015620007ff575b6020821014620005f757601f811162000795575b506020601f82116001146200072657819293946000926200071a575b50508160011b916000199060031b1c1916176018555b81516001600160401b0381116200061857601954600181811c911680156200070f575b6020821014620005f757601f8111620006a5575b50602092601f82116001146200063a57928192936000926200062e575b50508160011b916000199060031b1c1916176019555b601a805461ff00191661010017905580516001600160401b0381116200061857602354600181811c911680156200060d575b6020821014620005f757601f81116200058d575b50602091601f8211600114620005235791819260009262000517575b50508160011b916000199060031b1c1916176023555b604051615652908162000a5d823960805181818161377c01528181613fe70152818161417e0152614f45015260a05181818161076301528181610dee015281816112df015281816115740152818161165e0152818161206601528181613138015281816134e60152613732015260c051818181613f1c0152613f990152f35b01519050388062000482565b601f19821692602360005260206000209160005b85811062000574575083600195106200055a575b505050811b0160235562000498565b015160001960f88460031b161c191690553880806200054b565b9192602060018192868501518155019401920162000537565b60236000527fd57b2b5166478fd4318d2acc6cc2c704584312bdd8781b32d5d06abda57f4230601f830160051c81019160208410620005ec575b601f0160051c01905b818110620005df575062000466565b60008155600101620005d0565b9091508190620005c7565b634e487b7160e01b600052602260045260246000fd5b90607f169062000452565b634e487b7160e01b600052604160045260246000fd5b0151905038806200040a565b601f19821693601960005260206000209160005b8681106200068c575083600195961062000672575b505050811b0160195562000420565b015160001960f88460031b161c1916905538808062000663565b919260206001819286850151815501940192016200064e565b60196000527f944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9695601f830160051c8101916020841062000704575b601f0160051c01905b818110620006f75750620003ed565b60008155600101620006e8565b9091508190620006df565b90607f1690620003d9565b015190503880620003a0565b601860005260206000209060005b601f19841681106200077c5750600193949583601f1981161062000762575b505050811b01601855620003b6565b015160001960f88460031b161c1916905538808062000753565b9091602060018192858a01518155019301910162000734565b60186000527fb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e601f830160051c81019160208410620007f4575b601f0160051c01905b818110620007e7575062000384565b60008155600101620007d8565b9091508190620007cf565b90607f169062000370565b604051631e4fbdf760e01b815260006004820152602490fd5b906040823d6040116200086d575b816200084060409383620009ac565b810103126200086a5760206200085683620009d0565b920151801515036200086a57503862000244565b80fd5b3d915062000831565b6040513d6000823e3d90fd5b906020823d602011620008c0575b816200089f60209383620009ac565b810103126200086a57506040620008b8602492620009d0565b91506200020b565b3d915062000890565b906020823d60201162000907575b81620008e660209383620009ac565b810103126200086a57506020620008ff600492620009d0565b9150620001d6565b3d9150620008d7565b906020823d60201162000950575b816200092d60209383620009ac565b810103126200086a575060249162000947602092620009d0565b91509162000197565b3d91506200091e565b6020813d6020116200099e575b816200097560209383620009ac565b810103126200099a5751906001600160a01b03821682036200086a5750602062000162565b5080fd5b3d915062000966565b600080fd5b601f909101601f19168101906001600160401b038211908210176200061857604052565b51906001600160a01b0382168203620009a757565b919080601f84011215620009a7578251906001600160401b03821162000618576040519160209162000a21601f8301601f1916840185620009ac565b818452828287010111620009a75760005b81811062000a4857508260009394955001015290565b858101830151848201840152820162000a3256fe60808060405260048036101561001f575b5050361561001d57600080fd5b005b600091823560e01c908163049aacfe1461376857508063058ed1a11461371b578063144935861461349d5780631750b4c5146133825780631ad11edf146133595780631eea859c1461331a578063211152a1146132f657806323ea0e03146132745780632793a6521461316757806328f150eb14613122578281632f3666371461304a575080632f622e6b14612f5c5780633430063d14612bc55780633a9690e014612b245780633aeac4e114612a505780634241c97f14612727578063538e109c146126e557806353e97868146126bc57806357fb1d671461268d578063591ce2d0146126485780635e6efb7c1461262a578063661794711461229857806370d5ae051461226f578063715018a61461221b57806371df6d5d146121e257806376e80fc2146121a357806379ba5097146121305780637cf11f7f146120eb5780638190f42b146120c257806384397888146120995780638a8c08fa146120435780638da5cb5b1461201c578063996c6cc314611ff55780639bd11a2114611e775780639e28bdcf14611dba5780639f96218214611d75578063a63748e514611cb3578063a86f8e3b14611b98578063a93843b814611b1a578063a96b7f0514611af6578063aacf93af1461164257828163b2185bb11461155357508063b54a820d1461128b578063b9f26c9714611152578063bb9eba9914611112578063c0ee5127146110dd578063c21495bb146110b7578063c25dc66214611072578063c31c9c0714611049578063c34fe1dd14611020578063c4049f1114610fec578063c5299cf414610da9578063c7576ca314610d66578063c7b5223314610aa7578063cb286c1514610a11578063db66e74f14610743578063dbc0c0851461071a578063dd03b7dc146106d5578063e0a1e92c14610659578063e20db5e114610630578063e21ba9d7146105eb578063e30c3978146105c2578063ee8ca3b51461059e578063f0a71a1814610580578063f2fde38b14610513578063f5831d4e14610476578063f665d08914610453578063f73baed41461041c578063f777cc19146103ec5763ff56835b0361001057346103e85760203660031901126103e8576103476137ab565b61034f613c15565b6001600160a01b031680835260226020526040832054909190156103b857508082526022602052610383604083205461417c565b80825260226020528160408120557f394da581e0d2af7f8c930cd6f0b402e5f148faf6a0cec50e787064490bc07e4c8280a280f35b60649060206040519162461bcd60e51b83528201526009602482015268139bdd08185919195960ba1b6044820152fd5b5080fd5b8234610419576020366003190112610419576104166104096137ab565b610411613c15565b6153d8565b80f35b80fd5b82346104195780600319360112610419576080601e54601f5460205460215491604051938452602084015260408301526060820152f35b50346103e85760203660031901126103e8573033036103e857610416903561417c565b50903461041957602091826003193601126103e8576001600160a01b039083906024836104a16137ab565b1693600954169160405194859384926370a0823160e01b84528301525afa91821561050757916104d5575b50604051908152f35b90508181813d8311610500575b6104ec818361386c565b810103126104fb5751386104cc565b600080fd5b503d6104e2565b604051903d90823e3d90fd5b82346104195760203660031901126104195761052d6137ab565b610535613c15565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b82346104195780600319360112610419576020601f54604051908152f35b50346103e85760203660031901126103e857610416906105bc613c15565b3561532d565b82346104195780600319360112610419576001546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576106056137ab565b61060d613c15565b600680546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576006546040516001600160a01b039091168152602090f35b50346103e85760203660031901126103e857358015158091036103e85761067e613c15565b601a549060ff8260081c161515146000146106c6575060ff19601a5416601a555b7f07e0778b8b42ff4733be759cb5b9d16ba44cf39077a71c1fc34a11fdd307cb0f8180a180f35b60ff1916600117601a5561069f565b8234610419576020366003190112610419576106ef6137ab565b6106f7613c15565b600980546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576007546040516001600160a01b039091168152602090f35b5090346104195780600319360112610419576001600160a01b0361078a337f0000000000000000000000000000000000000000000000000000000000000000831614613c41565b8060025416803b15610a0d578280918560405180948193638942fc3160e01b83525af18015610a02579083916109ee575b5050602454166109d6575b602b546109be575b42601f556107de601e5442613c89565b602090815560405163aacf93af60e01b818301528381526107fe81613800565b6040519061080b8261381b565b60038252606036848401376040516108228161381b565b60038152610831848201614e18565b60026108516040519461084386613800565b808652868601938452614e38565b52600361085e8451614e45565b52600561086b8451614e55565b5261089060405161087b81613836565b86815282519061088a82614e38565b52614e38565b506108b56040516108a081613836565b8681528251906108af82614e45565b52614e45565b5061025842018042116109ab579161094f61093060008051602061548683398151915296959361093e610956966108f460018060801b03809216614e65565b90604051911689820152620927c060408201526040815261091481613851565b60405193849160008b8401526040808401526060830190613bd5565b03601f19810184528361386c565b519061094982614e55565b52614e55565b5030614e81565b80601d55604051908152a1600080516020615606833981519152610978613fd2565b906109838282613eee565b61099260405192839283613d85565b0390a1426000805160206155068339815191528280a280f35b634e487b7160e01b865260118752602486fd5b6017805460ff60a81b1916600160a81b1790556107ce565b6017805460ff60a01b1916600160a01b1790556107c6565b6109f7906137d7565b6103e85781386107bb565b6040513d85823e3d90fd5b8280fd5b50346103e85760203660031901126103e857610a2b6137ab565b610a33613c15565b6001600160a01b03168083526014602052604083205490919060ff16610a6d57508152601460205260408120805460ff1916600117905580f35b60649060206040519162461bcd60e51b83528201526013602482015272105b1c9958591e481dda1a5d195b1a5cdd1959606a1b6044820152fd5b50346103e85760403660031901126103e857610ac16137c1565b600a546040516370a0823160e01b80825233828601526001600160a01b03949093602093919260249290919085908390859082908b165afa8015610cdc5787928991610d32575b50610b14901515614259565b610b34601754610b2a60ff8260a01c16156142f3565b8316331415614327565b16918287526014845260ff60408820541615610cf95767016345785d8a000095868235049680880297808904821490151715610ce757610b8390610b7b6025548a1161435c565b881015614396565b6003541694604051908152338282015284818481895afa8015610cdc5787918991610ca7575b5095610bbc869392610bd99810156143ce565b6040518080988194636eb1769f60e11b835230903390840161440f565b03915afa8015610c9c5785948791610c5b575b506000805160206154a683398151915294610c08911015614429565b60018060a01b0319903382825416179055846025556026541617602655604051610c3181613800565b8381526001828201428152338752602784526040872092518355519101556040519283523392a280f35b809550848092503d8311610c95575b610c74818361386c565b810103126104fb5792518493906000805160206154a6833981519152610bec565b503d610c6a565b6040513d88823e3d90fd5b80939250868092503d8311610cd5575b610cc1818361386c565b810103126104fb5790518690610bbc610ba9565b503d610cb7565b6040513d8a823e3d90fd5b634e487b7160e01b8952601183528389fd5b6015606492856040519362461bcd60e51b8552840152820152742737ba103bb434ba32b634b9ba32b2103a37b5b2b760591b6044820152fd5b809350868092503d8311610d5f575b610d4b818361386c565b810103126104fb57610b1487925190610b08565b503d610d41565b8234610419578060031936011261041957608060018060a01b03806024541690602554906026541660285491604051938452602084015260408301526060820152f35b50346103e85760803660031901126103e857610dc36137ab565b610dcb6137c1565b604435916001600160a01b03908184168085036104fb57606435958691610e15857f0000000000000000000000000000000000000000000000000000000000000000163314613c41565b88858354168214600014610f3c57610e4e939150918460209387835416926040519687958694859363a9059cbb60e01b85528401613d9e565b03925af18015610f315760008051602061554683398151915294610e7e8592610eec948b91610f03575b506142b5565b6013548881811115610ef2575050886013555b16958688526029602052876005604082204260038201550155600080516020615606833981519152610ec1613fd2565b90610ecc8282613eee565b610edb60405192839283613d85565b0390a1604051938493169583613d9e565b0390a380f35b610efb91613cac565b601355610e91565b610f24915060203d8111610f2a575b610f1c818361386c565b810190613d04565b38610e78565b503d610f12565b6040513d89823e3d90fd5b90918560035416809314610f68575b50505050610eec8260008051602061554683398151915294610e91565b9184610f8d94926020946040519687958694859363a9059cbb60e01b85528401613d9e565b03925af18015610f315760008051602061554683398151915294610fbc8592610eec948b91610f0357506142b5565b6012548881811115610fdb575050886012555b94508691508738610f4b565b610fe491613cac565b601255610fcf565b823461041957806003193601126104195761101c611008613a1c565b604051918291602083526020830190613bd5565b0390f35b82346104195780600319360112610419576003546040516001600160a01b039091168152602090f35b82346104195780600319360112610419576008546040516001600160a01b039091168152602090f35b82346104195760203660031901126104195761108c6137ab565b611094613c15565b600880546001600160a01b0319166001600160a01b039290921691909117905580f35b8234610419578060031936011261041957602060ff601a5460081c166040519015158152f35b823461041957604036600319011261041957602061110a6110fc6137ab565b6111046137c1565b90614cf4565b604051908152f35b50346103e85760203660031901126103e85761112c6137ab565b611134613c15565b81546001600160a01b0319166001600160a01b039190911617905580f35b5090346104195761116236613973565b9161116b613c15565b8251906001600160401b03821161127857506111886018546139e2565b601f8111611231575b50602080601f83116001146111ce575082938293926111c3575b50508160011b916000199060031b1c19161760185580f35b0151905038806111ab565b90601f19831694601885528285209285905b878210611219575050836001959610611200575b505050811b0160185580f35b015160001960f88460031b161c191690553880806111f4565b806001859682949686015181550195019301906111e0565b6018835261126890600080516020615566833981519152601f840160051c8101916020851061126e575b601f0160051c0190613d2b565b38611191565b909150819061125b565b634e487b7160e01b835260419052602482fd5b50346103e85760603660031901126103e8576112a56137ab565b906112ae6137c1565b916044356001600160401b03811161154f576112cd90369084016138e1565b6001600160a01b0392908590611306337f0000000000000000000000000000000000000000000000000000000000000000871614613c41565b60608101958651151580611541575b80611529575b1561149c57506113626020918660075416838201526113418760085416895190886140d0565b86600854169060405194858094819363c04b8d5960e01b8352898301614086565b03925af18015610c9c57611471575b505b845b6015805482108080611467575b156113cf57156113ba57906113b591600052601460208683826000200154168952526040872060ff198154169055613d1c565b611375565b603283634e487b7160e01b6000525260246000fd5b87857f861ecaf4181c9874419a0979e36f584362245595975983e658d50ff1897f01fb6020898b60155460006015558061144b575b5060008051602061560683398151915261141c613fd2565b906114278282613eee565b61143660405192839283613d85565b0390a18560285551936040519485521692a280f35b6114619060156000528460002090810190613d2b565b86611404565b50600a8310611382565b602090813d8111611495575b611487818361386c565b810103126104fb5738611371565b503d61147d565b9150508385511515918261151b575b82611503575b50501561137357600754845160405163a9059cbb60e01b815291602091839182916114e0918916878401613d9e565b0381898888165af18015610c9c576114fe918791610f0357506142b5565b611373565b168652506014602052604085205460ff1683386114b1565b8482168282161492506114ab565b508581168352601460205260ff60408420541661131b565b508581168686161415611315565b8480fd5b80833461163f578160031936011261163f576001600160a01b039061159b337f0000000000000000000000000000000000000000000000000000000000000000841614613c41565b601a5460081c60ff1690811561161e57600f549284600f556115c684828454168360025416906140d0565b60025416803b1561154f578492836044926040519687958694631c44ccb760e21b865215159085015260248401525af18015611613576116035750f35b61160c906137d7565b6104195780f35b6040513d84823e3d90fd5b600e549284600e5561163a8482600354168360025416906140d0565b6115c6565b50fd5b50346103e857816003193601126103e8576001600160a01b03337f000000000000000000000000000000000000000000000000000000000000000082161461168981613c41565b611698601c54601e5490613c89565b61012b198101908111611ae357906116b661172b9392421015613cb9565b60ff80601a5460081c1680600014611aac576116f86116ef6116e66116dd878a54166141f0565b600f5490613cac565b60115490613cac565b60135490613cac565b935b6064611708600b5487613cf1565b04958695611726606461171d600c5484613cf1565b04988992613cac565b613cac565b9360019285841c9087848b611740858b613cac565b9315611a6657611777926117829592611760925416886007541690613db9565b61176c8b600f54613c89565b600f55601154613c89565b601155601354613c89565b6013555b888260025416986040519963a48debd160e01b8b5260209a8b818481855afa908115611a5b578491611a3e575b50611994575b5050508360175460a01c1680611987575b611971575b6017805460ff60a01b19811690915560a81c841680611966575b6118cf575b50506017805460ff60a81b1916905550601a546000805160206154c68339815191529561187a9392828116611880575b50505042601c5560008051602061560683398151915261183c613fd2565b906118478282613eee565b61185660405192839283613d85565b0390a185601d55604051938493846040919493926060820195825260208201520152565b0390a180f35b61ffff198316600893841c821615841b61ff001617601a819055604051931c16151582527f7c2a69ed281741b39b3eb61caf936f428fa2a0c2d418a7dc43cc0ff03a4942b391a138808061181e565b88835b611901575b505050509061187a916000805160206154c6833981519152956118f8613d42565b958192936117ee565b602b548110156119615780838061193561191d61195b956139b1565b92905461192988613c41565b600393841b1c1661497c565b61193e836139b1565b9054911b1c168b52602a8a5260408b20805460ff19169055613d1c565b836118d2565b6118d7565b50602b5415156117e9565b61197a81613c41565b61198261446c565b6117cf565b50816024541615156117ca565b61199d84613c41565b601a5460081c8716908115611a225750600f549183600f556119c883878354168860025416906140d0565b8560025416803b1561154f578492836044926040519687958694631c44ccb760e21b865215159085015260248401525af1801561161357611a0a575b806117b9565b611a13906137d7565b611a1e578838611a04565b8880fd5b91611a39600e54809486600e5588600354166140d0565b6119c8565b611a5591508c8d3d10610f2a57610f1c818361386c565b386117b3565b6040513d86823e3d90fd5b5092611a82611a9992611aa49560035416886007541690613db9565b611a8e8b600e54613c89565b600e55601054613c89565b601055601254613c89565b601255611786565b611add611ad4611acb611ac287600354166141f0565b600e5490613cac565b60105490613cac565b60125490613cac565b936116fa565b634e487b7160e01b855260118452602485fd5b823461041957602036600319011261041957602061110a611b156137ab565b6141f0565b823461041957602036600319011261041957611b346137ab565b90611b3e8261494e565b9091602b54905b818410611b5757602083604051908152f35b9091611b8a611b9091611b84611b6c876139b1565b905460039190911b1c6001600160a01b031685614cf4565b90613c89565b93613d1c565b929190611b45565b50903461041957611ba836613973565b91611bb1613c15565b8251906001600160401b0382116112785750611bce6019546139e2565b601f8111611c77575b50602080601f8311600114611c1457508293829392611c09575b50508160011b916000199060031b1c19161760195580f35b015190503880611bf1565b90601f19831694601985528285209285905b878210611c5f575050836001959610611c46575b505050811b0160195580f35b015160001960f88460031b161c19169055388080611c3a565b80600185968294968601518155019501930190611c26565b60198352611cad90600080516020615626833981519152601f840160051c8101916020851061126e57601f0160051c0190613d2b565b38611bd7565b5090346104195760603660031901126104195781356024359060443593611cd8613c15565b6064611ced86611ce88686613c89565b613c89565b03611d42575061187a7fb12262f78918536665563f06927bca9e755beea6ec97c15bd4c0a6a525523915939482600b5583600c5580600d55604051938493846040919493926060820195825260208201520152565b60649060206040519162461bcd60e51b8352820152600c60248201526b496e76616c6964206665657360a01b6044820152fd5b823461041957602036600319011261041957611d8f6137ab565b611d97613c15565b600380546001600160a01b0319166001600160a01b039290921691909117905580f35b50903461041957604036600319011261041957611dd56137ab565b60025460243591906001600160a01b039081163303611e3f576020918495611e1b9585936003541692604051978895869485936323b872dd60e01b855230918501614293565b03925af1918215610a025761041692611e3a918591610f0357506142b5565b614d4c565b60405162461bcd60e51b815260208187015260116024820152704f6e6c792046656573476976656177617960781b6044820152606490fd5b50903461041957806003193601126104195750600b54600c54600d54604051919360c08301906001600160401b03821184831017611fe05750604052600e548252600f54602083015260105460408301526011546060830152601254608083015260135460a08301526016549160175492611ef0613ac7565b611ef8613b4e565b90601a5495601b5493601c5495601d54976040519b8c9b8c5260208c015260408b0152805160608b0152602081015160808b0152604081015160a08b0152606081015160c08b0152608081015160e08b015260a001516101008a0152610120890152600160a01b6001900381166101408901528060a01c60ff16151561016089015260a81c60ff161515610180880152610280806101a08901528701611f9d91613bd5565b8681036101c0880152611faf91613bd5565b9360ff811615156101e087015260081c60ff1615156102008601526102208501526102408401526102608301520390f35b604190634e487b7160e01b6000525260246000fd5b50346103e857816003193601126103e857546040516001600160a01b039091168152602090f35b8234610419578060031936011261041957546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576104166120606137ab565b612094337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031614613c41565b61497c565b8234610419578060031936011261041957600a546040516001600160a01b039091168152602090f35b82346104195780600319360112610419576002546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576121056137ab565b61210d613c15565b600a80546001600160a01b0319166001600160a01b039290921691909117905580f35b50346103e857816003193601126103e857600154906001600160a01b0390338284160361218b575060018060a01b0319809216600155600054913390831617600055339116600080516020615586833981519152600080a380f35b6024906040519063118cdaa760e01b82523390820152fd5b82346104195760203660031901126104195760209060ff906040906001600160a01b036121ce6137ab565b168152602a84522054166040519015158152f35b8234610419576020366003190112610419576020906040906001600160a01b0361220a6137ab565b168152602283522054604051908152f35b8234610419578060031936011261041957612234613c15565b600180546001600160a01b0319908116909155600080549182168155906001600160a01b03166000805160206155868339815191528280a380f35b82346104195780600319360112610419576005546040516001600160a01b039091168152602090f35b50346103e85760403660031901126103e8576122b26137c1565b600a546040516370a0823160e01b8082523385830152926020926001600160a01b0392919084908390602490829087165afa8015610f3157839288916125f6575b506122ff901515614259565b61231160ff60175460a81c16156142f3565b16938486526029835261232e33838360408a200154161415614327565b604051630a7d2f0d60e31b815283818381895afa908115610f315787916125bd575b5082806009541691160361258a5767016345785d8a000093848235049480860295808704821490151715612577576123a3908789526029865261239b600160408b200154881161435c565b861015614396565b82600354169060405190815233838201528481602481855afa8015610cdc5786908990612546575b6123d7925010156143ce565b836040518092636eb1769f60e11b825281806123f6303389840161440f565b03915afa8015610f315785908890612515575b61241592501015614429565b848652602a835260ff604087205416156124b3575b50508060296000805160206154e6833981519152925282600160408720600381018054156124a8575b5033828060a01b0319825416178155015560405161247081613800565b83815260018282014281528688526029845260026040892001336000528452604060002092518355519101556040519283523392a380f35b601b54905538612453565b602b5490600160401b821015611fe05750906124e58260016000805160206154e6833981519152959401602b556139b1565b819291549060031b9187831b921b1916179055838552602a815260408520600160ff19825416179055903861242a565b50508381813d831161253f575b61252c818361386c565b810103126104fb57846124159151612409565b503d612522565b50508481813d8311612570575b61255d818361386c565b810103126104fb57856123d791516123cb565b503d612553565b634e487b7160e01b885260118352602488fd5b60405162461bcd60e51b8152908101839052600c60248201526b125b9d985b1a59081c1bdbdb60a21b6044820152606490fd5b90508381813d83116125ef575b6125d4818361386c565b810103126125eb576125e590613fbe565b38612350565b8680fd5b503d6125ca565b809350858092503d8311612623575b61260f818361386c565b810103126104fb576122ff839251906122f3565b503d612605565b82346104195780600319360112610419576020601e54604051908152f35b8234610419576020366003190112610419576126626137ab565b61266a613c15565b600280546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576020604051737506c12a824d73d9b08564d5afc22c949434755e8152f35b82346104195780600319360112610419576009546040516001600160a01b039091168152602090f35b50346103e85760203660031901126103e8573590602b5482101561041957602061270e836139b1565b905460405160039290921b1c6001600160a01b03168152f35b509034610419576020806003193601126103e857823592612746613c15565b83159384159485612a44575b15612a12578061276991601e5542601f5542613c89565b825542601b5542601c55612786602854612781613c15565b61532d565b612794601d54612781613c15565b6127a2602154612781613c15565b6127aa614070565b825b602b5481101561285657806127c3612851926139b1565b9054906127ce613c15565b6001600160a01b03916003916127e99190831b1c83166153d8565b816127f3846139b1565b905490831b1c16875260298087526000600160408a20828155015582612818856139b1565b905490841b1c16885286528681604082200155612834836139b1565b9054911b1c168552602a845260408520805460ff19169055613d1c565b6127ac565b5092612860613d42565b6017805461ffff60a01b1916905561289b575b507f9a49eeb4937d3bf5ec82aac78b34160029b47efe32ca3f6f919a93656663b76e8180a180f35b6002546001600160a01b0316803b15610a0d578280918560405180948193630a4ec5c760e11b83525af18015610a02579083916129fe575b505060405163db66e74f60e01b828201529283526128f083613800565b6040516128fc81613851565b60028152604036838301376040519361291485613851565b6002855260005b604081106129ef5750906129dd9161094f610930600080516020615486833981519152969760026129606040519661295288613800565b808852898801938452614e38565b52600561296d8651614e45565b5261298c60405161297d81613836565b8a815282519061088a82614e38565b5086546129d2906001600160801b03906129a7908216614e65565b906129b581601e5416614e65565b8160405193168b8401521660408201526040815261091481613851565b51906108af82614e45565b80602155604051908152a18038612873565b6060868201850152830161291b565b612a07906137d7565b6103e85781386128d3565b506064916040519162461bcd60e51b8352820152600c60248201526b54696d6520746f6f206c6f7760a01b6044820152fd5b506104b0811015612752565b50346103e85760403660031901126103e857612a6a6137ab565b90612a736137c1565b91612a7c613c15565b6040516370a0823160e01b815230928101929092526001600160a01b031691602082602481865afa908115611a5b578491612ae3575b6000805160206155268339815191529250612ace828286613db9565b612add60405192839283613d9e565b0390a280f35b90506020823d8211612b1c575b81612afd6020938361386c565b810103126104fb57600080516020615526833981519152915190612ab2565b3d9150612af0565b50346103e85760203660031901126103e857612b3e6137ab565b600754916001600160a01b0391908284163303612b905750166001600160a01b03199190911681176007557f7a647445a4e730026e2c1994e60120e45528249cc60705e7a38c72e066834f9d8280a280f35b60649060206040519162461bcd60e51b8352820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152fd5b50346103e857602080600319360112610a0d57612be06137ab565b91612be9613c15565b6001600160a01b03928316808552602283526040852054909390612f2957612c1030615207565b612c1985615207565b60405163313ce56760e01b81529092858286818a5afa8015610cdc5760ff612c4d91612c80948b91612efc575b50166150a5565b90612c67612c5e8260035416615207565b91875416615207565b90612c71466150a5565b926040519687968a8801615038565b03612c93601f199182810184528361386c565b60405192612ca08461381b565b6003845260609182368787013760405191612cba8361381b565b60038352612cc9878401614e18565b6002612ce960405197612cdb89613800565b808952898901958652614e38565b52612cf48651614e45565b526005612d018651614e55565b52612d20604051612d1181613836565b89815283519061088a82614e38565b50612d41612d3585612d30613a1c565b6152ec565b8351906108af82614e45565b5060405192612d4f84613800565b6001938481528760005b818110612eed575050604051612d6e81613800565b858152883681830137612d8082614e38565b52612d8a81614e38565b50600080516020615506833981519152612dac612da683614e38565b51614e38565b52604051946080860190308a880152836040880152825180925260a08701918c8b60a08360051b8b0101950193815b838310612e945750505050505084612e6a9461093e8a999585612e418561094f977f829ca1e6f5ac6dcb63b6ca82b6efeefce80a186f58cb7fbeeae114dda6baa31f9f9c6000805160206154868339815191529e9a60079101520383810187528661386c565b612e5e60405195869260028d850152604080850152830190613bd5565b0390810184528361386c565b85875260228252806040882055604051908152a1828452602281526040842054604051908152a280f35b909192938d819697609f198d8203018552885190828083519283815201920194905b808210612ed357505081929350970192019201909392918e612ddb565b9280919492865181520194019201928f9193889394612eb6565b83828285010152018890612d59565b612f1c9150893d8b11612f22575b612f14818361386c565b81019061501f565b38612c46565b503d612f0a565b506064916040519162461bcd60e51b8352820152600d60248201526c105b1c9958591e481859191959609a1b6044820152fd5b50346103e85760203660031901126103e857612f766137ab565b612f7e613c15565b4790811561300e576001600160a01b0316918380808085875af1612fa0613e5b565b5015612fd5575060207fc4825c2033e49b7d8db9d453f0a5953dc550c9452166b576df9f456893f1695f91604051908152a280f35b60649060206040519162461bcd60e51b83528201526012602482015271151c985b9cd858dd1a5bdb8819985a5b195960721b6044820152fd5b60405162461bcd60e51b815260208185015260156024820152744e6f204e617469766520746f20776974686472617760581b6044820152606490fd5b80833461163f57602036600319011261163f57600a546040516370a0823160e01b815233838201526001600160a01b03916020908290602490829086165afa908115611a5b5784916130eb575b506130a3901515614259565b60025416803b156130e75760405163fdad3a5f60e01b815291839183918290849082906130d69033908035908401613d85565b03925af18015611613576116035750f35b5050fd5b9350506020833d821161311a575b816131066020938361386c565b810103126104fb576130a384935190613097565b3d91506130f9565b82346104195780600319360112610419576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b50346103e85760203660031901126103e8576131816137ab565b9061318a613c15565b6001600160a01b039182168084526014602052604084205490929060ff161561323e576026541682036132275760155490600160401b821015611fe0576001820180601555821015613212575060156000527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750180546001600160a01b031916909117905580f35b603290634e487b7160e01b6000525260246000fd5b508152601460205260408120805460ff1916905580f35b60405162461bcd60e51b8152602081840152600f60248201526e139bdd081dda1a5d195b1a5cdd1959608a1b6044820152606490fd5b50346103e85760203660031901126103e85760a0916001600160a01b0391906040908361329f6137ab565b168152602960205220604051916132b583613800565b600584835416948585526020600185015495019485526003840154928401541692015492604051948552516020850152604084015260608301526080820152f35b823461041957602036600319011261041957602061110a6133156137ab565b61494e565b82346104195760203660031901126104195760209060ff906040906001600160a01b036133456137ab565b168152601484522054166040519015158152f35b50346103e85760203660031901126103e85735613374613c15565b606481116103e85760165580f35b5090346104195761339236613973565b9161339b613c15565b8251906001600160401b03821161127857506133b86023546139e2565b601f8111613461575b50602080601f83116001146133fe575082938293926133f3575b50508160011b916000199060031b1c19161760235580f35b0151905038806133db565b90601f19831694602385528285209285905b878210613449575050836001959610613430575b505050811b0160235580f35b015160001960f88460031b161c19169055388080613424565b80600185968294968601518155019501930190613410565b60238352613497906000805160206155a6833981519152601f840160051c8101916020851061126e57601f0160051c0190613d2b565b386133c1565b50346103e85760403660031901126103e8576134b76137ab565b906024356001600160401b038111613717576134d690369083016138e1565b916001600160a01b039061350d337f0000000000000000000000000000000000000000000000000000000000000000841614613c41565b601a5460081c60ff161561370557613527828454166141f0565b8260095416946060810195878751823b156103e85760405163f3fef3a360e01b815292839182908490829061355f908b838f01613d9e565b03925af18015610cdc576136f2575b50869060ff601a5460081c1680806136e2575b81156136c4575b5015613637575b5050906135e083927fa1644d67f50368863681a400048e0e892596b0bfceae204b0b2e879b26e2e6829560409560ff601a5460081c16600014613623576135d79154166141f0565b965b5196613cac565b6000805160206156068339815191526135f7613fd2565b906136028282613eee565b613610875192839283613d85565b0390a1835195865260208601521692a280f35b6136319150600354166141f0565b966135d9565b61367d602091308382015261365c61364e876141f0565b808b528860085416886140d0565b86600854169060405194858094819363c04b8d5960e01b83528c8301614086565b03925af18015610f3157613693575b869061358f565b60209081949392943d81116136bd575b6136ad818361386c565b810103126104fb5790913861368c565b503d6136a3565b905015806136d3575b38613588565b508460035416858516146136cd565b9050858754168686161490613581565b6136fe909791976137d7565b953861356e565b61371282600354166141f0565b613527565b8380fd5b8234610419578060031936011261041957613760337f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031614613c41565b61041661446c565b8390346103e857816003193601126103e8577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b600435906001600160a01b03821682036104fb57565b602435906001600160a01b03821682036104fb57565b6001600160401b0381116137ea57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b038211176137ea57604052565b608081019081106001600160401b038211176137ea57604052565b602081019081106001600160401b038211176137ea57604052565b606081019081106001600160401b038211176137ea57604052565b601f909101601f19168101906001600160401b038211908210176137ea57604052565b6001600160401b0381116137ea57601f01601f191660200190565b9291926138b68261388f565b916138c4604051938461386c565b8294818452818301116104fb578281602093846000960137010152565b91909160a0818403126104fb576040516001600160401b039390919060a08301858111848210176137ea57604052829482359081116104fb5782019080601f830112156104fb57816020613937933591016138aa565b825260208101356001600160a01b03811681036104fb576080918291602085015260408101356040850152606081013560608501520135910152565b60206003198201126104fb57600435906001600160401b0382116104fb57806023830112156104fb578160246139ae936004013591016138aa565b90565b602b548110156139cc57602b60005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b90600182811c92168015613a12575b60208310146139fc57565b634e487b7160e01b600052602260045260246000fd5b91607f16916139f1565b6040519060008260235491613a30836139e2565b808352600193808516908115613aa65750600114613a58575b50613a569250038361386c565b565b602360009081526000805160206155a683398151915294602093509091905b818310613a8e575050613a56935082010138613a49565b85548884018501529485019487945091830191613a77565b9050613a5694506020925060ff191682840152151560051b82010138613a49565b6040519060008260185491613adb836139e2565b808352600193808516908115613aa65750600114613b005750613a569250038361386c565b6018600090815260008051602061556683398151915294602093509091905b818310613b36575050613a56935082010138613a49565b85548884018501529485019487945091830191613b1f565b6040519060008260195491613b62836139e2565b808352600193808516908115613aa65750600114613b875750613a569250038361386c565b6019600090815260008051602061562683398151915294602093509091905b818310613bbd575050613a56935082010138613a49565b85548884018501529485019487945091830191613ba6565b919082519283825260005b848110613c01575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201613be0565b6000546001600160a01b03163303613c2957565b60405163118cdaa760e01b8152336004820152602490fd5b15613c4857565b60405162461bcd60e51b815260206004820152601960248201527827b7363c903232b234b1b0ba32b21036b9b39739b2b73232b960391b6044820152606490fd5b91908201809211613c9657565b634e487b7160e01b600052601160045260246000fd5b91908203918211613c9657565b15613cc057565b60405162461bcd60e51b8152602060048201526009602482015268546f6f206561726c7960b81b6044820152606490fd5b81810292918115918404141715613c9657565b908160209103126104fb575180151581036104fb5790565b6000198114613c965760010190565b818110613d36575050565b60008155600101613d2b565b602b546000602b5580613d525750565b602b600052613a56907f11c44e4875b74d31ff9fd779bf2566af7bd15b87fc985d01f5094b89e3669e4f90810190613d2b565b9081526001600160a01b03909116602082015260400190565b6001600160a01b039091168152602081019190915260400190565b6000613e12928192613df4613de696604051978891602083019563a9059cbb60e01b875260248401613d9e565b03601f19810188528761386c565b60018060a01b031694519082865af1613e0b613e5b565b9083613e8b565b8051908115159182613e40575b5050613e285750565b60249060405190635274afe760e01b82526004820152fd5b613e539250602080918301019101613d04565b153880613e1f565b3d15613e86573d90613e6c8261388f565b91613e7a604051938461386c565b82523d6000602084013e565b606090565b90613eb25750805115613ea057805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580613ee5575b613ec3575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15613ebb565b906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103613f9257506000808080937f00000000000000000000000000000000000000000000000000000000000000005af1613f45613e5b565b5015613f4d57565b60405162461bcd60e51b815260206004820152601e60248201527f5f7472616e736665723a20455448207472616e73666572206661696c656400006044820152606490fd5b90613a56917f000000000000000000000000000000000000000000000000000000000000000090613db9565b51906001600160a01b03821682036104fb57565b60408051635c08631b60e11b815281816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa908115614065576000928392614028575b50509091565b9080939250813d831161405e575b614040818361386c565b810103126104195750614057602082519201613fbe565b3880614022565b503d614036565b82513d6000823e3d90fd5b6000602455600060255560006026556000602855565b6020815260a060806140a3845183602086015260c0850190613bd5565b93600180841b03602082015116604085015260408101516060850152606081015182850152015191015290565b60009291836140fb6141098295604051928391602083019663095ea7b360e01b885260248401613d9e565b03601f19810183528261386c565b51925af1614115613e5b565b8161414d575b501561412357565b60405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606490fd5b8051801592508215614162575b50503861411b565b6141759250602080918301019101613d04565b388061415a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690813b156104fb5760009160248392604051948593849263ee8ca3b560e01b845260048401525af180156141e4576141db5750565b613a56906137d7565b6040513d6000823e3d90fd5b6040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa9081156141e45760009161422b575090565b906020823d8211614251575b816142446020938361386c565b8101031261041957505190565b3d9150614237565b1561426057565b60405162461bcd60e51b815260206004820152600b60248201526a2737ba102628103ab9b2b960a91b6044820152606490fd5b6001600160a01b03918216815291166020820152604081019190915260600190565b156142bc57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b156142fa57565b60405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606490fd5b1561432e57565b60405162461bcd60e51b815260206004820152600660248201526510985b9b995960d21b6044820152606490fd5b1561436357565b60405162461bcd60e51b815260206004820152600b60248201526a42696420746f6f206c6f7760a81b6044820152606490fd5b1561439d57565b60405162461bcd60e51b81526020600482015260096024820152683c20302e312024414760b81b6044820152606490fd5b156143d557565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420656e6f7567682062616c616e636560701b6044820152606490fd5b6001600160a01b0391821681529116602082015260400190565b1561443057565b60405162461bcd60e51b81526020600482015260146024820152734e6f7420656e6f75676820616c6c6f77616e636560601b6044820152606490fd5b60175461447e60ff8260a01c16613cb9565b60018060a01b03908160245416916025549060039281845416916040938451926370a0823160e01b845260049488868601526020948581602481855afa9081156149105787879160009361491b575b506144ee938c8b51809681948293636eb1769f60e11b84523091840161440f565b03915afa918215614910579084916000936148de575b5081119182156148d4575b50506148b3575061453f8382848954168760008c8b51968795869485936323b872dd60e01b855230918501614293565b03925af19081156148a8576145609291611e3a9160009161489157506142b5565b601a5460081c60ff161561485d576011549261458b606461458360165487613cf1565b048095613cac565b95600060115584614845575b601780546001600160a01b03191690556026548316926145b5614070565b601a5460081c60ff161561483b5780835416935b6145d230615207565b916145e08160075416615207565b9585886145ec85615207565b948c519283809263313ce56760e01b82525afa908115614830578b959493929160ff91600091614813575b5016614622906150a5565b9161462c8d6150a5565b911661463790615207565b91614641466150a5565b938651998a968c880160e09052610100880161465c91613bd5565b601f199889898303019089015261467291613bd5565b8787820301606088015261468591613bd5565b8686820301608087015261469891613bd5565b858582030160a08601526146ab91613bd5565b848482030160c08501526146be91613bd5565b838382030160e08401526146d191613bd5565b0390810184526146e1908461386c565b8551916146ed8361381b565b818352606036868501378651916147038361381b565b808352614711868401614e18565b87519361471d85613800565b80855286850193845261472f90614e38565b60029052835161473e90614e45565b52825161474a90614e55565b52855161475681613836565b6000815281519061476682614e38565b5261477090614e38565b50855161477c81613836565b6000815281519061478c82614e45565b5261479690614e45565b50826147a0613ac7565b906147aa916152ec565b9051906147b682614e55565b526147c090614e55565b506147cb9130614e81565b8060285581845191825260008051602061548683398151915291a182519384528301527f6628ed72e16e5aedaefe37d11641b2f8463c19d223cce10cac20f853f64d8ed691a2565b61482a91508b3d8d11612f2257612f14818361386c565b38614617565b8b513d6000823e3d90fd5b80825416936145c9565b6148588584845416856006541690613db9565b614597565b60105492614872606461458360165487613cf1565b9560006010558415614597576148588584835416856006541690613db9565b610f249150863d8811610f2a57610f1c818361386c565b86513d6000823e3d90fd5b6001600160a01b0319169690961760175550613a5694506140709350505050565b109050823861450f565b9150918682813d8311614909575b6148f6818361386c565b8101031261041957505190839081614504565b503d6148ec565b88513d6000823e3d90fd5b8281949392503d8311614947575b614933818361386c565b8101031261041957505185876144ee6144cd565b503d614929565b6001600160a01b031660009081526027602052604090206001810154601c54106149785750600090565b5490565b61498d60ff60175460a81c16613cb9565b60018060a01b038091169060008281526020602981526040808320936001818654169501549060039080825416928451936370a0823160e01b855260049489868201528781602481855afa908115614cb9578a89918b93614cc3575b50614a099389518080968194636eb1769f60e11b835230908d840161440f565b03915afa918215614cb9579083918a93614c86575b508111918215614c7c575b5050614c4e57614a57868284865416878b8d8b51968795869485936323b872dd60e01b855230918501614293565b03925af1908115614c445784614b5c89614b4e614c07978f8f977f2389140956343c2bdbaa10a0a94f87a1cdc988150cee813429f3d86fbd16012e9f9e9c999b8f6000805160206154868339815191529f9d614ac490611e3a614af29561094f9d8591614c2d57506142b5565b838152602987528d81208c810180546001600160a01b03191690558181556001810191909155015442613cac565b9160ff601a5460081c16600014614c2057614b37818b5416915b614b30614b2a614b24614b1e30615207565b9d615207565b966150a5565b94615207565b9216615207565b91614b41466150a5565b938d519a8b978801615038565b03601f19810185528461386c565b855193614b688561381b565b81855260603689870137865191614b7e8361381b565b808352614b8c898401614e18565b6002614bab895197614b9d89613800565b8089528b8901958652614e38565b52614bb68651614e45565b52614bc18551614e55565b52614bd0865161297d81613836565b50614bee8651614bdf81613836565b8a81528251906108af82614e45565b50614bfb83612d30613b4e565b90519061094982614e55565b9087855260298352816005828720015551908152a180a3565b614b378188541691614b0c565b610f2491508b3d8d11610f2a57610f1c818361386c565b86513d8a823e3d90fd5b5050509483526029909152812092830180546001600160a01b03191690921790915580825560019190910155565b1090508138614a29565b89809294508193503d8311614cb2575b614ca0818361386c565b81010312611a1e575190829081614a1e565b503d614c96565b87513d8b823e3d90fd5b92505081813d8311614ced575b614cda818361386c565b81010312611a1e5751878a614a096149e9565b503d614cd0565b9060018060a01b03809116916000918383526029602052600260408420019116908183526020526001604083200154601c5410614d315750905090565b60409282526029602052600283832001908252602052205490565b614d8160208260018060a01b0380600354169060055416600060405180968195829463a9059cbb60e01b845260048401613d9e565b03925af19081156141e457600091614dfa575b5015614dc75760207f6ef4855b666dcc7884561072e4358b28dfe01feb1b7f4dcebc00e62d50394ac791604051908152a1565b60405162461bcd60e51b815260206004820152600b60248201526a109d5c9b8819985a5b195960aa1b6044820152606490fd5b614e12915060203d8111610f2a57610f1c818361386c565b38614d94565b9060005b606080821015614e325783820152602001614e1c565b50509050565b8051156139cc5760200190565b8051600110156139cc5760400190565b8051600210156139cc5760600190565b6001600160801b039081166103e80290811691908203613c9657565b6040518093633323b46760e01b825260018060a01b0390816004941684840152614eb76024956080878601526084850190613bd5565b906003198483030160448501526040820190805195604084528651809352606084019260209889809901926000915b838310614fd9575050505050850151918581830391015281518082528582019186808360051b8301019401926000915b838310614fa8575050505050600083809273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee606483015203927f0000000000000000000000000000000000000000000000000000000000000000165af19081156141e457600091614f7c575b50905090565b82813d8311614fa1575b614f90818361386c565b810103126104195750518038614f76565b503d614f86565b9295978091949750614fc760019396601f198682030187528951613bd5565b97019301930188959388979592614f16565b92959194969850928097995051600681101561500b578a8281926001945201970193018a979593928a99979592614ee6565b82602185634e487b7160e01b600052526000fd5b908160209103126104fb575160ff811681036104fb5790565b94919361507b6150979461506d6139ae999761505f6150899660c08c5260c08c0190613bd5565b908a820360208c0152613bd5565b9088820360408a0152613bd5565b908682036060880152613bd5565b908482036080860152613bd5565b9160a0818403910152613bd5565b6000908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b808210156151f9575b506904ee2d6d415b85acef8160201b808310156151ea575b50662386f26fc10000808310156151db575b506305f5e100808310156151cc575b50612710808310156151bd575b5060648210156151ad575b600a809210156151a3575b600190816021818601956151388761388f565b96615146604051988961386c565b808852615155601f199161388f565b01366020890137860101905b61516d575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a83530491821561519e57919082615161565b615166565b9160010191615125565b919060646002910491019161511a565b6004919392049101913861510f565b60089193920491019138615102565b601091939204910191386150f3565b602091939204910191386150e1565b6040935081049150386150c9565b806040519161521583613851565b602a8352602080840160403682378451156139cc57603090538351906001918210156139cc5790607860218601536029915b81831161527857505050615259575090565b6044906040519063e22e27eb60e01b8252600482015260146024820152fd5b909192600f811660108110156152d75786518510156152d7576f181899199a1a9b1b9c1cb0b131b232b360811b901a86850183015360041c9280156152c257600019019190615247565b60246000634e487b7160e01b81526011600452fd5b60246000634e487b7160e01b81526032600452fd5b61530e916139ae91615321604051948592604060208501526060840190613bd5565b601f199384848303016040850152613bd5565b0390810183528261386c565b80156153b35760405190602082019163f665d08960e01b83528160248201526024815261535981613851565b600080938192519082305af161536d613e5b565b50156153bb576000805160206155c68339815191526020604051838152a15b602154810361539b5750602155565b601d5481036153aa5750601d55565b602854146153b6575b50565b602855565b6000805160206155e68339815191526020604051838152a161538c565b6001600160a01b03166000818152602960205260408120600501549091908015615480578280604051602081019063f665d08960e01b82528460248201526024815261542381613851565b519082305af1615431613e5b565b50156154625760206000805160206155c683398151915291604051908152a15b815260296020526005604082200155565b60206000805160206155e683398151915291604051908152a1615451565b50505056feb66c33d8dd981a05324331a06b40246adf774342c5561bc733d6134dd466a19e48c018e71a5dddbb3340ed814b28d8fa50919f2fadf743c08cfd081efd11e7aa9f3e24edc907a241049b64e96602212fa241281ba3234624fedac5b53eaebd8f59f4f66439eb3d711963a950e96a495061b2f45fa3fd12dd4948d1e785621a7264920dc17b8f48b9dd5335e42de77bb424b9967ea5cac96416476812e7b7bdee11dd463c4f2edd676b85f050130c7ab2f5832f52becb5444b09a92404aa1498a31956f32560a2aca7e6457f3ebe535b8b3ef72765b5ecffa4d32a073e37e23bdb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0d57b2b5166478fd4318d2acc6cc2c704584312bdd8781b32d5d06abda57f4230d2b8cd190f54408a8e1f68c863951d8b6515b9694fef3330e5942ac18a198999b975133a729b6e748425f7ad2ac304f2111a2f986c4daa4a769a3cd89d68a14924e583ad06c0a341b20a393419bb6b35dd48f347397d061a8531a73804420263944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9695a164736f6c6343000814000a000000000000000000000000005851f943ee2957b1748957f26319e4f9edebc10000000000000000000000004f77c5d13004bd1af865e453c2f38c2dc05120da000000000000000000000000f382517ede11aba5baf3fd287dfb492804d144ba00000000000000000000000015db03e67ed78605efff6ef454f14b4b56ccf33b0000000000000000000000002e6b9c8d4a0972f87f21437a3ac7e4a1810f54380000000000000000000000005084e9fdf9264489a14e77c011073d757e572bb40000000000000000000000005be5f71bc89a2e5fdbbb2d9aeff1f4a38d5870f7000000000000000000000000fe9777078ca0d60d2e9f489bf0297b433abccdec000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3800000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000002e516d54704d743763676b7541554350564c3957456b46365a34734a66614572546768385332525867796256516e4e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e516d633647763743454a6d4a4c557338624a54516b345a7532785173694557726375706f476e75536e5669355377000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e516d564a724644654e4c6f7169474e426439506d52735a506b416571526f4b61346157635a5a31694b4e66783273000000000000000000000000000000000000

Deployed Bytecode

0x60808060405260048036101561001f575b5050361561001d57600080fd5b005b600091823560e01c908163049aacfe1461376857508063058ed1a11461371b578063144935861461349d5780631750b4c5146133825780631ad11edf146133595780631eea859c1461331a578063211152a1146132f657806323ea0e03146132745780632793a6521461316757806328f150eb14613122578281632f3666371461304a575080632f622e6b14612f5c5780633430063d14612bc55780633a9690e014612b245780633aeac4e114612a505780634241c97f14612727578063538e109c146126e557806353e97868146126bc57806357fb1d671461268d578063591ce2d0146126485780635e6efb7c1461262a578063661794711461229857806370d5ae051461226f578063715018a61461221b57806371df6d5d146121e257806376e80fc2146121a357806379ba5097146121305780637cf11f7f146120eb5780638190f42b146120c257806384397888146120995780638a8c08fa146120435780638da5cb5b1461201c578063996c6cc314611ff55780639bd11a2114611e775780639e28bdcf14611dba5780639f96218214611d75578063a63748e514611cb3578063a86f8e3b14611b98578063a93843b814611b1a578063a96b7f0514611af6578063aacf93af1461164257828163b2185bb11461155357508063b54a820d1461128b578063b9f26c9714611152578063bb9eba9914611112578063c0ee5127146110dd578063c21495bb146110b7578063c25dc66214611072578063c31c9c0714611049578063c34fe1dd14611020578063c4049f1114610fec578063c5299cf414610da9578063c7576ca314610d66578063c7b5223314610aa7578063cb286c1514610a11578063db66e74f14610743578063dbc0c0851461071a578063dd03b7dc146106d5578063e0a1e92c14610659578063e20db5e114610630578063e21ba9d7146105eb578063e30c3978146105c2578063ee8ca3b51461059e578063f0a71a1814610580578063f2fde38b14610513578063f5831d4e14610476578063f665d08914610453578063f73baed41461041c578063f777cc19146103ec5763ff56835b0361001057346103e85760203660031901126103e8576103476137ab565b61034f613c15565b6001600160a01b031680835260226020526040832054909190156103b857508082526022602052610383604083205461417c565b80825260226020528160408120557f394da581e0d2af7f8c930cd6f0b402e5f148faf6a0cec50e787064490bc07e4c8280a280f35b60649060206040519162461bcd60e51b83528201526009602482015268139bdd08185919195960ba1b6044820152fd5b5080fd5b8234610419576020366003190112610419576104166104096137ab565b610411613c15565b6153d8565b80f35b80fd5b82346104195780600319360112610419576080601e54601f5460205460215491604051938452602084015260408301526060820152f35b50346103e85760203660031901126103e8573033036103e857610416903561417c565b50903461041957602091826003193601126103e8576001600160a01b039083906024836104a16137ab565b1693600954169160405194859384926370a0823160e01b84528301525afa91821561050757916104d5575b50604051908152f35b90508181813d8311610500575b6104ec818361386c565b810103126104fb5751386104cc565b600080fd5b503d6104e2565b604051903d90823e3d90fd5b82346104195760203660031901126104195761052d6137ab565b610535613c15565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b82346104195780600319360112610419576020601f54604051908152f35b50346103e85760203660031901126103e857610416906105bc613c15565b3561532d565b82346104195780600319360112610419576001546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576106056137ab565b61060d613c15565b600680546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576006546040516001600160a01b039091168152602090f35b50346103e85760203660031901126103e857358015158091036103e85761067e613c15565b601a549060ff8260081c161515146000146106c6575060ff19601a5416601a555b7f07e0778b8b42ff4733be759cb5b9d16ba44cf39077a71c1fc34a11fdd307cb0f8180a180f35b60ff1916600117601a5561069f565b8234610419576020366003190112610419576106ef6137ab565b6106f7613c15565b600980546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576007546040516001600160a01b039091168152602090f35b5090346104195780600319360112610419576001600160a01b0361078a337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a3831614613c41565b8060025416803b15610a0d578280918560405180948193638942fc3160e01b83525af18015610a02579083916109ee575b5050602454166109d6575b602b546109be575b42601f556107de601e5442613c89565b602090815560405163aacf93af60e01b818301528381526107fe81613800565b6040519061080b8261381b565b60038252606036848401376040516108228161381b565b60038152610831848201614e18565b60026108516040519461084386613800565b808652868601938452614e38565b52600361085e8451614e45565b52600561086b8451614e55565b5261089060405161087b81613836565b86815282519061088a82614e38565b52614e38565b506108b56040516108a081613836565b8681528251906108af82614e45565b52614e45565b5061025842018042116109ab579161094f61093060008051602061548683398151915296959361093e610956966108f460018060801b03809216614e65565b90604051911689820152620927c060408201526040815261091481613851565b60405193849160008b8401526040808401526060830190613bd5565b03601f19810184528361386c565b519061094982614e55565b52614e55565b5030614e81565b80601d55604051908152a1600080516020615606833981519152610978613fd2565b906109838282613eee565b61099260405192839283613d85565b0390a1426000805160206155068339815191528280a280f35b634e487b7160e01b865260118752602486fd5b6017805460ff60a81b1916600160a81b1790556107ce565b6017805460ff60a01b1916600160a01b1790556107c6565b6109f7906137d7565b6103e85781386107bb565b6040513d85823e3d90fd5b8280fd5b50346103e85760203660031901126103e857610a2b6137ab565b610a33613c15565b6001600160a01b03168083526014602052604083205490919060ff16610a6d57508152601460205260408120805460ff1916600117905580f35b60649060206040519162461bcd60e51b83528201526013602482015272105b1c9958591e481dda1a5d195b1a5cdd1959606a1b6044820152fd5b50346103e85760403660031901126103e857610ac16137c1565b600a546040516370a0823160e01b80825233828601526001600160a01b03949093602093919260249290919085908390859082908b165afa8015610cdc5787928991610d32575b50610b14901515614259565b610b34601754610b2a60ff8260a01c16156142f3565b8316331415614327565b16918287526014845260ff60408820541615610cf95767016345785d8a000095868235049680880297808904821490151715610ce757610b8390610b7b6025548a1161435c565b881015614396565b6003541694604051908152338282015284818481895afa8015610cdc5787918991610ca7575b5095610bbc869392610bd99810156143ce565b6040518080988194636eb1769f60e11b835230903390840161440f565b03915afa8015610c9c5785948791610c5b575b506000805160206154a683398151915294610c08911015614429565b60018060a01b0319903382825416179055846025556026541617602655604051610c3181613800565b8381526001828201428152338752602784526040872092518355519101556040519283523392a280f35b809550848092503d8311610c95575b610c74818361386c565b810103126104fb5792518493906000805160206154a6833981519152610bec565b503d610c6a565b6040513d88823e3d90fd5b80939250868092503d8311610cd5575b610cc1818361386c565b810103126104fb5790518690610bbc610ba9565b503d610cb7565b6040513d8a823e3d90fd5b634e487b7160e01b8952601183528389fd5b6015606492856040519362461bcd60e51b8552840152820152742737ba103bb434ba32b634b9ba32b2103a37b5b2b760591b6044820152fd5b809350868092503d8311610d5f575b610d4b818361386c565b810103126104fb57610b1487925190610b08565b503d610d41565b8234610419578060031936011261041957608060018060a01b03806024541690602554906026541660285491604051938452602084015260408301526060820152f35b50346103e85760803660031901126103e857610dc36137ab565b610dcb6137c1565b604435916001600160a01b03908184168085036104fb57606435958691610e15857f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a3163314613c41565b88858354168214600014610f3c57610e4e939150918460209387835416926040519687958694859363a9059cbb60e01b85528401613d9e565b03925af18015610f315760008051602061554683398151915294610e7e8592610eec948b91610f03575b506142b5565b6013548881811115610ef2575050886013555b16958688526029602052876005604082204260038201550155600080516020615606833981519152610ec1613fd2565b90610ecc8282613eee565b610edb60405192839283613d85565b0390a1604051938493169583613d9e565b0390a380f35b610efb91613cac565b601355610e91565b610f24915060203d8111610f2a575b610f1c818361386c565b810190613d04565b38610e78565b503d610f12565b6040513d89823e3d90fd5b90918560035416809314610f68575b50505050610eec8260008051602061554683398151915294610e91565b9184610f8d94926020946040519687958694859363a9059cbb60e01b85528401613d9e565b03925af18015610f315760008051602061554683398151915294610fbc8592610eec948b91610f0357506142b5565b6012548881811115610fdb575050886012555b94508691508738610f4b565b610fe491613cac565b601255610fcf565b823461041957806003193601126104195761101c611008613a1c565b604051918291602083526020830190613bd5565b0390f35b82346104195780600319360112610419576003546040516001600160a01b039091168152602090f35b82346104195780600319360112610419576008546040516001600160a01b039091168152602090f35b82346104195760203660031901126104195761108c6137ab565b611094613c15565b600880546001600160a01b0319166001600160a01b039290921691909117905580f35b8234610419578060031936011261041957602060ff601a5460081c166040519015158152f35b823461041957604036600319011261041957602061110a6110fc6137ab565b6111046137c1565b90614cf4565b604051908152f35b50346103e85760203660031901126103e85761112c6137ab565b611134613c15565b81546001600160a01b0319166001600160a01b039190911617905580f35b5090346104195761116236613973565b9161116b613c15565b8251906001600160401b03821161127857506111886018546139e2565b601f8111611231575b50602080601f83116001146111ce575082938293926111c3575b50508160011b916000199060031b1c19161760185580f35b0151905038806111ab565b90601f19831694601885528285209285905b878210611219575050836001959610611200575b505050811b0160185580f35b015160001960f88460031b161c191690553880806111f4565b806001859682949686015181550195019301906111e0565b6018835261126890600080516020615566833981519152601f840160051c8101916020851061126e575b601f0160051c0190613d2b565b38611191565b909150819061125b565b634e487b7160e01b835260419052602482fd5b50346103e85760603660031901126103e8576112a56137ab565b906112ae6137c1565b916044356001600160401b03811161154f576112cd90369084016138e1565b6001600160a01b0392908590611306337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a3871614613c41565b60608101958651151580611541575b80611529575b1561149c57506113626020918660075416838201526113418760085416895190886140d0565b86600854169060405194858094819363c04b8d5960e01b8352898301614086565b03925af18015610c9c57611471575b505b845b6015805482108080611467575b156113cf57156113ba57906113b591600052601460208683826000200154168952526040872060ff198154169055613d1c565b611375565b603283634e487b7160e01b6000525260246000fd5b87857f861ecaf4181c9874419a0979e36f584362245595975983e658d50ff1897f01fb6020898b60155460006015558061144b575b5060008051602061560683398151915261141c613fd2565b906114278282613eee565b61143660405192839283613d85565b0390a18560285551936040519485521692a280f35b6114619060156000528460002090810190613d2b565b86611404565b50600a8310611382565b602090813d8111611495575b611487818361386c565b810103126104fb5738611371565b503d61147d565b9150508385511515918261151b575b82611503575b50501561137357600754845160405163a9059cbb60e01b815291602091839182916114e0918916878401613d9e565b0381898888165af18015610c9c576114fe918791610f0357506142b5565b611373565b168652506014602052604085205460ff1683386114b1565b8482168282161492506114ab565b508581168352601460205260ff60408420541661131b565b508581168686161415611315565b8480fd5b80833461163f578160031936011261163f576001600160a01b039061159b337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a3841614613c41565b601a5460081c60ff1690811561161e57600f549284600f556115c684828454168360025416906140d0565b60025416803b1561154f578492836044926040519687958694631c44ccb760e21b865215159085015260248401525af18015611613576116035750f35b61160c906137d7565b6104195780f35b6040513d84823e3d90fd5b600e549284600e5561163a8482600354168360025416906140d0565b6115c6565b50fd5b50346103e857816003193601126103e8576001600160a01b03337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a382161461168981613c41565b611698601c54601e5490613c89565b61012b198101908111611ae357906116b661172b9392421015613cb9565b60ff80601a5460081c1680600014611aac576116f86116ef6116e66116dd878a54166141f0565b600f5490613cac565b60115490613cac565b60135490613cac565b935b6064611708600b5487613cf1565b04958695611726606461171d600c5484613cf1565b04988992613cac565b613cac565b9360019285841c9087848b611740858b613cac565b9315611a6657611777926117829592611760925416886007541690613db9565b61176c8b600f54613c89565b600f55601154613c89565b601155601354613c89565b6013555b888260025416986040519963a48debd160e01b8b5260209a8b818481855afa908115611a5b578491611a3e575b50611994575b5050508360175460a01c1680611987575b611971575b6017805460ff60a01b19811690915560a81c841680611966575b6118cf575b50506017805460ff60a81b1916905550601a546000805160206154c68339815191529561187a9392828116611880575b50505042601c5560008051602061560683398151915261183c613fd2565b906118478282613eee565b61185660405192839283613d85565b0390a185601d55604051938493846040919493926060820195825260208201520152565b0390a180f35b61ffff198316600893841c821615841b61ff001617601a819055604051931c16151582527f7c2a69ed281741b39b3eb61caf936f428fa2a0c2d418a7dc43cc0ff03a4942b391a138808061181e565b88835b611901575b505050509061187a916000805160206154c6833981519152956118f8613d42565b958192936117ee565b602b548110156119615780838061193561191d61195b956139b1565b92905461192988613c41565b600393841b1c1661497c565b61193e836139b1565b9054911b1c168b52602a8a5260408b20805460ff19169055613d1c565b836118d2565b6118d7565b50602b5415156117e9565b61197a81613c41565b61198261446c565b6117cf565b50816024541615156117ca565b61199d84613c41565b601a5460081c8716908115611a225750600f549183600f556119c883878354168860025416906140d0565b8560025416803b1561154f578492836044926040519687958694631c44ccb760e21b865215159085015260248401525af1801561161357611a0a575b806117b9565b611a13906137d7565b611a1e578838611a04565b8880fd5b91611a39600e54809486600e5588600354166140d0565b6119c8565b611a5591508c8d3d10610f2a57610f1c818361386c565b386117b3565b6040513d86823e3d90fd5b5092611a82611a9992611aa49560035416886007541690613db9565b611a8e8b600e54613c89565b600e55601054613c89565b601055601254613c89565b601255611786565b611add611ad4611acb611ac287600354166141f0565b600e5490613cac565b60105490613cac565b60125490613cac565b936116fa565b634e487b7160e01b855260118452602485fd5b823461041957602036600319011261041957602061110a611b156137ab565b6141f0565b823461041957602036600319011261041957611b346137ab565b90611b3e8261494e565b9091602b54905b818410611b5757602083604051908152f35b9091611b8a611b9091611b84611b6c876139b1565b905460039190911b1c6001600160a01b031685614cf4565b90613c89565b93613d1c565b929190611b45565b50903461041957611ba836613973565b91611bb1613c15565b8251906001600160401b0382116112785750611bce6019546139e2565b601f8111611c77575b50602080601f8311600114611c1457508293829392611c09575b50508160011b916000199060031b1c19161760195580f35b015190503880611bf1565b90601f19831694601985528285209285905b878210611c5f575050836001959610611c46575b505050811b0160195580f35b015160001960f88460031b161c19169055388080611c3a565b80600185968294968601518155019501930190611c26565b60198352611cad90600080516020615626833981519152601f840160051c8101916020851061126e57601f0160051c0190613d2b565b38611bd7565b5090346104195760603660031901126104195781356024359060443593611cd8613c15565b6064611ced86611ce88686613c89565b613c89565b03611d42575061187a7fb12262f78918536665563f06927bca9e755beea6ec97c15bd4c0a6a525523915939482600b5583600c5580600d55604051938493846040919493926060820195825260208201520152565b60649060206040519162461bcd60e51b8352820152600c60248201526b496e76616c6964206665657360a01b6044820152fd5b823461041957602036600319011261041957611d8f6137ab565b611d97613c15565b600380546001600160a01b0319166001600160a01b039290921691909117905580f35b50903461041957604036600319011261041957611dd56137ab565b60025460243591906001600160a01b039081163303611e3f576020918495611e1b9585936003541692604051978895869485936323b872dd60e01b855230918501614293565b03925af1918215610a025761041692611e3a918591610f0357506142b5565b614d4c565b60405162461bcd60e51b815260208187015260116024820152704f6e6c792046656573476976656177617960781b6044820152606490fd5b50903461041957806003193601126104195750600b54600c54600d54604051919360c08301906001600160401b03821184831017611fe05750604052600e548252600f54602083015260105460408301526011546060830152601254608083015260135460a08301526016549160175492611ef0613ac7565b611ef8613b4e565b90601a5495601b5493601c5495601d54976040519b8c9b8c5260208c015260408b0152805160608b0152602081015160808b0152604081015160a08b0152606081015160c08b0152608081015160e08b015260a001516101008a0152610120890152600160a01b6001900381166101408901528060a01c60ff16151561016089015260a81c60ff161515610180880152610280806101a08901528701611f9d91613bd5565b8681036101c0880152611faf91613bd5565b9360ff811615156101e087015260081c60ff1615156102008601526102208501526102408401526102608301520390f35b604190634e487b7160e01b6000525260246000fd5b50346103e857816003193601126103e857546040516001600160a01b039091168152602090f35b8234610419578060031936011261041957546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576104166120606137ab565b612094337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a36001600160a01b031614613c41565b61497c565b8234610419578060031936011261041957600a546040516001600160a01b039091168152602090f35b82346104195780600319360112610419576002546040516001600160a01b039091168152602090f35b8234610419576020366003190112610419576121056137ab565b61210d613c15565b600a80546001600160a01b0319166001600160a01b039290921691909117905580f35b50346103e857816003193601126103e857600154906001600160a01b0390338284160361218b575060018060a01b0319809216600155600054913390831617600055339116600080516020615586833981519152600080a380f35b6024906040519063118cdaa760e01b82523390820152fd5b82346104195760203660031901126104195760209060ff906040906001600160a01b036121ce6137ab565b168152602a84522054166040519015158152f35b8234610419576020366003190112610419576020906040906001600160a01b0361220a6137ab565b168152602283522054604051908152f35b8234610419578060031936011261041957612234613c15565b600180546001600160a01b0319908116909155600080549182168155906001600160a01b03166000805160206155868339815191528280a380f35b82346104195780600319360112610419576005546040516001600160a01b039091168152602090f35b50346103e85760403660031901126103e8576122b26137c1565b600a546040516370a0823160e01b8082523385830152926020926001600160a01b0392919084908390602490829087165afa8015610f3157839288916125f6575b506122ff901515614259565b61231160ff60175460a81c16156142f3565b16938486526029835261232e33838360408a200154161415614327565b604051630a7d2f0d60e31b815283818381895afa908115610f315787916125bd575b5082806009541691160361258a5767016345785d8a000093848235049480860295808704821490151715612577576123a3908789526029865261239b600160408b200154881161435c565b861015614396565b82600354169060405190815233838201528481602481855afa8015610cdc5786908990612546575b6123d7925010156143ce565b836040518092636eb1769f60e11b825281806123f6303389840161440f565b03915afa8015610f315785908890612515575b61241592501015614429565b848652602a835260ff604087205416156124b3575b50508060296000805160206154e6833981519152925282600160408720600381018054156124a8575b5033828060a01b0319825416178155015560405161247081613800565b83815260018282014281528688526029845260026040892001336000528452604060002092518355519101556040519283523392a380f35b601b54905538612453565b602b5490600160401b821015611fe05750906124e58260016000805160206154e6833981519152959401602b556139b1565b819291549060031b9187831b921b1916179055838552602a815260408520600160ff19825416179055903861242a565b50508381813d831161253f575b61252c818361386c565b810103126104fb57846124159151612409565b503d612522565b50508481813d8311612570575b61255d818361386c565b810103126104fb57856123d791516123cb565b503d612553565b634e487b7160e01b885260118352602488fd5b60405162461bcd60e51b8152908101839052600c60248201526b125b9d985b1a59081c1bdbdb60a21b6044820152606490fd5b90508381813d83116125ef575b6125d4818361386c565b810103126125eb576125e590613fbe565b38612350565b8680fd5b503d6125ca565b809350858092503d8311612623575b61260f818361386c565b810103126104fb576122ff839251906122f3565b503d612605565b82346104195780600319360112610419576020601e54604051908152f35b8234610419576020366003190112610419576126626137ab565b61266a613c15565b600280546001600160a01b0319166001600160a01b039290921691909117905580f35b82346104195780600319360112610419576020604051737506c12a824d73d9b08564d5afc22c949434755e8152f35b82346104195780600319360112610419576009546040516001600160a01b039091168152602090f35b50346103e85760203660031901126103e8573590602b5482101561041957602061270e836139b1565b905460405160039290921b1c6001600160a01b03168152f35b509034610419576020806003193601126103e857823592612746613c15565b83159384159485612a44575b15612a12578061276991601e5542601f5542613c89565b825542601b5542601c55612786602854612781613c15565b61532d565b612794601d54612781613c15565b6127a2602154612781613c15565b6127aa614070565b825b602b5481101561285657806127c3612851926139b1565b9054906127ce613c15565b6001600160a01b03916003916127e99190831b1c83166153d8565b816127f3846139b1565b905490831b1c16875260298087526000600160408a20828155015582612818856139b1565b905490841b1c16885286528681604082200155612834836139b1565b9054911b1c168552602a845260408520805460ff19169055613d1c565b6127ac565b5092612860613d42565b6017805461ffff60a01b1916905561289b575b507f9a49eeb4937d3bf5ec82aac78b34160029b47efe32ca3f6f919a93656663b76e8180a180f35b6002546001600160a01b0316803b15610a0d578280918560405180948193630a4ec5c760e11b83525af18015610a02579083916129fe575b505060405163db66e74f60e01b828201529283526128f083613800565b6040516128fc81613851565b60028152604036838301376040519361291485613851565b6002855260005b604081106129ef5750906129dd9161094f610930600080516020615486833981519152969760026129606040519661295288613800565b808852898801938452614e38565b52600561296d8651614e45565b5261298c60405161297d81613836565b8a815282519061088a82614e38565b5086546129d2906001600160801b03906129a7908216614e65565b906129b581601e5416614e65565b8160405193168b8401521660408201526040815261091481613851565b51906108af82614e45565b80602155604051908152a18038612873565b6060868201850152830161291b565b612a07906137d7565b6103e85781386128d3565b506064916040519162461bcd60e51b8352820152600c60248201526b54696d6520746f6f206c6f7760a01b6044820152fd5b506104b0811015612752565b50346103e85760403660031901126103e857612a6a6137ab565b90612a736137c1565b91612a7c613c15565b6040516370a0823160e01b815230928101929092526001600160a01b031691602082602481865afa908115611a5b578491612ae3575b6000805160206155268339815191529250612ace828286613db9565b612add60405192839283613d9e565b0390a280f35b90506020823d8211612b1c575b81612afd6020938361386c565b810103126104fb57600080516020615526833981519152915190612ab2565b3d9150612af0565b50346103e85760203660031901126103e857612b3e6137ab565b600754916001600160a01b0391908284163303612b905750166001600160a01b03199190911681176007557f7a647445a4e730026e2c1994e60120e45528249cc60705e7a38c72e066834f9d8280a280f35b60649060206040519162461bcd60e51b8352820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b6044820152fd5b50346103e857602080600319360112610a0d57612be06137ab565b91612be9613c15565b6001600160a01b03928316808552602283526040852054909390612f2957612c1030615207565b612c1985615207565b60405163313ce56760e01b81529092858286818a5afa8015610cdc5760ff612c4d91612c80948b91612efc575b50166150a5565b90612c67612c5e8260035416615207565b91875416615207565b90612c71466150a5565b926040519687968a8801615038565b03612c93601f199182810184528361386c565b60405192612ca08461381b565b6003845260609182368787013760405191612cba8361381b565b60038352612cc9878401614e18565b6002612ce960405197612cdb89613800565b808952898901958652614e38565b52612cf48651614e45565b526005612d018651614e55565b52612d20604051612d1181613836565b89815283519061088a82614e38565b50612d41612d3585612d30613a1c565b6152ec565b8351906108af82614e45565b5060405192612d4f84613800565b6001938481528760005b818110612eed575050604051612d6e81613800565b858152883681830137612d8082614e38565b52612d8a81614e38565b50600080516020615506833981519152612dac612da683614e38565b51614e38565b52604051946080860190308a880152836040880152825180925260a08701918c8b60a08360051b8b0101950193815b838310612e945750505050505084612e6a9461093e8a999585612e418561094f977f829ca1e6f5ac6dcb63b6ca82b6efeefce80a186f58cb7fbeeae114dda6baa31f9f9c6000805160206154868339815191529e9a60079101520383810187528661386c565b612e5e60405195869260028d850152604080850152830190613bd5565b0390810184528361386c565b85875260228252806040882055604051908152a1828452602281526040842054604051908152a280f35b909192938d819697609f198d8203018552885190828083519283815201920194905b808210612ed357505081929350970192019201909392918e612ddb565b9280919492865181520194019201928f9193889394612eb6565b83828285010152018890612d59565b612f1c9150893d8b11612f22575b612f14818361386c565b81019061501f565b38612c46565b503d612f0a565b506064916040519162461bcd60e51b8352820152600d60248201526c105b1c9958591e481859191959609a1b6044820152fd5b50346103e85760203660031901126103e857612f766137ab565b612f7e613c15565b4790811561300e576001600160a01b0316918380808085875af1612fa0613e5b565b5015612fd5575060207fc4825c2033e49b7d8db9d453f0a5953dc550c9452166b576df9f456893f1695f91604051908152a280f35b60649060206040519162461bcd60e51b83528201526012602482015271151c985b9cd858dd1a5bdb8819985a5b195960721b6044820152fd5b60405162461bcd60e51b815260208185015260156024820152744e6f204e617469766520746f20776974686472617760581b6044820152606490fd5b80833461163f57602036600319011261163f57600a546040516370a0823160e01b815233838201526001600160a01b03916020908290602490829086165afa908115611a5b5784916130eb575b506130a3901515614259565b60025416803b156130e75760405163fdad3a5f60e01b815291839183918290849082906130d69033908035908401613d85565b03925af18015611613576116035750f35b5050fd5b9350506020833d821161311a575b816131066020938361386c565b810103126104fb576130a384935190613097565b3d91506130f9565b82346104195780600319360112610419576040517f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a36001600160a01b03168152602090f35b50346103e85760203660031901126103e8576131816137ab565b9061318a613c15565b6001600160a01b039182168084526014602052604084205490929060ff161561323e576026541682036132275760155490600160401b821015611fe0576001820180601555821015613212575060156000527f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750180546001600160a01b031916909117905580f35b603290634e487b7160e01b6000525260246000fd5b508152601460205260408120805460ff1916905580f35b60405162461bcd60e51b8152602081840152600f60248201526e139bdd081dda1a5d195b1a5cdd1959608a1b6044820152606490fd5b50346103e85760203660031901126103e85760a0916001600160a01b0391906040908361329f6137ab565b168152602960205220604051916132b583613800565b600584835416948585526020600185015495019485526003840154928401541692015492604051948552516020850152604084015260608301526080820152f35b823461041957602036600319011261041957602061110a6133156137ab565b61494e565b82346104195760203660031901126104195760209060ff906040906001600160a01b036133456137ab565b168152601484522054166040519015158152f35b50346103e85760203660031901126103e85735613374613c15565b606481116103e85760165580f35b5090346104195761339236613973565b9161339b613c15565b8251906001600160401b03821161127857506133b86023546139e2565b601f8111613461575b50602080601f83116001146133fe575082938293926133f3575b50508160011b916000199060031b1c19161760235580f35b0151905038806133db565b90601f19831694602385528285209285905b878210613449575050836001959610613430575b505050811b0160235580f35b015160001960f88460031b161c19169055388080613424565b80600185968294968601518155019501930190613410565b60238352613497906000805160206155a6833981519152601f840160051c8101916020851061126e57601f0160051c0190613d2b565b386133c1565b50346103e85760403660031901126103e8576134b76137ab565b906024356001600160401b038111613717576134d690369083016138e1565b916001600160a01b039061350d337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a3841614613c41565b601a5460081c60ff161561370557613527828454166141f0565b8260095416946060810195878751823b156103e85760405163f3fef3a360e01b815292839182908490829061355f908b838f01613d9e565b03925af18015610cdc576136f2575b50869060ff601a5460081c1680806136e2575b81156136c4575b5015613637575b5050906135e083927fa1644d67f50368863681a400048e0e892596b0bfceae204b0b2e879b26e2e6829560409560ff601a5460081c16600014613623576135d79154166141f0565b965b5196613cac565b6000805160206156068339815191526135f7613fd2565b906136028282613eee565b613610875192839283613d85565b0390a1835195865260208601521692a280f35b6136319150600354166141f0565b966135d9565b61367d602091308382015261365c61364e876141f0565b808b528860085416886140d0565b86600854169060405194858094819363c04b8d5960e01b83528c8301614086565b03925af18015610f3157613693575b869061358f565b60209081949392943d81116136bd575b6136ad818361386c565b810103126104fb5790913861368c565b503d6136a3565b905015806136d3575b38613588565b508460035416858516146136cd565b9050858754168686161490613581565b6136fe909791976137d7565b953861356e565b61371282600354166141f0565b613527565b8380fd5b8234610419578060031936011261041957613760337f00000000000000000000000022af170bd1c4577b56ea0bd40db78540cad441a36001600160a01b031614613c41565b61041661446c565b8390346103e857816003193601126103e8577f000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e6001600160a01b03168152602090f35b600435906001600160a01b03821682036104fb57565b602435906001600160a01b03821682036104fb57565b6001600160401b0381116137ea57604052565b634e487b7160e01b600052604160045260246000fd5b604081019081106001600160401b038211176137ea57604052565b608081019081106001600160401b038211176137ea57604052565b602081019081106001600160401b038211176137ea57604052565b606081019081106001600160401b038211176137ea57604052565b601f909101601f19168101906001600160401b038211908210176137ea57604052565b6001600160401b0381116137ea57601f01601f191660200190565b9291926138b68261388f565b916138c4604051938461386c565b8294818452818301116104fb578281602093846000960137010152565b91909160a0818403126104fb576040516001600160401b039390919060a08301858111848210176137ea57604052829482359081116104fb5782019080601f830112156104fb57816020613937933591016138aa565b825260208101356001600160a01b03811681036104fb576080918291602085015260408101356040850152606081013560608501520135910152565b60206003198201126104fb57600435906001600160401b0382116104fb57806023830112156104fb578160246139ae936004013591016138aa565b90565b602b548110156139cc57602b60005260206000200190600090565b634e487b7160e01b600052603260045260246000fd5b90600182811c92168015613a12575b60208310146139fc57565b634e487b7160e01b600052602260045260246000fd5b91607f16916139f1565b6040519060008260235491613a30836139e2565b808352600193808516908115613aa65750600114613a58575b50613a569250038361386c565b565b602360009081526000805160206155a683398151915294602093509091905b818310613a8e575050613a56935082010138613a49565b85548884018501529485019487945091830191613a77565b9050613a5694506020925060ff191682840152151560051b82010138613a49565b6040519060008260185491613adb836139e2565b808352600193808516908115613aa65750600114613b005750613a569250038361386c565b6018600090815260008051602061556683398151915294602093509091905b818310613b36575050613a56935082010138613a49565b85548884018501529485019487945091830191613b1f565b6040519060008260195491613b62836139e2565b808352600193808516908115613aa65750600114613b875750613a569250038361386c565b6019600090815260008051602061562683398151915294602093509091905b818310613bbd575050613a56935082010138613a49565b85548884018501529485019487945091830191613ba6565b919082519283825260005b848110613c01575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201613be0565b6000546001600160a01b03163303613c2957565b60405163118cdaa760e01b8152336004820152602490fd5b15613c4857565b60405162461bcd60e51b815260206004820152601960248201527827b7363c903232b234b1b0ba32b21036b9b39739b2b73232b960391b6044820152606490fd5b91908201809211613c9657565b634e487b7160e01b600052601160045260246000fd5b91908203918211613c9657565b15613cc057565b60405162461bcd60e51b8152602060048201526009602482015268546f6f206561726c7960b81b6044820152606490fd5b81810292918115918404141715613c9657565b908160209103126104fb575180151581036104fb5790565b6000198114613c965760010190565b818110613d36575050565b60008155600101613d2b565b602b546000602b5580613d525750565b602b600052613a56907f11c44e4875b74d31ff9fd779bf2566af7bd15b87fc985d01f5094b89e3669e4f90810190613d2b565b9081526001600160a01b03909116602082015260400190565b6001600160a01b039091168152602081019190915260400190565b6000613e12928192613df4613de696604051978891602083019563a9059cbb60e01b875260248401613d9e565b03601f19810188528761386c565b60018060a01b031694519082865af1613e0b613e5b565b9083613e8b565b8051908115159182613e40575b5050613e285750565b60249060405190635274afe760e01b82526004820152fd5b613e539250602080918301019101613d04565b153880613e1f565b3d15613e86573d90613e6c8261388f565b91613e7a604051938461386c565b82523d6000602084013e565b606090565b90613eb25750805115613ea057805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580613ee5575b613ec3575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15613ebb565b906001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103613f9257506000808080937f00000000000000000000000092478c7eccb3c7a3932263712c1555dbaea7d56c5af1613f45613e5b565b5015613f4d57565b60405162461bcd60e51b815260206004820152601e60248201527f5f7472616e736665723a20455448207472616e73666572206661696c656400006044820152606490fd5b90613a56917f00000000000000000000000092478c7eccb3c7a3932263712c1555dbaea7d56c90613db9565b51906001600160a01b03821682036104fb57565b60408051635c08631b60e11b815281816004817f000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e6001600160a01b03165afa908115614065576000928392614028575b50509091565b9080939250813d831161405e575b614040818361386c565b810103126104195750614057602082519201613fbe565b3880614022565b503d614036565b82513d6000823e3d90fd5b6000602455600060255560006026556000602855565b6020815260a060806140a3845183602086015260c0850190613bd5565b93600180841b03602082015116604085015260408101516060850152606081015182850152015191015290565b60009291836140fb6141098295604051928391602083019663095ea7b360e01b885260248401613d9e565b03601f19810183528261386c565b51925af1614115613e5b565b8161414d575b501561412357565b60405162461bcd60e51b8152602060048201526002602482015261534160f01b6044820152606490fd5b8051801592508215614162575b50503861411b565b6141759250602080918301019101613d04565b388061415a565b7f000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e6001600160a01b031690813b156104fb5760009160248392604051948593849263ee8ca3b560e01b845260048401525af180156141e4576141db5750565b613a56906137d7565b6040513d6000823e3d90fd5b6040516370a0823160e01b815230600482015290602090829060249082906001600160a01b03165afa9081156141e45760009161422b575090565b906020823d8211614251575b816142446020938361386c565b8101031261041957505190565b3d9150614237565b1561426057565b60405162461bcd60e51b815260206004820152600b60248201526a2737ba102628103ab9b2b960a91b6044820152606490fd5b6001600160a01b03918216815291166020820152604081019190915260600190565b156142bc57565b60405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606490fd5b156142fa57565b60405162461bcd60e51b8152602060048201526005602482015264115b99195960da1b6044820152606490fd5b1561432e57565b60405162461bcd60e51b815260206004820152600660248201526510985b9b995960d21b6044820152606490fd5b1561436357565b60405162461bcd60e51b815260206004820152600b60248201526a42696420746f6f206c6f7760a81b6044820152606490fd5b1561439d57565b60405162461bcd60e51b81526020600482015260096024820152683c20302e312024414760b81b6044820152606490fd5b156143d557565b60405162461bcd60e51b81526020600482015260126024820152714e6f7420656e6f7567682062616c616e636560701b6044820152606490fd5b6001600160a01b0391821681529116602082015260400190565b1561443057565b60405162461bcd60e51b81526020600482015260146024820152734e6f7420656e6f75676820616c6c6f77616e636560601b6044820152606490fd5b60175461447e60ff8260a01c16613cb9565b60018060a01b03908160245416916025549060039281845416916040938451926370a0823160e01b845260049488868601526020948581602481855afa9081156149105787879160009361491b575b506144ee938c8b51809681948293636eb1769f60e11b84523091840161440f565b03915afa918215614910579084916000936148de575b5081119182156148d4575b50506148b3575061453f8382848954168760008c8b51968795869485936323b872dd60e01b855230918501614293565b03925af19081156148a8576145609291611e3a9160009161489157506142b5565b601a5460081c60ff161561485d576011549261458b606461458360165487613cf1565b048095613cac565b95600060115584614845575b601780546001600160a01b03191690556026548316926145b5614070565b601a5460081c60ff161561483b5780835416935b6145d230615207565b916145e08160075416615207565b9585886145ec85615207565b948c519283809263313ce56760e01b82525afa908115614830578b959493929160ff91600091614813575b5016614622906150a5565b9161462c8d6150a5565b911661463790615207565b91614641466150a5565b938651998a968c880160e09052610100880161465c91613bd5565b601f199889898303019089015261467291613bd5565b8787820301606088015261468591613bd5565b8686820301608087015261469891613bd5565b858582030160a08601526146ab91613bd5565b848482030160c08501526146be91613bd5565b838382030160e08401526146d191613bd5565b0390810184526146e1908461386c565b8551916146ed8361381b565b818352606036868501378651916147038361381b565b808352614711868401614e18565b87519361471d85613800565b80855286850193845261472f90614e38565b60029052835161473e90614e45565b52825161474a90614e55565b52855161475681613836565b6000815281519061476682614e38565b5261477090614e38565b50855161477c81613836565b6000815281519061478c82614e45565b5261479690614e45565b50826147a0613ac7565b906147aa916152ec565b9051906147b682614e55565b526147c090614e55565b506147cb9130614e81565b8060285581845191825260008051602061548683398151915291a182519384528301527f6628ed72e16e5aedaefe37d11641b2f8463c19d223cce10cac20f853f64d8ed691a2565b61482a91508b3d8d11612f2257612f14818361386c565b38614617565b8b513d6000823e3d90fd5b80825416936145c9565b6148588584845416856006541690613db9565b614597565b60105492614872606461458360165487613cf1565b9560006010558415614597576148588584835416856006541690613db9565b610f249150863d8811610f2a57610f1c818361386c565b86513d6000823e3d90fd5b6001600160a01b0319169690961760175550613a5694506140709350505050565b109050823861450f565b9150918682813d8311614909575b6148f6818361386c565b8101031261041957505190839081614504565b503d6148ec565b88513d6000823e3d90fd5b8281949392503d8311614947575b614933818361386c565b8101031261041957505185876144ee6144cd565b503d614929565b6001600160a01b031660009081526027602052604090206001810154601c54106149785750600090565b5490565b61498d60ff60175460a81c16613cb9565b60018060a01b038091169060008281526020602981526040808320936001818654169501549060039080825416928451936370a0823160e01b855260049489868201528781602481855afa908115614cb9578a89918b93614cc3575b50614a099389518080968194636eb1769f60e11b835230908d840161440f565b03915afa918215614cb9579083918a93614c86575b508111918215614c7c575b5050614c4e57614a57868284865416878b8d8b51968795869485936323b872dd60e01b855230918501614293565b03925af1908115614c445784614b5c89614b4e614c07978f8f977f2389140956343c2bdbaa10a0a94f87a1cdc988150cee813429f3d86fbd16012e9f9e9c999b8f6000805160206154868339815191529f9d614ac490611e3a614af29561094f9d8591614c2d57506142b5565b838152602987528d81208c810180546001600160a01b03191690558181556001810191909155015442613cac565b9160ff601a5460081c16600014614c2057614b37818b5416915b614b30614b2a614b24614b1e30615207565b9d615207565b966150a5565b94615207565b9216615207565b91614b41466150a5565b938d519a8b978801615038565b03601f19810185528461386c565b855193614b688561381b565b81855260603689870137865191614b7e8361381b565b808352614b8c898401614e18565b6002614bab895197614b9d89613800565b8089528b8901958652614e38565b52614bb68651614e45565b52614bc18551614e55565b52614bd0865161297d81613836565b50614bee8651614bdf81613836565b8a81528251906108af82614e45565b50614bfb83612d30613b4e565b90519061094982614e55565b9087855260298352816005828720015551908152a180a3565b614b378188541691614b0c565b610f2491508b3d8d11610f2a57610f1c818361386c565b86513d8a823e3d90fd5b5050509483526029909152812092830180546001600160a01b03191690921790915580825560019190910155565b1090508138614a29565b89809294508193503d8311614cb2575b614ca0818361386c565b81010312611a1e575190829081614a1e565b503d614c96565b87513d8b823e3d90fd5b92505081813d8311614ced575b614cda818361386c565b81010312611a1e5751878a614a096149e9565b503d614cd0565b9060018060a01b03809116916000918383526029602052600260408420019116908183526020526001604083200154601c5410614d315750905090565b60409282526029602052600283832001908252602052205490565b614d8160208260018060a01b0380600354169060055416600060405180968195829463a9059cbb60e01b845260048401613d9e565b03925af19081156141e457600091614dfa575b5015614dc75760207f6ef4855b666dcc7884561072e4358b28dfe01feb1b7f4dcebc00e62d50394ac791604051908152a1565b60405162461bcd60e51b815260206004820152600b60248201526a109d5c9b8819985a5b195960aa1b6044820152606490fd5b614e12915060203d8111610f2a57610f1c818361386c565b38614d94565b9060005b606080821015614e325783820152602001614e1c565b50509050565b8051156139cc5760200190565b8051600110156139cc5760400190565b8051600210156139cc5760600190565b6001600160801b039081166103e80290811691908203613c9657565b6040518093633323b46760e01b825260018060a01b0390816004941684840152614eb76024956080878601526084850190613bd5565b906003198483030160448501526040820190805195604084528651809352606084019260209889809901926000915b838310614fd9575050505050850151918581830391015281518082528582019186808360051b8301019401926000915b838310614fa8575050505050600083809273eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee606483015203927f000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e165af19081156141e457600091614f7c575b50905090565b82813d8311614fa1575b614f90818361386c565b810103126104195750518038614f76565b503d614f86565b9295978091949750614fc760019396601f198682030187528951613bd5565b97019301930188959388979592614f16565b92959194969850928097995051600681101561500b578a8281926001945201970193018a979593928a99979592614ee6565b82602185634e487b7160e01b600052526000fd5b908160209103126104fb575160ff811681036104fb5790565b94919361507b6150979461506d6139ae999761505f6150899660c08c5260c08c0190613bd5565b908a820360208c0152613bd5565b9088820360408a0152613bd5565b908682036060880152613bd5565b908482036080860152613bd5565b9160a0818403910152613bd5565b6000908072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b808210156151f9575b506904ee2d6d415b85acef8160201b808310156151ea575b50662386f26fc10000808310156151db575b506305f5e100808310156151cc575b50612710808310156151bd575b5060648210156151ad575b600a809210156151a3575b600190816021818601956151388761388f565b96615146604051988961386c565b808852615155601f199161388f565b01366020890137860101905b61516d575b5050505090565b600019019083906f181899199a1a9b1b9c1cb0b131b232b360811b8282061a83530491821561519e57919082615161565b615166565b9160010191615125565b919060646002910491019161511a565b6004919392049101913861510f565b60089193920491019138615102565b601091939204910191386150f3565b602091939204910191386150e1565b6040935081049150386150c9565b806040519161521583613851565b602a8352602080840160403682378451156139cc57603090538351906001918210156139cc5790607860218601536029915b81831161527857505050615259575090565b6044906040519063e22e27eb60e01b8252600482015260146024820152fd5b909192600f811660108110156152d75786518510156152d7576f181899199a1a9b1b9c1cb0b131b232b360811b901a86850183015360041c9280156152c257600019019190615247565b60246000634e487b7160e01b81526011600452fd5b60246000634e487b7160e01b81526032600452fd5b61530e916139ae91615321604051948592604060208501526060840190613bd5565b601f199384848303016040850152613bd5565b0390810183528261386c565b80156153b35760405190602082019163f665d08960e01b83528160248201526024815261535981613851565b600080938192519082305af161536d613e5b565b50156153bb576000805160206155c68339815191526020604051838152a15b602154810361539b5750602155565b601d5481036153aa5750601d55565b602854146153b6575b50565b602855565b6000805160206155e68339815191526020604051838152a161538c565b6001600160a01b03166000818152602960205260408120600501549091908015615480578280604051602081019063f665d08960e01b82528460248201526024815261542381613851565b519082305af1615431613e5b565b50156154625760206000805160206155c683398151915291604051908152a15b815260296020526005604082200155565b60206000805160206155e683398151915291604051908152a1615451565b50505056feb66c33d8dd981a05324331a06b40246adf774342c5561bc733d6134dd466a19e48c018e71a5dddbb3340ed814b28d8fa50919f2fadf743c08cfd081efd11e7aa9f3e24edc907a241049b64e96602212fa241281ba3234624fedac5b53eaebd8f59f4f66439eb3d711963a950e96a495061b2f45fa3fd12dd4948d1e785621a7264920dc17b8f48b9dd5335e42de77bb424b9967ea5cac96416476812e7b7bdee11dd463c4f2edd676b85f050130c7ab2f5832f52becb5444b09a92404aa1498a31956f32560a2aca7e6457f3ebe535b8b3ef72765b5ecffa4d32a073e37e23bdb13d2d76d1f4b7be834882e410b3e3a8afaf69f83600ae24db354391d2378d2e8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0d57b2b5166478fd4318d2acc6cc2c704584312bdd8781b32d5d06abda57f4230d2b8cd190f54408a8e1f68c863951d8b6515b9694fef3330e5942ac18a198999b975133a729b6e748425f7ad2ac304f2111a2f986c4daa4a769a3cd89d68a14924e583ad06c0a341b20a393419bb6b35dd48f347397d061a8531a73804420263944998273e477b495144fb8794c914197f3ccb46be2900f4698fd0ef743c9695a164736f6c6343000814000a

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000005851f943ee2957b1748957f26319e4f9edebc10000000000000000000000004f77c5d13004bd1af865e453c2f38c2dc05120da000000000000000000000000f382517ede11aba5baf3fd287dfb492804d144ba00000000000000000000000015db03e67ed78605efff6ef454f14b4b56ccf33b0000000000000000000000002e6b9c8d4a0972f87f21437a3ac7e4a1810f54380000000000000000000000005084e9fdf9264489a14e77c011073d757e572bb40000000000000000000000005be5f71bc89a2e5fdbbb2d9aeff1f4a38d5870f7000000000000000000000000fe9777078ca0d60d2e9f489bf0297b433abccdec000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3800000000000000000000000000000000000000000000000000000000000001a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000260000000000000000000000000000000000000000000000000000000000000002e516d54704d743763676b7541554350564c3957456b46365a34734a66614572546768385332525867796256516e4e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e516d633647763743454a6d4a4c557338624a54516b345a7532785173694557726375706f476e75536e5669355377000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002e516d564a724644654e4c6f7169474e426439506d52735a506b416571526f4b61346157635a5a31694b4e66783273000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _silver (address): 0x005851f943ee2957B1748957F26319e4f9EdeBC1
Arg [1] : _silverFeesGiveaway (address): 0x4F77c5D13004bd1af865e453c2f38C2DC05120da
Arg [2] : _burnAddress (address): 0xF382517EDE11aba5baf3fD287dFb492804d144ba
Arg [3] : _flareProgramAddress (address): 0x15DB03e67eD78605efFf6eF454F14B4B56CcF33b
Arg [4] : _swapRouter (address): 0x2e6b9c8D4a0972F87f21437A3AC7E4a1810f5438
Arg [5] : _nftPositionManager (address): 0x5084E9fDF9264489A14E77c011073D757e572bB4
Arg [6] : _communityVault (address): 0x5bE5f71bC89a2E5Fdbbb2D9Aeff1F4a38d5870F7
Arg [7] : _teamMultisig (address): 0xfe9777078Ca0d60d2e9F489bF0297B433AbcCdEC
Arg [8] : _automate (address): 0xafd37d0558255aA687167560cd3AaeEa75c2841E
Arg [9] : _wrappedToken (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
Arg [10] : _flareCID (string): QmTpMt7cgkuAUCPVL9WEkF6Z4sJfaErTgh8S2RXgybVQnN
Arg [11] : _snatchCID (string): Qmc6Gv7CEJmJLUs8bJTQk4Zu2xQsiEWrcupoGnuSnVi5Sw
Arg [12] : _feesTokenCID (string): QmVJrFDeNLoqiGNBd9PmRsZPkAeqRoKa4aWcZZ1iKNfx2s

-----Encoded View---------------
22 Constructor Arguments found :
Arg [0] : 000000000000000000000000005851f943ee2957b1748957f26319e4f9edebc1
Arg [1] : 0000000000000000000000004f77c5d13004bd1af865e453c2f38c2dc05120da
Arg [2] : 000000000000000000000000f382517ede11aba5baf3fd287dfb492804d144ba
Arg [3] : 00000000000000000000000015db03e67ed78605efff6ef454f14b4b56ccf33b
Arg [4] : 0000000000000000000000002e6b9c8d4a0972f87f21437a3ac7e4a1810f5438
Arg [5] : 0000000000000000000000005084e9fdf9264489a14e77c011073d757e572bb4
Arg [6] : 0000000000000000000000005be5f71bc89a2e5fdbbb2d9aeff1f4a38d5870f7
Arg [7] : 000000000000000000000000fe9777078ca0d60d2e9f489bf0297b433abccdec
Arg [8] : 000000000000000000000000afd37d0558255aa687167560cd3aaeea75c2841e
Arg [9] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [10] : 00000000000000000000000000000000000000000000000000000000000001a0
Arg [11] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000260
Arg [13] : 000000000000000000000000000000000000000000000000000000000000002e
Arg [14] : 516d54704d743763676b7541554350564c3957456b46365a34734a6661457254
Arg [15] : 6768385332525867796256516e4e000000000000000000000000000000000000
Arg [16] : 000000000000000000000000000000000000000000000000000000000000002e
Arg [17] : 516d633647763743454a6d4a4c557338624a54516b345a753278517369455772
Arg [18] : 6375706f476e75536e5669355377000000000000000000000000000000000000
Arg [19] : 000000000000000000000000000000000000000000000000000000000000002e
Arg [20] : 516d564a724644654e4c6f7169474e426439506d52735a506b416571526f4b61
Arg [21] : 346157635a5a31694b4e66783273000000000000000000000000000000000000


Block Transaction Gas Used Reward
view all blocks produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ 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.