Skip to content

Commit

Permalink
Merge pull request #166 from Switcheo/feat/cross-selling-widget
Browse files Browse the repository at this point in the history
Feat/Cross Selling Widget
  • Loading branch information
andrewsoon authored Jun 27, 2024
2 parents b3efe9f + d4a605e commit dccf4ba
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`perp_pool_banners` |`PerpPoolBanner` |true |List of Objects that indicate the banner content on specific perp pool pages. |
|`demex_points_config` |`DemexPointsConfig` |false |Object that contains the parameters to earn demex points. |This object **must be included** for mainnet.json as demex points is already live on mainnet. |
|`perp_pool_promo` |`PerpPoolPromo` |false |Map of Objects that contains perp pool promo parameters for each pool |If the `perp_pool_promo` property is omitted, no promo will be shown. The key of each entry is the ids of the perp pools with existing promo. |
|`cross_selling_source_tokens` |`string[]` |true |The array of cross selling source tokens. Acquiring these tokens on the spot market will trigger a help wizard, prompting users to borrow USDG and trade perps on Demex. |The token denoms listed here **MUST** match the token denoms listed under the Carbon [Tokens API](https://api.carbon.network/carbon/coin/v1/tokens?pagination.limit=10000). |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Currently, each JSON file contain the following data on its corresponding networ
- blacklisted tokens
- default blockchain transfer option order in deposit/withdrawal forms dropdown
- default network token fee order
- cross selling source tokens

Additionally, the JSON file for mainnet contains the following data to support ongoing campaigns/promotions:
- demex points config
Expand Down Expand Up @@ -48,6 +49,7 @@ More metadata will be added in the future if required by the Demex frontend. Ple
"token_denom_1": 0,
"token_denom_2": 1,
"token_denom_3": 2
}
},
"cross_selling_source_tokens": ["source_token_1"]
}
```
14 changes: 13 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"blacklisted_tokens",
"transfer_options",
"network_fees",
"perp_pool_banners"
"perp_pool_banners",
"cross_selling_source_tokens"
],
"properties": {
"network": {
Expand Down Expand Up @@ -157,6 +158,13 @@
}
}
}
},
"cross_selling_source_tokens": {
"type": "array",
"description": "List of cross selling source token denoms",
"items": {
"$ref": "#/$defs/cross_selling_source_token"
}
}
},
"$defs": {
Expand Down Expand Up @@ -225,6 +233,10 @@
"perpTradingBoost": {
"type": "integer",
"description": "The spin boost multiplier for boosted perp markets trading volume"
},
"cross_selling_source_token": {
"type": "string",
"description": "Cross selling source token denom"
}
}
}
3 changes: 2 additions & 1 deletion configs/devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
"usdc": 1,
"eth": 2
},
"perp_pool_banners": []
"perp_pool_banners": [],
"cross_selling_source_tokens": []
}
3 changes: 2 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,6 @@
"perpPoolDepositBoost": 2,
"perpTradingBoost": 3
}
}
},
"cross_selling_source_tokens": ["swth"]
}
3 changes: 2 additions & 1 deletion configs/testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
"symbol": "1000PEPE"
}
}
}
},
"cross_selling_source_tokens": ["swth"]
}
33 changes: 24 additions & 9 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ interface ConfigJSON {
demex_points_config: DemexPointsConfig,
perp_pool_promo: {
[perpPoolId: string]: PerpPoolPromo,
}
},
cross_selling_source_tokens: string[];
}

interface InvalidEntry {
Expand Down Expand Up @@ -234,17 +235,31 @@ async function main() {
});
const tokens: string[] = allTokens.tokens.map(token => token.denom);

const hasInvalidTokens = checkValidEntries(jsonData.blacklisted_tokens, tokens);
if (hasInvalidTokens.status && hasInvalidTokens.entry) {
let listOfInvalidTokens: string = hasInvalidTokens.entry.join(', ');
console.error(`ERROR: ${network}.json has the following invalid token denom entries: ${listOfInvalidTokens}. Please make sure to only input valid token denom in ${network}`);
const hasInvalidBlacklistedTokens = checkValidEntries(jsonData.blacklisted_tokens, tokens);
if (hasInvalidBlacklistedTokens.status && hasInvalidBlacklistedTokens.entry) {
let listOfInvalidTokens: string = hasInvalidBlacklistedTokens.entry.join(', ');
console.error(`ERROR: ${network}.json has the following invalid blacklisted token denom entries: ${listOfInvalidTokens}. Please make sure to only input valid token denom in ${network}`);
outcomeMap[network] = false;
}

const hasDuplicateBlacklistedTokens = checkDuplicateEntries(jsonData.blacklisted_tokens);
if (hasDuplicateBlacklistedTokens.status && hasDuplicateBlacklistedTokens.entry) {
let listOfDuplicates: string = hasDuplicateBlacklistedTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated blacklisted token denom entries: ${listOfDuplicates}. Please make sure to input each token denom only once in ${network}`);
outcomeMap[network] = false;
}

const hasInvalidCrossSellingTokens = checkValidEntries(jsonData.cross_selling_source_tokens, tokens);
if (hasInvalidCrossSellingTokens.status && hasInvalidCrossSellingTokens.entry) {
let listOfInvalidTokens: string = hasInvalidCrossSellingTokens.entry.join(', ');
console.error(`ERROR: ${network}.json has the following invalid cross selling source token denom entries: ${listOfInvalidTokens}. Please make sure to only input valid token denom in ${network}`);
outcomeMap[network] = false;
}

const hasDuplicateTokens = checkDuplicateEntries(jsonData.blacklisted_tokens);
if (hasDuplicateTokens.status && hasDuplicateTokens.entry) {
let listOfDuplicates: string = hasDuplicateTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated token denom entries: ${listOfDuplicates}. Please make sure to input each token denom only once in ${network}`);
const hasDuplicateCrossSellingTokens = checkDuplicateEntries(jsonData.cross_selling_source_tokens);
if (hasDuplicateCrossSellingTokens.status && hasDuplicateCrossSellingTokens.entry) {
let listOfDuplicates: string = hasDuplicateCrossSellingTokens.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated cross selling source token denom entries: ${listOfDuplicates}. Please make sure to input each token denom only once in ${network}`);
outcomeMap[network] = false;
}

Expand Down

0 comments on commit dccf4ba

Please sign in to comment.