Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
interface ISnowconeRedemptionDelegate3_1_1 is IERC165 {
function didRedeem(SnowconeDidRedeemData3_1_1 calldata data) external payable;
}
struct SnowconeDidRedeemData3_1_1 {
address holder;
uint256 projectId;
uint256 currentFundingCycleConfiguration;
uint256 projectTokenCount;
SnowconeTokenAmount reclaimedAmount;
SnowconeTokenAmount forwardedAmount;
address payable beneficiary;
string memo;
bytes dataSourceMetadata;
bytes redeemerMetadata;
}
struct SnowconeTokenAmount {
address token;
uint256 value;
uint256 decimals;
uint256 currency;
}
# command linenpm install @Snowcones/snowcones-icy-contracts/const contract = require(`@Snowcones/snowcones-icy-contracts/deployments/${network}/${contractName}.json`)import '@Snowcone/snowcones-icy-contracts/contracts/[file-path].sol'interface ISnowconeSplitAllocator {
function allocate(SnowconeSplitAllocationData calldata _data) external payable;
}
struct SnowconeSplitAllocationData {
address token;
uint256 amount;
uint256 decimals;
uint256 projectId;
uint256 group;
SnowconeSplit split;
}
struct SnowconeSplit {
bool preferClaimed;
bool preferAddToBalance;
uint256 percent;
uint256 projectId;
address payable beneficiary;
uint256 lockedUntil;
ISnowconeSplitAllocator allocator;
}
interface ISnowconeFundingCycleDataSource3_1_1 is IERC165 {
function payParams(
SnowconePayParamsData calldata data
)
external
view
returns (
uint256 weight,
string memory memo,
SnowconePayDelegateAllocation3_1_1[] memory delegateAllocations
);
function redeemParams(
SnowconeRedeemParamsData calldata data
)
external
view
returns (
uint256 reclaimAmount,
string memory memo,
SnowconeRedemptionDelegateAllocation3_1_1[] memory delegateAllocations
);
}
SNOWSplitsPayer.pay(...)SNOWSplitsPayer.addToBalanceOf(...)SNOWSplitsPayer._payToSplits(...)SNOWSplitsPayer._payTo(...)struct SnowconePayParamsData {
ISnowconePaymentTerminal terminal;
address payer;
SnowconeTokenAmount amount;
uint256 projectId;
uint256 currentFundingCycleConfiguration;
address beneficiary;
uint256 weight;
uint256 reservedRate;
string memo;
bytes metadata;
}
struct SnowconeTokenAmount {
address token;
uint256 value;
uint256 decimals;
uint256 currency;
}
struct SnowconeRedeemParamsData {
ISnowconePaymentTerminal terminal;
address holder;
uint256 projectId;
uint256 currentFundingCycleConfiguration;
uint256 tokenCount;
uint256 totalSupply;
uint256 overflow;
SnowconeTokenAmount reclaimAmount;
bool useTotalOverflow;
uint256 redemptionRate;
uint256 ballotRedemptionRate;
string memo;
bytes metadata;
}
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@snowcone-protocol/contracts-v2/contracts/interfaces/ISnowconeFundingCycleDataSource.sol';
contract AllowlistDataSource is ISnowconeFundingCycleDataSource {
error NOT_ALLOWED();
mapping(address => bool) allowed;
function payParams(SnowconePayParamsData calldata _data)
external
view
override
returns (
uint256 weight,
string memory memo,
ISnowconePayDelegate delegate
)
{
if (!allowed[_data.payer]) revert NOT_ALLOWED();
// Forward the received weight and memo, and use no delegate.
return (_data.weight, _data.memo, ISnowconePayDelegate(address(0)));
}
// This is unused but needs to be included to fulfill ISnowconeFundingCycleDataSource.
function redeemParams(SnowconeRedeemParamsData calldata _data)
external
pure
override
returns (
uint256 reclaimAmount,
string memory memo,
ISnowconeRedemptionDelegate delegate
)
{
// Return the default values.
return (_data.reclaimAmount.value, _data.memo, ISnowconeRedemptionDelegate(address(0)));
}
}
interface ISNWPayDelegate3_1_1 is IERC165 {
function didPay(SNWDidPayData3_1_1 calldata data) external payable;
}
struct SNWDidPayData3_1_1 {
address payer;
uint256 projectId;
uint256 currentFundingCycleConfiguration;
SNWTokenAmount amount;
SNWTokenAmount forwardedAmount;
uint256 projectTokenCount;
address beneficiary;
bool preferClaimedTokens;
string memo;
bytes dataSourceMetadata;
bytes payerMetadata;
}
struct SNWTokenAmount {
address token;
uint256 value;
uint256 decimals;
uint256 currency;
}
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@snx-protocol/contracts-v2/contracts/interfaces/ISNWFundingCycleDataSource.sol';
import '@snx-protocol/contracts-v2/contracts/interfaces/ISNWPayDelegate.sol';
import '@snx-protocol/contracts-v2/contracts/structs/SNWTokenAmount.sol';
contract NFTPayDelegate is ERC721, ISNWFundingCycleDataSource, ISNWPayDelegate {
error INVALID_PAYMENT_EVENT();
ISNWDirectory directory;
uint256 projectId;
SNWTokenAmount contributionThreshold;
uint256 supply;
// This contract can be used as a funding cycle data source to ensure its didPay function is called once the payment has gone through.
function payParams(SNWPayParamsData calldata _data)
external
view
override
returns (
uint256 weight,
string memory memo,
ISNWPayDelegate delegate
)
{
// Forward the received weight and memo, and use this contract as a pay delegate.
return (_data.weight, _data.memo, ISNWPayDelegate(address(this)));
}
// This is unused but needs to be included to fulfill ISNWFundingCycleDataSource.
function redeemParams(SNWRedeemParamsData calldata _data)
external
pure
override
returns (
uint256 reclaimAmount,
string memory memo,
ISNWRedemptionDelegate delegate
)
{
// Return the default values.
return (_data.reclaimAmount.value, _data.memo, ISNWRedemptionDelegate(address(0)));
}
constructor(ISNWDirectory _directory, uint256 _projectId, SNWTokenAmount _contributionThreshold, string calldata _name, string calldata _symbol) ERC721(_name, _symbol) {
directory = _directory;
projectId = _projectId;
},
// Called once the payment has gone through if the project's current funding cycle is using a data source that returns this delegate.
function didPay(SNWDidPayData calldata _data) external override {
// Make sure the caller is a terminal of the project, and the call is being made on behalf of an interaction with the correct project.
if (
!directory.isTerminalOf(projectId, ISNWPaymentTerminal(msg.sender)) ||
_data.projectId != projectId
) revert INVALID_PAYMENT_EVENT();
// Make the contribution is being made in the expected token.
if (_data.amount.token != contributionThreshold.token) return;
// Make sure the values use the same number of decimals.
if (_data.amount.decimals < contributionThreshold.decimals) return;
// Make sure the threshold is met.
if (_data.amount.value < contributionThreshold.value) return;
uint256 _tokenId = ++supply;
_mint(_data.beneficiary, _tokenId);
}
}
interface ISnowconeFundingCycleBallot {
function duration() external view returns (uint256);
function stateOf(
uint256 _projectId,
uint256 _configuration,
uint256 _start
) external view returns (SnowconeBallotState);
}