Types

Contains the types contracts.

Contracts

LibAddressSet

import "@etherisc/gif-next/contracts/type/AddressSet.sol";
Functions
  • [add(set, element)]

  • [remove(set, element)]

  • [isEmpty(set)]

  • [contains(set, element)]

  • [getLength(set)]

  • [getElementAt(set, index)]

add(struct LibAddressSet.Set set, address element) → bool added external

remove(struct LibAddressSet.Set set, address element) → bool removed external

isEmpty(struct LibAddressSet.Set set) → bool empty external

contains(struct LibAddressSet.Set set, address element) → bool inSet external

getLength(struct LibAddressSet.Set set) → uint256 length external

getElementAt(struct LibAddressSet.Set set, uint256 index) → address element external

AmountLib

import "@etherisc/gif-next/contracts/type/Amount.sol";
Functions
  • [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()]

zero() → Amount public

max() → Amount public

toAmount(uint256 amount) → Amount public

converts the uint amount into Amount function reverts if value is exceeding max Amount value

eqz(Amount amount) → bool public

return true if amount equals 0

eq(Amount amount1, Amount amount2) → bool public

return true if amount1 equals amount2

lt(Amount a1, Amount a2) → bool public

return true if amount a1 is less than a2

lte(Amount a1, Amount a2) → bool public

return true if amount a1 is less or equal than a2

gt(Amount a1, Amount a2) → bool public

return true if amount a1 is greater than a2

gte(Amount a1, Amount a2) → bool public

return true if amount a1 is greater or equal than a2

min(Amount a1, Amount a2) → Amount public

return minimum of a1 and a2.

gtz(Amount amount) → bool public

return true if amount is larger than 0

add(Amount a1, Amount a2) → Amount public

sub(Amount a1, Amount a2) → Amount public

toInt(Amount amount) → uint256 public

toUFixed(Amount amount) → UFixed public

multiplyWith(Amount amount, UFixed factor) → Amount public

_max() → uint96 internal

BlocknumberLib

import "@etherisc/gif-next/contracts/type/Blocknumber.sol";
Functions
  • [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)]

zero() → Blocknumber public

max() → Blocknumber public

current() → Blocknumber public

toBlocknumber(uint256 blocknum) → Blocknumber public

eqz(Blocknumber blocknumber) → bool public

return true iff blocknumber is 0

gtz(Blocknumber blocknumber) → bool public

return true iff blocknumber is > 0

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

ne(Blocknumber a, Blocknumber b) → bool isDifferent public

return true if Blocknumber a is not equal to Blocknumber b

toInt(Blocknumber blocknumber) → uint256 public

converts the Blocknumber to a uint256

ChainIdLib

import "@etherisc/gif-next/contracts/type/ChainId.sol";
Functions
  • [zero()]

  • [max()]

  • [current()]

  • [eqz(chainId)]

  • [gtz(chainId)]

  • [toChainId(chainId)]

  • [isCurrentChain(nftId)]

  • [fromNftId(nftId)]

  • [toInt(chainId)]

  • [_fromNftId(nftId)]

  • [_max()]

zero() → ChainId public

max() → ChainId public

current() → ChainId public

eqz(ChainId chainId) → bool public

return true iff chainId is 0

gtz(ChainId chainId) → bool public

return true iff chainId is > 0

toChainId(uint256 chainId) → ChainId public

converts the uint into ChainId function reverts if value is exceeding max ChainId value

isCurrentChain(NftId nftId) → bool public

returns true iff NFT ID is from the current chain.

fromNftId(NftId nftId) → ChainId public

toInt(ChainId chainId) → uint256 public

converts the ChainId to a uint256

_fromNftId(NftId nftId) → uint256 chainIdInt internal

_max() → uint96 internal

ClaimIdLib

