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

Add config for nitron native apr #317

Merged
merged 6 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/markets/pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`quick_select_tokens` |`QuickSelectToken[]` |true |List of quick select tokens for deposit and withdrawal forms. |
|`disabled_transfer_banner_config` |`DisabledTransferBannerConfig` |false |Config parameters for displaying banner to inform users that transfers for the relevant tokens are disabled |
|`trading_leagues` |`TradingLeague[]` |false |Map of trading league config with their path. |
|`lst_native_aprs` |`LSTNativeAPR[]` |false |List of LST native APR APIs. |

## Maintenance Data Structure
|Field |Type |Required |Description |Notes |
Expand Down Expand Up @@ -147,3 +148,10 @@ Each json file under the [configs](../../configs) folder correspond to their res
|`trading_league` |`string` |true |The trading league name |
|`trading_league_title` |`string` |true |The trading league title |

## LSTNativeAPR Data Structure
|Field |Type |Required |Description |Notes |
|---|---|---|---|---|
|`protocol` |`string` |true |The protocol name |
|`api_url` |`string` |true |The API to fetch LST Native APR |
|`lst_denoms` |`object` |true |The key value object for mapping denom of protocol api and carbon lst denom |

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Currently, each JSON file contain the following data on its corresponding networ
- map of IBC channels for external IBC chains (such as Osmosis, Noble, etc.)
- information about IBC tokens that are not added on chain or require packet forwarding
- default quick select tokens in deposit/withdrawal forms
- LSTs native apr config to show on Nitron markets

