bancorprotocol / carbon-app

https://app.carbondefi.xyz
MIT License
21 stars 13 forks source link

Add share option to the strategy cards #716

Open Costa769 opened 11 months ago

Costa769 commented 11 months ago

Twitter icon ->will allow users to share their strategy stats on twitter. Clicking on the icon will create a new tweet with pre-populated text. On a later stages we will consider adding dynamic images to the tweets

My #buylow #sellhigh trading strategy between ${base} / ${quote} tokens, reached {ROI} ROI! buy low, sell high, repeat.

Create your own strategy at carbondefi.xyz

Expected result:
<img width="584" alt="image" src="https://github.com/bancorprotocol/carbon-app/assets/40430285/53dd9a3a-3764-4677-b976-62296b070b0c">

ELSE, IF shared from Explorer page (indicating this can be a strategy I do not own)

Smart trading is done on #carbondefi.

This #buylow #sellhigh trading strategy between ${base} / ${quote} tokens, reached {ROI} ROI! buy low, sell high, repeat.

Create your own strategy at carbondefi.xyz

Expected result:
<img width="587" alt="image" src="https://github.com/bancorprotocol/carbon-app/assets/40430285/fbe5eeaf-9047-42a2-831e-023eb801504f">

### Resources
https://github.com/tsayen/dom-to-image
https://joyofcode.xyz/dynamic-social-share-images

---
## Option B for the share image design
#### Text

My $(Base} / ${Quote} position is {ROI}% on @carbondefixyz Copy my automated strategy or create your own recurring limit orders at carbondefi.xyz 👈


#### Mockup image
- NOTE: the token logos should also be added dynamically based on the {Base}/{Quote} tokens in the pair
https://www.figma.com/file/YpsatcY9jtxJr0SJwlFYNj/Carbon-Screen-Design?type=design&node-id=8994-2676&mode=design&t=3kCUr1nm0IYxWawu-4

#### Example
<img width="583" alt="image" src="https://github.com/bancorprotocol/carbon-app/assets/40430285/73e472b0-cff8-47fe-8d68-63d47725bac8">
GrandSchtroumpf commented 9 months ago

Two solutions :

  1. Create img on the server based on request from twitter page
  2. Create img on the client and store it on a server


1. Create img on the fly

Provide a link to a server on the twitter preview. This link points to a server that generate the image based on some params.

Pro: No need to store the image Cons: We need to recreate the card on the server, svg graph included, which create 2 source of truth. Or we run a full react app on the server and reuse the component, which will require a lot of config.

2. Create on the client

Create a snapshot of the card, potentially we can create an off-screen card specific to this, upload it to a storage and set the link in the twitter preview.

Pro: Reuse exisiting code Cons: Need a storage

We can use a public IPFS gateway to store the file to avoid managing our own storage. By default IPFS's garbage collector will remove this img after a period of time if not used.