@swapkit/plugins 4.0.0-beta.49 → 4.0.0-beta.51

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.
Files changed (88) hide show
  1. package/dist/chainflip/index.cjs +2 -2
  2. package/dist/chainflip/index.cjs.map +3 -3
  3. package/dist/chainflip/index.js +2 -2
  4. package/dist/chainflip/index.js.map +3 -3
  5. package/dist/chunk-hzmkxs26.js +5 -0
  6. package/dist/chunk-hzmkxs26.js.map +10 -0
  7. package/dist/chunk-npbmqeem.js +4 -0
  8. package/dist/chunk-npbmqeem.js.map +10 -0
  9. package/dist/evm/index.cjs +2 -2
  10. package/dist/evm/index.cjs.map +3 -3
  11. package/dist/evm/index.js +2 -2
  12. package/dist/evm/index.js.map +3 -3
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.cjs.map +3 -4
  15. package/dist/index.js +2 -2
  16. package/dist/index.js.map +3 -4
  17. package/dist/near/index.cjs +2 -2
  18. package/dist/near/index.cjs.map +3 -3
  19. package/dist/near/index.js +2 -2
  20. package/dist/near/index.js.map +3 -3
  21. package/dist/radix/index.cjs +2 -2
  22. package/dist/radix/index.cjs.map +3 -3
  23. package/dist/radix/index.js +2 -2
  24. package/dist/radix/index.js.map +3 -3
  25. package/dist/solana/index.cjs +2 -2
  26. package/dist/solana/index.cjs.map +3 -3
  27. package/dist/solana/index.js +2 -2
  28. package/dist/solana/index.js.map +3 -3
  29. package/dist/thorchain/index.cjs +2 -2
  30. package/dist/thorchain/index.cjs.map +3 -3
  31. package/dist/thorchain/index.js +2 -2
  32. package/dist/thorchain/index.js.map +3 -3
  33. package/dist/types/chainflip/broker.d.ts +20 -0
  34. package/dist/types/chainflip/broker.d.ts.map +1 -0
  35. package/{src/chainflip/index.ts → dist/types/chainflip/index.d.ts} +1 -0
  36. package/dist/types/chainflip/index.d.ts.map +1 -0
  37. package/dist/types/chainflip/plugin.d.ts +10 -0
  38. package/dist/types/chainflip/plugin.d.ts.map +1 -0
  39. package/dist/types/chainflip/types.d.ts +41 -0
  40. package/dist/types/chainflip/types.d.ts.map +1 -0
  41. package/dist/types/evm/index.d.ts +19 -0
  42. package/dist/types/evm/index.d.ts.map +1 -0
  43. package/{src/index.ts → dist/types/index.d.ts} +1 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/{src/near/index.ts → dist/types/near/index.d.ts} +1 -0
  46. package/dist/types/near/index.d.ts.map +1 -0
  47. package/dist/types/near/nearNames.d.ts +3 -0
  48. package/dist/types/near/nearNames.d.ts.map +1 -0
  49. package/dist/types/near/plugin.d.ts +19 -0
  50. package/dist/types/near/plugin.d.ts.map +1 -0
  51. package/dist/types/near/types.d.ts +11 -0
  52. package/dist/types/near/types.d.ts.map +1 -0
  53. package/dist/types/radix/index.d.ts +10 -0
  54. package/dist/types/radix/index.d.ts.map +1 -0
  55. package/{src/solana/index.ts → dist/types/solana/index.d.ts} +1 -0
  56. package/dist/types/solana/index.d.ts.map +1 -0
  57. package/dist/types/solana/plugin.d.ts +10 -0
  58. package/dist/types/solana/plugin.d.ts.map +1 -0
  59. package/{src/thorchain/index.ts → dist/types/thorchain/index.d.ts} +1 -0
  60. package/dist/types/thorchain/index.d.ts.map +1 -0
  61. package/dist/types/thorchain/plugin.d.ts +107 -0
  62. package/dist/types/thorchain/plugin.d.ts.map +1 -0
  63. package/dist/types/thorchain/shared.d.ts +21 -0
  64. package/dist/types/thorchain/shared.d.ts.map +1 -0
  65. package/dist/types/thorchain/types.d.ts +64 -0
  66. package/dist/types/thorchain/types.d.ts.map +1 -0
  67. package/{src/types.ts → dist/types/types.d.ts} +7 -9
  68. package/dist/types/types.d.ts.map +1 -0
  69. package/dist/types/utils.d.ts +11 -0
  70. package/dist/types/utils.d.ts.map +1 -0
  71. package/package.json +12 -15
  72. package/dist/chunk-fazw0jvt.js +0 -4
  73. package/dist/chunk-fazw0jvt.js.map +0 -9
  74. package/dist/chunk-wfktpptf.js +0 -5
  75. package/dist/chunk-wfktpptf.js.map +0 -9
  76. package/src/chainflip/broker.ts +0 -127
  77. package/src/chainflip/plugin.ts +0 -73
  78. package/src/chainflip/types.ts +0 -48
  79. package/src/evm/index.ts +0 -82
  80. package/src/near/nearNames.ts +0 -37
  81. package/src/near/plugin.ts +0 -192
  82. package/src/near/types.ts +0 -11
  83. package/src/radix/index.ts +0 -36
  84. package/src/solana/plugin.ts +0 -36
  85. package/src/thorchain/plugin.ts +0 -528
  86. package/src/thorchain/shared.ts +0 -17
  87. package/src/thorchain/types.ts +0 -66
  88. package/src/utils.ts +0 -34
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/near/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAEZ,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,kBAAkB,EAAc,MAAM,sBAAsB,CAAC;AAI3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D,eAAO,MAAM,UAAU;;;;yBAMI,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC;;0BAuCvC,MAAM;8BA6BF,MAAM;0BAKV,MAAM;mCA6BG,MAAM;6BAuBZ,0BAA0B;2BAyBlC,MAAM,YAAY,MAAM;;;CAqB3C,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type NearNameInfo = {
2
+ owner: string;
3
+ price?: string;
4
+ expiresAt?: string;
5
+ registeredAt?: string;
6
+ };
7
+ export type NearNameRegistrationParams = {
8
+ name: string;
9
+ publicKey?: string;
10
+ };
11
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/near/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ProviderName, type SwapParams } from "@swapkit/helpers";
2
+ import type { QuoteResponseRoute } from "@swapkit/helpers/api";
3
+ export declare const RadixPlugin: {
4
+ radix: (pluginParams: import("..").SwapKitPluginParams) => {
5
+ supportedSwapkitProviders: ProviderName[];
6
+ } & {
7
+ swap: ({ route: { tx, sellAmount, sellAsset }, }: SwapParams<"radix", QuoteResponseRoute>) => Promise<string>;
8
+ };
9
+ };
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/radix/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,eAAO,MAAM,WAAW;;;;0DAMjB,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC;;CAmB5C,CAAC"}
@@ -1 +1,2 @@
1
1
  export { SolanaPlugin } from "./plugin";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/solana/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ProviderName, type SwapParams } from "@swapkit/helpers";
