@proton/wrap-constants 0.3.0 → 0.3.1
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/dist/index.cjs +297 -0
- package/dist/index.d.cts +61 -86
- package/dist/index.d.mts +61 -86
- package/dist/index.mjs +292 -1
- package/package.json +15 -9
- package/src/coins.ts +0 -1632
- package/src/constants.ts +0 -202
- package/src/graph.ts +0 -126
- package/src/index.ts +0 -6
- package/src/math.ts +0 -147
- package/src/parsers/actions.ts +0 -105
- package/src/parsers/address.ts +0 -27
- package/src/parsers/auth.ts +0 -36
- package/src/parsers/base.ts +0 -24
- package/src/parsers/currency.ts +0 -89
- package/src/parsers/deposit.ts +0 -31
- package/src/parsers/dex.ts +0 -785
- package/src/parsers/index.ts +0 -13
- package/src/parsers/login.ts +0 -8
- package/src/parsers/otc.ts +0 -23
- package/src/parsers/pool.ts +0 -53
- package/src/parsers/withdraw.ts +0 -39
- package/src/parsers/withdrawalHistory.ts +0 -23
- package/src/parsers/wrap.ts +0 -41
- package/src/utils.ts +0 -22
package/src/parsers/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './actions'
|
|
2
|
-
export * from './address'
|
|
3
|
-
export * from './auth'
|
|
4
|
-
export * from './base'
|
|
5
|
-
export * from './currency'
|
|
6
|
-
export * from './deposit'
|
|
7
|
-
export * from './otc'
|
|
8
|
-
export * from './pool'
|
|
9
|
-
export * from './withdraw'
|
|
10
|
-
export * from './withdrawalHistory'
|
|
11
|
-
export * from './wrap'
|
|
12
|
-
export * from './dex'
|
|
13
|
-
export * from './login'
|
package/src/parsers/login.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { generateAuthParser } from "./auth";
|
|
3
|
-
|
|
4
|
-
export const loginAccountParamsV3Parser = generateAuthParser.extend({
|
|
5
|
-
email: z.string().optional(),
|
|
6
|
-
verificationCode: z.string().optional(),
|
|
7
|
-
});
|
|
8
|
-
export type LoginAccountParamsV3 = z.infer<typeof loginAccountParamsV3Parser>;
|
package/src/parsers/otc.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod'
|
|
2
|
-
|
|
3
|
-
export const otcOrderResponseParser = z.object({
|
|
4
|
-
success : z.boolean(),
|
|
5
|
-
transaction_id: z.string(),
|
|
6
|
-
errormsg : z.string().optional()
|
|
7
|
-
})
|
|
8
|
-
export type OtcOrderResponse = z.infer<typeof otcOrderResponseParser>
|
|
9
|
-
|
|
10
|
-
export const otcQuoteBodyParser = z.object({
|
|
11
|
-
baseAmount : z.number(),
|
|
12
|
-
baseSymbol : z.string(),
|
|
13
|
-
quoteSymbol: z.string()
|
|
14
|
-
})
|
|
15
|
-
export type OtcQuoteBody = z.infer<typeof otcQuoteBodyParser>
|
|
16
|
-
|
|
17
|
-
export const otcQuoteResponseParser = z.object({
|
|
18
|
-
success : z.boolean(),
|
|
19
|
-
token : z.string(),
|
|
20
|
-
qty : z.number(),
|
|
21
|
-
errormsg: z.string().optional()
|
|
22
|
-
})
|
|
23
|
-
export type OtcQuoteResponse = z.infer<typeof otcQuoteResponseParser>
|
package/src/parsers/pool.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { ExtendedAsset } from "@bloks/numbers";
|
|
2
|
-
import { Coin } from "../coins";
|
|
3
|
-
import { INode } from "../graph";
|
|
4
|
-
|
|
5
|
-
export interface RawPool {
|
|
6
|
-
lt_symbol: string;
|
|
7
|
-
creator: string;
|
|
8
|
-
memo: string;
|
|
9
|
-
pool1: {
|
|
10
|
-
quantity: string;
|
|
11
|
-
contract: string;
|
|
12
|
-
};
|
|
13
|
-
pool2: {
|
|
14
|
-
quantity: string;
|
|
15
|
-
contract: string;
|
|
16
|
-
};
|
|
17
|
-
hash: string;
|
|
18
|
-
fee: {
|
|
19
|
-
exchange_fee: number;
|
|
20
|
-
add_liquidity_fee: number;
|
|
21
|
-
remove_liquidity_fee: number;
|
|
22
|
-
};
|
|
23
|
-
active: boolean;
|
|
24
|
-
amplifier: number;
|
|
25
|
-
}
|
|
26
|
-
export interface Pool extends Omit<RawPool, "pool1" | "pool2"> {
|
|
27
|
-
lt_symbol: string;
|
|
28
|
-
creator: string;
|
|
29
|
-
memo: string;
|
|
30
|
-
pool1: ExtendedTokenWithRate;
|
|
31
|
-
pool2: ExtendedTokenWithRate;
|
|
32
|
-
hash: string;
|
|
33
|
-
fee: {
|
|
34
|
-
exchange_fee: number;
|
|
35
|
-
add_liquidity_fee: number;
|
|
36
|
-
remove_liquidity_fee: number;
|
|
37
|
-
};
|
|
38
|
-
liquidityUsd: number;
|
|
39
|
-
liquidityApr: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type ExtendedToken = Coin & ExtendedAsset & { key: string };
|
|
43
|
-
export type ExtendedTokenWithRate = ExtendedToken & { rate: number };
|
|
44
|
-
|
|
45
|
-
export type PoolTable =
|
|
46
|
-
| {
|
|
47
|
-
pool1: ExtendedTokenWithRate;
|
|
48
|
-
pool2: ExtendedTokenWithRate;
|
|
49
|
-
path: INode<Pool>[];
|
|
50
|
-
shortestPath: INode<Pool>[];
|
|
51
|
-
getPathString: () => string;
|
|
52
|
-
}
|
|
53
|
-
| undefined;
|
package/src/parsers/withdraw.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { singleActionTransactionParser } from "./actions";
|
|
3
|
-
import { authorizationParser } from "./base";
|
|
4
|
-
import { WRAP_CONTRACT } from "../constants";
|
|
5
|
-
import { baseActionParser } from "./actions";
|
|
6
|
-
|
|
7
|
-
const withdrawData = {
|
|
8
|
-
from: z.string().refine((val) => val !== WRAP_CONTRACT, {
|
|
9
|
-
error: `${WRAP_CONTRACT} must be receiver`,
|
|
10
|
-
}),
|
|
11
|
-
to: z.literal(WRAP_CONTRACT),
|
|
12
|
-
quantity: z.string(),
|
|
13
|
-
memo: z.string(),
|
|
14
|
-
};
|
|
15
|
-
export const withdrawBodyBaseAction = baseActionParser("*", "transfer", withdrawData);
|
|
16
|
-
export type WithdrawBodyBaseAction = z.infer<typeof withdrawBodyBaseAction>;
|
|
17
|
-
|
|
18
|
-
export const withdrawBodyParser = z.object({
|
|
19
|
-
signer: authorizationParser,
|
|
20
|
-
signatures: z.array(z.string()).length(1),
|
|
21
|
-
transaction: singleActionTransactionParser("*", "transfer", withdrawData),
|
|
22
|
-
quoteId: z.string(),
|
|
23
|
-
provider: z.string().optional(),
|
|
24
|
-
});
|
|
25
|
-
export type WithdrawBody = z.infer<typeof withdrawBodyParser>;
|
|
26
|
-
|
|
27
|
-
export const withdrawMetalResponseParser = z.object({
|
|
28
|
-
success: z.boolean(),
|
|
29
|
-
id: z.string(),
|
|
30
|
-
});
|
|
31
|
-
export type WithdrawMetalResponse = z.infer<typeof withdrawMetalResponseParser>;
|
|
32
|
-
|
|
33
|
-
export const withdrawalFeeQuoteParser = z.object({
|
|
34
|
-
quoteId: z.string(),
|
|
35
|
-
estimatedFee: z.string(),
|
|
36
|
-
currency: z.string(),
|
|
37
|
-
network: z.string(),
|
|
38
|
-
});
|
|
39
|
-
export type WithdrawalFeeQuote = z.infer<typeof withdrawalFeeQuoteParser>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod'
|
|
2
|
-
|
|
3
|
-
export const withdrawHistoryMetalSwapParser = z.object({
|
|
4
|
-
id : z.string(),
|
|
5
|
-
status : z.string(),
|
|
6
|
-
amount : z.string(),
|
|
7
|
-
currency : z.string(),
|
|
8
|
-
network : z.string(),
|
|
9
|
-
created : z.string(),
|
|
10
|
-
withdrawalAddress: z.string(),
|
|
11
|
-
withdrawalHash : z.string().optional()
|
|
12
|
-
})
|
|
13
|
-
export type WithdrawHistoryMetalSwap = z.infer<typeof withdrawHistoryMetalSwapParser>
|
|
14
|
-
|
|
15
|
-
export const withdrawHistoryMetalResponseParser = z.object({
|
|
16
|
-
swaps : z.array(withdrawHistoryMetalSwapParser),
|
|
17
|
-
page : z.number(),
|
|
18
|
-
pageSize : z.number(),
|
|
19
|
-
numberOfElements: z.number(),
|
|
20
|
-
totalPages : z.number(),
|
|
21
|
-
totalElements : z.number()
|
|
22
|
-
})
|
|
23
|
-
export type WithdrawHistoryMetalResponse = z.infer<typeof withdrawHistoryMetalResponseParser>
|
package/src/parsers/wrap.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { ExtendedAssetParser } from "./base";
|
|
3
|
-
|
|
4
|
-
export enum Status {
|
|
5
|
-
PENDING = "pending",
|
|
6
|
-
SUCCESS = "success",
|
|
7
|
-
FAIL = "fail",
|
|
8
|
-
PROCESSING = "processing",
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const wrapStartParser = z.object({
|
|
12
|
-
balance: ExtendedAssetParser,
|
|
13
|
-
id: z.string(),
|
|
14
|
-
txid: z.string(),
|
|
15
|
-
chain: z.string(),
|
|
16
|
-
deposit_address: z.string(),
|
|
17
|
-
confirmations: z.number(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export type WrapStart = z.infer<typeof wrapStartParser>;
|
|
21
|
-
|
|
22
|
-
export const wrapSetConfParser = z.object({
|
|
23
|
-
wrap_hash: z.string(),
|
|
24
|
-
confirmations: z.number(),
|
|
25
|
-
});
|
|
26
|
-
export type WrapSetConf = z.infer<typeof wrapSetConfParser>;
|
|
27
|
-
|
|
28
|
-
export const wrapParser = z.object({
|
|
29
|
-
index: z.number(),
|
|
30
|
-
proton_account: z.string(),
|
|
31
|
-
balance: ExtendedAssetParser,
|
|
32
|
-
id: z.string(),
|
|
33
|
-
txid: z.string(),
|
|
34
|
-
chain: z.string(),
|
|
35
|
-
deposit_address: z.string(),
|
|
36
|
-
status: z.enum(Status),
|
|
37
|
-
finish_txid: z.string(),
|
|
38
|
-
wrap_hash: z.string(),
|
|
39
|
-
confirmations: z.number(),
|
|
40
|
-
});
|
|
41
|
-
export type Wrap = z.infer<typeof wrapParser>;
|
package/src/utils.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
interface PartialCoin {
|
|
2
|
-
xtokenSymbol: string;
|
|
3
|
-
xtokenPrecision: number;
|
|
4
|
-
xtokenContract: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const isSameToken = (token1: PartialCoin, token2: PartialCoin) => {
|
|
8
|
-
return token1.xtokenSymbol === token2.xtokenSymbol &&
|
|
9
|
-
token1.xtokenPrecision === token2.xtokenPrecision &&
|
|
10
|
-
token1.xtokenContract === token2.xtokenContract
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const median = (numbers: number[]) => {
|
|
14
|
-
const sorted = numbers.slice().sort((a, b) => a - b);
|
|
15
|
-
const middle = Math.floor(sorted.length / 2);
|
|
16
|
-
|
|
17
|
-
if (sorted.length % 2 === 0) {
|
|
18
|
-
return (sorted[middle - 1] + sorted[middle]) / 2;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return sorted[middle];
|
|
22
|
-
}
|