Skip to content

Commit b27fbb3

Browse files
authored
Merge pull request #567 from AmbireTech/unify_prices
ValidatorDesc fees are now per 1
2 parents 9b51aca + 66fda0b commit b27fbb3

File tree

14 files changed

+72
-101
lines changed

14 files changed

+72
-101
lines changed

adview-manager/src/manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl Size {
104104
#[derive(Debug, Clone)]
105105
pub struct NextAdUnit {
106106
pub unit: AdUnit,
107+
// Price per 1 event
107108
pub price: UnifiedNum,
108109
pub accepted_referrers: Vec<Url>,
109110
pub html: String,

docs/config/ganache.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ ip_rate_limit = { type = 'ip', timeframe = 1200000 }
2929
# The maximum number of campaigns a publisher can earn from
3030
# This will limit the returned Campaigns to the set number
3131
max_campaigns_earning_from = 25
32-
# 0.0001 (UnifiedNum) per 1000 impressions
33-
# 10 * (per) 1_000 / 10^8 = 0.0001
34-
# 0.00010000
35-
global_min_impression_price = '10000'
32+
33+
# 0.0000001 (UnifiedNum) per 1 impression
34+
# 10 / 10^8 = 0.0000001
35+
global_min_impression_price = '10'
3636

3737
[sentry]
3838
# in milliseconds

docs/config/prod.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ ip_rate_limit = { type = 'ip', timeframe = 7200000 }
1414
# The maximum number of campaigns a publisher can earn from
1515
# This will limit the returned Campaigns to the set number
1616
max_campaigns_earning_from = 25
17-
# 0.01 (UnifiedNum) per 1000 impressions
18-
# 1_000 * (per) 1_000 / 10^8 = 0.01
19-
global_min_impression_price = '1000000'
17+
18+
# 0.00001 (UnifiedNum) per 1 impression
19+
# 1_000 / 10^8 = 0.00001
20+
global_min_impression_price = '1000'
2021

2122
[sentry]
2223
# in milliseconds

primitives/examples/campaign_list_response.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ fn main() {
3030
"title": "Dummy Campaign",
3131
"pricingBounds": {
3232
"CLICK": {
33-
"min": "6000000",
34-
"max": "10000000"
33+
"min": "6000",
34+
"max": "10000"
3535
},
3636
"IMPRESSION": {
37-
"min": "4000000",
38-
"max": "5000000"
37+
"min": "4000",
38+
"max": "5000"
3939
}
4040
},
4141
"eventSubmission": {
@@ -97,12 +97,12 @@ fn main() {
9797
"title": "Dummy Campaign 2 in Chain #1337",
9898
"pricingBounds": {
9999
"CLICK": {
100-
"min": "300000000",
101-
"max": "500000000"
100+
"min": "300000",
101+
"max": "500000"
102102
},
103103
"IMPRESSION": {
104-
"min": "100000000",
105-
"max": "200000000"
104+
"min": "100000",
105+
"max": "200000"
106106
}
107107
},
108108
"eventSubmission": {
@@ -165,12 +165,12 @@ fn main() {
165165
"title": "Dummy Campaign 3 in Chain #1",
166166
"pricingBounds": {
167167
"CLICK": {
168-
"min": "3500000",
169-
"max": "6500000"
168+
"min": "3500",
169+
"max": "6500"
170170
},
171171
"IMPRESSION": {
172-
"min": "1500000",
173-
"max": "2500000"
172+
"min": "1500",
173+
"max": "2500"
174174
}
175175
},
176176
"eventSubmission": {

primitives/examples/create_campaign_request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ fn main() {
2424
"validators":[
2525
{
2626
"id":"0x80690751969B234697e9059e04ed72195c3507fa",
27-
"fee":"3000000",
27+
"fee":"3000",
2828
"url":"http://localhost:8005"
2929
},
3030
{
3131
"id":"0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
32-
"fee":"2000000",
32+
"fee":"2000",
3333
"url":"http://localhost:8006"
3434
}
3535
],
@@ -75,12 +75,12 @@ fn main() {
7575
"validators":[
7676
{
7777
"id":"0x80690751969B234697e9059e04ed72195c3507fa",
78-
"fee":"3000000",
78+
"fee":"3000",
7979
"url":"http://localhost:8005"
8080
},
8181
{
8282
"id":"0xf3f583AEC5f7C030722Fe992A5688557e1B86ef7",
83-
"fee":"2000000",
83+
"fee":"2000",
8484
"url":"http://localhost:8006"
8585
}
8686
],

primitives/examples/get_cfg_response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() {
4545
"limits": {
4646
"units_for_slot": {
4747
"max_campaigns_earning_from": 25,
48-
"global_min_impression_price": "10000"
48+
"global_min_impression_price": "10"
4949
},
5050
"channels_find": 200,
5151
"campaigns_find": 200,

primitives/src/campaign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub struct Campaign {
179179
pub validators: Validators,
180180
#[serde(default, skip_serializing_if = "Option::is_none")]
181181
pub title: Option<String>,
182-
/// Events pricing bounds
182+
/// Events pricing bounds, per 1 event
183183
#[serde(default, skip_serializing_if = "PricingBounds::is_empty")]
184184
pub pricing_bounds: PricingBounds,
185185
/// EventSubmission object, applied to event submission

primitives/src/targeting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct Output {
3333
/// price.{eventType}
3434
/// For example: price.IMPRESSION
3535
/// The default is the min of the bound of event type:
36+
/// The price is per one event
3637
/// Default: pricingBounds.IMPRESSION.min
3738
pub price: HashMap<EventType, UnifiedNum>,
3839
}

primitives/src/test_util.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ mod logger {
149149
pub static DUMMY_VALIDATOR_LEADER: Lazy<ValidatorDesc> = Lazy::new(|| ValidatorDesc {
150150
id: IDS[&LEADER],
151151
url: "http://localhost:8005".to_string(),
152-
fee: UnifiedNum::from_whole(0.03),
152+
fee: UnifiedNum::from_whole(0.00003),
153153
fee_addr: None,
154154
});
155155

156156
pub static DUMMY_VALIDATOR_FOLLOWER: Lazy<ValidatorDesc> = Lazy::new(|| ValidatorDesc {
157157
id: IDS[&FOLLOWER],
158158
url: "http://localhost:8006".to_string(),
159-
fee: UnifiedNum::from_whole(0.02),
159+
fee: UnifiedNum::from_whole(0.00002),
160160
fee_addr: None,
161161
});
162162

@@ -315,12 +315,12 @@ pub static CAMPAIGNS: Lazy<[ChainOf<Campaign>; 3]> = Lazy::new(|| {
315315
};
316316

317317
let leader_desc = ValidatorDesc {
318-
fee: UnifiedNum::from_whole(0.5),
318+
fee: UnifiedNum::from_whole(0.0005),
319319
..DUMMY_VALIDATOR_LEADER.clone()
320320
};
321321

322322
let follower_desc = ValidatorDesc {
323-
fee: UnifiedNum::from_whole(0.4),
323+
fee: UnifiedNum::from_whole(0.0004),
324324
..DUMMY_VALIDATOR_FOLLOWER.clone()
325325
};
326326

@@ -378,12 +378,12 @@ pub static CAMPAIGNS: Lazy<[ChainOf<Campaign>; 3]> = Lazy::new(|| {
378378
};
379379

380380
let leader_desc = ValidatorDesc {
381-
fee: UnifiedNum::from_whole(0.1),
381+
fee: UnifiedNum::from_whole(0.0001),
382382
..DUMMY_VALIDATOR_FOLLOWER.clone()
383383
};
384384

385385
let follower_desc = ValidatorDesc {
386-
fee: UnifiedNum::from_whole(0.05),
386+
fee: UnifiedNum::from_whole(0.00005),
387387
..DUMMY_VALIDATOR_LEADER.clone()
388388
};
389389
let validators = Validators::new((leader_desc, follower_desc));
@@ -440,12 +440,12 @@ pub static CAMPAIGNS: Lazy<[ChainOf<Campaign>; 3]> = Lazy::new(|| {
440440
};
441441

442442
let leader_desc = ValidatorDesc {
443-
fee: UnifiedNum::from_whole(0.02),
443+
fee: UnifiedNum::from_whole(0.00002),
444444
..DUMMY_VALIDATOR_LEADER.clone()
445445
};
446446

447447
let follower_desc = ValidatorDesc {
448-
fee: UnifiedNum::from_whole(0.0175),
448+
fee: UnifiedNum::from_whole(0.0000175),
449449
..DUMMY_VALIDATOR_FOLLOWER.clone()
450450
};
451451

primitives/src/validator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ impl TryFrom<Value> for ValidatorId {
113113

114114
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
115115
#[serde(rename_all = "camelCase")]
116-
/// A Validator description which includes the identity, fee (pro milles) and the Sentry URL.
116+
/// A Validator description which includes the identity, fee (per event) and the Sentry URL.
117117
pub struct ValidatorDesc {
118118
pub id: ValidatorId,
119-
/// The validator fee in pro milles (per 1000)
119+
/// The validator fee per event
120120
///
121121
/// Each fee is calculated based on the payout for an event.
122122
///
123-
/// payout * fee / 1000 = event fee payout
123+
/// payout * fee = event fee payout
124124
pub fee: UnifiedNum,
125125
#[serde(default, skip_serializing_if = "Option::is_none")]
126126
/// The address which will receive the fees

0 commit comments

Comments
 (0)