2
+ import type { QuoteResponseRoute } from "@swapkit/helpers/api";
3
+ export declare const SolanaPlugin: {
4
+ solana: (pluginParams: import("..").SwapKitPluginParams) => {
5
+ supportedSwapkitProviders: ProviderName[];
6
+ } & {
7
+ swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<string>;
8
+ };
9
+ };
10
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/solana/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,YAAY,EAAgB,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,eAAO,MAAM,YAAY;;;;0BAMsB,UAAU,CAAC,QAAQ,EAAE,kBAAkB,CAAC;;CAmBrF,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { ThorchainPlugin, MayachainPlugin } from "./plugin";
2
2
  export { validateAddressType } from "./shared";
3
3
  export * from "./types";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/thorchain/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,cAAc,SAAS,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { AssetValue, Chain, FeeOption, ProviderName, type SwapParams } from "@swapkit/helpers";
2
+ import { type InboundAddressesItem, type QuoteResponseRoute } from "@swapkit/helpers/api";
3
+ import type { SwapKitPluginParams } from "../types";
4
+ import type { AddLiquidityParams, AddLiquidityPartParams, CoreTxParams, CreateLiquidityParams, NodeActionParams, RegisterThornameParams, WithdrawParams } from "./types";
5
+ export declare const ThorchainPlugin: {
6
+ thorchain: (pluginParams: SwapKitPluginParams) => {
7
+ supportedSwapkitProviders: ProviderName[];
8
+ } & {
9
+ addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
10
+ baseAssetTx: string | undefined;
11
+ assetTx: string | undefined;
12
+ }>;
13
+ addLiquidityPart: ({ assetValue, poolAddress, address, symmetric, }: AddLiquidityPartParams) => Promise<string>;
14
+ approveAssetValue: ({ assetValue }: {
15
+ assetValue: AssetValue;
16
+ }) => Promise<string | boolean | Promise<string>>;
17
+ createLiquidity: ({ baseAssetValue, assetValue }: CreateLiquidityParams) => Promise<{
18
+ baseAssetTx: string | undefined;
19
+ assetTx: string | undefined;
20
+ }>;
21
+ deposit: ({ assetValue, recipient, router, ...rest }: CoreTxParams & {
22
+ router?: string;
23
+ }) => Promise<string>;
24
+ depositToPool: ({ assetValue, memo, feeOptionKey, }: {
25
+ assetValue: AssetValue;
26
+ memo: string;
27
+ feeOptionKey?: FeeOption;
28
+ }) => Promise<string>;
29
+ getInboundDataByChain: <T extends Chain>(chain: T) => Promise<InboundAddressesItem>;
30
+ isAssetValueApproved: ({ assetValue }: {
31
+ assetValue: AssetValue;
32
+ }) => Promise<string | boolean | Promise<boolean>>;
33
+ nodeAction: ({ type, assetValue, address }: NodeActionParams) => Promise<string>;
34
+ registerName: ({ assetValue, ...params }: RegisterThornameParams) => Promise<string>;
35
+ registerPreferredAsset: ({ assetValue, payoutAddress, name, ownerAddress, }: {
36
+ assetValue: AssetValue;
37
+ payoutAddress?: string;
38
+ name: string;
39
+ ownerAddress: string;
40
+ }) => Promise<string>;
41
+ claimTcy: ({ chain, thorAddress }: {
42
+ chain: Chain;
43
+ thorAddress: string;
44
+ }) => Promise<string>;
45
+ stakeTcyAction: (params: {
46
+ type: "unstake";
47
+ unstakeBps: number;
48
+ } | {
49
+ type: "stake";
50
+ assetValue: AssetValue;
51
+ }) => Promise<string>;
52
+ swap: ({ feeOptionKey, route, }: SwapParams<"thorchain" | "mayachain", QuoteResponseRoute>) => Promise<string>;
53
+ withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<string>;
54
+ };
55
+ };
56
+ export declare const MayachainPlugin: {
57
+ mayachain: (pluginParams: SwapKitPluginParams) => {
58
+ supportedSwapkitProviders: ProviderName[];
59
+ } & {
60
+ addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
61
+ baseAssetTx: string | undefined;
62
+ assetTx: string | undefined;
63
+ }>;
64
+ addLiquidityPart: ({ assetValue, poolAddress, address, symmetric, }: AddLiquidityPartParams) => Promise<string>;
65
+ approveAssetValue: ({ assetValue }: {
66
+ assetValue: AssetValue;
67
+ }) => Promise<string | boolean | Promise<string>>;
68
+ createLiquidity: ({ baseAssetValue, assetValue }: CreateLiquidityParams) => Promise<{
69
+ baseAssetTx: string | undefined;
70
+ assetTx: string | undefined;
71
+ }>;
72
+ deposit: ({ assetValue, recipient, router, ...rest }: CoreTxParams & {
73
+ router?: string;
74
+ }) => Promise<string>;
75
+ depositToPool: ({ assetValue, memo, feeOptionKey, }: {
76
+ assetValue: AssetValue;
77
+ memo: string;
78
+ feeOptionKey?: FeeOption;
79
+ }) => Promise<string>;
80
+ getInboundDataByChain: <T extends Chain>(chain: T) => Promise<InboundAddressesItem>;
81
+ isAssetValueApproved: ({ assetValue }: {
82
+ assetValue: AssetValue;
83
+ }) => Promise<string | boolean | Promise<boolean>>;
84
+ nodeAction: ({ type, assetValue, address }: NodeActionParams) => Promise<string>;
85
+ registerName: ({ assetValue, ...params }: RegisterThornameParams) => Promise<string>;
86
+ registerPreferredAsset: ({ assetValue, payoutAddress, name, ownerAddress, }: {
87
+ assetValue: AssetValue;
88
+ payoutAddress?: string;
89
+ name: string;
90
+ ownerAddress: string;
91
+ }) => Promise<string>;
92
+ claimTcy: ({ chain, thorAddress }: {
93
+ chain: Chain;
94
+ thorAddress: string;
95
+ }) => Promise<string>;
96
+ stakeTcyAction: (params: {
97
+ type: "unstake";
98
+ unstakeBps: number;
99
+ } | {
100
+ type: "stake";
101
+ assetValue: AssetValue;
102
+ }) => Promise<string>;
103
+ swap: ({ feeOptionKey, route, }: SwapParams<"thorchain" | "mayachain", QuoteResponseRoute>) => Promise<string>;
104
+ withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<string>;
105
+ };
106
+ };
107
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/thorchain/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEV,KAAK,EAKL,SAAS,EAET,YAAY,EAEZ,KAAK,UAAU,EAWhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAGxB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAGpD,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACf,MAAM,SAAS,CAAC;AAoBjB,eAAO,MAAM,eAAe;;;;4GAuSrB,kBAAkB;;;;6EArBlB,sBAAsB;;wBAlFgC,UAAU;;0DAoDJ,qBAAqB;;;;;qBAzJvD,MAAM;;;wBAqFlB,UAAU;kBAAQ,MAAM;2BAAiB,SAAS;;gCA/JzB,CAAC,SAAS,KAAK,SAAS,CAAC;;wBAmLP,UAAU;;oDAqCnB,gBAAgB;kDAjClB,sBAAsB;;wBAUzD,UAAU;4BACN,MAAM;kBAChB,MAAM;0BACE,MAAM;;;mBAkJmC,KAAK;yBAAe,MAAM;;;kBAiBjE,SAAS;wBAAc,MAAM;;kBAAa,OAAO;wBAAc,UAAU;;yCA4BxF,UAAU,4BAAoB,kBAAkB,CAAC;4DAnEO,cAAc;;CA3U3E,CAAC;AAEH,eAAO,MAAM,eAAe;;;;4GA+RrB,kBAAkB;;;;6EArBlB,sBAAsB;;wBAlFgC,UAAU;;0DAoDJ,qBAAqB;;;;;qBAzJvD,MAAM;;;wBAqFlB,UAAU;kBAAQ,MAAM;2BAAiB,SAAS;;gCA/JzB,CAAC,SAAS,KAAK,SAAS,CAAC;;wBAmLP,UAAU;;oDAqCnB,gBAAgB;kDAjClB,sBAAsB;;wBAUzD,UAAU;4BACN,MAAM;kBAChB,MAAM;0BACE,MAAM;;;mBAkJmC,KAAK;yBAAe,MAAM;;;kBAiBjE,SAAS;wBAAc,MAAM;;kBAAa,OAAO;wBAAc,UAAU;;yCA4BxF,UAAU,4BAAoB,kBAAkB,CAAC;4DAnEO,cAAc;;CAnU3E,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Chain } from "@swapkit/helpers";
2
+ import type { CoreTxParams } from "./types";
3
+ export declare function validateAddressType({ chain, address }: {
4
+ chain?: Chain;
5
+ address?: string;
6
+ }): boolean;
7
+ export declare function prepareTxParams({ assetValue, from, memo, ...restTxParams }: CoreTxParams & {
8
+ from: string;
9
+ router?: string;
10
+ }): {
11
+ memo: string;
12
+ from: string;
13
+ assetValue: import("@swapkit/helpers").AssetValue;
14
+ recipient: string;
15
+ feeOptionKey?: import("@swapkit/helpers").FeeOption;
16
+ feeRate?: number;
17
+ data?: string;
18
+ expiration?: number;
19
+ router?: string;
20
+ };
21
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/thorchain/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,WAI1F;AAED,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,IAAI,EACJ,IAAS,EACT,GAAG,YAAY,EAChB,EAAE,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;;;;;aAAR,MAAM;EAEhD"}
@@ -0,0 +1,64 @@
1
+ import type { AssetValue, FeeOption, MemoType } from "@swapkit/helpers";
2
+ export type AddLiquidityPartParams = {
3
+ assetValue: AssetValue;
4
+ address?: string;
5
+ poolAddress: string;
6
+ symmetric: boolean;
7
+ };
8
+ export type AddLiquidityParams = {
9
+ assetAddr?: string;
10
+ assetValue: AssetValue;
11
+ baseAssetAddr?: string;
12
+ baseAssetValue: AssetValue;
13
+ isPendingSymmAsset?: boolean;
14
+ mode?: "sym" | "baseAsset" | "asset";
15
+ };
16
+ export type CreateLiquidityParams = {
17
+ baseAssetValue: AssetValue;
18
+ assetValue: AssetValue;
19
+ };
20
+ export type CoreTxParams = {
21
+ assetValue: AssetValue;
22
+ recipient: string;
23
+ memo?: string;
24
+ feeOptionKey?: FeeOption;
25
+ feeRate?: number;
26
+ data?: string;
27
+ from?: string;
28
+ expiration?: number;
29
+ };
30
+ export type NodeActionParams = {
31
+ address: string;
32
+ } & ({
33
+ type: MemoType.BOND | MemoType.UNBOND;
34
+ assetValue: AssetValue;
35
+ } | {
36
+ type: MemoType.LEAVE;
37
+ assetValue?: undefined;
38
+ });
39
+ export type RegisterThornameParams = {
40
+ assetValue: AssetValue;
41
+ name: string;
42
+ chain: string;
43
+ address: string;
44
+ owner?: string;
45
+ preferredAsset?: string;
46
+ };
47
+ export type RegisterPreferredAssetParams = {
48
+ assetValue: AssetValue;
49
+ name: string;
50
+ chain: string;
51
+ address: string;
52
+ owner: string;
53
+ };
54
+ type CommonWithdrawParams = {
55
+ assetValue: AssetValue;
56
+ memo?: string;
57
+ percent: number;
58
+ };
59
+ export type WithdrawParams = CommonWithdrawParams & {
60
+ from: "sym" | "baseAsset" | "asset";
61
+ to: "sym" | "baseAsset" | "asset";
62
+ };
63
+ export {};
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/thorchain/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,UAAU,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,IAAI,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,OAAO,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,cAAc,EAAE,UAAU,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,CACjD;IAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,CAAA;CAAE,CACnD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,IAAI,EAAE,KAAK,GAAG,WAAW,GAAG,OAAO,CAAC;IACpC,EAAE,EAAE,KAAK,GAAG,WAAW,GAAG,OAAO,CAAC;CACnC,CAAC"}
@@ -1,18 +1,16 @@
1
+ import type { CryptoChain } from "@swapkit/helpers";
2
+ import type { FullWallet } from "@swapkit/toolboxes";
1
3
  import type { ChainflipPlugin } from "./chainflip";
