Skip to content

Commit 120b1fe

Browse files
committed
Unified the rest of the prices + documented the changes
1 parent bafbd02 commit 120b1fe

File tree

11 files changed

+30
-34
lines changed

11 files changed

+30
-34
lines changed

adview-manager/src/manager.rs

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

docs/config/ganache.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ keep_alive_interval = 1200000
6060
# This will limit the returned Campaigns to the set number
6161
max_campaigns_earning_from = 25
6262

63-
# 0.0001 (UnifiedNum) per 1000 impressions
64-
# 10 * (per) 1_000 / 10^8 = 0.0001
63+
# 0.0001 (UnifiedNum) per 1 impression
64+
# 10 / 10^8 = 0.0000001
6565
# 0.00010000
66-
global_min_impression_price = '10000'
66+
global_min_impression_price = '10'
6767

6868
[chain."Ganache #1"]
6969
chain_id = 1

docs/config/prod.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ keep_alive_interval = 1200000
4040
max_campaigns_earning_from = 25
4141

4242
# 0.01 (UnifiedNum) per 1000 impressions
43-
# 1_000 * (per) 1_000 / 10^8 = 0.01
44-
global_min_impression_price = '1000000'
43+
# 1_000 / 10^8 = 0.00001
44+
global_min_impression_price = '1000'
4545

4646
[chain."Ethereum Mainnet"]
4747
chain_id = 1

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/get_cfg_response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn main() {
7171
"limits": {
7272
"units_for_slot": {
7373
"max_campaigns_earning_from": 25,
74-
"global_min_impression_price": "10000"
74+
"global_min_impression_price": "10"
7575
}
7676
}
7777
});

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/validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl TryFrom<Value> for ValidatorId {
116116
/// 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 per event
119+
/// The validator fee per event
120120
///
121121
/// Each fee is calculated based on the payout for an event.
122122
///

sentry/src/routes/campaign.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,12 @@ pub mod insert_events {
10061006
"Campaign budget has no remaining funds to spend or an error occurred"
10071007
);
10081008

1009-
// Payout: 0.03 (min pricing bound)
1009+
// Payout: 0.00003 (min pricing bound per 1 event)
10101010
// Leader fee: 0.03
1011-
// Leader payout: 0.03 * 0.03 / 1000.0 = 0.00 000 090 = UnifiedNum(90)
1011+
// Leader payout: 0.00003 * 0.03 = 0.00 000 090 = UnifiedNum(90_000)
10121012
//
10131013
// Follower fee: 0.02
1014-
// Follower payout: 0.03 * 0.02 / 1000.0 = 0.00 000 060 = UnifiedNum(60)
1014+
// Follower payout: 0.00003 * 0.02 = 0.00 000 060 = UnifiedNum(60_000)
10151015
//
10161016
// campaign budget left - payout - leader fee - follower fee
10171017
// 1000.0 - 0.03 - 0.00 000 090 - 0.00 000 060 = 999.9699985

sentry/src/routes/units_for_slot_test.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ const TEST_AD_SLOT: Lazy<(AdSlot, AdUnit)> = Lazy::new(|| {
5858
[
5959
(
6060
GANACHE_INFO_1.tokens["Mocked TOKEN 1"].address,
61-
UnifiedNum::from_whole(0.010),
61+
UnifiedNum::from_whole(0.000010),
6262
),
6363
(
6464
GANACHE_INFO_1337.tokens["Mocked TOKEN 1337"].address,
65-
UnifiedNum::from_whole(0.001),
65+
UnifiedNum::from_whole(0.000001),
6666
),
6767
]
6868
.into_iter()
@@ -808,7 +808,6 @@ async fn test_price_is_less_than_min_per_impression() {
808808
total: UnifiedNum::from_whole(200_000)
809809
.to_precision(campaign.token.precision.into()),
810810
};
811-
812811
app.adapter.client.set_deposit(
813812
&campaign.of_channel(),
814813
campaign.context.creator,
@@ -843,9 +842,9 @@ async fn test_price_is_less_than_min_per_impression() {
843842
// override the pricing bound
844843
let pricing_less_than_global = Pricing {
845844
min: app.config.limits.units_for_slot.global_min_impression_price
846-
- UnifiedNum::from_whole(0.00003),
845+
- UnifiedNum::from_whole(0.00000003),
847846
max: app.config.limits.units_for_slot.global_min_impression_price
848-
- UnifiedNum::from_whole(0.00001),
847+
- UnifiedNum::from_whole(0.00000001),
849848
};
850849
assert!(
851850
pricing_less_than_global.min
@@ -860,7 +859,6 @@ async fn test_price_is_less_than_min_per_impression() {
860859
.pricing_bounds
861860
.insert(IMPRESSION, pricing_less_than_global)
862861
.expect("Should have a pricing bound for IMPRESSION before we've overwritten it");
863-
864862
let deposit = Deposit {
865863
total: UnifiedNum::from_whole(200_000)
866864
.to_precision(campaign.token.precision.into()),
@@ -908,7 +906,7 @@ async fn test_price_is_less_than_min_per_impression() {
908906
.as_mut()
909907
.expect("Should have min_per_impression set");
910908

911-
let min_per_impression = UnifiedNum::from_whole(0.00001);
909+
let min_per_impression = UnifiedNum::from_whole(0.00000001);
912910
assert!(
913911
min_per_impression < campaign_0.context.pricing_bounds[&IMPRESSION].min,
914912
"AdSlot.min_per_impression should be less than Campaign 0 pricing bound in order to match it"

0 commit comments

Comments
 (0)