@rainprotocolsdk/sdk 1.0.0 → 1.0.2
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.
- package/README.md +191 -0
- package/dist/Rain.d.ts +2 -1
- package/dist/Rain.js +4 -0
- package/dist/{Rainaa.d.ts → RainAA.d.ts} +1 -1
- package/dist/{Rainaa.js → RainAA.js} +1 -2
- package/dist/abi/ERC20Abi.d.ts +594 -0
- package/dist/abi/ERC20Abi.js +772 -0
- package/dist/config/api.d.ts +1 -0
- package/dist/config/api.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/markets/constants.d.ts +17 -0
- package/dist/markets/constants.js +17 -0
- package/dist/markets/getMarkets.js +9 -8
- package/dist/markets/types.d.ts +2 -2
- package/dist/tx/buildApprovalRawTx.d.ts +2 -0
- package/dist/tx/buildApprovalRawTx.js +20 -0
- package/dist/tx/types.d.ts +6 -0
- package/dist/types.d.ts +2 -2
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const API_BASE_URL = "https://dev-api.rain.one";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const API_BASE_URL = "https://dev-api.rain.one";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const MARKET_STATUS: {
|
|
2
|
+
readonly New: "New";
|
|
3
|
+
readonly Live: "Live";
|
|
4
|
+
readonly WaitingForResult: "Waiting_for_Result";
|
|
5
|
+
readonly UnderDispute: "Under_Dispute";
|
|
6
|
+
readonly UnderAppeal: "Under_Appeal";
|
|
7
|
+
readonly Closed: "Closed";
|
|
8
|
+
readonly ClosingSoon: "Closing_Soon";
|
|
9
|
+
readonly InReview: "Dispute_Window_Open";
|
|
10
|
+
readonly InEvaluation: "Appeal_Window_Open";
|
|
11
|
+
readonly Trading: "Pending_Finalization";
|
|
12
|
+
};
|
|
13
|
+
export declare const MARKET_SORT_BY: {
|
|
14
|
+
Liquidity: string;
|
|
15
|
+
Volumn: string;
|
|
16
|
+
latest: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const MARKET_STATUS = {
|
|
2
|
+
New: "New",
|
|
3
|
+
Live: "Live",
|
|
4
|
+
WaitingForResult: 'Waiting_for_Result',
|
|
5
|
+
UnderDispute: "Under_Dispute",
|
|
6
|
+
UnderAppeal: "Under_Appeal",
|
|
7
|
+
Closed: "Closed",
|
|
8
|
+
ClosingSoon: "Closing_Soon",
|
|
9
|
+
InReview: "Dispute_Window_Open",
|
|
10
|
+
InEvaluation: "Appeal_Window_Open",
|
|
11
|
+
Trading: "Pending_Finalization"
|
|
12
|
+
};
|
|
13
|
+
export const MARKET_SORT_BY = {
|
|
14
|
+
Liquidity: "totalLiquidity",
|
|
15
|
+
Volumn: "totalVolumn",
|
|
16
|
+
latest: "age"
|
|
17
|
+
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { API_BASE_URL } from '../config/api';
|
|
2
|
+
import { MARKET_SORT_BY, MARKET_STATUS } from './constants';
|
|
1
3
|
export async function getMarkets(params) {
|
|
2
4
|
const query = new URLSearchParams();
|
|
3
|
-
|
|
4
|
-
if (params.limit)
|
|
5
|
+
if (params?.limit)
|
|
5
6
|
query.append('limit', params.limit.toString());
|
|
6
|
-
if (params
|
|
7
|
+
if (params?.offset)
|
|
7
8
|
query.append('offset', params.offset.toString());
|
|
8
|
-
if (params
|
|
9
|
-
query.append('sortBy', params.sortBy);
|
|
10
|
-
if (params
|
|
11
|
-
query.append('status', params.status);
|
|
12
|
-
const res = await fetch(`${
|
|
9
|
+
if (params?.sortBy)
|
|
10
|
+
query.append('sortBy', MARKET_SORT_BY[params.sortBy]);
|
|
11
|
+
if (params?.status)
|
|
12
|
+
query.append('status', MARKET_STATUS[params.status]);
|
|
13
|
+
const res = await fetch(`${API_BASE_URL}/pools/public-pools?${query.toString()}`);
|
|
13
14
|
if (!res.ok) {
|
|
14
15
|
throw new Error(`Failed to fetch markets: ${res.status}`);
|
|
15
16
|
}
|
package/dist/markets/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type MarketStatus = 'Live' | 'Closed' | '
|
|
2
|
-
export type MarketSortBy = '
|
|
1
|
+
export type MarketStatus = 'Live' | 'New' | 'WaitingForResult' | 'UnderDispute' | 'UnderAppeal' | 'ClosingSoon' | 'InReview' | 'InEvaluation' | 'Closed' | 'Trading';
|
|
2
|
+
export type MarketSortBy = 'Liquidity' | 'Volumn' | 'latest';
|
|
3
3
|
export interface GetMarketsParams {
|
|
4
4
|
limit?: number;
|
|
5
5
|
offset?: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { encodeFunctionData } from "viem";
|
|
2
|
+
import { ERC20Abi } from "../abi/ERC20Abi";
|
|
3
|
+
import { ethers } from "ethers";
|
|
4
|
+
const DEFAULT_APPROVE_AMOUNT = ethers.MaxUint256;
|
|
5
|
+
export function buildApproveRawTx(params) {
|
|
6
|
+
const { tokenAddress, spender, amount = DEFAULT_APPROVE_AMOUNT, } = params;
|
|
7
|
+
if (!params.tokenAddress)
|
|
8
|
+
throw new Error("token address is required");
|
|
9
|
+
if (!params.spender)
|
|
10
|
+
throw new Error("spender address is required");
|
|
11
|
+
return {
|
|
12
|
+
to: tokenAddress,
|
|
13
|
+
data: encodeFunctionData({
|
|
14
|
+
abi: ERC20Abi,
|
|
15
|
+
functionName: "approve",
|
|
16
|
+
args: [spender, amount],
|
|
17
|
+
}),
|
|
18
|
+
value: 0n,
|
|
19
|
+
};
|
|
20
|
+
}
|
package/dist/tx/types.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { WalletClient } from 'viem';
|
|
|
2
2
|
import { Chain } from 'viem/chains';
|
|
3
3
|
export interface RainConfig {
|
|
4
4
|
walletClient: WalletClient;
|
|
5
|
-
alchemyApiKey
|
|
6
|
-
paymasterPolicyId
|
|
5
|
+
alchemyApiKey?: string;
|
|
6
|
+
paymasterPolicyId?: string;
|
|
7
7
|
chain: Chain;
|
|
8
8
|
rpcUrl?: string;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainprotocolsdk/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Rain SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"@account-kit/infra": "^4.48.0",
|
|
30
30
|
"@account-kit/wallet-client": "^0.1.0-alpha.10",
|
|
31
31
|
"@alchemy/aa-alchemy": "^3.0.0",
|
|
32
|
-
"@alchemy/aa-core": "^3.0.0"
|
|
32
|
+
"@alchemy/aa-core": "^3.0.0",
|
|
33
|
+
"ethers": "^6.16.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"typescript": "^5.9.3"
|