2
4
  import type { EVMPlugin } from "./evm";
3
5
  import type { NearPlugin } from "./near";
4
6
  import type { RadixPlugin } from "./radix";
5
7
  import type { SolanaPlugin } from "./solana/plugin";
6
8
  import type { ThorchainPlugin } from "./thorchain";
7
-
8
9
  export type * from "./chainflip/types";
9
10
  export type * from "./thorchain/types";
10
-
11
- export type SKPlugins = typeof ChainflipPlugin &
12
- typeof ThorchainPlugin &
13
- typeof RadixPlugin &
14
- typeof SolanaPlugin &
15
- typeof EVMPlugin &
16
- typeof NearPlugin;
17
-
11
+ export type SKPlugins = typeof ChainflipPlugin & typeof ThorchainPlugin & typeof RadixPlugin & typeof SolanaPlugin & typeof EVMPlugin & typeof NearPlugin;
18
12
  export type PluginName = keyof SKPlugins;
13
+ export type SwapKitPluginParams = {
14
+ getWallet: <T extends CryptoChain>(chain: T) => FullWallet[T];
15
+ };
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,mBAAmB,mBAAmB,CAAC;AACvC,mBAAmB,mBAAmB,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG,OAAO,eAAe,GAC5C,OAAO,eAAe,GACtB,OAAO,WAAW,GAClB,OAAO,YAAY,GACnB,OAAO,SAAS,GAChB,OAAO,UAAU,CAAC;AAEpB,MAAM,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,CAAC,CAAC,SAAS,WAAW,EAAE,KAAK,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;CAC/D,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { ProviderName } from "@swapkit/helpers";
2
+ import type { PluginName, SKPlugins, SwapKitPluginParams } from "./types";
3
+ export declare function createPlugin<const Name extends string, T extends (params: SwapKitPluginParams) => Record<string, unknown>, K extends {
4
+ supportedSwapkitProviders?: (ProviderName | string)[];
5
+ }>({ name, properties, methods }: {
6
+ name: Name;
7
+ properties?: K;
8
+ methods: T;
9
+ }): { [key in Name]: (pluginParams: SwapKitPluginParams) => K & ReturnType<T>; };
10
+ export declare function loadPlugin<P extends PluginName>(pluginName: P): Promise<SKPlugins[P]>;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE1E,wBAAgB,YAAY,CAC1B,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,CAAC,SAAS,CAAC,MAAM,EAAE,mBAAmB,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,CAAC,SAAS;IAAE,yBAAyB,CAAC,EAAE,CAAC,YAAY,GAAG,MAAM,CAAC,EAAE,CAAA;CAAE,EACnE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,GAK5C,GAAG,GAAG,IAAI,IAAI,kBAJb,mBAAmB,KACO,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,GAGZ,CAC9D;AAED,wBAAsB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,yBA+BnE"}
package/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "@polkadot/keyring": "~13.5.0",
5
5
  "@polkadot/util": "~13.5.0",
