diff --git a/package-lock.json b/package-lock.json index ef43b91..e713c46 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.57", + "version": "0.20.59", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.20.57", + "version": "0.20.59", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index fa171c9..1998e7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.58", + "version": "0.20.59", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/ReferralSystem/index.ts b/src/services/ReferralSystem/index.ts index ea51262..92bf000 100644 --- a/src/services/ReferralSystem/index.ts +++ b/src/services/ReferralSystem/index.ts @@ -13,6 +13,7 @@ import { aggregatedHistorySchema, inviteCodeLinkSchema, contractsAddressesSchema, + allTimeLeadersSchema, } from './schemas/index.js'; import type { SupportedChainId } from '../../types.js'; @@ -71,6 +72,7 @@ class ReferralSystem { this.claimRewards = this.claimRewards.bind(this); this.getLeaderboard = this.getLeaderboard.bind(this); this.getLeaderboardSingleChain = this.getLeaderboardSingleChain.bind(this); + this.getAllTimeLeaders = this.getAllTimeLeaders.bind(this); this.getContractsAddresses = this.getContractsAddresses.bind(this); this.getClaimInfo = this.getClaimInfo.bind(this); this.getAggregatedHistory = this.getAggregatedHistory.bind(this); @@ -231,6 +233,19 @@ class ReferralSystem { errorSchema ); + getAllTimeLeaders = (refererAddress: string | undefined) => + fetchWithValidation( + `${this.apiUrl}/referer/ve/leaderboard-lifetime`, + ratingSchema, + { + headers: + refererAddress !== undefined + ? { 'referer-address': refererAddress } + : {}, + }, + allTimeLeadersSchema + ); + getContractsAddresses = () => fetchWithValidation( `${this.apiUrl}/referer/view/contracts`, diff --git a/src/services/ReferralSystem/schemas/allTimeLeadersSchema.ts b/src/services/ReferralSystem/schemas/allTimeLeadersSchema.ts new file mode 100644 index 0000000..885e1c8 --- /dev/null +++ b/src/services/ReferralSystem/schemas/allTimeLeadersSchema.ts @@ -0,0 +1,11 @@ +import { z } from 'zod'; + +const allTimeLeadersSchema = z.array(z.object({ + wallet: z.string(), + total_earnings_fmt: z.number(), + referrals_count_fmt: z.number(), + total_trades_fmt: z.number(), + weekly_earnings_fmt: z.number(), +})); + +export default allTimeLeadersSchema; diff --git a/src/services/ReferralSystem/schemas/index.ts b/src/services/ReferralSystem/schemas/index.ts index f1a1391..972d940 100644 --- a/src/services/ReferralSystem/schemas/index.ts +++ b/src/services/ReferralSystem/schemas/index.ts @@ -10,3 +10,4 @@ export { default as claimInfoSchema } from './claimInfoSchema.js'; export { default as aggregatedHistorySchema } from './aggregatedHistorySchema.js'; export { default as contractsAddressesSchema } from './contractsAddressesSchema.js'; export { default as inviteCodeLinkSchema } from './inviteCodeLinkSchema.js'; +export { default as allTimeLeadersSchema } from './allTimeLeadersSchema.js';