You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// For passing parameter and store state variables
CoverRequest[] requests; // CoverRequest.idmapping(address=>uint[]) buyerToRequests;
mapping(string=>uint[]) coinIdToRequests;
struct CoverRequest {
uint coverQty; // coverQty decimals depends on coinIdToDecimals mappinguint8 coverMonths; // represent month value 1-12uint insuredSum;
uint insuredSumTarget; // if full funding : insuredSum - 2$
CurrencyType insuredSumCurrency;
uint premiumSum;
CurrencyType premiumCurrency;
uint expiredAt; // now + 14 daysstring coinId; // CoinGecko
CoverLimit coverLimit;
InsuredSumRule insuredSumRule;
address buyer;
}
CoverOffer
// For passing parameter and store state variables
CoverOffer[] offers; // CoverOffer.idmapping(address=>uint[]) funderToOffers;
mapping(string=>uint[]) coinIdToOffers;
struct CoverOffer {
uint8 minCoverMonths; // represent month value 1-12 (expiredAt + 1 month - now >= minCoverMonths)uint insuredSum;
CurrencyType insuredSumCurrency;
uint premiumCostPerMonth; // $0.02 per $1 insured per Month (2000)
CurrencyType premiumCurrency;
// IMPORTANT: max date for buying cover = expiredAt + 1 monthuint expiredAt; // despositEndDate - 14 days beforeDepositEndDatestring coinId; // CoinGecko
CoverLimit coverLimit;
uint insuredSumRemaining;
InsuredSumRule insuredSumRule;
address funder; // address which created the listing
}
Cover Limit
struct CoverLimit {
CoverType coverType;
uint[] teritoryIds; // Platform Id, Price Feed Id, Custodian Id , (Dex Pool Id not Yet implemented)
}
Cover / Insurance
// Storage struct// Relationship: CoverCoverOffer ||--< Cover// Relationship: CoverRequest ||--< Cover// Relationship: One cover can have only one offer// Relationship: One cover can have only one request
InsuranceCover[] covers; // InsuranceCover.idmapping(address=>uint[]) holderToCovers;
mapping(uint=>uint[]) offerIdToCovers;
mapping(uint=>uint[]) requestIdToCovers;
struct InsuranceCover {
// type computed from (offerId != 0) or (requestId != 0)// If BuyCover (take offer)uint offerId; // from BuyCover.offerId// If CoverFunding (take request)uint requestId; // from CoverFunding.requestId// uint[] provideIds;// will validate claimSenderaddress holder; // from BuyCover.buyer or CoverRequest.buyer// will validate maximum claimSumuint insuredSum; // from BuyCover.insuredSum or sum(CoverFunding.fundingSum)// will validate maximum claimQuantityuint coverQty; // from BuyCover.coverQty or CoverRequest.coverQty// will validate claimDeadlineuint endAt;
// if take offer, cover starts immediately// endAt = now + BuyCover.coverMonths// if take request, and fully funded before expired, cover starts immediately...// endAt = now + CoverRequest.coverMonths// if take request, and expired before fully funded, cover starts on CoverRequest.expiredAt// if (endAt == 0 && now > CoverRequest.expiredAt) endAt = expiredAt + CoverRequest.coverMonths
}
Take Request
// Storage: "Booking" object when take request// Relationship: CoverRequest ||--< CoverFundingmapping(uint=> CoverFunding[]) requestIdToCoverFundings;
mapping(address=> CoverFunding[]) funderToCoverFundings;
struct CoverFunding {
uint requestId;
address funder;
// insurance data:uint fundingSum; // part or portion of total insuredSum
}
// Payload: object when take request// Virtual struct/type for payload (type of payloadBuyCover)struct ProvideCover {
uint requestId;
address provider;
// insurance data:uint fundingSum;
CoinPricingInfo assetPriceInfo;
CollectPermit assetPermit;
}
Take Offer
// Payload: object when take offer// Virtual struct/type for payload (type of payloadBuyCover)struct BuyCover {
uint offerId;
address buyer;
// insurance data:uint8 coverMonths; // represent month value 1-12uint coverQty; // coverQty decimals depends on coinIdToDecimals mappinguint insuredSum; // need validation : coverQty * assetPriceInfo.coinCurrentPrice
CoinPricingInfo assetPriceInfo;
CollectPermit premiumPermit;
// TODO: validate coverQty based on insuredSum
}