6
6
  "@solana/web3.js": "~1.98.0",
7
- "@swapkit/helpers": "4.0.0-beta.32",
8
- "@swapkit/toolboxes": "4.0.0-beta.49",
7
+ "@swapkit/helpers": "4.0.0-beta.34",
8
+ "@swapkit/toolboxes": "4.0.0-beta.51",
9
9
  "ts-pattern": "~5.7.0"
10
10
  },
11
11
  "devDependencies": {
@@ -19,43 +19,40 @@
19
19
  ".": {
20
20
  "default": "./dist/index.js",
21
21
  "require": "./dist/index.cjs",
22
- "types": "./src/index.ts"
22
+ "types": "./dist/types/index.d.ts"
23
23
  },
24
24
  "./chainflip": {
25
25
  "default": "./dist/chainflip/index.js",
26
26
  "require": "./dist/chainflip/index.cjs",
27
- "types": "./src/chainflip/index.ts"
27
+ "types": "./dist/types/chainflip/index.d.ts"
28
28
  },
29
29
  "./evm": {
30
30
  "default": "./dist/evm/index.js",
31
31
  "require": "./dist/evm/index.cjs",
32
- "types": "./src/evm/index.ts"
32
+ "types": "./dist/types/evm/index.d.ts"
33
33
  },
34
34
  "./near": {
35
35
  "default": "./dist/near/index.js",
36
36
  "require": "./dist/near/index.cjs",
37
- "types": "./src/near/index.ts"
37
+ "types": "./dist/types/near/index.d.ts"
38
38
  },
39
39
  "./radix": {
40
40
  "default": "./dist/radix/index.js",
41
41
  "require": "./dist/radix/index.cjs",
42
- "types": "./src/radix/index.ts"
42
+ "types": "./dist/types/radix/index.d.ts"
43
43
  },
44
44
  "./solana": {
45
45
  "default": "./dist/solana/index.js",
46
46
  "require": "./dist/solana/index.cjs",
47
- "types": "./src/solana/index.ts"
47
+ "types": "./dist/types/solana/index.d.ts"
48
48
  },
49
49
  "./thorchain": {
50
50
  "default": "./dist/thorchain/index.js",
51
51
  "require": "./dist/thorchain/index.cjs",
52
- "types": "./src/thorchain/index.ts"
52
+ "types": "./dist/types/thorchain/index.d.ts"
53
53
  }
54
54
  },