import "@etherisc/gif-next/contracts/type/ClaimId.sol";
Functions
  • [zero()]

  • [max()]

  • [toClaimId(a)]

  • [toInt(a)]

  • [toKey32(claimId, policyNftId)]

  • [toKeyId(claimId, policyNftId)]

  • [gtz(a)]

  • [eq(a, b)]

  • [eqz(a)]

zero() → ClaimId public

claim id min value (0), use only for non-initialized values

max() → ClaimId public

claim id max value (2**16-1), use only for non-initialized values

toClaimId(uint256 a) → ClaimId public

Converts an uint into a ClaimId.

toInt(ClaimId a) → uint16 public

Converts the ClaimId to a uint.

toKey32(ClaimId claimId, NftId policyNftId) → Key32 public

Converts the ClaimId and NftId to a Key32.

toKeyId(ClaimId claimId, NftId policyNftId) → KeyId public

Converts the ClaimId and NftId to a Key32.

gtz(ClaimId a) → bool public

Returns true if the value is non-zero (> 0).

eq(ClaimId a, ClaimId b) → bool public

eqz(ClaimId a) → bool public

Returns true if the value is zero (== 0).

DistributorTypeLib

import "@etherisc/gif-next/contracts/type/DistributorType.sol";
Functions
  • [zero()]

  • [toDistributorType(distributionNftId, name)]

  • [toKey32(id)]

  • [toKeyId(id)]

zero() → DistributorType public

toDistributorType(NftId distributionNftId, string name) → DistributorType public

toKey32(DistributorType id) → Key32 key public

Returns the key32 value for the specified nft id and object type.

toKeyId(DistributorType id) → KeyId keyId public

Returns the key id value for the specified nft id

FeeLib

import "@etherisc/gif-next/contracts/type/Fee.sol";
Functions
  • [zero()]

  • [toFee(fractionalFee, fixedFee)]

  • [calculateFee(fee, amount)]

  • [percentageFee(percent)]

  • [eq(a, b)]

  • [gtz(fee)]

  • [eqz(fee)]

zero() → struct Fee fee public

Return a zero fee struct (0, 0)

toFee(UFixed fractionalFee, uint256 fixedFee) → struct Fee fee public

Converts the uint256 to a fee struct.

calculateFee(struct Fee fee, Amount amount) → Amount feeAmount, Amount netAmount public

Calculates fee and net amounts for the provided parameters

percentageFee(uint8 percent) → struct Fee fee public

Return the percent fee struct (x%, 0)

eq(struct Fee a, struct Fee b) → bool isSame public

gtz(struct Fee fee) → bool public

eqz(struct Fee fee) → bool public

Key32Lib

import "@etherisc/gif-next/contracts/type/Key32.sol";
Functions
  • [toKey32(objectType, id)]

  • [toObjectType(key)]

  • [toKeyId(key)]

toKey32(ObjectType objectType, KeyId id) → Key32 public

toObjectType(Key32 key) → ObjectType objectType public

toKeyId(Key32 key) → KeyId id public

LibNftIdSet

import "@etherisc/gif-next/contracts/type/NftIdSet.sol";
Functions
  • [add(set, nftId)]

  • [remove(set, nftId)]

  • [isEmpty(set)]

  • [contains(set, nftId)]

  • [size(set)]

  • [getElementAt(set, index)]

add(struct LibNftIdSet.Set set, NftId nftId) external

remove(struct LibNftIdSet.Set set, NftId nftId) external

isEmpty(struct LibNftIdSet.Set set) → bool empty external

contains(struct LibNftIdSet.Set set, NftId nftId) → bool inSet external

size(struct LibNftIdSet.Set set) → uint256 length external

getElementAt(struct LibNftIdSet.Set set, uint256 index) → NftId nftId external

NftIdLib

import "@etherisc/gif-next/contracts/type/NftId.sol";
Functions
  • [zero()]

  • [toNftId(id)]

  • [toInt(nftId)]

  • [gtz(a)]

  • [eqz(a)]

  • [eq(a, b)]

  • [ne(a, b)]

  • [toKey32(id, objectType)]

  • [toKeyId(id)]

  • [toNftId(keyId)]

