forked from cisc0f/hedera
-
Notifications
You must be signed in to change notification settings - Fork 5
/
FeeHelper.sol
104 lines (94 loc) · 3.47 KB
/
FeeHelper.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.5.0 <0.9.0;
pragma experimental ABIEncoderV2;
import "./HederaTokenService.sol";
import "./HederaResponseCodes.sol";
import "./IHederaTokenService.sol";
import "./KeyHelper.sol";
contract FeeHelper is KeyHelper {
function createFixedHbarFee(
uint32 amount,
address feeCollector
) internal pure returns (IHederaTokenService.FixedFee memory fixedFee) {
fixedFee.amount = amount;
fixedFee.useHbarsForPayment = true;
fixedFee.feeCollector = feeCollector;
}
function createFixedTokenFee(
uint32 amount,
address tokenId,
address feeCollector
) internal pure returns (IHederaTokenService.FixedFee memory fixedFee) {
fixedFee.amount = amount;
fixedFee.tokenId = tokenId;
fixedFee.feeCollector = feeCollector;
}
function createFixedSelfDenominatedFee(
uint32 amount,
address feeCollector
) internal pure returns (IHederaTokenService.FixedFee memory fixedFee) {
fixedFee.amount = amount;
fixedFee.useCurrentTokenForPayment = true;
fixedFee.feeCollector = feeCollector;
}
function createFractionalFee(
uint32 numerator,
uint32 denominator,
bool netOfTransfers,
address feeCollector
) internal pure returns (IHederaTokenService.FractionalFee memory fractionalFee) {
fractionalFee.numerator = numerator;
fractionalFee.denominator = denominator;
fractionalFee.netOfTransfers = netOfTransfers;
fractionalFee.feeCollector = feeCollector;
}
function createFractionalFeeWithMinAndMax(
uint32 numerator,
uint32 denominator,
uint32 minimumAmount,
uint32 maximumAmount,
bool netOfTransfers,
address feeCollector
) internal pure returns (IHederaTokenService.FractionalFee memory fractionalFee) {
fractionalFee.numerator = numerator;
fractionalFee.denominator = denominator;
fractionalFee.minimumAmount = minimumAmount;
fractionalFee.maximumAmount = maximumAmount;
fractionalFee.netOfTransfers = netOfTransfers;
fractionalFee.feeCollector = feeCollector;
}
function createRoyaltyFeeWithoutFallback(
uint32 numerator,
uint32 denominator,
address feeCollector
) internal pure returns (IHederaTokenService.RoyaltyFee memory royaltyFee) {
royaltyFee.numerator = numerator;
royaltyFee.denominator = denominator;
royaltyFee.feeCollector = feeCollector;
}
function createRoyaltyFeeWithHbarFallbackFee(
uint32 numerator,
uint32 denominator,
uint32 amount,
address feeCollector
) internal pure returns (IHederaTokenService.RoyaltyFee memory royaltyFee) {
royaltyFee.numerator = numerator;
royaltyFee.denominator = denominator;
royaltyFee.amount = amount;
royaltyFee.useHbarsForPayment = true;
royaltyFee.feeCollector = feeCollector;
}
function createRoyaltyFeeWithTokenDenominatedFallbackFee(
uint32 numerator,
uint32 denominator,
uint32 amount,
address tokenId,
address feeCollector
) internal pure returns (IHederaTokenService.RoyaltyFee memory royaltyFee) {
royaltyFee.numerator = numerator;
royaltyFee.denominator = denominator;
royaltyFee.amount = amount;
royaltyFee.tokenId = tokenId;
royaltyFee.feeCollector = feeCollector;
}
}