-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: profitability endpoint (#1214)
- Loading branch information
Showing
17 changed files
with
894 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@moralisweb3/common-evm-utils': patch | ||
'@moralisweb3/evm-api': patch | ||
'moralis': patch | ||
--- | ||
|
||
Adding new Profitability endpoints to the SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/common/evmUtils/src/generated/operations/GetTopProfitableWalletPerTokenOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { EvmAddress, EvmAddressInput, EvmAddressJSON, EvmChain, EvmChainInput, EvmChainJSON } from '../../dataTypes'; | ||
import { EvmWalletTopProfitableWalletPerTokenResponse, EvmWalletTopProfitableWalletPerTokenResponseJSON } from '../types/EvmWalletTopProfitableWalletPerTokenResponse'; | ||
|
||
// request parameters: | ||
// - address ($ref: #/paths/~1erc20~1{address}~1top-gainers/get/parameters/0/schema) | ||
// - days ($ref: #/paths/~1erc20~1{address}~1top-gainers/get/parameters/1/schema) | ||
// - chain ($ref: #/components/schemas/discoveryApiChainsList) | ||
|
||
export interface GetTopProfitableWalletPerTokenOperationRequest { | ||
/** | ||
* @description The ERC20 token address. | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
/** | ||
* @description Timeframe in days for which profitability is calculated, can be 'all', '7d' or '30d' | ||
*/ | ||
readonly days?: string; | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
} | ||
|
||
export interface GetTopProfitableWalletPerTokenOperationRequestJSON { | ||
readonly address: EvmAddressJSON; | ||
readonly days?: string; | ||
readonly chain?: EvmChainJSON; | ||
} | ||
|
||
export type GetTopProfitableWalletPerTokenOperationResponse = EvmWalletTopProfitableWalletPerTokenResponse; | ||
export type GetTopProfitableWalletPerTokenOperationResponseJSON = EvmWalletTopProfitableWalletPerTokenResponseJSON; | ||
|
||
export const GetTopProfitableWalletPerTokenOperation = { | ||
operationId: "getTopProfitableWalletPerToken", | ||
groupName: "token", | ||
httpMethod: "get", | ||
routePattern: "/erc20/{address}/top-gainers", | ||
parameterNames: ["address","days","chain"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmWalletTopProfitableWalletPerTokenResponseJSON): EvmWalletTopProfitableWalletPerTokenResponse { | ||
return EvmWalletTopProfitableWalletPerTokenResponse.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetTopProfitableWalletPerTokenOperationRequest): GetTopProfitableWalletPerTokenOperationRequestJSON { | ||
const address = EvmAddress.create(request.address); | ||
const days = request.days; | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
return { | ||
address: address.toJSON(), | ||
days: days, | ||
chain: chain ? chain.toJSON() : undefined, | ||
}; | ||
}, | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
packages/common/evmUtils/src/generated/operations/GetWalletProfitabilityOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { EvmAddress, EvmAddressInput, EvmAddressJSON, EvmChain, EvmChainInput, EvmChainJSON } from '../../dataTypes'; | ||
import { EvmWalletProfitabilityResponse, EvmWalletProfitabilityResponseJSON } from '../types/EvmWalletProfitabilityResponse'; | ||
|
||
// request parameters: | ||
// - address ($ref: #/paths/~1wallets~1{address}~1profitability/get/parameters/0/schema) | ||
// - days ($ref: #/paths/~1wallets~1{address}~1profitability/get/parameters/1/schema) | ||
// - chain ($ref: #/components/schemas/discoveryApiChainsList) | ||
// - token_addresses ($ref: #/paths/~1wallets~1{address}~1profitability/get/parameters/3/schema) | ||
|
||
export interface GetWalletProfitabilityOperationRequest { | ||
/** | ||
* @description The wallet address for which profitability is to be retrieved. | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
/** | ||
* @description Timeframe in days for which profitability is calculated, Options include 'all', '7', '30', '60', '90' default is 'all'. | ||
*/ | ||
readonly days?: string; | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
/** | ||
* @description The token addresses list to filter the result with | ||
*/ | ||
readonly tokenAddresses?: EvmAddressInput[] | EvmAddress[]; | ||
} | ||
|
||
export interface GetWalletProfitabilityOperationRequestJSON { | ||
readonly address: EvmAddressJSON; | ||
readonly days?: string; | ||
readonly chain?: EvmChainJSON; | ||
readonly token_addresses?: EvmAddressJSON[]; | ||
} | ||
|
||
export type GetWalletProfitabilityOperationResponse = EvmWalletProfitabilityResponse; | ||
export type GetWalletProfitabilityOperationResponseJSON = EvmWalletProfitabilityResponseJSON; | ||
|
||
export const GetWalletProfitabilityOperation = { | ||
operationId: "getWalletProfitability", | ||
groupName: "wallets", | ||
httpMethod: "get", | ||
routePattern: "/wallets/{address}/profitability", | ||
parameterNames: ["address","days","chain","token_addresses"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmWalletProfitabilityResponseJSON): EvmWalletProfitabilityResponse { | ||
return EvmWalletProfitabilityResponse.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetWalletProfitabilityOperationRequest): GetWalletProfitabilityOperationRequestJSON { | ||
const address = EvmAddress.create(request.address); | ||
const days = request.days; | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
const tokenAddresses = request.tokenAddresses ? request.tokenAddresses.map((item) => EvmAddress.create(item)) : undefined; | ||
return { | ||
address: address.toJSON(), | ||
days: days, | ||
chain: chain ? chain.toJSON() : undefined, | ||
token_addresses: tokenAddresses ? tokenAddresses.map((item) => item.toJSON()) : undefined, | ||
}; | ||
}, | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
packages/common/evmUtils/src/generated/operations/GetWalletProfitabilitySummaryOperation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { EvmAddress, EvmAddressInput, EvmAddressJSON, EvmChain, EvmChainInput, EvmChainJSON } from '../../dataTypes'; | ||
import { EvmGetWalletProfitabilitySummary, EvmGetWalletProfitabilitySummaryJSON } from '../types/EvmGetWalletProfitabilitySummary'; | ||
|
||
// request parameters: | ||
// - address ($ref: #/paths/~1wallets~1{address}~1profitability~1summary/get/parameters/0/schema) | ||
// - days ($ref: #/paths/~1wallets~1{address}~1profitability~1summary/get/parameters/1/schema) | ||
// - chain ($ref: #/components/schemas/discoveryApiChainsList) | ||
|
||
export interface GetWalletProfitabilitySummaryOperationRequest { | ||
/** | ||
* @description The wallet address for which profitability summary is to be retrieved. | ||
*/ | ||
readonly address: EvmAddressInput | EvmAddress; | ||
/** | ||
* @description Timeframe in days for the profitability summary. Options include 'all', '7', '30', '60', '90' default is 'all'. | ||
*/ | ||
readonly days?: string; | ||
/** | ||
* @description The chain to query | ||
*/ | ||
readonly chain?: EvmChainInput | EvmChain; | ||
} | ||
|
||
export interface GetWalletProfitabilitySummaryOperationRequestJSON { | ||
readonly address: EvmAddressJSON; | ||
readonly days?: string; | ||
readonly chain?: EvmChainJSON; | ||
} | ||
|
||
export type GetWalletProfitabilitySummaryOperationResponse = EvmGetWalletProfitabilitySummary; | ||
export type GetWalletProfitabilitySummaryOperationResponseJSON = EvmGetWalletProfitabilitySummaryJSON; | ||
|
||
export const GetWalletProfitabilitySummaryOperation = { | ||
operationId: "getWalletProfitabilitySummary", | ||
groupName: "wallets", | ||
httpMethod: "get", | ||
routePattern: "/wallets/{address}/profitability/summary", | ||
parameterNames: ["address","days","chain"], | ||
hasResponse: true, | ||
hasBody: false, | ||
|
||
parseResponse(json: EvmGetWalletProfitabilitySummaryJSON): EvmGetWalletProfitabilitySummary { | ||
return EvmGetWalletProfitabilitySummary.fromJSON(json); | ||
}, | ||
|
||
serializeRequest(request: GetWalletProfitabilitySummaryOperationRequest): GetWalletProfitabilitySummaryOperationRequestJSON { | ||
const address = EvmAddress.create(request.address); | ||
const days = request.days; | ||
const chain = request.chain ? EvmChain.create(request.chain) : undefined; | ||
return { | ||
address: address.toJSON(), | ||
days: days, | ||
chain: chain ? chain.toJSON() : undefined, | ||
}; | ||
}, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/common/evmUtils/src/generated/types/EvmDiscoveryApiChainsList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// $ref: #/components/schemas/discoveryApiChainsList | ||
// typeName: discoveryApiChainsList | ||
|
||
export type EvmDiscoveryApiChainsListJSON = "eth" | "mainnet" | "0x1" | "matic" | "0x89" | "polygon" | "bsc" | "binance" | "0x38" | "fantom" | "ftm" | "0xfa" | "arbitrum" | "0xa4b1" | "optimism" | "0xa" | "pulsechain" | "0x171" | "base" | "0x2105"; | ||
export type EvmDiscoveryApiChainsListInput = "eth" | "mainnet" | "0x1" | "matic" | "0x89" | "polygon" | "bsc" | "binance" | "0x38" | "fantom" | "ftm" | "0xfa" | "arbitrum" | "0xa4b1" | "optimism" | "0xa" | "pulsechain" | "0x171" | "base" | "0x2105"; | ||
export type EvmDiscoveryApiChainsListValue = "eth" | "mainnet" | "0x1" | "matic" | "0x89" | "polygon" | "bsc" | "binance" | "0x38" | "fantom" | "ftm" | "0xfa" | "arbitrum" | "0xa4b1" | "optimism" | "0xa" | "pulsechain" | "0x171" | "base" | "0x2105"; | ||
|
||
export abstract class EvmDiscoveryApiChainsList { | ||
public static create(input: EvmDiscoveryApiChainsListInput | EvmDiscoveryApiChainsListValue): EvmDiscoveryApiChainsListValue { | ||
return input; | ||
} | ||
|
||
public static fromJSON(json: EvmDiscoveryApiChainsListJSON): EvmDiscoveryApiChainsListValue { | ||
return json; | ||
} | ||
} |
Oops, something went wrong.
9ddc8c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test coverage