mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-22 05:37:56 +00:00
Organize shared code across web, mobile, and SDK UI projects
Centralized common code into shared/ folder to eliminate duplication and improve maintainability across all three frontend projects (web, mobile, pezkuwi-sdk-ui). Changes: - Added token types and constants to shared/types/tokens.ts - TokenInfo, PoolInfo, SwapQuote, and other DEX types - KNOWN_TOKENS with HEZ, PEZ, wUSDT definitions - Token logos (🟡🟣💵) - Added Kurdistan color palette to shared/constants/ - Kesk, Sor, Zer, Spî, Reş color definitions - Added TOKEN_DISPLAY_SYMBOLS mapping (USDT vs wUSDT) - Updated blockchain configuration in shared/blockchain/polkadot.ts - Added beta testnet endpoint (wss://beta-rpc.pezkuwi.art) - Defined DEFAULT_ENDPOINT constant - Moved i18n to shared/i18n/ - Centralized translation files for 6 languages (EN, TR, KMR, CKB, AR, FA) - Added LANGUAGES configuration with RTL support - Created isRTL() helper function - Updated web and mobile to import from shared - web/src/types/dex.ts now re-exports from shared - web/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT - mobile/src/i18n/index.ts uses shared translations - mobile/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT - Updated shared/README.md with comprehensive documentation This architecture reduces code duplication and ensures consistency across all frontend projects.
This commit is contained in:
@@ -8,4 +8,7 @@
|
||||
// Export blockchain-related types here
|
||||
export * from './blockchain';
|
||||
|
||||
// Export token-related types
|
||||
export * from './tokens';
|
||||
|
||||
// Add more type exports as needed
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Token-related type definitions
|
||||
*/
|
||||
|
||||
export interface TokenInfo {
|
||||
id: number;
|
||||
symbol: string;
|
||||
name: string;
|
||||
decimals: number;
|
||||
logo?: string;
|
||||
}
|
||||
|
||||
export interface PoolInfo {
|
||||
id: string; // asset1-asset2 pair
|
||||
asset1: number;
|
||||
asset2: number;
|
||||
asset1Symbol: string;
|
||||
asset2Symbol: string;
|
||||
asset1Decimals: number;
|
||||
asset2Decimals: number;
|
||||
reserve1: string; // Raw balance string
|
||||
reserve2: string;
|
||||
lpTokenSupply: string;
|
||||
volume24h?: string;
|
||||
tvl?: string;
|
||||
apr7d?: string;
|
||||
feeRate?: string;
|
||||
}
|
||||
|
||||
export interface UserLiquidityPosition {
|
||||
poolId: string;
|
||||
asset1: number;
|
||||
asset2: number;
|
||||
lpTokenBalance: string;
|
||||
shareOfPool: string; // Percentage as string (e.g., "2.5")
|
||||
asset1Amount: string;
|
||||
asset2Amount: string;
|
||||
valueUSD?: string;
|
||||
feesEarned?: string;
|
||||
}
|
||||
|
||||
export interface SwapQuote {
|
||||
amountIn: string;
|
||||
amountOut: string;
|
||||
path: number[]; // Asset IDs in route
|
||||
priceImpact: string; // Percentage as string
|
||||
minimumReceived: string; // After slippage
|
||||
route: string; // Human readable (e.g., "wHEZ → PEZ → wUSDT")
|
||||
}
|
||||
|
||||
export interface AddLiquidityParams {
|
||||
asset1: number;
|
||||
asset2: number;
|
||||
amount1: string;
|
||||
amount2: string;
|
||||
amount1Min: string;
|
||||
amount2Min: string;
|
||||
recipient: string;
|
||||
}
|
||||
|
||||
export interface RemoveLiquidityParams {
|
||||
asset1: number;
|
||||
asset2: number;
|
||||
lpTokenAmount: string;
|
||||
amount1Min: string;
|
||||
amount2Min: string;
|
||||
recipient: string;
|
||||
}
|
||||
|
||||
export interface SwapParams {
|
||||
path: number[];
|
||||
amountIn: string;
|
||||
amountOutMin: string;
|
||||
recipient: string;
|
||||
deadline?: number;
|
||||
}
|
||||
|
||||
export interface PoolCreationParams {
|
||||
asset1: number;
|
||||
asset2: number;
|
||||
feeRate?: number;
|
||||
}
|
||||
|
||||
// Transaction status
|
||||
export enum TransactionStatus {
|
||||
IDLE = 'idle',
|
||||
PENDING = 'pending',
|
||||
SUCCESS = 'success',
|
||||
ERROR = 'error',
|
||||
}
|
||||
Reference in New Issue
Block a user