get(uint256) :
This function is used to retrieve a FundingCycle struct from the contract's storage. It takes a uint256 _fundingCycleId as an argument and returns a FundingCycle memory. The function first checks to make sure that the _fundingCycleId is greater than 0 and less than or equal to the count of FundingCycles stored in the contract. If the check passes, the function calls the _getStruct() function to retrieve the FundingCycle struct from the contract's storage. (autogenerated documentation)
queuedOf(uint256) :
This function returns the FundingCycle memory associated with a given project ID. It first checks if the latest ID of the project is 0, and if so, it returns a struct with 0. It then checks if there is a funding cycle in the standby queue, and if so, it returns the associated struct. If not, it checks if there is an eligible funding cycle and if so, it checks if it is approved. If it is approved, it returns a mock funding cycle based on the eligible funding cycle. If not, it sets the funding cycle ID to the basedOn field of the eligible funding cycle. If there is no eligible funding cycle, it sets the funding cycle ID to the latest ID of the project. Finally, (autogenerated documentation)
currentOf(uint256) :
This function retrieves the current FundingCycle for a given projectId. It first checks if the latestIdOf the projectId is 0, and if so, it returns a struct with 0 values. If the latestIdOf the projectId is not 0, it checks if the fundingCycleId is eligible or in standby. If it is eligible, it checks if the start time is before the current block timestamp and if it is approved. If it is approved, it returns the fundingCycle. If it is not approved, it sets the fundingCycleId to the basedOn value and checks if it is 0. If it is 0, it returns a struct with 0 values. If it is not 0, it (autogenerated documentation)
currentBallotStateOf(uint256) :
This function returns the current ballot state of a given project. It first checks if the project exists by checking if the latestIdOf the project is greater than 0. If it is, it retrieves the FundingCycle struct associated with the project and checks if it is based on a previous FundingCycle. If it is, it returns the ballot state of the FundingCycle. Otherwise, it returns the Standby state. (autogenerated documentation)
configure(uint256,uint256,uint256,bool) :
This function configures a new Funding Cycle for a given project. It takes in a project ID, Funding Cycle Properties, metadata, fee, and a boolean value to configure an active Funding Cycle. It checks that the duration, cycle limit, discount rate, and currency are within the allowed limits. It then stores the configuration properties, target, and metadata in the respective mappings. Finally, it emits a Configure event and returns the Funding Cycle struct. (autogenerated documentation)
tap(uint256,uint256) :
This function allows a user to tap into a project's funding cycle. It takes in two parameters, a project ID and an amount, and checks that the amount is not greater than the target amount of the funding cycle. If the amount is valid, the tapped amount is increased by the amount and an event is emitted. Finally, the function returns the updated funding cycle. (autogenerated documentation)
_configurable(uint256,uint256,bool) :
This function is used to configure a new funding cycle for a given project. It takes in the project ID, the configured amount, and a boolean value indicating whether the active funding cycle should be configured. It first checks if the project has an existing funding cycle, and if so, it creates a new funding cycle based on the existing one. It then checks if the funding cycle is eligible, and if so, it either configures the active funding cycle or creates a new one based on the configured amount. Finally, it initializes the new funding cycle with the given parameters. (autogenerated documentation)
_tappable(uint256) :
This function is used to determine if a project is eligible for funding. It takes in a project ID as an argument and checks if the project is eligible for funding. If it is, it returns the funding cycle ID. If not, it checks if the project is in standby mode and returns the funding cycle ID if it is. It then checks if the funding cycle has been approved and if the start time is before the current block timestamp. If all of these conditions are met, it returns the funding cycle ID. If not, it sets the funding cycle ID to the latest ID of the project and checks if the discount rate is less than 201. If it is, it initializes the funding cycle with the project ID, funding cycle (autogenerated documentation)
_init(uint256,uint256,bool) :
This function is used to initialize a new FundingCycle. It takes in a projectId, a baseFundingCycle, a mustStartOnOrAfter timestamp, and a boolean value indicating whether the new FundingCycle should be a copy of the baseFundingCycle. It then increments the count, stores the intrinsic properties of the new FundingCycle, updates the FundingCycle with the given parameters, and emits an Init event. (autogenerated documentation)
_standby(uint256) :
This function is used to put a project into standby mode. It takes in a project ID as an argument and returns the funding cycle ID associated with the project. It first checks if the funding cycle ID is 0, and if it is, it returns 0. It then retrieves the FundingCycle struct associated with the funding cycle ID and checks if the current block timestamp is greater than the start timestamp of the FundingCycle. If it is, it returns 0. Otherwise, the project is put into standby mode. (autogenerated documentation)
_eligible(uint256) :
This function checks if a project is eligible for funding. It takes in a project ID as an argument and returns the funding cycle ID associated with the project. It first checks if the funding cycle ID is valid and if the funding cycle has a duration set. If so, it checks if the current block timestamp is greater than the start time of the funding cycle plus the duration. If not, it checks if the funding cycle is based on another funding cycle. If so, it checks if the current block timestamp is greater than the start time of the base funding cycle plus the duration. If all these conditions are met, the function returns the funding cycle ID. (autogenerated documentation)
_mockFundingCycleBasedOn(bool) :
This function is used to mock a FundingCycle based on a given FundingCycle. It takes in a FundingCycle memory _baseFundingCycle and a boolean _allowMidCycle as parameters. It first checks if the discount rate of the _baseFundingCycle is equal to 201, and if so, it returns a struct with a value of 0. Otherwise, it calculates the latest permanent FundingCycle before the _baseFundingCycle, and then calculates the time from the immediate start multiple. It then calculates the start, cycle limit, and weight of the FundingCycle, and returns a new FundingCycle with the calculated values. (autogenerated documentation)
_updateFundingCycle(uint256,uint256,bool) :
This function updates a FundingCycle with new properties. It takes in the ID of the FundingCycle, the base FundingCycle, a mustStartOnOrAfter value, and a boolean value indicating whether or not to copy the properties from the base FundingCycle. It then calculates the start, weight, and number of the FundingCycle based on the base FundingCycle and the mustStartOnOrAfter value. If the boolean value is true, it will also copy the configuration and target properties from the base FundingCycle. Finally, it stores the intrinsic properties of the FundingCycle. (autogenerated documentation)
_packAndStoreIntrinsicProperties(uint256,uint256,uint256,uint256,uint256,uint256) :
This function packs and stores intrinsic properties of a funding cycle. It takes in five parameters: the funding cycle ID, the project ID, the weight, the number, the based on, and the start. It then packs these parameters into a single uint256 variable, and stores it in the _packedIntrinsicPropertiesOf mapping, using the funding cycle ID as the key. The packing is done by shifting the bits of each parameter to the left by the appropriate amount, and then using a bitwise OR operation to combine them into a single value. (autogenerated documentation)
_packAndStoreConfigurationProperties(uint256,uint256,uint256,uint256,uint256,uint256,uint256) :
This function is used to store the configuration properties of a Funding Cycle in a single packed variable. It takes in 8 parameters, which represent the configuration properties of the Funding Cycle, and packs them into a single uint256 variable. The first 160 bits of the packed variable are used to store the address of the IFundingCycleBallot associated with the Funding Cycle. The next 48 bits are used to store the configured flag, the duration, the currency, the fee, the discount rate, and the cycle limit. The packed variable is then stored in the _packedConfigurationPropertiesOf mapping, with the Funding Cycle ID as the key. (autogenerated documentation)
_getStruct(uint256) :
This function is used to retrieve the details of a FundingCycle from the blockchain. It takes an ID as an input parameter and returns a FundingCycle memory structure containing the details of the FundingCycle. The function first checks if the ID is 0, in which case it returns the default FundingCycle. Otherwise, it retrieves the packed intrinsic and configuration properties of the FundingCycle from the blockchain and assigns them to the FundingCycle memory structure. It then retrieves the target, tapped, and metadata values from the blockchain and assigns them to the FundingCycle memory structure. Finally, it returns the FundingCycle memory structure. (autogenerated documentation)
_deriveStart(uint256) :
This function is used to derive the start time of a new Funding Cycle based on the parameters of the base Funding Cycle, the latest Permanent Funding Cycle, and the minimum start time that is required. It first checks if the base Funding Cycle has a duration of 0, in which case it returns the minimum start time. Otherwise, it calculates the duration of the base Funding Cycle in seconds and the next immediate start time. If the minimum start time is greater than the next immediate start time, it calculates the time from the immediate start time that is a multiple of the duration in seconds. It then subtracts this multiple from the minimum start time to get the start time of the new Funding Cycle. Finally, it checks if the minimum start time is (autogenerated documentation)
_deriveWeight(uint256) :
This function is used to calculate the weight of a Funding Cycle based on the start time, the base Funding Cycle, and the latest Permanent Funding Cycle. It takes the base Funding Cycle's weight and applies a discount rate to it for each cycle limit or permanent discount multiple, depending on the length of the Funding Cycle. The discount rate is applied by multiplying the weight by 1000 minus the discount rate, and then dividing by 1000. If the Funding Cycle is permanent, the discount rate is applied for each permanent discount multiple. (autogenerated documentation)
_deriveNumber(uint256) :
This function is used to derive the number of a FundingCycle from a given start time. It takes in three parameters: a base FundingCycle, a latest Permanent FundingCycle, and a start time. It then calculates the start distance (the difference between the start time and the base FundingCycle's start time) and the limit length (the cycle limit multiplied by the duration of the base FundingCycle). If the limit length is 0 or greater than the start distance, the number of the FundingCycle is calculated by adding the start distance divided by the duration of the base FundingCycle to the base FundingCycle's number. If the limit length is less than the start distance, the number of the FundingCy (autogenerated documentation)
_deriveCycleLimit(uint256) :
This function calculates the remaining cycle limit for a given Funding Cycle. It takes two parameters, the Funding Cycle and the start time, and returns the remaining cycle limit as a uint256. The function first checks if the cycle limit is greater than 1 and the duration is not 0. It then calculates the number of cycles that have passed since the start time by dividing the difference between the start time and the Funding Cycle start time by the duration of the Funding Cycle multiplied by the number of seconds in a day. If the number of cycles is greater than or equal to the cycle limit, the function returns 0. Otherwise, it returns the difference between the cycle limit and the number of cycles. (autogenerated documentation)
_isIdApproved(uint256) :
This function checks if a given funding cycle ID has been approved. It does this by retrieving the associated FundingCycle struct from storage and then checking if the approved flag is set to true. If it is, the function returns true, otherwise it returns false. (autogenerated documentation)
_isApproved() :
This function checks if a given FundingCycle has been approved by checking the BallotState associated with the FundingCycle. It does this by taking in the FundingCycle's id, configured value, and basedOn value and using them to look up the associated BallotState. If the BallotState is equal to Approved, the function returns true, otherwise it returns false. (autogenerated documentation)
_ballotState(uint256,uint256,uint256) :
This function is used to determine the state of a ballot. It takes in three parameters: the ID of the ballot, the configuration of the ballot, and the ID of the ballot funding cycle. It first checks if the ballot funding cycle ID is 0, in which case it returns the state of the ballot as Approved. If the ballot funding cycle ID is not 0, it retrieves the corresponding funding cycle struct and checks if the configured value matches the configuration parameter. If it does, the state of the ballot is returned as Approved. If not, the state of the ballot is determined by calling the state function of the ballot funding cycle's ballot. (autogenerated documentation)
_latestPermanentCycleBefore() :
This function recursively searches for the latest permanent funding cycle before a given funding cycle. A permanent funding cycle is one with a cycle limit of 0. The function takes in a FundingCycle struct as an argument and returns the latest permanent FundingCycle struct before it. It does this by checking the basedOn property of the given FundingCycle struct. If the basedOn property is 0, then the given FundingCycle is returned. Otherwise, the function calls itself with the FundingCycle struct stored at the basedOn address. This process is repeated until a FundingCycle with a cycleLimit of 0 is found, which is then returned. (autogenerated documentation)
_getTimeAfterBallot(uint256) :
This function is used to get the time after a ballot in a FundingCycle. It takes in a FundingCycle memory and a uint256 _from as parameters. It first checks if the ballot in the FundingCycle is not equal to the address of 0. If it is not, it adds the duration of the ballot to the _from parameter and assigns it to the _ballotExpiration variable. It then returns either the block timestamp or the _ballotExpiration, whichever is greater. (autogenerated documentation)