Types
Contains the types contracts.
Contracts
LibAddressSet
import "@etherisc/gif-next/contracts/type/AddressSet.sol";
-
[
add(set, element)] -
[
remove(set, element)] -
[
isEmpty(set)] -
[
contains(set, element)] -
[
getLength(set)] -
[
getElementAt(set, index)]
AmountLib
import "@etherisc/gif-next/contracts/type/Amount.sol";
-
[
zero()] -
[
max()] -
[
toAmount(amount)] -
[
eqz(amount)] -
[
eq(amount1, amount2)] -
[
lt(a1, a2)] -
[
lte(a1, a2)] -
[
gt(a1, a2)] -
[
gte(a1, a2)] -
[
min(a1, a2)] -
[
gtz(amount)] -
[
add(a1, a2)] -
[
sub(a1, a2)] -
[
toInt(amount)] -
[
toUFixed(amount)] -
[
multiplyWith(amount, factor)] -
[
_max()]
BlocknumberLib
import "@etherisc/gif-next/contracts/type/Blocknumber.sol";
-
[
zero()] -
[
max()] -
[
current()] -
[
toBlocknumber(blocknum)] -
[
eqz(blocknumber)] -
[
gtz(blocknumber)] -
[
gt(a, b)] -
[
gte(a, b)] -
[
lt(a, b)] -
[
lte(a, b)] -
[
eq(a, b)] -
[
ne(a, b)] -
[
toInt(blocknumber)]
gt(Blocknumber a, Blocknumber b) → bool isAfter public
return true if Blocknumber a is greater than Blocknumber b
gte(Blocknumber a, Blocknumber b) → bool isAfterOrSame public
return true if Blocknumber a is greater than or equal to Blocknumber b
lt(Blocknumber a, Blocknumber b) → bool isBefore public
return true if Blocknumber a is less than Blocknumber b
lte(Blocknumber a, Blocknumber b) → bool isBeforeOrSame public
return true if Blocknumber a is less than or equal to Blocknumber b
eq(Blocknumber a, Blocknumber b) → bool isSame public
return true if Blocknumber a is equal to Blocknumber b
ChainIdLib
import "@etherisc/gif-next/contracts/type/ChainId.sol";
-
[
zero()] -
[
max()] -
[
current()] -
[
eqz(chainId)] -
[
gtz(chainId)] -
[
toChainId(chainId)] -
[
isCurrentChain(nftId)] -
[
fromNftId(nftId)] -
[
toInt(chainId)] -
[
_fromNftId(nftId)] -
[
_max()]
ClaimIdLib
import "@etherisc/gif-next/contracts/type/ClaimId.sol";
-
[
zero()] -
[
max()] -
[
toClaimId(a)] -
[
toInt(a)] -
[
toKey32(claimId, policyNftId)] -
[
toKeyId(claimId, policyNftId)] -
[
gtz(a)] -
[
eq(a, b)] -
[
eqz(a)]
toKey32(ClaimId claimId, NftId policyNftId) → Key32 public
Converts the ClaimId and NftId to a Key32.
DistributorTypeLib
import "@etherisc/gif-next/contracts/type/DistributorType.sol";
-
[
zero()] -
[
toDistributorType(distributionNftId, name)] -
[
toKey32(id)] -
[
toKeyId(id)]
FeeLib
import "@etherisc/gif-next/contracts/type/Fee.sol";
-
[
zero()] -
[
toFee(fractionalFee, fixedFee)] -
[
calculateFee(fee, amount)] -
[
percentageFee(percent)] -
[
eq(a, b)] -
[
gtz(fee)] -
[
eqz(fee)]
toFee(UFixed fractionalFee, uint256 fixedFee) → struct Fee fee public
Converts the uint256 to a fee struct.
Key32Lib
import "@etherisc/gif-next/contracts/type/Key32.sol";
-
[
toKey32(objectType, id)] -
[
toObjectType(key)] -
[
toKeyId(key)]
LibNftIdSet
import "@etherisc/gif-next/contracts/type/NftIdSet.sol";
-
[
add(set, nftId)] -
[
remove(set, nftId)] -
[
isEmpty(set)] -
[
contains(set, nftId)] -
[
size(set)] -
[
getElementAt(set, index)]
NftIdLib
import "@etherisc/gif-next/contracts/type/NftId.sol";
-
[
zero()] -
[
toNftId(id)] -
[
toInt(nftId)] -
[
gtz(a)] -
[
eqz(a)] -
[
eq(a, b)] -
[
ne(a, b)] -
[
toKey32(id, objectType)] -
[
toKeyId(id)] -
[
toNftId(keyId)]
ObjectTypeLib
import "@etherisc/gif-next/contracts/type/ObjectType.sol";
-
[
zero()] -
[
toObjectType(objectType)] -
[
toInt(objectType)] -
[
gtz(a)] -
[
eqz(a)] -
[
eq(a, b)] -
[
ne(a, b)] -
[
toName(objectType)] -
[
toVersionedName(name, suffix, release)]
PayoutIdLib
import "@etherisc/gif-next/contracts/type/PayoutId.sol";
-
[
zero()] -
[
toPayoutId(claimId, payoutNo)] -
[
toClaimId(payoutId)] -
[
toPayoutNo(payoutId)] -
[
toInt(a)] -
[
gtz(a)] -
[
eqz(a)] -
[
toKey32(payoutId, policyNftId)] -
[
toKeyId(payoutId, policyNftId)]
ReferralLib
import "@etherisc/gif-next/contracts/type/Referral.sol";
-
[
zero()] -
[
toReferralId(distributionNftId, referral)] -
[
toReferralStatus(status)] -
[
toInt(referralId)] -
[
toKey32(id)] -
[
toKeyId(id)] -
[
eqz(id)]
RiskIdLib
import "@etherisc/gif-next/contracts/type/RiskId.sol";
-
[
zero()] -
[
toInt(riskId)] -
[
toRiskId(productNftId, risk)] -
[
toKey32(riskId)] -
[
toKeyId(id)] -
[
toRiskId(keyId)] -
[
eq(a, b)] -
[
eqz(a)] -
[
gtz(a)]
RoleIdLib
import "@etherisc/gif-next/contracts/type/RoleId.sol";
-
[
zero()] -
[
toRoleId(a)] -
[
isServiceRole(roleId)] -
[
toGenericServiceRoleId(objectType)] -
[
toServiceRoleId(serviceDomain, release)] -
[
toInt(a)] -
[
gtz(a)] -
[
eqz(a)]
SecondsLib
import "@etherisc/gif-next/contracts/type/Seconds.sol";
-
[
zero()] -
[
max()] -
[
fromHours(numberOfHours)] -
[
oneDay()] -
[
fromDays(numberOfDays)] -
[
oneYear()] -
[
toSeconds(duration)] -
[
eqz(duration)] -
[
gtz(duration)] -
[
eq(duration1, duration2)] -
[
gt(duration1, duration2)] -
[
lt(duration1, duration2)] -
[
min(duration1, duration2)] -
[
add(duration1, duration2)] -
[
toInt(duration)] -
[
_max()]
toSeconds(uint256 duration) → Seconds public
converts the uint duration into Seconds function reverts if duration is exceeding max Seconds value
eq(Seconds duration1, Seconds duration2) → bool public
return true iff duration1 and duration2 are the same
gt(Seconds duration1, Seconds duration2) → bool public
return true if duration1 is larger than duration2
StateIdLib
import "@etherisc/gif-next/contracts/type/StateId.sol";
-
[
zero()] -
[
toInt(stateId)] -
[
gtz(a)] -
[
eqz(a)] -
[
eq(a, b)]
TimestampLib
import "@etherisc/gif-next/contracts/type/Timestamp.sol";
-
[
zero()] -
[
max()] -
[
current()] -
[
toTimestamp(timestamp)] -
[
gt(a, b)] -
[
gte(a, b)] -
[
lt(a, b)] -
[
lte(a, b)] -
[
eq(a, b)] -
[
ne(a, b)] -
[
eqz(timestamp)] -
[
gtz(timestamp)] -
[
addSeconds(timestamp, duration)] -
[
subtractSeconds(timestamp, duration)] -
[
toInt(timestamp)]
gte(Timestamp a, Timestamp b) → bool isAfterOrSame public
return true if Timestamp a is after or the same than Timestamp b
lt(Timestamp a, Timestamp b) → bool isBefore public
return true if Timestamp a is before Timestamp b
lte(Timestamp a, Timestamp b) → bool isBeforeOrSame public
return true if Timestamp a is before or the same than Timestamp b
eq(Timestamp a, Timestamp b) → bool isSame public
return true if Timestamp a is equal to Timestamp b
ne(Timestamp a, Timestamp b) → bool isDifferent public
return true if Timestamp a is not equal to Timestamp b
addSeconds(Timestamp timestamp, Seconds duration) → Timestamp public
return a new timestamp that is duration seconds later than the provided timestamp.
UFixedLib
import "@etherisc/gif-next/contracts/type/UFixed.sol";
-
[
ROUNDING_DOWN()] -
[
ROUNDING_UP()] -
[
ROUNDING_HALF_UP()] -
[
toUFixed(a)] -
[
toUFixed(a, exp)] -
[
decimals()] -
[
toInt(a)] -
[
toInt1000(a)] -
[
toIntWithRounding(a, rounding)] -
[
add(a, b)] -
[
sub(a, b)] -
[
mul(a, b)] -
[
div(a, b)] -
[
gt(a, b)] -
[
gte(a, b)] -
[
lt(a, b)] -
[
lte(a, b)] -
[
eq(a, b)] -
[
gtz(a)] -
[
eqz(a)] -
[
zero()] -
[
one()] -
[
max()] -
[
delta(a, b)]
ROUNDING_DOWN() → uint8 public
returns the rounding mode DOWN - 0.4 becomes 0, 0.5 becomes 0, 0.6 becomes 0
ROUNDING_UP() → uint8 public
returns the rounding mode UP - 0.4 becomes 1, 0.5 becomes 1, 0.6 becomes 1
ROUNDING_HALF_UP() → uint8 public
returns the rounding mode HALF_UP - 0.4 becomes 0, 0.5 becomes 1, 0.6 becomes 1
toUFixed(uint256 a) → UFixed public
Converts the uint256 to a uint160 based UFixed. This method reverts if the number is too large to fit in a uint160.
toIntWithRounding(UFixed a, uint8 rounding) → uint256 public
Converts a UFixed to a uint256 with given rounding mode.
gte(UFixed a, UFixed b) → bool isGreaterThan public
return true if UFixed a is greater than or equal to UFixed b
VersionLib
import "@etherisc/gif-next/contracts/type/Version.sol";
-
[
toInt(version)] -
[
toUint64(version)] -
[
toMajorPart(version)] -
[
toVersionParts(version)] -
[
toVersion(major, minor, patch)] -
[
toVersion(versionNumber)] -
[
zeroVersion()]