From 9014b88fbed9c58eee4849a47064b0d63f63b696 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Tue, 20 Aug 2019 00:38:56 +0530 Subject: [PATCH 01/36] feat: add clr label to grant --- app/assets/v2/css/grants/card.css | 8 ++++++ app/assets/v2/css/grants/fund.css | 8 ++++++ app/assets/v2/js/grants/fund.js | 32 +++++++++++++++++++++ app/grants/templates/grants/card/front.html | 4 +++ app/grants/templates/grants/fund.html | 9 ++++-- 5 files changed, 58 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/css/grants/card.css b/app/assets/v2/css/grants/card.css index ab11710ce76..0c63d50e16d 100644 --- a/app/assets/v2/css/grants/card.css +++ b/app/assets/v2/css/grants/card.css @@ -30,6 +30,14 @@ display: flex; } +.clr { + right: 1.25rem; +} + +.clr h2 { + color: #f6851b; +} + .grant-item__img { height: 11rem; overflow: hidden; diff --git a/app/assets/v2/css/grants/fund.css b/app/assets/v2/css/grants/fund.css index 2702bfc24f1..387df35ce81 100644 --- a/app/assets/v2/css/grants/fund.css +++ b/app/assets/v2/css/grants/fund.css @@ -4,6 +4,14 @@ } } +.popover-body .clr-popover h1 { + color: #f6851b +} + +.popover-body .clr-popover p { + font-weight: 500; +} + .admin_profile a, #grant-link { color: #0D0764; diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 37d7082f95e..76f5660b069 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -10,6 +10,17 @@ let gitcoinDonationAddress; $(document).ready(function() { + + showCLRPopover(); + + $('#amount').on('input', () => { + showCLRPopover(); + }); + + $('.popover').on('click', () => { + $('#amount-container').popover('hide'); + }); + gitcoinDonationAddress = $('#gitcoin_donation_address').val(); splitterAddress = $('#splitter_contract_address').val(); @@ -492,3 +503,24 @@ const splitGrantAmount = () => { $('.summary-gitcoin-amount').html(gitcoin_grant_amount); $('#summary-amount').html(grant_amount); }; + +const showCLRPopover = () => { + // TODO: Check if grant has CLR else return + + const clr_amount = 0; // TODO: trigger CLR calculation + const total_clr = 0; // TODO: fetch CLR + const random = 0; // TODO: figure out what this is + const html = ` +
+

CLR MATCH ${clr_amount} DAI

+

( out of ${total_clr} DAI )

+

+ This is how much your contribution at this moment would + increase the CLR Match amount for the grant by ${random} amount +

+
+ `; + + $('#amount-container').attr('data-content', html); + $('#amount-container').popover('show'); +}; \ No newline at end of file diff --git a/app/grants/templates/grants/card/front.html b/app/grants/templates/grants/card/front.html index 356a691a681..f6840cf2292 100644 --- a/app/grants/templates/grants/card/front.html +++ b/app/grants/templates/grants/card/front.html @@ -37,6 +37,10 @@

+

CLR MATCH 0 DAI

+

( out of 0 DAI )

+
diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index dc9291374aa..9ab7b2824c9 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -54,7 +54,6 @@

{% trans "Fund Grant" %}

{% include 'grants/banner.html' %} - {% if can_phantom_fund %}

+ {% include './clr_estimate.html' with class='extraleft' %} diff --git a/app/grants/views.py b/app/grants/views.py index b9eac8a7cc8..42b74e1ba18 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -619,6 +619,7 @@ def grant_fund(request, grant_id, grant_slug): 'active_tab': active_tab, 'fund_reward': fund_reward, 'phantom_funds': phantom_funds, + 'clr_contributoin_estimate': 750, # TODO - fill this in dynamicaly. } return TemplateResponse(request, 'grants/fund.html', params) From 25a9a12f642ff2fe0645861babe5ba9853eb7e11 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 18 Sep 2019 20:38:57 +0530 Subject: [PATCH 16/36] merged clr frontend code --- app/assets/v2/css/grants/card.css | 8 ++- app/assets/v2/css/grants/fund.css | 64 +++++++++++-------- app/assets/v2/js/grants/fund.js | 31 --------- app/grants/templates/grants/card/front.html | 12 ++-- app/grants/templates/grants/clr_estimate.html | 16 +++-- app/grants/templates/grants/fund.html | 16 ++--- app/grants/views.py | 11 +++- 7 files changed, 82 insertions(+), 76 deletions(-) diff --git a/app/assets/v2/css/grants/card.css b/app/assets/v2/css/grants/card.css index 0c63d50e16d..3e63ac13d85 100644 --- a/app/assets/v2/css/grants/card.css +++ b/app/assets/v2/css/grants/card.css @@ -35,7 +35,13 @@ } .clr h2 { - color: #f6851b; + background: #10cd7a; + color: #fff; + border-radius: 3px; +} + +.clr p { + font-size: 10px; } .grant-item__img { diff --git a/app/assets/v2/css/grants/fund.css b/app/assets/v2/css/grants/fund.css index da2f8d81f08..b41ef0da35a 100644 --- a/app/assets/v2/css/grants/fund.css +++ b/app/assets/v2/css/grants/fund.css @@ -4,18 +4,11 @@ } } -.popover-body .clr-popover h1 { - color: #f6851b -} - -.popover-body .clr-popover p { - font-weight: 500; -} - .admin_profile a, #grant-link { color: #0D0764; } + .tab_target{ width: 100%; } @@ -154,35 +147,41 @@ bottom: -1.2rem; } -.nav{ +.nav { text-align: center; } -.nav-link{ + +.nav-link { border-right: 1px solid black; border-top: 1px solid black; border-left: 1px solid black; margin-right: 10px; } -.nav-link:visited{ + +.nav-link:visited { color: black; } -.nav-item.active{ + +.nav-item.active { text-decoration: underline; } -.clr_estimate{ + +.clr_estimate { background-color: white; border-radius: 5px; border: 2px solid #10cd7a; text-align: left; width: 250px; - padding: 10px 15px; + padding: 1rem 15px; position: absolute; top: 0px; left: 0px; } -.clr_estimate.extraleft{ + +.clr_estimate.extraleft { left: -270px; } + .clr_estimate:after { content: ''; position: absolute; @@ -197,34 +196,43 @@ margin-top: -10px; margin-right: -20px; } -.clr_estimate img{ + +.clr_estimate img { float: right; width: 50px; } -.clr_estimate h3{ + +.clr_estimate h3 { text-align: left; - background-color: #10cd7a; color: white; - border-radius: 3px; font-size: 12px; - padding: 4px 6px; text-transform: uppercase; width: 150px; } -.clr_estimate h4{ + +.clr_estimate h3 span { + background-color: #10cd7a; + border-radius: 3px; + padding: 4px 6px; + +} + +.clr_estimate h4 { padding-top: 0px; text-align: left; color: #10cd7a; font-size: 10px; + font-weight: bold; } -.clr_estimate h4 span{ + +.clr_estimate h4 span { font-size: 16px; - font-weight: bold; } -.clr_estimate p{ + +.clr_estimate p { text-align: left; color: #10cd7a; - font-size: 10px; + font-size: 12px; color: #959595; } @@ -254,3 +262,9 @@ max-width: 100%; } } + +@media (max-width: 1199.98px) { + .clr_estimate { + display: none; + } +} \ No newline at end of file diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 76f5660b069..78a5c1d38ba 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -11,16 +11,6 @@ let gitcoinDonationAddress; $(document).ready(function() { - showCLRPopover(); - - $('#amount').on('input', () => { - showCLRPopover(); - }); - - $('.popover').on('click', () => { - $('#amount-container').popover('hide'); - }); - gitcoinDonationAddress = $('#gitcoin_donation_address').val(); splitterAddress = $('#splitter_contract_address').val(); @@ -502,25 +492,4 @@ const splitGrantAmount = () => { $('.gitcoin-grant-percent').html(percent); $('.summary-gitcoin-amount').html(gitcoin_grant_amount); $('#summary-amount').html(grant_amount); -}; - -const showCLRPopover = () => { - // TODO: Check if grant has CLR else return - - const clr_amount = 0; // TODO: trigger CLR calculation - const total_clr = 0; // TODO: fetch CLR - const random = 0; // TODO: figure out what this is - const html = ` -
-

CLR MATCH ${clr_amount} DAI

-

( out of ${total_clr} DAI )

-

- This is how much your contribution at this moment would - increase the CLR Match amount for the grant by ${random} amount -

-
- `; - - $('#amount-container').attr('data-content', html); - $('#amount-container').popover('show'); }; \ No newline at end of file diff --git a/app/grants/templates/grants/card/front.html b/app/grants/templates/grants/card/front.html index 2aaf4d98cdf..5a35a2cdba9 100644 --- a/app/grants/templates/grants/card/front.html +++ b/app/grants/templates/grants/card/front.html @@ -37,10 +37,14 @@

-

CLR MATCH 0 DAI

-

( out of 0 DAI )

-

+ {% if clr_active %} +
+

+ CLR MATCH 0 DAI +

+

( out of {{ total_clr_pot }} DAI )

+
+ {% endif %}
diff --git a/app/grants/templates/grants/clr_estimate.html b/app/grants/templates/grants/clr_estimate.html index 492a922683f..e8c3a31c0ac 100644 --- a/app/grants/templates/grants/clr_estimate.html +++ b/app/grants/templates/grants/clr_estimate.html @@ -1,10 +1,18 @@ {% load static%} -{% if clr_contributoin_estimate %} +{% if clr_contribution_estimate and clr_active %}
-

Clr Match Round 3

+

+ Clr Match Round {{ clr_round }} +

-

{{clr_contributoin_estimate}} DAI of 100,000 DAI

-

Your contribution at this moment would increase the CLR Match amount for this grant by {{clr_contributoin_estimate}} DAI.

+

+ {{ clr_contribution_estimate }} DAI + of {{ total_clr_pot }} DAI +

+

+ Your contribution at this moment would increase the CLR Match amount + for this grant by {{clr_contribution_estimate}} DAI. +

{% endif %} diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 04a591266a9..2b489674a9f 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -107,11 +107,11 @@

{% trans "Fund Grant" %}

{% include './clr_estimate.html' %}
@@ -139,7 +139,7 @@

{% trans "Fund Grant" %}

-
+
@@ -369,10 +369,6 @@
{% trans "Gas Settings" %}
- - diff --git a/app/grants/views.py b/app/grants/views.py index 42b74e1ba18..84cc4bc65f1 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -57,6 +57,10 @@ clr_matching_banners_style = 'pledging' matching_live = '($50K matching live now!) ' +total_clr_pot = 10000 +clr_round = 3 +clr_active = True + if True: clr_matching_banners_style = 'results' matching_live = '' @@ -125,6 +129,8 @@ def grants(request): 'grants_count': _grants.count(), 'keywords': get_keywords(), 'grant_amount': grant_amount, + 'total_clr_pot': total_clr_pot, + 'clr_active': True } # log this search, it might be useful for matching purposes down the line @@ -619,7 +625,10 @@ def grant_fund(request, grant_id, grant_slug): 'active_tab': active_tab, 'fund_reward': fund_reward, 'phantom_funds': phantom_funds, - 'clr_contributoin_estimate': 750, # TODO - fill this in dynamicaly. + 'clr_round': clr_round, + 'clr_contribution_estimate': 750, # TODO - fill this in dynamicaly. + 'total_clr_pot': total_clr_pot, + 'clr_active': True } return TemplateResponse(request, 'grants/fund.html', params) From 36ec03a794220f240c6d5aeab2d8a281366ee599 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 00:26:47 +0900 Subject: [PATCH 17/36] cleanup and small tweaks --- app/grants/clr.py | 118 ++++++------------ .../management/commands/estimate_clr.py | 13 +- 2 files changed, 51 insertions(+), 80 deletions(-) diff --git a/app/grants/clr.py b/app/grants/clr.py index 4e112bcf524..b11b6c7fa4f 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -26,27 +26,8 @@ from grants.models import Contribution, Grant CLR_DISTRIBUTION_AMOUNT = 100000 +CLR_START_DATE = dt.datetime(2019, 1, 16, 0, 0) -grant_contributions = [ - { - 'id': '1', - 'contributions': [ - { '1': 5 }, - { '2': 10 }, - { '3': 25 } - ] - }, - { - 'id': '2', - 'contributions': [ - { '3': 20 }, - { '1': 2 }, - { '4': 2 }, - { '5': 5 }, - { '1': 15 } - ] - } -] ''' Helper function that generates all combinations of pair of grant @@ -83,9 +64,6 @@ def generate_grant_pair(grant): else: unique_contributions[profile] = amount - # print(f'Grant Contributions: {grant_contributions}') - # print(f'Unique Contributions: {unique_contributions}') - profile_pairs = list(combinations(unique_contributions.keys(), 2)) contribution_pairs = list(combinations(unique_contributions.values(), 2)) @@ -94,7 +72,6 @@ def generate_grant_pair(grant): sqrt_of_product = round(math.sqrt(contribution_1 * contribution_2)) sqrt_of_product_pairs.append(sqrt_of_product) - grant = { 'id': grant_id, 'profile_pairs': profile_pairs, @@ -102,13 +79,6 @@ def generate_grant_pair(grant): 'sqrt_of_product_pairs': sqrt_of_product_pairs } - # print(f'Grant ID: {grant["id"]}') - # print(f'Profile Pairs: {grant["profile_pairs"]}') - # print(f'Contribution Pairs: {grant["contribution_pairs"]}') - # print(f'Sqrt Of Product Pairs: {grant["sqrt_of_product_pairs"]}') - - # print('=================\n') - return grant @@ -160,14 +130,11 @@ def calculate_clr(threshold, grant_contributions): else: group_by_pair[pair] = grant['sqrt_of_product_pairs'][index] - # print(f'SUM OF GROUPED BY PAIRS {group_by_pair} \n=================\n') - _clrs = [] for grant in grants: grant_clr = 0 lr_contributions = [] - # print(grant['profile_pairs']) for index, profile_pair in enumerate(grant['profile_pairs']): pair = str('&'.join(profile_pair)) pair_reversed = str('&'.join(profile_pair[::-1])) @@ -188,14 +155,11 @@ def calculate_clr(threshold, grant_contributions): lr_contributions.append(lr_contribution) grant_clr += lr_contribution total_clr += lr_contribution - # print(f'LR CONTRIBUTION {lr_contribution} | PAIR {profile_pair}') - # print(f'\n+++++\nGRANT {grant["id"]} - CLR CONTRIBUTION {grant_clr} \n+++++') _clrs.append({ 'id': grant["id"], 'clr_amount': grant_clr }) - # print(f'\n\n============ \nTOTAL CLR {total_clr} \n=============') return total_clr, _clrs @@ -227,70 +191,63 @@ def grants_clr_calculate (total_pot, grant_contributions, min_threshold, max_thr threshold = (max_threshold + min_threshold) / 2 total_clr, grants_clrs = calculate_clr(threshold, grant_contributions) - print(f'\n\n************ POT: {total_pot} | Calculated CLR: {total_clr} | Threshold {threshold} | Iterations {iterations} | GRANT SPLIT {grants_clrs}') - if iterations == 100 or total_pot == threshold or previous_threshold == threshold: # No more accuracy to be had return grants_clrs, total_clr, threshold, iterations if total_clr > total_pot: max_threshold = threshold - # print(f'++ MIN {min_threshold} NEW MAX {max_threshold}') elif total_clr < total_pot: min_threshold = threshold - # print(f'-- NEW MIN {min_threshold} MAX {max_threshold}') else: return grants_clrs, total_clr, threshold, iterations return grants_clr_calculate(total_pot, grant_contributions, min_threshold, max_threshold, iterations, threshold) -''' -total_pot = 50 -max_threshold = total_pot -min_threshold= 0 - -grants_clr, total_clr, threshold, iterations = grants_clr_calculate(total_pot, grant_contributions, min_threshold, max_threshold) -print(f'\n\n\n=============== \nFINAL \nPOT: {total_pot} \nCalculated CLR: {total_clr} \nThreshold {threshold} \nIterations {iterations} \nCLR Breakup\n') -print(json.dumps(grants_clr, indent=2)) -print('===============') -''' - def generate_random_contribution_data(): import random contrib_data = [] - for grant_id in range(33): - contrib_data.append({'id': grant_id, 'contributions': [{str(profile_id): random.randint(3000,6890)} for profile_id in range(random.randint(0,17))]}) + # whatever the range is here, you should have that many grants locally to test with + # this function generates fake contribution data, but assumes the grants are in the db + + grants_to_use = 33 + low_donation = 3000 + high_donation = 6890 + number_of_profiles = 17 + for grant_id in range(grants_to_use): + contrib_data.append({'id': grant_id, + 'contributions': [{str(profile_id): random.randint(low_donation, high_donation)} for profile_id in range(random.randint(1, number_of_profiles))]}) return contrib_data def calculate_clr_for_donation(donation_grant, donation_amount, total_pot, base_grant_contributions): grant_contributions = copy.deepcopy(base_grant_contributions) - # find grant in contributions list + # find grant in contributions list and add donation if donation_amount != 0: for grant_contribution in grant_contributions: if grant_contribution['id'] == donation_grant.id: - # add this donation with a new profile to get impact + # add this donation with a new profile (id 99999999999) to get impact grant_contribution['contributions'].append({'999999999999': donation_amount}) + grants_clr, _, _, _ = grants_clr_calculate(CLR_DISTRIBUTION_AMOUNT, grant_contributions, 0, CLR_DISTRIBUTION_AMOUNT) - # print("GRANTS CLR: {}".format(grants_clr)) - # print("TOTAL CLR: {}".format(total_clr)) - # if grants_clr == 0: - # return 0 + + # find grant we added the contribution to and get the new clr amount for grant_clr in grants_clr: if grant_clr['id'] == donation_grant.id: return (grant_clr['clr_amount'], grants_clr) + print('error: could not find grant in final grants_clr data') return (None, None) -def predict_clr(random_data=False): - clr_start_date = dt.datetime(2019, 1, 15, 0, 0) +def predict_clr(random_data=False, save_to_db=False): # get all the eligible contributions and calculate total - contributions = Contribution.objects.prefetch_related('subscription').filter(created_on__gte=clr_start_date) + contributions = Contribution.objects.prefetch_related('subscription').filter(created_on__gte=CLR_START_DATE) + debug_output = [] grants = Grant.objects.all() - final_output = [] - contrib_data = [] # set up data to load contributions for each grant if not random_data: + contrib_data = [] + for grant in grants: # go through all the individual contributions for each grant g_contributions = copy.deepcopy(contributions).filter(subscription__grant_id=grant.id) @@ -298,29 +255,36 @@ def predict_clr(random_data=False): # put in correct format all_contributing_profile_ids = list(set([c.subscription.contributor_profile.id for c in g_contributions])) all_summed_contributions = [] - print("*** grant id:{} has contributions from profiles: {}".format(grant.id, all_contributing_profile_ids)) + for profile_id in all_contributing_profile_ids: + # get sum of contributions per grant for each profile profile_g_contributions = g_contributions.filter(subscription__contributor_profile_id=profile_id) sum_of_each_profiles_contributions = float(sum([c.subscription.get_converted_monthly_amount() for c in profile_g_contributions])) - print("*** profile id:{} contributed total:{}".format(profile_id, sum_of_each_profiles_contributions)) all_summed_contributions.append({str(profile_id): sum_of_each_profiles_contributions}) - #contrib_data.append({'id': grant.id, 'contributions': [{str(c.subscription.contributor_profile.id): c.subscription.get_converted_monthly_amount()} for c in g_contributions]}) + + # for each grant, list the contributions in key value pairs like {'profile id': sum of contributions} contrib_data.append({'id': grant.id, 'contributions': all_summed_contributions}) else: + # use random contribution data for testing contrib_data = generate_random_contribution_data() - print('\n\ncontributions data:\n\n') + + print('\n\ncontributions data:') print(contrib_data) - # apply potential donations for each grant + + # calculate clr given additional donations for grant in grants: - # five potential additional donations + # five potential additional donations plus the base case of 0 potential_donations = [0, 1, 10, 100, 1000, 10000] potential_clr = [] + for donation_amount in potential_donations: - # calculate impact for each additional donation and save as number to display + # calculate clr with each additional donation and save to grants model predicted_clr, grants_clr = calculate_clr_for_donation(grant, donation_amount, CLR_DISTRIBUTION_AMOUNT, contrib_data) potential_clr.append(predicted_clr) - # grant.clr_prediction_curve = zip(potential_donations, potential_clr) - # grant.save() - # print("grant: {} potential_clr: {}".format(grant.id, potential_clr)) - final_output.append({'grant': grant.id, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr}) - return final_output + + if save_to_db: + grant.clr_prediction_curve = list(zip(potential_donations, potential_clr)) + grant.save() + + debug_output.append({'grant': grant.id, "clr_prediction_curve": (potential_donations, potential_clr), "grants_clr": grants_clr}) + return debug_output diff --git a/app/grants/management/commands/estimate_clr.py b/app/grants/management/commands/estimate_clr.py index 0654c29a042..40ddda54e10 100644 --- a/app/grants/management/commands/estimate_clr.py +++ b/app/grants/management/commands/estimate_clr.py @@ -32,13 +32,20 @@ class Command(BaseCommand): help = 'calculate CLR estimates for all grants' def handle(self, *args, **options): - clr_prediction_curves = predict_clr(random_data=False) + clr_prediction_curves = predict_clr(random_data=False, save_to_db=False) + + # Uncomment these for debugging and sanity checking # for grant in clr_prediction_curves: #print("CLR predictions for grant {}".format(grant['grant'])) #print("All grants: {}".format(grant['grants_clr'])) #print("prediction curve: {}\n\n".format(grant['clr_prediction_curve'])) - #sanity check: sum all the estimated clr distributions - should equal 100000 + + # sanity check: sum all the estimated clr distributions - should be close to CLR_DISTRIBUTION_AMOUNT clr_data = [g['grants_clr'] for g in clr_prediction_curves] - #print(clr_data) + + # print(clr_data) + total_clr_funds = sum([each_grant['clr_amount'] for each_grant in clr_data[0]]) print("allocated CLR funds:{}".format(total_clr_funds)) + + print("finished CLR estimates") From c74582074fd2945b0155509a834e7721eccf6587 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 18 Sep 2019 21:23:01 +0530 Subject: [PATCH 18/36] wiring UI to BE --- app/assets/v2/js/grants/fund.js | 31 ++++++++++++++++++- app/grants/templates/grants/clr_estimate.html | 10 ++++-- app/grants/templates/grants/fund.html | 12 ++++--- app/grants/views.py | 2 +- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 78a5c1d38ba..ed6a3d58300 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -11,6 +11,10 @@ let gitcoinDonationAddress; $(document).ready(function() { + $('#amount').on('input', () => { + predictCLRMatch(); + }); + gitcoinDonationAddress = $('#gitcoin_donation_address').val(); splitterAddress = $('#splitter_contract_address').val(); @@ -490,6 +494,31 @@ const splitGrantAmount = () => { } $('.gitcoin-grant-percent').html(percent); - $('.summary-gitcoin-amount').html(gitcoin_grant_amount); + $('.summary-gitcoin-amount').html(gitcoin_grant_amount.toFixed(2)); $('#summary-amount').html(grant_amount); +}; + +const predictCLRMatch = () => { + + const amount = Number.parseFloat($('#amount').val()); + let predicted_clr = 0; + + if (amount == 0) { + predicted_clr = prediction_curve[0]; + } else if (amount <= 1) { + predicted_clr = (prediction_curve[0] + prediction_curve[1]) / 2; + } else if (amount <= 10) { + predicted_clr = (prediction_curve[1] + prediction_curve[2]) / 2; + } else if (amount <= 100) { + predicted_clr = (prediction_curve[2] + prediction_curve[3]) / 2; + } else if (amount <= 1000) { + predicted_clr = (prediction_curve[3] + prediction_curve[4]) / 2; + } else if (amount <= 10000) { + predicted_clr = (prediction_curve[4] + prediction_curve[5]) / 2; + } else { + predicted_clr = prediction_curve[5]; + } + + $('.clr_match_prediction').html(predicted_clr); + $('.clr_increase').html(predicted_clr - prediction_curve[0]); }; \ No newline at end of file diff --git a/app/grants/templates/grants/clr_estimate.html b/app/grants/templates/grants/clr_estimate.html index e8c3a31c0ac..122e1bf9f7b 100644 --- a/app/grants/templates/grants/clr_estimate.html +++ b/app/grants/templates/grants/clr_estimate.html @@ -1,5 +1,5 @@ {% load static%} -{% if clr_contribution_estimate and clr_active %} +{% if clr_active %}

@@ -7,12 +7,16 @@

- {{ clr_contribution_estimate }} DAI + {{ prediction_curve.0 }} + DAI of {{ total_clr_pot }} DAI

Your contribution at this moment would increase the CLR Match amount - for this grant by {{clr_contribution_estimate}} DAI. + for this grant by + + 0 DAI + .

{% endif %} diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 2b489674a9f..e3903507aab 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -359,13 +359,15 @@
{% trans "Gas Settings" %}
{% include 'shared/footer.html' %} {% include 'grants/shared/shared_scripts.html' %} - {% if show_tweet_modal %} - - {% endif %} + {% endif %} + + const prediction_curve = {{ prediction_curve }}; + diff --git a/app/grants/views.py b/app/grants/views.py index 84cc4bc65f1..37610a1dad5 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -626,7 +626,7 @@ def grant_fund(request, grant_id, grant_slug): 'fund_reward': fund_reward, 'phantom_funds': phantom_funds, 'clr_round': clr_round, - 'clr_contribution_estimate': 750, # TODO - fill this in dynamicaly. + 'prediction_curve': [5, 10, 15, 20, 25, 30], # grant.clr_prediction_curve 'total_clr_pot': total_clr_pot, 'clr_active': True } From e0e62430a4a27426e3a861bb94a643717419da33 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 00:58:18 +0900 Subject: [PATCH 19/36] add admin, fix url conf, etc. --- app/grants/admin.py | 6 +++--- app/grants/clr.py | 1 + app/grants/management/commands/estimate_clr.py | 2 +- app/grants/models.py | 4 +++- app/grants/urls.py | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/grants/admin.py b/app/grants/admin.py index 869cbfa574f..77b531f8996 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -47,12 +47,12 @@ class GrantAdmin(GeneralAdmin): 'token_address', 'contract_address', 'contract_version', 'network', 'required_gas_price', 'logo_svg_asset', 'logo_asset', 'created_on', 'modified_on', 'team_member_list', 'subscriptions_links', 'contributions_links', 'logo', 'logo_svg', 'image_css', - 'link', 'clr_matching', 'hidden' + 'link', 'clr_matching', 'clr_prediction_curve', 'hidden' ] readonly_fields = [ 'logo_svg_asset', 'logo_asset', 'team_member_list', - 'subscriptions_links', 'contributions_links', 'link', + 'subscriptions_links', 'contributions_links', 'link', ] raw_id_fields = ['admin_profile'] @@ -179,7 +179,7 @@ class ContributionAdmin(GeneralAdmin): """Define the Contribution administration layout.""" raw_id_fields = ['subscription'] - + admin.site.register(PhantomFunding, GeneralAdmin) admin.site.register(MatchPledge, MatchPledgeAdmin) admin.site.register(Grant, GrantAdmin) diff --git a/app/grants/clr.py b/app/grants/clr.py index b11b6c7fa4f..7d011d6c2d6 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -213,6 +213,7 @@ def generate_random_contribution_data(): low_donation = 3000 high_donation = 6890 number_of_profiles = 17 + for grant_id in range(grants_to_use): contrib_data.append({'id': grant_id, 'contributions': [{str(profile_id): random.randint(low_donation, high_donation)} for profile_id in range(random.randint(1, number_of_profiles))]}) diff --git a/app/grants/management/commands/estimate_clr.py b/app/grants/management/commands/estimate_clr.py index 40ddda54e10..613f5a3ef73 100644 --- a/app/grants/management/commands/estimate_clr.py +++ b/app/grants/management/commands/estimate_clr.py @@ -32,7 +32,7 @@ class Command(BaseCommand): help = 'calculate CLR estimates for all grants' def handle(self, *args, **options): - clr_prediction_curves = predict_clr(random_data=False, save_to_db=False) + clr_prediction_curves = predict_clr(random_data=False, save_to_db=True) # Uncomment these for debugging and sanity checking # for grant in clr_prediction_curves: diff --git a/app/grants/models.py b/app/grants/models.py index 5af4ec5cb37..1c3c01814b1 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -209,8 +209,10 @@ def __str__(self): def clr_prediction(self, donation): """Linear interpolation between 5 point curve""" curve = self.clr_prediction_curve - for i in range(1, length(curve)): + donation = float(donation) + for i in range(1, len(curve)): if curve[i-1][0] <= donation and donation <= curve[i][0]: + print('value between {} and {}'.format(curve[i-1][0], curve[i][0])) break m = (curve[i-1][0] - curve[i-1][1]) / (curve[i][0] - curve[i][1]) prediction = (donation - curve[i][1]) * m + curve[i-1][1] diff --git a/app/grants/urls.py b/app/grants/urls.py index 025461cb21c..864be358720 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -27,9 +27,9 @@ app_name = 'grants' urlpatterns = [ path('', grants, name='grants'), + path('/potential_clr', potential_clr, name='potential_clr'), path('/', grant_details, name='details'), path('//', grant_details, name='details2'), - path('/potential_clr', potential_clr, name='potential_clr'), re_path(r'^new', grant_new, name='new'), re_path(r'^old', grant_new_v0, name='old'), path('//milestones', milestones, name='milestones'), From 3a5d80634454d2d2fed4aa33f32c419cf330dc54 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 01:14:01 +0900 Subject: [PATCH 20/36] remove backend lerp --- app/grants/models.py | 15 +-------------- app/grants/urls.py | 1 - 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/app/grants/models.py b/app/grants/models.py index 028172887c3..0998d50990b 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -206,19 +206,6 @@ def __str__(self): return f"id: {self.pk}, active: {self.active}, title: {self.title}" - def clr_prediction(self, donation): - """Linear interpolation between 5 point curve""" - curve = self.clr_prediction_curve - donation = float(donation) - for i in range(1, len(curve)): - if curve[i-1][0] <= donation and donation <= curve[i][0]: - print('value between {} and {}'.format(curve[i-1][0], curve[i][0])) - break - m = (curve[i-1][0] - curve[i-1][1]) / (curve[i][0] - curve[i][1]) - prediction = (donation - curve[i][1]) * m + curve[i-1][1] - return prediction - - def percentage_done(self): """Return the percentage of token received based on the token goal.""" if not self.amount_goal: @@ -965,7 +952,7 @@ def estimated_matching_value(self): def to_mock_contribution(self): context = self.to_standard_dict() - context['subscription'] = { + context['subscription'] = { 'contributor_profile': self.profile, 'amount_per_period': self.value, 'token_symbol': 'DAI', diff --git a/app/grants/urls.py b/app/grants/urls.py index 864be358720..fa60b8a60c0 100644 --- a/app/grants/urls.py +++ b/app/grants/urls.py @@ -27,7 +27,6 @@ app_name = 'grants' urlpatterns = [ path('', grants, name='grants'), - path('/potential_clr', potential_clr, name='potential_clr'), path('/', grant_details, name='details'), path('//', grant_details, name='details2'), re_path(r'^new', grant_new, name='new'), From d4402b915bb7480de04cbc79f6bc07e151d97cc1 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 18 Sep 2019 23:12:34 +0530 Subject: [PATCH 21/36] added lerp --- app/assets/v2/js/grants/fund.js | 70 +++++++++++++++---- app/grants/templates/grants/card/front.html | 2 +- app/grants/templates/grants/clr_estimate.html | 4 +- app/grants/templates/grants/fund.html | 3 +- app/grants/views.py | 3 +- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index ed6a3d58300..6866ab179cf 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -498,27 +498,67 @@ const splitGrantAmount = () => { $('#summary-amount').html(grant_amount); }; +const lerp = (x_lower, x_upper, y_lower, y_upper, x) => { + console.log(x_lower, x_upper, y_lower, y_upper, x); + return y_lower + (((y_upper - y_lower) * (x - x_lower)) / (x_upper - x_lower)); +}; + const predictCLRMatch = () => { const amount = Number.parseFloat($('#amount').val()); let predicted_clr = 0; - if (amount == 0) { - predicted_clr = prediction_curve[0]; - } else if (amount <= 1) { - predicted_clr = (prediction_curve[0] + prediction_curve[1]) / 2; - } else if (amount <= 10) { - predicted_clr = (prediction_curve[1] + prediction_curve[2]) / 2; - } else if (amount <= 100) { - predicted_clr = (prediction_curve[2] + prediction_curve[3]) / 2; - } else if (amount <= 1000) { - predicted_clr = (prediction_curve[3] + prediction_curve[4]) / 2; - } else if (amount <= 10000) { - predicted_clr = (prediction_curve[4] + prediction_curve[5]) / 2; + const contributions_axis = [ 0, 1, 10, 100, 1000, 10000 ]; + + if (isNaN(amount)) { + predicted_clr = clr_prediction_curve[index]; + } else if (contributions_axis.indexOf(amount) >= 0) { + index = contributions_axis.indexOf(amount); + predicted_clr = clr_prediction_curve[index]; } else { - predicted_clr = prediction_curve[5]; + let x_lower = 0; + let x_upper = 0; + let y_lower = 0; + let y_upper = 0; + + if (0 < amount && amount < 1) { + x_lower = 0; + x_upper = 1; + y_lower = clr_prediction_curve[0]; + y_upper = clr_prediction_curve[1]; + } else if (1 < amount && amount < 10) { + x_lower = 1; + x_upper = 10; + y_lower = clr_prediction_curve[1]; + y_upper = clr_prediction_curve[2]; + } else if (10 < amount && amount < 100) { + x_lower = 10; + x_upper = 100; + y_lower = prediction_curve[2]; + y_upper = prediction_curve[3]; + } else if (100 < amount && amount < 1000) { + x_lower = 100; + x_upper = 1000; + y_lower = clr_prediction_curve[3]; + y_upper = clr_prediction_curve[4]; + } else if (1000 < amount && amount <= 10000) { + x_lower = 1000; + x_upper = 10000; + y_lower = clr_prediction_curve[4]; + y_upper = clr_prediction_curve[5]; + } else { + // NOT SURE WHAT TO DO HERE + // NEED TO ESTIMATE ONE WITH MAX CONTRIBUTION + // CAN WE ASSUME MAX AMOUNT IS 10000 ? + x_lower = 10000; + x_upper = 0; // WHAT ? + y_lower = clr_prediction_curve[5]; + y_upper = 0; // WHAT ? + } + + predicted_clr = lerp(x_lower, x_upper, y_lower, y_upper, amount); } - $('.clr_match_prediction').html(predicted_clr); - $('.clr_increase').html(predicted_clr - prediction_curve[0]); + $('.clr_match_prediction').html(predicted_clr.toFixed(2)); + $('.clr_increase').html((predicted_clr - clr_prediction_curve[0]).toFixed(2)); }; \ No newline at end of file diff --git a/app/grants/templates/grants/card/front.html b/app/grants/templates/grants/card/front.html index 5a35a2cdba9..f8662e60f91 100644 --- a/app/grants/templates/grants/card/front.html +++ b/app/grants/templates/grants/card/front.html @@ -40,7 +40,7 @@

- CLR MATCH 0 DAI + CLR MATCH {{ grant.clr_prediction_curve.0}} DAI

( out of {{ total_clr_pot }} DAI )

diff --git a/app/grants/templates/grants/clr_estimate.html b/app/grants/templates/grants/clr_estimate.html index 122e1bf9f7b..c6a91b515b7 100644 --- a/app/grants/templates/grants/clr_estimate.html +++ b/app/grants/templates/grants/clr_estimate.html @@ -7,7 +7,7 @@

- {{ prediction_curve.0 }} + {{ grant.clr_prediction_curve.0|floatformat:2 }} DAI of {{ total_clr_pot }} DAI

@@ -15,7 +15,7 @@

Your contribution at this moment would increase the CLR Match amount for this grant by - 0 DAI + 0.00 DAI .

diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index e3903507aab..44646d66fd0 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -366,7 +366,8 @@
{% trans "Gas Settings" %}
}); {% endif %} - const prediction_curve = {{ prediction_curve }}; + let clr_prediction_curve = {{ grant.clr_prediction_curve }}; + clr_prediction_curve = [5, 10, 15, 20, 25, 30]; // TODO: REMOVE diff --git a/app/grants/views.py b/app/grants/views.py index 37610a1dad5..4a6ea78a55a 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -57,7 +57,7 @@ clr_matching_banners_style = 'pledging' matching_live = '($50K matching live now!) ' -total_clr_pot = 10000 +total_clr_pot = 100000 clr_round = 3 clr_active = True @@ -626,7 +626,6 @@ def grant_fund(request, grant_id, grant_slug): 'fund_reward': fund_reward, 'phantom_funds': phantom_funds, 'clr_round': clr_round, - 'prediction_curve': [5, 10, 15, 20, 25, 30], # grant.clr_prediction_curve 'total_clr_pot': total_clr_pot, 'clr_active': True } From 4c0c59812368cc104719edda02bee35d671c6c92 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 19:03:14 +0900 Subject: [PATCH 22/36] fix bugs and edge case --- app/assets/v2/js/grants/fund.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 6866ab179cf..0a79aa9c553 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -505,7 +505,12 @@ const lerp = (x_lower, x_upper, y_lower, y_upper, x) => { const predictCLRMatch = () => { - const amount = Number.parseFloat($('#amount').val()); + let amount = Number.parseFloat($('#amount').val()); + + if (amount > 10000) { + amount = 10000 + } + let predicted_clr = 0; const contributions_axis = [ 0, 1, 10, 100, 1000, 10000 ]; @@ -534,8 +539,8 @@ const predictCLRMatch = () => { } else if (10 < amount && amount < 100) { x_lower = 10; x_upper = 100; - y_lower = prediction_curve[2]; - y_upper = prediction_curve[3]; + y_lower = clr_prediction_curve[2]; + y_upper = clr_prediction_curve[3]; } else if (100 < amount && amount < 1000) { x_lower = 100; x_upper = 1000; @@ -561,4 +566,4 @@ const predictCLRMatch = () => { $('.clr_match_prediction').html(predicted_clr.toFixed(2)); $('.clr_increase').html((predicted_clr - clr_prediction_curve[0]).toFixed(2)); -}; \ No newline at end of file +}; From 0708ab340234ef4d1860ad75db1d21b737932ab4 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 19:04:37 +0900 Subject: [PATCH 23/36] fix crontab name --- scripts/crontab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/crontab b/scripts/crontab index abb3e765116..40fa6042308 100644 --- a/scripts/crontab +++ b/scripts/crontab @@ -41,7 +41,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us 1 1 1 * * cd gitcoin/coin; bash scripts/run_management_command.bash activity_report $(date --date='-1 month' +%Y/%m/%d) $(date +%Y/%m/%d) >> /var/log/gitcoin/activity_report.log 2>&1 ## CLR -0 */4 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash generate_clr_predictions >> /var/log/gitcoin/generate_clr_predictions.log 2>&1 +0 */4 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash estimate_clr >> /var/log/gitcoin/estimate_clr.log 2>&1 ## GITCOIN MARKETING 30 */12 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash sync_mail >> /var/log/gitcoin/sync_mail.log 2>&1 From 3e6c16f3811ef3250004e337effa603c520d4bd6 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 20:12:46 +0900 Subject: [PATCH 24/36] fix migration? --- app/grants/migrations/0030_grant_clr_prediction_curve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/grants/migrations/0030_grant_clr_prediction_curve.py b/app/grants/migrations/0030_grant_clr_prediction_curve.py index bba0e8319b0..415b713e509 100644 --- a/app/grants/migrations/0030_grant_clr_prediction_curve.py +++ b/app/grants/migrations/0030_grant_clr_prediction_curve.py @@ -1,4 +1,4 @@ -# Generated by Django 2.2.4 on 2019-09-17 14:37 +# Generated by Django 2.2.4 on 2019-09-19 11:09 import django.contrib.postgres.fields from django.db import migrations, models From 274a2cf8eda5ae5156229f4029dda876a2000cbf Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 20:14:19 +0900 Subject: [PATCH 25/36] fix eslint --- app/assets/v2/js/grants/fund.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 0a79aa9c553..708b197a318 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -508,7 +508,7 @@ const predictCLRMatch = () => { let amount = Number.parseFloat($('#amount').val()); if (amount > 10000) { - amount = 10000 + amount = 10000; } let predicted_clr = 0; From 2ef653095fc50c733d43e8dc82a74a4c98ced24d Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 20:15:55 +0900 Subject: [PATCH 26/36] cleanup unused imports --- app/grants/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/grants/models.py b/app/grants/models.py index 0998d50990b..39943826787 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -18,7 +18,6 @@ """ import logging -import math from datetime import timedelta from decimal import Decimal From 053c7ae4c03afb1be4f7e91a9badf630d6fb7a98 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 21:42:36 +0900 Subject: [PATCH 27/36] remove bad migration --- app/grants/migrations/0022_auto_20190604_1547.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/app/grants/migrations/0022_auto_20190604_1547.py b/app/grants/migrations/0022_auto_20190604_1547.py index efc7cec36eb..552b227694c 100644 --- a/app/grants/migrations/0022_auto_20190604_1547.py +++ b/app/grants/migrations/0022_auto_20190604_1547.py @@ -7,14 +7,7 @@ logger = logging.getLogger(__name__) def forwards(apps, schema_editor): - from grants.models import CLRMatch - for grant in Grant.objects.all(): - if grant.clr_matching: - CLRMatch.objects.create( - grant=grant, - round_number=1, - amount=grant.clr_matching, - ) + pass def backwards(apps, schema_editor): pass From 90cd3ee5925d7b9213ddc1dc7611fdfc5231f259 Mon Sep 17 00:00:00 2001 From: Dan Lipert Date: Thu, 19 Sep 2019 21:50:13 +0900 Subject: [PATCH 28/36] remove another bad migration --- app/grants/migrations/0023_auto_20190604_1552.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/grants/migrations/0023_auto_20190604_1552.py b/app/grants/migrations/0023_auto_20190604_1552.py index fc262ef140e..f5e00720f6d 100644 --- a/app/grants/migrations/0023_auto_20190604_1552.py +++ b/app/grants/migrations/0023_auto_20190604_1552.py @@ -8,6 +8,7 @@ def forwards(apps, schema_editor): ## ROUND 2 CLR Match Amounts + ''' from grants.models import CLRMatch # array of [grant_id, amount] try: @@ -27,6 +28,8 @@ def forwards(apps, schema_editor): ) except Exception as e: logger.info(e) + ''' + pass def backwards(apps, schema_editor): pass From 81b8f2449480d565467550666096069b574d1192 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Thu, 19 Sep 2019 19:04:56 +0530 Subject: [PATCH 29/36] final fixes --- app/app/settings.py | 2 +- app/assets/v2/css/grants/fund.css | 12 ++++++++++ app/assets/v2/js/grants/fund.js | 13 +++-------- app/grants/models.py | 4 ---- app/grants/templates/grants/fund.html | 33 +++++++++++---------------- 5 files changed, 29 insertions(+), 35 deletions(-) diff --git a/app/app/settings.py b/app/app/settings.py index f5eb52aa893..503e2beb8a2 100644 --- a/app/app/settings.py +++ b/app/app/settings.py @@ -120,7 +120,7 @@ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'app.middleware.drop_accept_langauge', - 'app.middleware.bleach_requests', + # 'app.middleware.bleach_requests', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/app/assets/v2/css/grants/fund.css b/app/assets/v2/css/grants/fund.css index b41ef0da35a..d14cb9e08dc 100644 --- a/app/assets/v2/css/grants/fund.css +++ b/app/assets/v2/css/grants/fund.css @@ -24,6 +24,12 @@ object-fit: cover; } +#grants_form .nav-link { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + color: #000; +} + #grants_form .form__input.valid, #grants_form .form__input.error { background-position: top 0.5rem right 0.5rem; @@ -236,6 +242,12 @@ color: #959595; } +#phantom_fund .description i { + font-size: 10px; + position: relative; + top: -1px; +} + @media (min-width:1140px) and (max-width: 1600px) { #gitcoin-grant-section .fee-slider, diff --git a/app/assets/v2/js/grants/fund.js b/app/assets/v2/js/grants/fund.js index 708b197a318..4ed8f74e6a7 100644 --- a/app/assets/v2/js/grants/fund.js +++ b/app/assets/v2/js/grants/fund.js @@ -11,6 +11,8 @@ let gitcoinDonationAddress; $(document).ready(function() { + predictCLRMatch(); + $('#amount').on('input', () => { predictCLRMatch(); }); @@ -499,7 +501,6 @@ const splitGrantAmount = () => { }; const lerp = (x_lower, x_upper, y_lower, y_upper, x) => { - console.log(x_lower, x_upper, y_lower, y_upper, x); return y_lower + (((y_upper - y_lower) * (x - x_lower)) / (x_upper - x_lower)); }; @@ -546,19 +547,11 @@ const predictCLRMatch = () => { x_upper = 1000; y_lower = clr_prediction_curve[3]; y_upper = clr_prediction_curve[4]; - } else if (1000 < amount && amount <= 10000) { + } else { x_lower = 1000; x_upper = 10000; y_lower = clr_prediction_curve[4]; y_upper = clr_prediction_curve[5]; - } else { - // NOT SURE WHAT TO DO HERE - // NEED TO ESTIMATE ONE WITH MAX CONTRIBUTION - // CAN WE ASSUME MAX AMOUNT IS 10000 ? - x_lower = 10000; - x_upper = 0; // WHAT ? - y_lower = clr_prediction_curve[5]; - y_upper = 0; // WHAT ? } predicted_clr = lerp(x_lower, x_upper, y_lower, y_upper, amount); diff --git a/app/grants/models.py b/app/grants/models.py index 39943826787..5d31b6447d0 100644 --- a/app/grants/models.py +++ b/app/grants/models.py @@ -945,10 +945,6 @@ def competing_phantum_funds(self): def value(self): return 5/(self.competing_phantum_funds().count()) - @property - def estimated_matching_value(self): - return 'TODO' - def to_mock_contribution(self): context = self.to_standard_dict() context['subscription'] = { diff --git a/app/grants/templates/grants/fund.html b/app/grants/templates/grants/fund.html index 44646d66fd0..b251864c4eb 100644 --- a/app/grants/templates/grants/fund.html +++ b/app/grants/templates/grants/fund.html @@ -69,42 +69,35 @@

{% trans "Fund Grant" %}