@reyaxyz/common 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ exports.getSocketDepositFeesAsBigInt = getSocketDepositFeesAsBigInt;
16
16
  var getSocketDepositFees = function (params) {
17
17
  return {
18
18
  fees: (0, token_1.descale)(18)(socketDepositFees[params.moneyInOutChainId]),
19
- feesUnit: (0, getNativeToken_1.getNativeToken)(params.moneyInOutChainId),
19
+ feesUnderlyingToken: (0, getNativeToken_1.getNativeToken)(params.moneyInOutChainId),
20
20
  };
21
21
  };
22
22
  exports.getSocketDepositFees = getSocketDepositFees;
@@ -1 +1 @@
1
- {"version":3,"file":"getSocketDepositFees.js","sourceRoot":"/","sources":["services/getSocketDepositFees.ts"],"names":[],"mappings":";;;;AAAA,kCAIkB;AAClB,wCAAyC;AACzC,mDAAkD;AAElD,OAAO;AACP,IAAM,iBAAiB;IACrB,GAAC,yBAAiB,CAAC,eAAe,IAAG,MAAM,CAAC,CAAC,CAAC;OAC/C,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,MAAkC;IAElC,OAAO,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC,CAAC;AAJW,QAAA,4BAA4B,gCAIvC;AAEK,IAAM,oBAAoB,GAAG,UAClC,MAAkC;IAElC,OAAO;QACL,IAAI,EAAE,IAAA,eAAO,EAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC9D,QAAQ,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,iBAAiB,CAAC;KACnD,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B","sourcesContent":["import {\n GetSocketDepositFeesParams,\n GetSocketDepositFeesResult,\n MoneyInOutChainId,\n} from '../types';\nimport { descale } from '../utils/token';\nimport { getNativeToken } from './getNativeToken';\n\n// todo\nconst socketDepositFees: Record<MoneyInOutChainId, bigint> = {\n [MoneyInOutChainId.ethereumSepolia]: BigInt(0),\n};\n\nexport const getSocketDepositFeesAsBigInt = (\n params: GetSocketDepositFeesParams,\n): bigint => {\n return socketDepositFees[params.moneyInOutChainId];\n};\n\nexport const getSocketDepositFees = (\n params: GetSocketDepositFeesParams,\n): GetSocketDepositFeesResult => {\n return {\n fees: descale(18)(socketDepositFees[params.moneyInOutChainId]),\n feesUnit: getNativeToken(params.moneyInOutChainId),\n };\n};\n"]}
1
+ {"version":3,"file":"getSocketDepositFees.js","sourceRoot":"/","sources":["services/getSocketDepositFees.ts"],"names":[],"mappings":";;;;AAAA,kCAIkB;AAClB,wCAAyC;AACzC,mDAAkD;AAElD,OAAO;AACP,IAAM,iBAAiB;IACrB,GAAC,yBAAiB,CAAC,eAAe,IAAG,MAAM,CAAC,CAAC,CAAC;OAC/C,CAAC;AAEK,IAAM,4BAA4B,GAAG,UAC1C,MAAkC;IAElC,OAAO,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACrD,CAAC,CAAC;AAJW,QAAA,4BAA4B,gCAIvC;AAEK,IAAM,oBAAoB,GAAG,UAClC,MAAkC;IAElC,OAAO;QACL,IAAI,EAAE,IAAA,eAAO,EAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC9D,mBAAmB,EAAE,IAAA,+BAAc,EAAC,MAAM,CAAC,iBAAiB,CAAC;KAC9D,CAAC;AACJ,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B","sourcesContent":["import {\n GetSocketDepositFeesParams,\n GetSocketDepositFeesResult,\n MoneyInOutChainId,\n} from '../types';\nimport { descale } from '../utils/token';\nimport { getNativeToken } from './getNativeToken';\n\n// todo\nconst socketDepositFees: Record<MoneyInOutChainId, bigint> = {\n [MoneyInOutChainId.ethereumSepolia]: BigInt(0),\n};\n\nexport const getSocketDepositFeesAsBigInt = (\n params: GetSocketDepositFeesParams,\n): bigint => {\n return socketDepositFees[params.moneyInOutChainId];\n};\n\nexport const getSocketDepositFees = (\n params: GetSocketDepositFeesParams,\n): GetSocketDepositFeesResult => {\n return {\n fees: descale(18)(socketDepositFees[params.moneyInOutChainId]),\n feesUnderlyingToken: getNativeToken(params.moneyInOutChainId),\n };\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { Signer } from 'ethers';
1
2
  export type Address = Lowercase<string>;
2
3
  export type MarketOrderInfo = {
3
4
  counterpartyAccountIds: number[];
@@ -214,7 +215,7 @@ export type GetSocketDepositFeesParams = {
214
215
  };
215
216
  export type GetSocketDepositFeesResult = {
216
217
  fees: number;
217
- feesUnit: string;
218
+ feesUnderlyingToken: string;
218
219
  };
219
220
  export type GetSocketWithdrawFeesParams = {
220
221
  reyaChainId: ReyaChainId;
@@ -294,4 +295,10 @@ export type GetFundingRateChartDataResult = {
294
295
  }[];
295
296
  fundingRate: number;
296
297
  };
298
+ export type GetERC20AllowanceParams = {
299
+ walletAddress: string;
300
+ tokenAddress: LpPoolEntity['tokenAddress'];
301
+ spenderAddress: string;
302
+ subject: Signer;
303
+ };
297
304
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;AAGxC,MAAM,MAAM,eAAe,GAAG;IAC5B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,SA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MAAM,CAAC;KACf,EAAE,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,0CAA0C,GAAG;IACvD,WAAW,EAAE;QACX,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAEF,oBAAY,mCAAmC;IAC7C,UAAU,QAAY;IACtB,QAAQ,UAAiB;IACzB,OAAO,WAAsB;IAC7B,QAAQ,YAA0B;IAClC,SAAS,aAA2B;IACpC,QAAQ,cAA4B;CACrC;AAGD,oBAAY,6BAA6B;IACvC,UAAU,QAAY;IACtB,QAAQ,UAAiB;IACzB,OAAO,WAAsB;IAC7B,QAAQ,YAA0B;IAClC,SAAS,aAA2B;IACpC,QAAQ,cAA4B;CACrC;AACD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,eAAe,EAAE;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
@@ -1,2 +1,9 @@
1
1
  export declare const MAX_UINT128: number;
2
+ import { Address } from '../types';
3
+ export declare const tokenDetails: {
4
+ [address: Address]: {
5
+ tokenName: Uppercase<string>;
6
+ tokenDecimals: number;
7
+ };
8
+ };
2
9
  //# sourceMappingURL=consts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"/","sources":["utils/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAe,CAAC"}
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"/","sources":["utils/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,QAAe,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGnC,eAAO,MAAM,YAAY,EAAE;IACzB,CAAC,OAAO,EAAE,OAAO,GAAG;QAClB,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QAC7B,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;CAiDH,CAAC"}
@@ -1,5 +1,6 @@
1
+ export * from './consts';
1
2
  export * from './number';
3
+ export * from './retry';
2
4
  export * from './timestamp';
3
5
  export * from './token';
4
- export * from './consts';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const exponentialBackoff: <T = never>(query: () => Promise<T>, attempts?: number, factor?: number) => Promise<T>;
2
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"/","sources":["utils/retry.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,kBAAkB,wFAuB9B,CAAC"}
@@ -1,3 +1,19 @@
1
+ import { Contract, Signer } from 'ethers';
2
+ import { Address, GetERC20AllowanceParams } from '../types';
1
3
  export declare const descale: (tokenDecimals: number) => (value: bigint) => number;
2
4
  export declare const scale: (tokenDecimals: number) => (value: number) => bigint;
5
+ export declare const getERC20TokenContract: (tokenAddress: string, subject: Signer) => Contract;
6
+ export declare const convertToAddress: (str: string) => Address;
7
+ export declare const getTokenDetails: (caseSensitiveAddress: string) => {
8
+ tokenName: Uppercase<string>;
9
+ tokenDecimals: number;
10
+ tokenDescaler: (value: bigint) => number;
11
+ };
12
+ export declare const getERC20Allowance: ({ walletAddress, tokenAddress, spenderAddress, subject, }: GetERC20AllowanceParams) => Promise<number>;
13
+ export type GetERC20BalanceArgs = {
14
+ tokenAddress: string;
15
+ walletAddress: string;
16
+ subject: Signer;
17
+ };
18
+ export declare const getERC20Balance: ({ tokenAddress, walletAddress, subject, }: GetERC20BalanceArgs) => Promise<number>;
3
19
  //# sourceMappingURL=token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"/","sources":["utils/token.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,OAAO,kBAAmB,MAAM,aACzB,MAAM,WAKzB,CAAC;AAEF,eAAO,MAAM,KAAK,kBAAmB,MAAM,aACvB,MAAM,WAOzB,CAAC"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"/","sources":["utils/token.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAE5D,eAAO,MAAM,OAAO,kBAAmB,MAAM,aACzB,MAAM,WAKzB,CAAC;AAEF,eAAO,MAAM,KAAK,kBAAmB,MAAM,aACvB,MAAM,WAOzB,CAAC;AAEF,eAAO,MAAM,qBAAqB,iBAClB,MAAM,WACX,MAAM,KACd,QAWF,CAAC;A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tC,CAAC,EAPW,oBAAoB,oCAApB,oBAAoB,QAO/B;AAqED,iCAAiC;AACjC,IAAY,+BAOX;AAPD,WAAY,+BAA+B;IACzC,qGAAsB,CAAA;IACtB,mGAAyB,CAAA;IACzB,kGAA6B,CAAA;IAC7B,qGAAkC,CAAA;IAClC,wGAAoC,CAAA;IACpC,uGAAoC,CAAA;AACtC,CAAC,EAPW,+BAA+B,+CAA/B,+BAA+B,QAO1C;AAWD,6CAA6C;AAC7C,IAAY,0CAOX;AAPD,WAAY,0CAA0C;IACpD,2HAAsB,CAAA;IACtB,yHAAyB,CAAA;IACzB,wHAA6B,CAAA;IAC7B,2HAAkC,CAAA;IAClC,8HAAoC,CAAA;IACpC,6HAAoC,CAAA;AACtC,CAAC,EAPW,0CAA0C,0DAA1C,0CAA0C,QAOrD;AA6BD,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,6GAAsB,CAAA;IACtB,2GAAyB,CAAA;IACzB,0GAA6B,CAAA;IAC7B,6GAAkC,CAAA;IAClC,gHAAoC,CAAA;IACpC,+GAAoC,CAAA;AACtC,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED,gCAAgC;AAChC,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACvC,iGAAsB,CAAA;IACtB,+FAAyB,CAAA;IACzB,8FAA6B,CAAA;IAC7B,iGAAkC,CAAA;IAClC,oGAAoC,CAAA;IACpC,mGAAoC,CAAA;AACtC,CAAC,EAPW,6BAA6B,6CAA7B,6BAA6B,QAOxC","sourcesContent":["export type Address = Lowercase<string>;\n\n// -- Markets --\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n};\n\nexport enum ReyaChainId {\n polygonMumbai = 80001,\n // TODO: add the correct ID here\n reyaNetwork = -1,\n reyaCronos = 1729,\n}\n\nexport enum MoneyInOutChainId {\n ethereumSepolia = 11155111,\n}\n\nexport enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n id: string;\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n}\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'long' | 'short';\n\nexport type CollateralEntity = {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n exchangeRate: number;\n exchangeRateChange24HPercentage: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n totalBalanceChange24HPercentage: 5;\n livePnL: number;\n livePnLUnderlyingAsset: string;\n realizedPnL: number;\n realizedPnLUnderlyingAsset: string;\n totalPositionsCount: number;\n collaterals: CollateralEntity[];\n};\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n apyChange24H: number;\n tokenAddress: Address;\n token: string;\n allowedChainsForLiquidity: MoneyInOutChainId[];\n};\n\nexport type LpWithdrawBalanceEntity = {\n withdrawableBalance: number;\n poolSharePrice: number;\n};\n\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n timestamp: number;\n};\n\nexport type LpPositionEntity = {\n id: number;\n capitalInvested: number;\n currentBalance: number;\n pnl: number;\n lpPool: LpPoolEntity;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionStatus = 'confirmed' | 'pending';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n status: MarginAccountTransactionStatus;\n timestamp: number;\n};\n\nexport type TokenEntity = {\n id: string;\n address: Address;\n};\n// --- Lp Pool Balance ---\nexport enum LpBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport type GetSocketConnectorParams = {\n chainId: ReyaChainId | MoneyInOutChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketControllerParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketVaultParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketBridgeTimeParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketBridgeTimeResult = {\n bridgeTimeInMS: number;\n};\n\nexport type GetSocketDepositFeesParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketDepositFeesResult = {\n fees: number;\n feesUnit: string;\n};\n\nexport type GetSocketWithdrawFeesParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetSocketWithdrawFeesResult = {\n fees: number;\n};\n\n// --- Margin Account Balance ---\nexport enum MarginAccountBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\n// --- Margin Account Collaterals Balance ---\nexport enum MarginAccountCollateralsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountCollateralsBalanceChartDataResult = {\n data: {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n token: string;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport type OwnerMetadataEntity = {\n address: Address;\n coreSigNonce: number;\n poolSigNonce: number;\n};\n\nexport type GetAllMarginAccountsBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport enum AllMarginAccountsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\n// --- Funding Rate History ----\nexport enum FundingRateHistoryGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetFundingRateChartDataResult = {\n fundingRateData: {\n timestampInMs: number;\n value: number;\n }[];\n fundingRate: number;\n};\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;AA4BA,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,mEAAqB,CAAA;IACrB,gCAAgC;IAChC,4DAAgB,CAAA;IAChB,4DAAiB,CAAA;AACnB,CAAC,EALW,WAAW,2BAAX,WAAW,QAKtB;AAED,IAAY,iBAEX;AAFD,WAAY,iBAAiB;IAC3B,sFAA0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AAPD,WAAY,6BAA6B;IACvC,iGAAsB,CAAA;IACtB,+FAAyB,CAAA;IACzB,8FAA6B,CAAA;IAC7B,iGAAkC,CAAA;IAClC,oGAAoC,CAAA;IACpC,mGAAoC,CAAA;AACtC,CAAC,EAPW,6BAA6B,6CAA7B,6BAA6B,QAOxC","sourcesContent":["import { Signer } from 'ethers';\n\nexport type Address = Lowercase<string>;\n\n// -- Markets --\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n description: string;\n orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n};\n\nexport enum ReyaChainId {\n polygonMumbai = 80001,\n // TODO: add the correct ID here\n reyaNetwork = -1,\n reyaCronos = 1729,\n}\n\nexport enum MoneyInOutChainId {\n ethereumSepolia = 11155111,\n}\n\nexport enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n id: string;\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n}\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'long' | 'short';\n\nexport type CollateralEntity = {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n exchangeRate: number;\n exchangeRateChange24HPercentage: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n totalBalanceChange24HPercentage: 5;\n livePnL: number;\n livePnLUnderlyingAsset: string;\n realizedPnL: number;\n realizedPnLUnderlyingAsset: string;\n totalPositionsCount: number;\n collaterals: CollateralEntity[];\n};\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl?: number | null;\n unrealisedPnl?: number | null;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n date: Date;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n size: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n};\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n apyChange24H: number;\n tokenAddress: Address;\n token: string;\n allowedChainsForLiquidity: MoneyInOutChainId[];\n};\n\nexport type LpWithdrawBalanceEntity = {\n withdrawableBalance: number;\n poolSharePrice: number;\n};\n\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n timestamp: number;\n};\n\nexport type LpPositionEntity = {\n id: number;\n capitalInvested: number;\n currentBalance: number;\n pnl: number;\n lpPool: LpPoolEntity;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionStatus = 'confirmed' | 'pending';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n status: MarginAccountTransactionStatus;\n timestamp: number;\n};\n\nexport type TokenEntity = {\n id: string;\n address: Address;\n};\n// --- Lp Pool Balance ---\nexport enum LpBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport type GetSocketConnectorParams = {\n chainId: ReyaChainId | MoneyInOutChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketControllerParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketVaultParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenAddress: Address;\n};\n\nexport type GetSocketBridgeTimeParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketBridgeTimeResult = {\n bridgeTimeInMS: number;\n};\n\nexport type GetSocketDepositFeesParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketDepositFeesResult = {\n fees: number;\n feesUnderlyingToken: string;\n};\n\nexport type GetSocketWithdrawFeesParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetSocketWithdrawFeesResult = {\n fees: number;\n};\n\n// --- Margin Account Balance ---\nexport enum MarginAccountBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\n// --- Margin Account Collaterals Balance ---\nexport enum MarginAccountCollateralsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountCollateralsBalanceChartDataResult = {\n data: {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n token: string;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport type OwnerMetadataEntity = {\n address: Address;\n coreSigNonce: number;\n poolSigNonce: number;\n};\n\nexport type GetAllMarginAccountsBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport enum AllMarginAccountsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\n// --- Funding Rate History ----\nexport enum FundingRateHistoryGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetFundingRateChartDataResult = {\n fundingRateData: {\n timestampInMs: number;\n value: number;\n }[];\n fundingRate: number;\n};\n\nexport type GetERC20AllowanceParams = {\n walletAddress: string;\n tokenAddress: LpPoolEntity['tokenAddress'];\n spenderAddress: string;\n subject: Signer;\n};\n"]}
@@ -1,5 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MAX_UINT128 = void 0;
3
+ exports.tokenDetails = exports.MAX_UINT128 = void 0;
4
4
  exports.MAX_UINT128 = Math.pow(2, 128) - 1;
5
+ // @todo update values for mainnet
6
+ exports.tokenDetails = {
7
+ // ====== USDC ======
8
+ // mumbai
9
+ '0x52d800ca262522580cebad275395ca6e7598c014': {
10
+ tokenName: 'USDC',
11
+ tokenDecimals: 6,
12
+ },
13
+ // reya cronos
14
+ '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f': {
15
+ tokenName: 'USDC',
16
+ tokenDecimals: 6,
17
+ },
18
+ // ====== wETH ======
19
+ // mumbai
20
+ '0xc199807af4fedb02ee567ed0feb814a077de4802': {
21
+ tokenName: 'WETH',
22
+ tokenDecimals: 18,
23
+ },
24
+ // reya cronos
25
+ '0xcbdba2ac8f840711948ccd7a1b9ec0226d641693': {
26
+ tokenName: 'WETH',
27
+ tokenDecimals: 18,
28
+ },
29
+ // ====== wBTC ======
30
+ // mumbai
31
+ '0x2fa2e7a6deb7bb51b625336dbe1da23511914a8a': {
32
+ tokenName: 'WBTC',
33
+ tokenDecimals: 8,
34
+ },
35
+ // mainnet
36
+ '0xaf21abab55a7c0ab143e0379a3c01054e4ebb514': {
37
+ tokenName: 'WBTC',
38
+ tokenDecimals: 8,
39
+ },
40
+ // ====== USDT ======
41
+ // reya cronos
42
+ '0xeba6f8d7d4d4787f29441db1164548299ef4641f': {
43
+ tokenName: 'USDT',
44
+ tokenDecimals: 6,
45
+ },
46
+ // ====== dai ======
47
+ // reya cronos
48
+ '0x0d4fad8b258a467286fc2419ffc19015fdcae7f9': {
49
+ tokenName: 'USDT',
50
+ tokenDecimals: 18,
51
+ },
52
+ };
5
53
  //# sourceMappingURL=consts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consts.js","sourceRoot":"/","sources":["utils/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,SAAA,CAAC,EAAI,GAAG,CAAA,GAAG,CAAC,CAAC","sourcesContent":["export const MAX_UINT128 = 2 ** 128 - 1;\n"]}
1
+ {"version":3,"file":"consts.js","sourceRoot":"/","sources":["utils/consts.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,SAAA,CAAC,EAAI,GAAG,CAAA,GAAG,CAAC,CAAC;AAIxC,kCAAkC;AACrB,QAAA,YAAY,GAKrB;IACF,qBAAqB;IACrB,SAAS;IACT,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,CAAC;KACjB;IACD,cAAc;IACd,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,CAAC;KACjB;IACD,qBAAqB;IACrB,SAAS;IACT,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,EAAE;KAClB;IACD,cAAc;IACd,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,EAAE;KAClB;IAED,qBAAqB;IACrB,SAAS;IACT,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,CAAC;KACjB;IACD,UAAU;IACV,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,CAAC;KACjB;IACD,qBAAqB;IACrB,cAAc;IACd,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,CAAC;KACjB;IAED,oBAAoB;IACpB,cAAc;IACd,4CAA4C,EAAE;QAC5C,SAAS,EAAE,MAAM;QACjB,aAAa,EAAE,EAAE;KAClB;CACF,CAAC","sourcesContent":["export const MAX_UINT128 = 2 ** 128 - 1;\n\nimport { Address } from '../types';\n\n// @todo update values for mainnet\nexport const tokenDetails: {\n [address: Address]: {\n tokenName: Uppercase<string>;\n tokenDecimals: number;\n };\n} = {\n // ====== USDC ======\n // mumbai\n '0x52d800ca262522580cebad275395ca6e7598c014': {\n tokenName: 'USDC',\n tokenDecimals: 6,\n },\n // reya cronos\n '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f': {\n tokenName: 'USDC',\n tokenDecimals: 6,\n },\n // ====== wETH ======\n // mumbai\n '0xc199807af4fedb02ee567ed0feb814a077de4802': {\n tokenName: 'WETH',\n tokenDecimals: 18,\n },\n // reya cronos\n '0xcbdba2ac8f840711948ccd7a1b9ec0226d641693': {\n tokenName: 'WETH',\n tokenDecimals: 18,\n },\n\n // ====== wBTC ======\n // mumbai\n '0x2fa2e7a6deb7bb51b625336dbe1da23511914a8a': {\n tokenName: 'WBTC',\n tokenDecimals: 8,\n },\n // mainnet\n '0xaf21abab55a7c0ab143e0379a3c01054e4ebb514': {\n tokenName: 'WBTC',\n tokenDecimals: 8,\n },\n // ====== USDT ======\n // reya cronos\n '0xeba6f8d7d4d4787f29441db1164548299ef4641f': {\n tokenName: 'USDT',\n tokenDecimals: 6,\n },\n\n // ====== dai ======\n // reya cronos\n '0x0d4fad8b258a467286fc2419ffc19015fdcae7f9': {\n tokenName: 'USDT',\n tokenDecimals: 18,\n },\n};\n"]}
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./consts"), exports);
17
18
  __exportStar(require("./number"), exports);
19
+ __exportStar(require("./retry"), exports);
18
20
  __exportStar(require("./timestamp"), exports);
19
21
  __exportStar(require("./token"), exports);
20
- __exportStar(require("./consts"), exports);
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,2CAAyB","sourcesContent":["export * from './number';\nexport * from './timestamp';\nexport * from './token';\nexport * from './consts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB","sourcesContent":["export * from './consts';\nexport * from './number';\nexport * from './retry';\nexport * from './timestamp';\nexport * from './token';\n"]}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.exponentialBackoff = void 0;
40
+ // It introduces a delay of ms milliseconds
41
+ function delay(ms) {
42
+ return new Promise(function (resolve) { return setTimeout(resolve, ms); });
43
+ }
44
+ // It returns a random number between [0, max-1]
45
+ function getRandomNumber(max) {
46
+ return Math.floor(Math.random() * max);
47
+ }
48
+ // It retries a call for a few times while waiting an exponential time before each new attempt.
49
+ // You pass the query and the number of attempts you want to use and it performs as follows:
50
+ // 1. Initiates the waiting time to 1s
51
+ // 2. Tries to fetch the data
52
+ // 3.1. If it succeeds, it returns the data
53
+ // 3.2. If it fails, it waits, it doubles the waiting time and go to point 2. if the number of attemps is not reached
54
+ var exponentialBackoff = function (query, attempts, factor) {
55
+ if (attempts === void 0) { attempts = 5; }
56
+ if (factor === void 0) { factor = 2; }
57
+ return __awaiter(void 0, void 0, void 0, function () {
58
+ var waitingTime, attempt, data, error_1;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0:
62
+ waitingTime = 1000;
63
+ attempt = 0;
64
+ _a.label = 1;
65
+ case 1:
66
+ if (!(attempt < attempts)) return [3 /*break*/, 8];
67
+ _a.label = 2;
68
+ case 2:
69
+ _a.trys.push([2, 4, , 5]);
70
+ return [4 /*yield*/, query()];
71
+ case 3:
72
+ data = _a.sent();
73
+ return [2 /*return*/, data];
74
+ case 4:
75
+ error_1 = _a.sent();
76
+ if (attempt + 1 === attempts) {
77
+ throw error_1;
78
+ }
79
+ return [3 /*break*/, 5];
80
+ case 5: return [4 /*yield*/, delay(waitingTime + getRandomNumber(100))];
81
+ case 6:
82
+ _a.sent();
83
+ waitingTime *= factor;
84
+ _a.label = 7;
85
+ case 7:
86
+ attempt += 1;
87
+ return [3 /*break*/, 1];
88
+ case 8: throw new Error('Retry loop failed unexpectedly');
89
+ }
90
+ });
91
+ });
92
+ };
93
+ exports.exponentialBackoff = exponentialBackoff;
94
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"/","sources":["utils/retry.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,EAAvB,CAAuB,CAAC,CAAC;AAC3D,CAAC;AAED,gDAAgD;AAChD,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,+FAA+F;AAC/F,4FAA4F;AAC5F,sCAAsC;AACtC,6BAA6B;AAC7B,2CAA2C;AAC3C,qHAAqH;AAC9G,IAAM,kBAAkB,GAAG,UAChC,KAAuB,EACvB,QAAY,EACZ,MAAU;IADV,yBAAA,EAAA,YAAY;IACZ,uBAAA,EAAA,UAAU;;;;;;oBAEN,WAAW,GAAG,IAAI,CAAC;oBAEd,OAAO,GAAG,CAAC;;;yBAAE,CAAA,OAAO,GAAG,QAAQ,CAAA;;;;oBAEvB,qBAAM,KAAK,EAAE,EAAA;;oBAApB,IAAI,GAAG,SAAa;oBAE1B,sBAAO,IAAI,EAAC;;;oBAEZ,IAAI,OAAO,GAAG,CAAC,KAAK,QAAQ,EAAE,CAAC;wBAC7B,MAAM,OAAK,CAAC;oBACd,CAAC;;wBAGH,qBAAM,KAAK,CAAC,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,EAAA;;oBAA/C,SAA+C,CAAC;oBAChD,WAAW,IAAI,MAAM,CAAC;;;oBAZkB,OAAO,IAAI,CAAC,CAAA;;wBAetD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;;;;CACnD,CAAC;AAvBW,QAAA,kBAAkB,sBAuB7B","sourcesContent":["// It introduces a delay of ms milliseconds\nfunction delay(ms: number): Promise<unknown> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n// It returns a random number between [0, max-1]\nfunction getRandomNumber(max: number): number {\n return Math.floor(Math.random() * max);\n}\n\n// It retries a call for a few times while waiting an exponential time before each new attempt.\n// You pass the query and the number of attempts you want to use and it performs as follows:\n// 1. Initiates the waiting time to 1s\n// 2. Tries to fetch the data\n// 3.1. If it succeeds, it returns the data\n// 3.2. If it fails, it waits, it doubles the waiting time and go to point 2. if the number of attemps is not reached\nexport const exponentialBackoff = async <T = never>(\n query: () => Promise<T>,\n attempts = 5,\n factor = 2,\n): Promise<T> => {\n let waitingTime = 1000;\n\n for (let attempt = 0; attempt < attempts; attempt += 1) {\n try {\n const data = await query();\n\n return data;\n } catch (error) {\n if (attempt + 1 === attempts) {\n throw error;\n }\n }\n\n await delay(waitingTime + getRandomNumber(100));\n waitingTime *= factor;\n }\n\n throw new Error('Retry loop failed unexpectedly');\n};\n"]}
@@ -1,7 +1,46 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.scale = exports.descale = void 0;
39
+ exports.getERC20Balance = exports.getERC20Allowance = exports.getTokenDetails = exports.convertToAddress = exports.getERC20TokenContract = exports.scale = exports.descale = void 0;
4
40
  var ethers_1 = require("ethers");
41
+ var ethers_2 = require("ethers");
42
+ var consts_1 = require("./consts");
43
+ var retry_1 = require("./retry");
5
44
  var descale = function (tokenDecimals) {
6
45
  var f = function (value) {
7
46
  return Number(ethers_1.ethers.formatUnits(value.toString(), tokenDecimals));
@@ -16,4 +55,74 @@ var scale = function (tokenDecimals) {
16
55
  return f;
17
56
  };
18
57
  exports.scale = scale;
58
+ var getERC20TokenContract = function (tokenAddress, subject) {
59
+ var abi = [
60
+ "function approve(address, uint256) external returns (bool)",
61
+ "function balanceOf(address) external view returns (uint256)",
62
+ "function allowance(address,address) external view returns (uint256)",
63
+ "function approve(address,uint256) external returns (bool)",
64
+ ];
65
+ var contract = new ethers_2.Contract(tokenAddress, abi, subject);
66
+ return contract;
67
+ };
68
+ exports.getERC20TokenContract = getERC20TokenContract;
69
+ var convertToAddress = function (str) {
70
+ return str.toLowerCase();
71
+ };
72
+ exports.convertToAddress = convertToAddress;
73
+ var getTokenDetails = function (caseSensitiveAddress) {
74
+ var address = (0, exports.convertToAddress)(caseSensitiveAddress);
75
+ if (!Object.keys(consts_1.tokenDetails).includes(address)) {
76
+ throw new Error("Token details not found for ".concat(address, "."));
77
+ }
78
+ var _a = consts_1.tokenDetails[address], tokenName = _a.tokenName, tokenDecimals = _a.tokenDecimals;
79
+ return {
80
+ tokenName: tokenName,
81
+ tokenDecimals: tokenDecimals,
82
+ tokenDescaler: (0, exports.descale)(tokenDecimals),
83
+ };
84
+ };
85
+ exports.getTokenDetails = getTokenDetails;
86
+ var getERC20Allowance = function (_a) {
87
+ var walletAddress = _a.walletAddress, tokenAddress = _a.tokenAddress, spenderAddress = _a.spenderAddress, subject = _a.subject;
88
+ return __awaiter(void 0, void 0, void 0, function () {
89
+ var tokenContract, tokenDecimals, allowance;
90
+ return __generator(this, function (_b) {
91
+ switch (_b.label) {
92
+ case 0:
93
+ tokenContract = (0, exports.getERC20TokenContract)(tokenAddress, subject);
94
+ tokenDecimals = (0, exports.getTokenDetails)(tokenAddress).tokenDecimals;
95
+ return [4 /*yield*/, (0, retry_1.exponentialBackoff)(function () {
96
+ return tokenContract.allowance(walletAddress, spenderAddress);
97
+ })];
98
+ case 1:
99
+ allowance = _b.sent();
100
+ return [2 /*return*/, BigInt(allowance) > (0, exports.scale)(tokenDecimals)(Number.MAX_SAFE_INTEGER)
101
+ ? Number.MAX_SAFE_INTEGER
102
+ : (0, exports.descale)(tokenDecimals)(allowance)];
103
+ }
104
+ });
105
+ });
106
+ };
107
+ exports.getERC20Allowance = getERC20Allowance;
108
+ var getERC20Balance = function (_a) {
109
+ var tokenAddress = _a.tokenAddress, walletAddress = _a.walletAddress, subject = _a.subject;
110
+ return __awaiter(void 0, void 0, void 0, function () {
111
+ var token, tokenDescaler, currentBalance;
112
+ return __generator(this, function (_b) {
113
+ switch (_b.label) {
114
+ case 0:
115
+ token = (0, exports.getERC20TokenContract)(tokenAddress, subject);
116
+ tokenDescaler = (0, exports.getTokenDetails)(tokenAddress).tokenDescaler;
117
+ return [4 /*yield*/, (0, retry_1.exponentialBackoff)(function () {
118
+ return token.balanceOf(walletAddress);
119
+ })];
120
+ case 1:
121
+ currentBalance = _b.sent();
122
+ return [2 /*return*/, tokenDescaler(currentBalance)];
123
+ }
124
+ });
125
+ });
126
+ };
127
+ exports.getERC20Balance = getERC20Balance;
19
128
  //# sourceMappingURL=token.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.js","sourceRoot":"/","sources":["utils/token.ts"],"names":[],"mappings":";;;AAAA,iCAAgC;AAEzB,IAAM,OAAO,GAAG,UAAC,aAAqB;IAC3C,IAAM,CAAC,GAAG,UAAC,KAAa;QACtB,OAAO,MAAM,CAAC,eAAM,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC;IACrE,CAAC,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AANW,QAAA,OAAO,WAMlB;AAEK,IAAM,KAAK,GAAG,UAAC,aAAqB;IACzC,IAAM,CAAC,GAAG,UAAC,KAAa;QACtB,OAAO,MAAM,CACX,eAAM,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC,CAC/D,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AARW,QAAA,KAAK,SAQhB","sourcesContent":["import { ethers } from 'ethers';\n\nexport const descale = (tokenDecimals: number) => {\n const f = (value: bigint) => {\n return Number(ethers.formatUnits(value.toString(), tokenDecimals));\n };\n\n return f;\n};\n\nexport const scale = (tokenDecimals: number) => {\n const f = (value: number) => {\n return BigInt(\n ethers.parseUnits(value.toFixed(tokenDecimals), tokenDecimals),\n );\n };\n\n return f;\n};\n"]}
1
+ {"version":3,"file":"token.js","sourceRoot":"/","sources":["utils/token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAEhC,iCAA0C;AAC1C,mCAAwC;AACxC,iCAA6C;AAGtC,IAAM,OAAO,GAAG,UAAC,aAAqB;IAC3C,IAAM,CAAC,GAAG,UAAC,K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G,SAEtB;oBAED,sBAAO,aAAa,CAAC,cAAc,CAAC,EAAC;;;;CACtC,CAAC;AAdW,QAAA,eAAe,mBAc1B","sourcesContent":["import { ethers } from 'ethers';\n\nimport { Contract, Signer } from 'ethers';\nimport { tokenDetails } from './consts';\nimport { exponentialBackoff } from './retry';\nimport { Address, GetERC20AllowanceParams } from '../types';\n\nexport const descale = (tokenDecimals: number) => {\n const f = (value: bigint) => {\n return Number(ethers.formatUnits(value.toString(), tokenDecimals));\n };\n\n return f;\n};\n\nexport const scale = (tokenDecimals: number) => {\n const f = (value: number) => {\n return BigInt(\n ethers.parseUnits(value.toFixed(tokenDecimals), tokenDecimals),\n );\n };\n\n return f;\n};\n\nexport const getERC20TokenContract = (\n tokenAddress: string,\n subject: Signer,\n): Contract => {\n const abi: string[] = [\n `function approve(address, uint256) external returns (bool)`,\n `function balanceOf(address) external view returns (uint256)`,\n `function allowance(address,address) external view returns (uint256)`,\n `function approve(address,uint256) external returns (bool)`,\n ];\n\n const contract = new Contract(tokenAddress, abi, subject);\n\n return contract;\n};\n\nexport const convertToAddress = (str: string): Address => {\n return str.toLowerCase() as Address;\n};\n\nexport const getTokenDetails = (\n caseSensitiveAddress: string,\n): {\n tokenName: Uppercase<string>;\n tokenDecimals: number;\n tokenDescaler: (value: bigint) => number;\n} => {\n const address = convertToAddress(caseSensitiveAddress);\n\n if (!Object.keys(tokenDetails).includes(address)) {\n throw new Error(`Token details not found for ${address}.`);\n }\n\n const { tokenName, tokenDecimals } = tokenDetails[address];\n\n return {\n tokenName,\n tokenDecimals,\n tokenDescaler: descale(tokenDecimals),\n };\n};\n\nexport const getERC20Allowance = async ({\n walletAddress,\n tokenAddress,\n spenderAddress,\n subject,\n}: GetERC20AllowanceParams): Promise<number> => {\n const tokenContract = getERC20TokenContract(tokenAddress, subject);\n const { tokenDecimals } = getTokenDetails(tokenAddress);\n\n const allowance = await exponentialBackoff(() =>\n tokenContract.allowance(walletAddress, spenderAddress),\n );\n\n return BigInt(allowance) > scale(tokenDecimals)(Number.MAX_SAFE_INTEGER)\n ? Number.MAX_SAFE_INTEGER\n : descale(tokenDecimals)(allowance);\n};\n\nexport type GetERC20BalanceArgs = {\n tokenAddress: string;\n walletAddress: string;\n subject: Signer;\n};\n\nexport const getERC20Balance = async ({\n tokenAddress,\n walletAddress,\n subject,\n}: GetERC20BalanceArgs): Promise<number> => {\n const token = getERC20TokenContract(tokenAddress, subject);\n\n const { tokenDescaler } = getTokenDetails(tokenAddress);\n\n const currentBalance = await exponentialBackoff(() =>\n token.balanceOf(walletAddress),\n );\n\n return tokenDescaler(currentBalance);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reyaxyz/common",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -41,5 +41,5 @@
41
41
  "generate:coverage-badges": "npx istanbul-badges-readme --silent"
42
42
  },
43
43
  "packageManager": "pnpm@8.10.4",
44
- "gitHead": "eccb0c061d91c383ae02680b3193ff8ee07a4ad6"
44
+ "gitHead": "a3abad43a112fb76ffa96e100360d5cecd6333b1"
45
45
  }
@@ -22,6 +22,6 @@ export const getSocketDepositFees = (
22
22
  ): GetSocketDepositFeesResult => {
23
23
  return {
24
24
  fees: descale(18)(socketDepositFees[params.moneyInOutChainId]),
25
- feesUnit: getNativeToken(params.moneyInOutChainId),
25
+ feesUnderlyingToken: getNativeToken(params.moneyInOutChainId),
26
26
  };
27
27
  };
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Signer } from 'ethers';
2
+
1
3
  export type Address = Lowercase<string>;
2
4
 
3
5
  // -- Markets --
@@ -260,7 +262,7 @@ export type GetSocketDepositFeesParams = {
260
262
 
261
263
  export type GetSocketDepositFeesResult = {
262
264
  fees: number;
263
- feesUnit: string;
265
+ feesUnderlyingToken: string;
264
266
  };
265
267
 
266
268
  export type GetSocketWithdrawFeesParams = {
@@ -353,3 +355,10 @@ export type GetFundingRateChartDataResult = {
353
355
  }[];
354
356
  fundingRate: number;
355
357
  };
358
+
359
+ export type GetERC20AllowanceParams = {
360
+ walletAddress: string;
361
+ tokenAddress: LpPoolEntity['tokenAddress'];
362
+ spenderAddress: string;
363
+ subject: Signer;
364
+ };
@@ -1 +1,59 @@
1
1
  export const MAX_UINT128 = 2 ** 128 - 1;
2
+
3
+ import { Address } from '../types';
4
+
5
+ // @todo update values for mainnet
6
+ export const tokenDetails: {
7
+ [address: Address]: {
8
+ tokenName: Uppercase<string>;
9
+ tokenDecimals: number;
10
+ };
11
+ } = {
12
+ // ====== USDC ======
13
+ // mumbai
14
+ '0x52d800ca262522580cebad275395ca6e7598c014': {
15
+ tokenName: 'USDC',
16
+ tokenDecimals: 6,
17
+ },
18
+ // reya cronos
19
+ '0x51b0b7f083e563d5cf9d0b5f3916b59fc49c7e5f': {
20
+ tokenName: 'USDC',
21
+ tokenDecimals: 6,
22
+ },
23
+ // ====== wETH ======
24
+ // mumbai
25
+ '0xc199807af4fedb02ee567ed0feb814a077de4802': {
26
+ tokenName: 'WETH',
27
+ tokenDecimals: 18,
28
+ },
29
+ // reya cronos
30
+ '0xcbdba2ac8f840711948ccd7a1b9ec0226d641693': {
31
+ tokenName: 'WETH',
32
+ tokenDecimals: 18,
33
+ },
34
+
35
+ // ====== wBTC ======
36
+ // mumbai
37
+ '0x2fa2e7a6deb7bb51b625336dbe1da23511914a8a': {
38
+ tokenName: 'WBTC',
39
+ tokenDecimals: 8,
40
+ },
41
+ // mainnet
42
+ '0xaf21abab55a7c0ab143e0379a3c01054e4ebb514': {
43
+ tokenName: 'WBTC',
44
+ tokenDecimals: 8,
45
+ },
46
+ // ====== USDT ======
47
+ // reya cronos
48
+ '0xeba6f8d7d4d4787f29441db1164548299ef4641f': {
49
+ tokenName: 'USDT',
50
+ tokenDecimals: 6,
51
+ },
52
+
53
+ // ====== dai ======
54
+ // reya cronos
55
+ '0x0d4fad8b258a467286fc2419ffc19015fdcae7f9': {
56
+ tokenName: 'USDT',
57
+ tokenDecimals: 18,
58
+ },
59
+ };
@@ -1,4 +1,5 @@
1
+ export * from './consts';
1
2
  export * from './number';
3
+ export * from './retry';
2
4
  export * from './timestamp';
3
5
  export * from './token';
4
- export * from './consts';
@@ -0,0 +1,40 @@
1
+ // It introduces a delay of ms milliseconds
2
+ function delay(ms: number): Promise<unknown> {
3
+ return new Promise((resolve) => setTimeout(resolve, ms));
4
+ }
5
+
6
+ // It returns a random number between [0, max-1]
7
+ function getRandomNumber(max: number): number {
8
+ return Math.floor(Math.random() * max);
9
+ }
10
+
11
+ // It retries a call for a few times while waiting an exponential time before each new attempt.
12
+ // You pass the query and the number of attempts you want to use and it performs as follows:
13
+ // 1. Initiates the waiting time to 1s
14
+ // 2. Tries to fetch the data
15
+ // 3.1. If it succeeds, it returns the data
16
+ // 3.2. If it fails, it waits, it doubles the waiting time and go to point 2. if the number of attemps is not reached
17
+ export const exponentialBackoff = async <T = never>(
18
+ query: () => Promise<T>,
19
+ attempts = 5,
20
+ factor = 2,
21
+ ): Promise<T> => {
22
+ let waitingTime = 1000;
23
+
24
+ for (let attempt = 0; attempt < attempts; attempt += 1) {
25
+ try {
26
+ const data = await query();
27
+
28
+ return data;
29
+ } catch (error) {
30
+ if (attempt + 1 === attempts) {
31
+ throw error;
32
+ }
33
+ }
34
+
35
+ await delay(waitingTime + getRandomNumber(100));
36
+ waitingTime *= factor;
37
+ }
38
+
39
+ throw new Error('Retry loop failed unexpectedly');
40
+ };
@@ -1,5 +1,10 @@
1
1
  import { ethers } from 'ethers';
2
2
 
3
+ import { Contract, Signer } from 'ethers';
4
+ import { tokenDetails } from './consts';
5
+ import { exponentialBackoff } from './retry';
6
+ import { Address, GetERC20AllowanceParams } from '../types';
7
+
3
8
  export const descale = (tokenDecimals: number) => {
4
9
  const f = (value: bigint) => {
5
10
  return Number(ethers.formatUnits(value.toString(), tokenDecimals));
@@ -17,3 +22,85 @@ export const scale = (tokenDecimals: number) => {
17
22
 
18
23
  return f;
19
24
  };
25
+
26
+ export const getERC20TokenContract = (
27
+ tokenAddress: string,
28
+ subject: Signer,
29
+ ): Contract => {
30
+ const abi: string[] = [
31
+ `function approve(address, uint256) external returns (bool)`,
32
+ `function balanceOf(address) external view returns (uint256)`,
33
+ `function allowance(address,address) external view returns (uint256)`,
34
+ `function approve(address,uint256) external returns (bool)`,
35
+ ];
36
+
37
+ const contract = new Contract(tokenAddress, abi, subject);
38
+
39
+ return contract;
40
+ };
41
+
42
+ export const convertToAddress = (str: string): Address => {
43
+ return str.toLowerCase() as Address;
44
+ };
45
+
46
+ export const getTokenDetails = (
47
+ caseSensitiveAddress: string,
48
+ ): {
49
+ tokenName: Uppercase<string>;
50
+ tokenDecimals: number;
51
+ tokenDescaler: (value: bigint) => number;
52
+ } => {
53
+ const address = convertToAddress(caseSensitiveAddress);
54
+
55
+ if (!Object.keys(tokenDetails).includes(address)) {
56
+ throw new Error(`Token details not found for ${address}.`);
57
+ }
58
+
59
+ const { tokenName, tokenDecimals } = tokenDetails[address];
60
+
61
+ return {
62
+ tokenName,
63
+ tokenDecimals,
64
+ tokenDescaler: descale(tokenDecimals),
65
+ };
66
+ };
67
+
68
+ export const getERC20Allowance = async ({
69
+ walletAddress,
70
+ tokenAddress,
71
+ spenderAddress,
72
+ subject,
73
+ }: GetERC20AllowanceParams): Promise<number> => {
74
+ const tokenContract = getERC20TokenContract(tokenAddress, subject);
75
+ const { tokenDecimals } = getTokenDetails(tokenAddress);
76
+
77
+ const allowance = await exponentialBackoff(() =>
78
+ tokenContract.allowance(walletAddress, spenderAddress),
79
+ );
80
+
81
+ return BigInt(allowance) > scale(tokenDecimals)(Number.MAX_SAFE_INTEGER)
82
+ ? Number.MAX_SAFE_INTEGER
83
+ : descale(tokenDecimals)(allowance);
84
+ };
85
+
86
+ export type GetERC20BalanceArgs = {
87
+ tokenAddress: string;
88
+ walletAddress: string;
89
+ subject: Signer;
90
+ };
91
+
92
+ export const getERC20Balance = async ({
93
+ tokenAddress,
94
+ walletAddress,
95
+ subject,
96
+ }: GetERC20BalanceArgs): Promise<number> => {
97
+ const token = getERC20TokenContract(tokenAddress, subject);
98
+
99
+ const { tokenDescaler } = getTokenDetails(tokenAddress);
100
+
101
+ const currentBalance = await exponentialBackoff(() =>
102
+ token.balanceOf(walletAddress),
103
+ );
104
+
105
+ return tokenDescaler(currentBalance);
106
+ };