zero() → NftId public

the zero nft id is never a valid nft id and implies a non-initialized value

toNftId(uint256 id) → NftId public

Converts the uint256 to a NftId.

toInt(NftId nftId) → uint96 public

Converts the NftId to a uint256.

gtz(NftId a) → bool public

Returns true if the value is non-zero (> 0).

eqz(NftId a) → bool public

Returns true if the value is zero (== 0).

eq(NftId a, NftId b) → bool isSame public

Returns true if the values are equal (==).

ne(NftId a, NftId b) → bool isSame public

Returns true if the values are not equal (!=).

toKey32(NftId id, ObjectType objectType) → Key32 key public

Returns the key32 value for the specified nft id and object type.

toKeyId(NftId id) → KeyId keyId public

Returns the key id value for the specified nft id

toNftId(KeyId keyId) → NftId nftId public

ObjectTypeLib

import "@etherisc/gif-next/contracts/type/ObjectType.sol";
Functions
  • [zero()]

  • [toObjectType(objectType)]

  • [toInt(objectType)]

  • [gtz(a)]

  • [eqz(a)]

  • [eq(a, b)]

  • [ne(a, b)]

  • [toName(objectType)]

  • [toVersionedName(name, suffix, release)]

zero() → ObjectType public

toObjectType(uint256 objectType) → ObjectType public

Converts the uint256 into ObjectType.

toInt(ObjectType objectType) → uint96 public

Converts the NftId to a uint256.

gtz(ObjectType a) → bool public

Returns true if the value is non-zero (> 0).

eqz(ObjectType a) → bool public

Returns true if the value is zero (== 0).

eq(ObjectType a, ObjectType b) → bool isSame public

Returns true if the values are equal (==).

ne(ObjectType a, ObjectType b) → bool isSame public

Returns true if the values are not equal (!=).

toName(ObjectType objectType) → string name public

Returns the type/domain name for the provided object type

toVersionedName(string name, string suffix, VersionPart release) → string versionedName external

PayoutIdLib

import "@etherisc/gif-next/contracts/type/PayoutId.sol";
Functions
  • [zero()]

  • [toPayoutId(claimId, payoutNo)]

  • [toClaimId(payoutId)]

  • [toPayoutNo(payoutId)]

  • [toInt(a)]

  • [gtz(a)]

  • [eqz(a)]

  • [toKey32(payoutId, policyNftId)]

  • [toKeyId(payoutId, policyNftId)]

zero() → PayoutId public

Converts the PayoutId to a uint.

toPayoutId(ClaimId claimId, uint24 payoutNo) → PayoutId public

Converts an uint into a PayoutId.

toClaimId(PayoutId payoutId) → ClaimId public

toPayoutNo(PayoutId payoutId) → uint24 public

toInt(PayoutId a) → uint40 public

Converts the PayoutId to a uint.

gtz(PayoutId a) → bool public

Returns true if the value is non-zero (> 0).

eqz(PayoutId a) → bool public

Returns true if the value is zero (== 0).

toKey32(PayoutId payoutId, NftId policyNftId) → Key32 public

Converts the PayoutId and NftId to a Key32.

toKeyId(PayoutId payoutId, NftId policyNftId) → KeyId public

Converts the PayoutId and NftId to a Key32.

ReferralLib

import "@etherisc/gif-next/contracts/type/Referral.sol";
Functions
  • [zero()]

  • [toReferralId(distributionNftId, referral)]

  • [toReferralStatus(status)]

  • [toInt(referralId)]

  • [toKey32(id)]

  • [toKeyId(id)]

  • [eqz(id)]

zero() → ReferralId public

toReferralId(NftId distributionNftId, string referral) → ReferralId public

toReferralStatus(uint8 status) → ReferralStatus public

toInt(ReferralId referralId) → uint256 public

