Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: foxwifhat discount #8663

Merged
merged 18 commits into from
Jan 28, 2025
Merged

feat: foxwifhat discount #8663

merged 18 commits into from
Jan 28, 2025

Conversation

NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Jan 24, 2025

Description

Adding the foxwifhat discount if the section is enabled:

  • Campaign is starting from now to 5th may (to be modified before the flag is turned on)
  • Decrease linearly to the 5 may from 100% to 0%
  • Added automated tests Removed them as the flag is off in prod and is always off in the tests

Issue (if applicable)

closes #8588

Risk

Medium, could result in free trades somehow

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Try every sort of trades amount (< 1000$, > 1000$) using different types of account:
    -- Traditional Fox discount
    -- Fox Wif Hat discount (if you have at least 10k FWH, the discount decrease linearly)
    -- If you are a dev, monkey patch the logic inside calculateFees to test that the highest discount possible

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

very big fox holding (dao's addy)

image

No discount => no foxwifhat and no foxes

image

FOXWifHat holder

image

Free because feeBps are under 1 as float

Foxwifhatholder but 50% of the time expired already

image

23bps instead of 47

Foxwifhatholder but 100% of the time expired already

image 47 bps!

Expired but fox holding is so big that it's free!

image

@NeOMakinG NeOMakinG marked this pull request as ready for review January 24, 2025 14:15
@NeOMakinG NeOMakinG requested a review from a team as a code owner January 24, 2025 14:15
@NeOMakinG NeOMakinG marked this pull request as draft January 25, 2025 14:13
@NeOMakinG NeOMakinG force-pushed the fox-wif-hat-discount branch from bc47046 to f44a4a2 Compare January 27, 2025 08:53
@NeOMakinG NeOMakinG marked this pull request as ready for review January 27, 2025 14:02
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally against develop (right):

  • 11,000 FWH held, moderate-size trade right above the fees curve - FWH discount higher than regular FOX fees curve
image
  • 11,000 FWH held, smaller trade right undeer the fees curve - no fees regardless of FWH holdings
image
  • No wallet, no discount
image
  • FOX fee curve discount higher than FWH discount (shapeshiftdao.eth)
image
  • Just under the fee curve - shapeshiftdao.eth
image
  • FWH holder (11,000 FWH), 50% elapsed, tested with the monkey-patch below to get midpoint: half the bps, 100% the lulz
diff --git a/src/lib/fees/model.ts b/src/lib/fees/model.ts
index 20007fbad3..7a965dbcd4 100644
--- a/src/lib/fees/model.ts
+++ b/src/lib/fees/model.ts
@@ -82,7 +82,11 @@ export const calculateFees: CalculateFeeBps = ({
     if (!isFoxWifHatCampaignActive) return bn(0)
     if (!isFoxWifHatDiscountEligible) return bn(0)
 
-    const currentTime = new Date().getTime()
+    // 50% monkey
+    const campaignStartTime = FOX_WIF_HAT_CAMPAIGN_STARTING_TIME_MS
+    const campaignEndTime = FOX_WIF_HAT_CAMPAIGN_ENDING_TIME_MS
+    const halfwayTime = campaignStartTime + (campaignEndTime - campaignStartTime) / 2
+    const currentTime = new Date(halfwayTime).getTime()
     const totalCampaignDuration =
       FOX_WIF_HAT_CAMPAIGN_ENDING_TIME_MS - FOX_WIF_HAT_CAMPAIGN_STARTING_TIME_MS
     const timeElapsed = currentTime - FOX_WIF_HAT_CAMPAIGN_STARTING_TIME_MS
image
  • Same as above but 100% time expired with the monkey-patch below: 0% the FWH discount, but still 100% here for the lulz
diff --git a/src/lib/fees/model.ts b/src/lib/fees/model.ts
index 20007fbad3..a66c1af4f9 100644
--- a/src/lib/fees/model.ts
+++ b/src/lib/fees/model.ts
@@ -82,7 +82,10 @@ export const calculateFees: CalculateFeeBps = ({
     if (!isFoxWifHatCampaignActive) return bn(0)
     if (!isFoxWifHatDiscountEligible) return bn(0)
 
-    const currentTime = new Date().getTime()
+    // 100% time expired, no dice for you FWH holder
+    const campaignEndTime = FOX_WIF_HAT_CAMPAIGN_ENDING_TIME_MS
+    const expiredTime = campaignEndTime + 1000 // 1 second after campaign ends
+    const currentTime = new Date(expiredTime).getTime()
     const totalCampaignDuration =
       FOX_WIF_HAT_CAMPAIGN_ENDING_TIME_MS - FOX_WIF_HAT_CAMPAIGN_STARTING_TIME_MS
     const timeElapsed = currentTime - FOX_WIF_HAT_CAMPAIGN_STARTING_TIME_MS
image

@NeOMakinG NeOMakinG enabled auto-merge (squash) January 27, 2025 23:32
@NeOMakinG NeOMakinG disabled auto-merge January 27, 2025 23:42
@NeOMakinG NeOMakinG enabled auto-merge (squash) January 27, 2025 23:45
@NeOMakinG NeOMakinG disabled auto-merge January 28, 2025 08:09
@NeOMakinG NeOMakinG enabled auto-merge (squash) January 28, 2025 08:37
@NeOMakinG NeOMakinG force-pushed the fox-wif-hat-discount branch from bda6f6f to 17c06a9 Compare January 28, 2025 11:29
@NeOMakinG NeOMakinG merged commit 0a69e2a into develop Jan 28, 2025
3 checks passed
@NeOMakinG NeOMakinG deleted the fox-wif-hat-discount branch January 28, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FOX Wif hat discount to trades
2 participants