Additionally, the JSON file for mainnet contains the following data to support ongoing campaigns/promotions:
- demex points config
Expand Down
26 changes: 26 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,32 @@
"items": {
"$ref": "#/$defs/trading_league"
}
},
"lst_native_apr": {
"type": "object",
"description": "API for query LST native APR show on Nitron",
"required": ["protocol", "api_url", "lst_denoms"],
"properties": {
"protocol": {
"type": "string",
"description": "Protocol name"
},
"api_url": {
"type": "string",
"description": "API URL"
},
"lst_denoms": {
"type": "string",
"description": "Reward denom map"
}
}
},
"lst_native_aprs": {
"type": "array",
"description": "List of APIs for fetch LST Native APR show on Nitron",
"items": {
"$ref": "#/$defs/lst_native_apr"
}
}
}
}
41 changes: 40 additions & 1 deletion configs/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,5 +504,44 @@
"trading_league": "Base",
"trading_league_title": "Base Trading League"
}
}
},
"lst_native_aprs": [
{
"protocol": "Drop",
"api_url": "https://app.drop.money/api/apy",
"lst_denoms": {
"dATOM": "ibc/EF37C83E78BD1F9B2401B3B3E5C00E0DBA71A648E2A8C3018861786F7A5F0105"
}
},
{
"protocol": "Stride",
"api_url": "https://edge.stride.zone/api/stake-stats",
"lst_denoms": {
"ATOM": "ibc/B7864B03E1B9FD4F049243E92ABD691586F682137037A9F3FCA5222815620B3C",
"OSMO": "ibc/75249A18DEFBEFE55F83B1C70CAD234DF164F174C6BC51682EE92C2C81C18C93",
"STARS": "ibc/8D749C5FB0213DF002E8FDCCB5B01E35DA241397EF825048C530C7EAE43BCE80",
"LUNA": "ibc/FBEE20115530F474F8BBE1460DA85437C3FBBFAF4A5DEBD71CA6B9C40559A161",
"EVMOS": "ibc/0BA1FA7A554B4347A87BD37AFF331683298730F9F8FCECB4896D58BED4B31F00",
"INJ": "ibc/2B9D089E73AC096934CD6BBBC71A1CD5DD2A4F8E94CC37CE7F861AC674044002",
"DYDX": "ibc/BAA1D21893B1D36865C6CA44D18F4ACF08BAD70CB6863C4722E0A61703808F77",
"TIA": "ibc/6569E05DEE32B339D9286A52BE33DFCEFC97267F23EF9CFDE0C055140967A9A5",
"DYM": "ibc/63BCB7805C5875C43F9CA101B2766E0AF1BA49DF928E9BC2A000D211614D3338",
"SAGA": "ibc/4EAAAE537853E9C0DDF458F0710C37BB3DE7C6A675AB75DB5731ACE93D6CC57B"
}
},
{
"protocol": "Lido",
"api_url": "https://eth-api.lido.fi/v1/protocol/steth/apr/sma",
"lst_denoms": {
"wstETH": "brdg/6901fa9eb45ef8351c0ab9e29fa45da3bb0538bfbc5a84ad1009e3544346d2c8"
}
},
{
"protocol": "MilkyWay",
"api_url": "https://apis.milkyway.zone/v2/protocols/osmosis.milkTIA",
"lst_denoms": {
"milkTIA": "ibc/16065EE5282C5217685C8F084FC44864C25C706AC37356B0D62811D50B96920F"
}
andrewsoon marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
36 changes: 36 additions & 0 deletions scripts/check_configs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CarbonSDK } from "carbon-js-sdk";
import { PageRequest } from "carbon-js-sdk/lib/codec/cosmos/base/query/v1beta1/pagination";
import { BridgeMap } from "carbon-js-sdk/lib/util/blockchain";
import { SimpleMap } from "carbon-js-sdk/lib/util/type";
import * as fs from "fs";
import Long from "long";

Expand Down Expand Up @@ -36,6 +37,7 @@ interface ConfigJSON {
disabled_transfer_banner_config?: DisabledTransferBannerConfig;
announcement_banner: AnnouncementBanner;
quick_select_deposit_options?: QuickSelectToken[];
lst_native_aprs?: LstNativeAPR[];
}

interface InvalidEntry {
Expand Down Expand Up @@ -154,6 +156,12 @@ interface QuickSelectToken {
target_denom: string;
}

interface LstNativeAPR {
protocol: string;
api_url: string;
lst_denoms: SimpleMap<string>;
}

type OutcomeMap = { [key in CarbonSDK.Network]: boolean }; // true = success, false = failure

const outcomeMap: OutcomeMap = {
Expand Down Expand Up @@ -499,6 +507,29 @@ function isValidQuickSelectTokens(quickSelectTokens: QuickSelectToken[], network
return true;
}

function isValidLSTNativeDenom(lstNativeAPRs: LstNativeAPR[], network: CarbonSDK.Network, denoms: string[]): boolean {
const lstDenoms = lstNativeAPRs.reduce((acc: string[], lst) => {
return acc.concat(Object.values(lst.lst_denoms))
}, [])

const duplicateLstDenoms = checkDuplicateEntries(lstDenoms);
if (duplicateLstDenoms.status && duplicateLstDenoms.entry) {
let listOfDuplicates: string = duplicateLstDenoms.entry.join(", ");
console.error(`ERROR: ${network}.json has the following duplicated lst native prs denoms: ${listOfDuplicates}. Please make sure to input each token denom only once in ${network}`);
return false;
}

const invalidLstDenoms = checkValidEntries(lstDenoms, denoms);
if (invalidLstDenoms.status && invalidLstDenoms.entry) {
let listOfInvalidDenoms: string = invalidLstDenoms.entry.join(", ");
console.error(`ERROR: ${network}.json has the following invalid lst native prs denoms: ${listOfInvalidDenoms}. Please make sure to only input valid token denoms in ${network}`);
return false;
}


return true;
}

async function main() {
for (const net of myArgs) {
let network: CarbonSDK.Network;
Expand Down Expand Up @@ -889,6 +920,11 @@ async function main() {
if (jsonData.quick_select_deposit_options && !isValidQuickSelectTokens(jsonData.quick_select_deposit_options, network, tokens)) {
outcomeMap[network] = false;
}

// check for LST native denom duplicate, existed
if (jsonData.lst_native_aprs && !isValidLSTNativeDenom(jsonData.lst_native_aprs, network, tokens)) {
outcomeMap[network] = false;
}
}
}
const outcomeArr = Object.values(outcomeMap);
Expand Down
Loading