Converts a referral id into a uint256.

toKey32(ReferralId id) → Key32 key public

Returns the key32 value for the specified nft id and object type.

toKeyId(ReferralId id) → KeyId keyId public

Returns the key id value for the specified nft id

eqz(ReferralId id) → bool public

RiskIdLib

import "@etherisc/gif-next/contracts/type/RiskId.sol";
Functions
  • [zero()]

  • [toInt(riskId)]

  • [toRiskId(productNftId, risk)]

  • [toKey32(riskId)]

  • [toKeyId(id)]

  • [toRiskId(keyId)]

  • [eq(a, b)]

  • [eqz(a)]

  • [gtz(a)]

zero() → RiskId public

toInt(RiskId riskId) → uint256 public

toRiskId(NftId productNftId, bytes32 risk) → RiskId public

toKey32(RiskId riskId) → Key32 key public

Returns the key32 value for the specified risk id.

toKeyId(RiskId id) → KeyId keyId public

Returns the key id value for the specified nft id

toRiskId(KeyId keyId) → RiskId riskId public

eq(RiskId a, RiskId b) → bool isSame public

eqz(RiskId a) → bool isZero public

gtz(RiskId a) → bool isZero public

RoleIdLib

import "@etherisc/gif-next/contracts/type/RoleId.sol";
Functions
  • [zero()]

  • [toRoleId(a)]

  • [isServiceRole(roleId)]

  • [toGenericServiceRoleId(objectType)]

  • [toServiceRoleId(serviceDomain, release)]

  • [toInt(a)]

  • [gtz(a)]

  • [eqz(a)]

zero() → RoleId public

Converts the RoleId to a uint.

toRoleId(uint256 a) → RoleId public

Converts an uint into a role id.

isServiceRole(RoleId roleId) → bool public

toGenericServiceRoleId(ObjectType objectType) → RoleId public

toServiceRoleId(ObjectType serviceDomain, VersionPart release) → RoleId serviceRoleId public

toInt(RoleId a) → uint64 public

Converts the role id to a uint.

gtz(RoleId a) → bool public

Returns true if the value is non-zero (> 0).

eqz(RoleId a) → bool public

Returns true if the value is zero (== 0).

SecondsLib

import "@etherisc/gif-next/contracts/type/Seconds.sol";
Functions
  • [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()]

zero() → Seconds public

max() → Seconds public

fromHours(uint32 numberOfHours) → Seconds duration public

oneDay() → Seconds duration public

fromDays(uint32 numberOfDays) → Seconds duration public

oneYear() → Seconds duration public

toSeconds(uint256 duration) → Seconds public

converts the uint duration into Seconds function reverts if duration is exceeding max Seconds value

eqz(Seconds duration) → bool public

return true if duration equals 0

gtz(Seconds duration) → bool public

return true if duration is larger than 0

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

lt(Seconds duration1, Seconds duration2) → bool public

return true if duration1 is smaller than duration2

min(Seconds duration1, Seconds duration2) → Seconds public

returns the smaller of the duration

add(Seconds duration1, Seconds duration2) → Seconds public

return add duration1 and duration2

toInt(Seconds duration) → uint256 public

_max() → uint40 internal

StateIdLib

import "@etherisc/gif-next/contracts/type/StateId.sol";
Functions
  • [zero()]

  • [toInt(stateId)]

  • [gtz(a)]

  • [eqz(a)]

  • [eq(a, b)]

zero() → StateId public

toInt(StateId stateId) → uint96 public

Converts the NftId to a uint256.

gtz(StateId a) → bool public

Returns true if the value is non-zero (> 0).

eqz(StateId a) → bool public

Returns true if the value is zero (== 0).

eq(StateId a, StateId b) → bool isSame public

Returns true if the values are equal (==).

TimestampLib

import "@etherisc/gif-next/contracts/type/Timestamp.sol";
Functions
  • [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)]

zero() → Timestamp public

max() → Timestamp public

