github.com/filecoin-project/specs-actors/v4@v4.0.2/actors/builtin/market/policy.go (about) 1 package market 2 3 import ( 4 "github.com/filecoin-project/go-state-types/abi" 5 "github.com/filecoin-project/go-state-types/big" 6 7 "github.com/filecoin-project/specs-actors/v4/actors/builtin" 8 ) 9 10 // The number of epochs between payment and other state processing for deals. 11 const DealUpdatesInterval = builtin.EpochsInDay // PARAM_SPEC 12 13 // The percentage of normalized cirulating 14 // supply that must be covered by provider collateral in a deal 15 var ProviderCollateralSupplyTarget = builtin.BigFrac{ 16 Numerator: big.NewInt(1), // PARAM_SPEC 17 Denominator: big.NewInt(100), 18 } 19 20 // Minimum deal duration. 21 var DealMinDuration = abi.ChainEpoch(180 * builtin.EpochsInDay) // PARAM_SPEC 22 23 // Maximum deal duration 24 var DealMaxDuration = abi.ChainEpoch(540 * builtin.EpochsInDay) // PARAM_SPEC 25 26 // DealMaxLabelSize is the maximum size of a deal label. 27 const DealMaxLabelSize = 256 28 29 // Bounds (inclusive) on deal duration 30 func DealDurationBounds(_ abi.PaddedPieceSize) (min abi.ChainEpoch, max abi.ChainEpoch) { 31 return DealMinDuration, DealMaxDuration 32 } 33 34 func DealPricePerEpochBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount) { 35 return abi.NewTokenAmount(0), builtin.TotalFilecoin 36 } 37 38 func DealProviderCollateralBounds(pieceSize abi.PaddedPieceSize, verified bool, networkRawPower, networkQAPower, baselinePower abi.StoragePower, 39 networkCirculatingSupply abi.TokenAmount) (min, max abi.TokenAmount) { 40 // minimumProviderCollateral = ProviderCollateralSupplyTarget * normalizedCirculatingSupply 41 // normalizedCirculatingSupply = networkCirculatingSupply * dealPowerShare 42 // dealPowerShare = dealRawPower / max(BaselinePower(t), NetworkRawPower(t), dealRawPower) 43 44 lockTargetNum := big.Mul(ProviderCollateralSupplyTarget.Numerator, networkCirculatingSupply) 45 lockTargetDenom := ProviderCollateralSupplyTarget.Denominator 46 powerShareNum := big.NewIntUnsigned(uint64(pieceSize)) 47 powerShareDenom := big.Max(big.Max(networkRawPower, baselinePower), powerShareNum) 48 49 num := big.Mul(lockTargetNum, powerShareNum) 50 denom := big.Mul(lockTargetDenom, powerShareDenom) 51 minCollateral := big.Div(num, denom) 52 return minCollateral, builtin.TotalFilecoin 53 } 54 55 func DealClientCollateralBounds(_ abi.PaddedPieceSize, _ abi.ChainEpoch) (min abi.TokenAmount, max abi.TokenAmount) { 56 return abi.NewTokenAmount(0), builtin.TotalFilecoin 57 } 58 59 // Penalty to provider deal collateral if the deadline expires before sector commitment. 60 func CollateralPenaltyForDealActivationMissed(providerCollateral abi.TokenAmount) abi.TokenAmount { 61 return providerCollateral 62 } 63 64 // Computes the weight for a deal proposal, which is a function of its size and duration. 65 func DealWeight(proposal *DealProposal) abi.DealWeight { 66 dealDuration := big.NewInt(int64(proposal.Duration())) 67 dealSize := big.NewIntUnsigned(uint64(proposal.PieceSize)) 68 dealSpaceTime := big.Mul(dealDuration, dealSize) 69 return dealSpaceTime 70 }