55
- "files": [
56
- "src/",
57
- "dist/"
58
- ],
55
+ "files": ["dist/"],
59
56
  "homepage": "https://github.com/swapkit/SwapKit",
60
57
  "license": "Apache-2.0",
61
58
  "name": "@swapkit/plugins",
@@ -72,5 +69,5 @@
72
69
  "type-check:go": "tsgo"
73
70
  },
74
71
  "type": "module",
75
- "version": "4.0.0-beta.49"
76
- }
72
+ "version": "4.0.0-beta.51"
73
+ }
@@ -1,4 +0,0 @@
1
- var j=Object.create;var{getPrototypeOf:k,defineProperty:e,getOwnPropertyNames:h,getOwnPropertyDescriptor:l}=Object,i=Object.prototype.hasOwnProperty;var m=(a,b,c)=>{c=a!=null?j(k(a)):{};let d=b||!a||!a.__esModule?e(c,"default",{value:a,enumerable:!0}):c;for(let f of h(a))if(!i.call(d,f))e(d,f,{get:()=>a[f],enumerable:!0});return d},g=new WeakMap,n=(a)=>{var b=g.get(a),c;if(b)return b;if(b=e({},"__esModule",{value:!0}),a&&typeof a==="object"||typeof a==="function")h(a).map((d)=>!i.call(b,d)&&e(b,d,{get:()=>a[d],enumerable:!(c=l(a,d))||c.enumerable}));return g.set(a,b),b};var o=(a,b)=>{for(var c in b)e(a,c,{get:b[c],enumerable:!0,configurable:!0,set:(d)=>b[c]=()=>d})};
2
-
3
- //# debugId=9E860276D712218864756E2164756E21
4
- //# sourceMappingURL=chunk-fazw0jvt.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "9E860276D712218864756E2164756E21",
8
- "names": []
9
- }
@@ -1,5 +0,0 @@
1
- var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,c,b)=>{b=a!=null?g(h(a)):{};let d=c||!a||!a.__esModule?f(b,"default",{value:a,enumerable:!0}):b;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=((a)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(a,{get:(c,b)=>(typeof require!=="undefined"?require:c)[b]}):a)(function(a){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
2
- export{k as a,l as b};
3
-
4
- //# debugId=5A093E2BA710099564756E2164756E21
5
- //# sourceMappingURL=chunk-wfktpptf.js.map
@@ -1,9 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [
5
- ],
6
- "mappings": "",
7
- "debugId": "5A093E2BA710099564756E2164756E21",
8
- "names": []
9
- }
@@ -1,127 +0,0 @@
1
- import { decodeAddress } from "@polkadot/keyring";
2
- import { isHex, u8aToHex } from "@polkadot/util";
3
- import { AssetValue, Chain, SwapKitError, wrapWithThrow } from "@swapkit/helpers";
4
- import type { getEvmToolbox } from "@swapkit/toolboxes/evm";
5
- import type { getSubstrateToolbox } from "@swapkit/toolboxes/substrate";
6
-
7
- import type { WithdrawFeeResponse } from "./types";
8
-
9
- type ChainflipToolbox = Awaited<ReturnType<typeof getSubstrateToolbox<Chain.Chainflip>>>;
10
-
11
- export const assetIdentifierToChainflipTicker = new Map<string, string>([
12
- ["ARB.ETH", "ArbEth"],
13
- ["ARB.USDC-0XAF88D065E77C8CC2239327C5EDB3A432268E5831", "ArbUsdc"],
14
- ["BTC.BTC", "Btc"],
15
- ["DOT.DOT", "Dot"],
16
- ["ETH.ETH", "Eth"],
17
- ["ETH.FLIP-0X826180541412D574CF1336D22C0C0A287822678A", "Flip"],
18
- ["ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48", "Usdc"],
19
- ["ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7", "Usdt"],
20
- ["SOL.SOL", "Sol"],
21
- ["SOL.USDC-EPJFWDD5AUFQSSQEM2QN1XZYBAPC8G4WEGGKZWYTDT1V", "SolUsdc"],
22
- ]);
23
-
24
- const registerAsBroker = (toolbox: ChainflipToolbox) => () => {
25
- const extrinsic = toolbox.api.tx.swapping?.registerAsBroker?.();
26
-
27
- if (!extrinsic) {
28
- throw new SwapKitError("chainflip_broker_register");
29
- }
30
-
31
- return toolbox.signAndBroadcast({ tx: extrinsic, address: toolbox.getAddress() });
32
- };
33
-
34
- const withdrawFee =
35
- (toolbox: ChainflipToolbox) =>
36
- ({ feeAsset, recipient }: { feeAsset: AssetValue; recipient: string }) => {
37
- const isFeeChainPolkadot = feeAsset.chain === Chain.Polkadot;
38
-
39
- const recipientAddress = wrapWithThrow(() => {
40
- return isFeeChainPolkadot
41
- ? toolbox.encodeAddress(toolbox.decodeAddress(recipient), "hex")
42
- : recipient;
43
- }, "chainflip_broker_recipient_error");
44
-
45
- return new Promise<WithdrawFeeResponse>((resolve) => {
46
- const extrinsic = toolbox.api.tx?.swapping?.withdraw?.(feeAsset.ticker.toLowerCase(), {
47
- [feeAsset.chain.toLowerCase()]: recipientAddress,
48
- });
49
-
50
- if (!extrinsic) {
51
- throw new SwapKitError("chainflip_broker_withdraw");
52
- }
53
-
54
- toolbox.signAndBroadcast({
55
- tx: extrinsic,
56
- callback: async (result) => {
57
- if (!result.status?.isFinalized) {
58
- return;
59
- }
60
-
61
- const withdrawEvent = result.events.find(
62
- (event) => event.event.method === "WithdrawalRequested",
63
- );
64
-
65
- if (!withdrawEvent) {
66
- throw new SwapKitError(
67
- "chainflip_channel_error",
68
- "Could not find 'WithdrawalRequested' event",
69
- );
70
- }
71
- const {
72
- event: {
73
- data: { egressId, egressAsset, egressAmount, egressFee, destinationAddress },
74
- },
75
- } = withdrawEvent.toHuman() as any;
76
- resolve({
77
- egressId,
78
- egressAsset,
79
- egressAmount,
80
- egressFee,
81
- destinationAddress,
82
- });
83
- },
84
- });
85
- });
86
- };
87
-
88
- const fundStateChainAccount =
89
- (chainflipToolbox: ChainflipToolbox) =>
90
- async ({
91
- evmToolbox,
92
- stateChainAccount,
93
- assetValue,
94
- }: {
95
- evmToolbox: Awaited<ReturnType<typeof getEvmToolbox>>;
96
- stateChainAccount: string;
97
- assetValue: AssetValue;
98
- }) => {
99
- const { chainflipGateway } = await import("@swapkit/helpers/contracts");
100
-
101
- const flipAssetValue = AssetValue.from({ asset: "ETH.FLIP" });
102
-
103
- if (!assetValue.eqAsset(flipAssetValue)) {
104
- throw new SwapKitError("chainflip_broker_fund_only_flip_supported");
105
- }
106
-
107
- if (!chainflipToolbox.validateAddress(stateChainAccount)) {
108
- throw new SwapKitError("chainflip_broker_fund_invalid_address");
109
- }
110
-
111
- const hexAddress = isHex(stateChainAccount)
112
- ? stateChainAccount
113
- : u8aToHex(decodeAddress(stateChainAccount));
114
-
115
- return evmToolbox.call<string>({
116
- abi: chainflipGateway,
117
- contractAddress: "0x6995ab7c4d7f4b03f467cf4c8e920427d9621dbd",
118
- funcName: "fundStateChainAccount",
119
- funcParams: [hexAddress, assetValue.getBaseValue("string")],
120
- });
121
- };
122
-
123
- export const ChainflipBroker = (chainflipToolbox: ChainflipToolbox) => ({
124
- registerAsBroker: registerAsBroker(chainflipToolbox),
125
- fundStateChainAccount: fundStateChainAccount(chainflipToolbox),
126
- withdrawFee: withdrawFee(chainflipToolbox),
127
- });
@@ -1,73 +0,0 @@
1
- import {
2
- AssetValue,
3
- type CryptoChain,
4
- ProviderName,
5
- SKConfig,
6
- SwapKitError,
7
- createPlugin,
8
- } from "@swapkit/helpers";
9
- import { SwapKitApi } from "@swapkit/helpers/api";
10
- import type { RequestSwapDepositAddressParams } from "./types";
11
-
12
- export const ChainflipPlugin = createPlugin({
13
- name: "chainflip",
14
- methods: ({ getWallet }) => ({
15
- swap: async function chainflipSwap(swapParams: RequestSwapDepositAddressParams) {
16
- const brokerUrl = SKConfig.get("integrations").chainflip?.brokerUrl;
17
-
18
- if (!(swapParams?.route?.buyAsset && brokerUrl && swapParams.route.meta.chainflip)) {
19
- throw new SwapKitError("core_swap_invalid_params", {
20
- ...swapParams,
21
- chainflipBrokerUrl: brokerUrl,
22
- });
23
- }
24
-
25
- const {
26
- route: {
27
- buyAsset: buyAssetString,
28
- sellAsset: sellAssetString,
29
- sellAmount,
30
- destinationAddress: recipient,
31
- meta: { chainflip },
32
- },
33
- maxBoostFeeBps = 0,
34
- } = swapParams;
35
-
36
- if (!(sellAssetString && buyAssetString)) {
37
- throw new SwapKitError("core_swap_asset_not_recognized");
38
- }
39
-
40
- const sellAsset = await AssetValue.from({
41
- asyncTokenLookup: true,
42
- asset: sellAssetString,
43
- value: sellAmount,
44
- });
45
-
46
- const wallet = getWallet(sellAsset.chain as CryptoChain);
47
-
48
- if (!wallet) {
49
- throw new SwapKitError("core_wallet_connection_not_found");
50
- }
51
-
52
- const { depositAddress } = await SwapKitApi.getChainflipDepositChannel({
53
- ...chainflip,
54
- destinationAddress: recipient || chainflip.destinationAddress,
55
- maxBoostFeeBps: maxBoostFeeBps || chainflip.maxBoostFeeBps,
56
- });
57
-
58
- // @ts-expect-error TODO: right now it's inferred from toolboxes
59
- // we need to simplify this to one object params
60
- const tx = await wallet.transfer({
61
- assetValue: sellAsset,
62
- sender: wallet.address,
63
- recipient: depositAddress,
64
- isProgramDerivedAddress: true,
65
- });
66
-
67
- return tx as string;
68
- },
69
- }),
70
- properties: {
71
- supportedSwapkitProviders: [ProviderName.CHAINFLIP, ProviderName.CHAINFLIP_STREAMING],
72
- },
73
- });