current() → Timestamp public

toTimestamp(uint256 timestamp) → Timestamp public

gt(Timestamp a, Timestamp b) → bool isAfter public

return true if Timestamp a is after Timestamp b

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

eqz(Timestamp timestamp) → bool public

return true if Timestamp equals 0

gtz(Timestamp timestamp) → bool public

return true if Timestamp is larger than 0

addSeconds(Timestamp timestamp, Seconds duration) → Timestamp public

return a new timestamp that is duration seconds later than the provided timestamp.

subtractSeconds(Timestamp timestamp, Seconds duration) → Timestamp public

return a new timestamp that is duration seconds earlier than the provided timestamp.

toInt(Timestamp timestamp) → uint256 public

UFixedLib

import "@etherisc/gif-next/contracts/type/UFixed.sol";
Functions
  • [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.

toUFixed(uint256 a, int8 exp) → UFixed public

Converts the uint256 to a UFixed with given exponent.

decimals() → uint256 public

returns the decimals precision of the UFixed type

toInt(UFixed a) → uint256 public

Converts a UFixed to a uint256.

toInt1000(UFixed a) → uint256 public

Converts a UFixed to a uint256.

toIntWithRounding(UFixed a, uint8 rounding) → uint256 public

Converts a UFixed to a uint256 with given rounding mode.

add(UFixed a, UFixed b) → UFixed public

adds two UFixed numbers

sub(UFixed a, UFixed b) → UFixed public

subtracts two UFixed numbers

mul(UFixed a, UFixed b) → UFixed public

multiplies two UFixed numbers

div(UFixed a, UFixed b) → UFixed public

divides two UFixed numbers

gt(UFixed a, UFixed b) → bool isGreaterThan public

return true if UFixed a is greater than UFixed b

gte(UFixed a, UFixed b) → bool isGreaterThan public

return true if UFixed a is greater than or equal to UFixed b

lt(UFixed a, UFixed b) → bool isGreaterThan public

return true if UFixed a is less than UFixed b

lte(UFixed a, UFixed b) → bool isGreaterThan public

return true if UFixed a is less than or equal to UFixed b

eq(UFixed a, UFixed b) → bool isEqual public

return true if UFixed a is equal to UFixed b

gtz(UFixed a) → bool isZero public

return true if UFixed a is not zero

eqz(UFixed a) → bool isZero public

return true if UFixed a is zero

zero() → UFixed public

one() → UFixed public

max() → UFixed public

delta(UFixed a, UFixed b) → UFixed public

return the absolute delta between two UFixed numbers

VersionLib

import "@etherisc/gif-next/contracts/type/Version.sol";
Functions
  • [toInt(version)]

  • [toUint64(version)]

  • [toMajorPart(version)]

  • [toVersionParts(version)]

  • [toVersion(major, minor, patch)]

  • [toVersion(versionNumber)]

  • [zeroVersion()]

toInt(Version version) → uint256 external

toUint64(Version version) → uint64 external

toMajorPart(Version version) → VersionPart major external

toVersionParts(Version version) → VersionPart major, VersionPart minor, VersionPart patch external

toVersion(uint256 major, uint256 minor, uint256 patch) → Version external

toVersion(uint64 versionNumber) → Version external

zeroVersion() → Version external

VersionPartLib

import "@etherisc/gif-next/contracts/type/Version.sol";
Functions
  • [releaseMin()]

  • [releaseMax()]

  • [isValidRelease(release)]

  • [toString(a)]

  • [eqz(a)]

  • [gtz(a)]

  • [toInt(a)]

  • [toVersionPart(a)]

releaseMin() → VersionPart public

releaseMax() → VersionPart public

isValidRelease(VersionPart release) → bool external

toString(VersionPart a) → string external

eqz(VersionPart a) → bool external

gtz(VersionPart a) → bool external

toInt(VersionPart a) → uint256 external

toVersionPart(uint256 a) → VersionPart public