@vetro-protocol/gateway 1.0.0-beta

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 (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -0
  3. package/_esm/abi/gatewayAbi.js +185 -0
  4. package/_esm/abi/gatewayAbi.js.map +1 -0
  5. package/_esm/actions/index.js +18 -0
  6. package/_esm/actions/index.js.map +1 -0
  7. package/_esm/actions/public/getMaxWithdraw.js +28 -0
  8. package/_esm/actions/public/getMaxWithdraw.js.map +1 -0
  9. package/_esm/actions/public/getMintFee.js +28 -0
  10. package/_esm/actions/public/getMintFee.js.map +1 -0
  11. package/_esm/actions/public/getPeggedToken.js +23 -0
  12. package/_esm/actions/public/getPeggedToken.js.map +1 -0
  13. package/_esm/actions/public/getRedeemFee.js +28 -0
  14. package/_esm/actions/public/getRedeemFee.js.map +1 -0
  15. package/_esm/actions/public/getRedeemRequest.js +28 -0
  16. package/_esm/actions/public/getRedeemRequest.js.map +1 -0
  17. package/_esm/actions/public/getTreasury.js +23 -0
  18. package/_esm/actions/public/getTreasury.js.map +1 -0
  19. package/_esm/actions/public/getWithdrawalDelay.js +23 -0
  20. package/_esm/actions/public/getWithdrawalDelay.js.map +1 -0
  21. package/_esm/actions/public/getWithdrawalDelayEnabled.js +23 -0
  22. package/_esm/actions/public/getWithdrawalDelayEnabled.js.map +1 -0
  23. package/_esm/actions/public/index.js +12 -0
  24. package/_esm/actions/public/index.js.map +1 -0
  25. package/_esm/actions/public/isInstantRedeemWhitelisted.js +28 -0
  26. package/_esm/actions/public/isInstantRedeemWhitelisted.js.map +1 -0
  27. package/_esm/actions/public/previewDeposit.js +35 -0
  28. package/_esm/actions/public/previewDeposit.js.map +1 -0
  29. package/_esm/actions/public/previewRedeem.js +35 -0
  30. package/_esm/actions/public/previewRedeem.js.map +1 -0
  31. package/_esm/actions/wallet/cancelRedeemRequest.js +89 -0
  32. package/_esm/actions/wallet/cancelRedeemRequest.js.map +1 -0
  33. package/_esm/actions/wallet/deposit.js +193 -0
  34. package/_esm/actions/wallet/deposit.js.map +1 -0
  35. package/_esm/actions/wallet/redeem.js +226 -0
  36. package/_esm/actions/wallet/redeem.js.map +1 -0
  37. package/_esm/actions/wallet/requestRedeem.js +153 -0
  38. package/_esm/actions/wallet/requestRedeem.js.map +1 -0
  39. package/_esm/gatewayAddresses.js +18 -0
  40. package/_esm/gatewayAddresses.js.map +1 -0
  41. package/_esm/index.js +30 -0
  42. package/_esm/index.js.map +1 -0
  43. package/_esm/types.js +2 -0
  44. package/_esm/types.js.map +1 -0
  45. package/_esm/utils/isAddressValid.js +3 -0
  46. package/_esm/utils/isAddressValid.js.map +1 -0
  47. package/_types/abi/gatewayAbi.d.ts +252 -0
  48. package/_types/abi/gatewayAbi.d.ts.map +1 -0
  49. package/_types/actions/index.d.ts +16 -0
  50. package/_types/actions/index.d.ts.map +1 -0
  51. package/_types/actions/public/getMaxWithdraw.d.ts +6 -0
  52. package/_types/actions/public/getMaxWithdraw.d.ts.map +1 -0
  53. package/_types/actions/public/getMintFee.d.ts +6 -0
  54. package/_types/actions/public/getMintFee.d.ts.map +1 -0
  55. package/_types/actions/public/getPeggedToken.d.ts +5 -0
  56. package/_types/actions/public/getPeggedToken.d.ts.map +1 -0
  57. package/_types/actions/public/getRedeemFee.d.ts +6 -0
  58. package/_types/actions/public/getRedeemFee.d.ts.map +1 -0
  59. package/_types/actions/public/getRedeemRequest.d.ts +6 -0
  60. package/_types/actions/public/getRedeemRequest.d.ts.map +1 -0
  61. package/_types/actions/public/getTreasury.d.ts +5 -0
  62. package/_types/actions/public/getTreasury.d.ts.map +1 -0
  63. package/_types/actions/public/getWithdrawalDelay.d.ts +5 -0
  64. package/_types/actions/public/getWithdrawalDelay.d.ts.map +1 -0
  65. package/_types/actions/public/getWithdrawalDelayEnabled.d.ts +5 -0
  66. package/_types/actions/public/getWithdrawalDelayEnabled.d.ts.map +1 -0
  67. package/_types/actions/public/index.d.ts +12 -0
  68. package/_types/actions/public/index.d.ts.map +1 -0
  69. package/_types/actions/public/isInstantRedeemWhitelisted.d.ts +6 -0
  70. package/_types/actions/public/isInstantRedeemWhitelisted.d.ts.map +1 -0
  71. package/_types/actions/public/previewDeposit.d.ts +7 -0
  72. package/_types/actions/public/previewDeposit.d.ts.map +1 -0
  73. package/_types/actions/public/previewRedeem.d.ts +7 -0
  74. package/_types/actions/public/previewRedeem.d.ts.map +1 -0
  75. package/_types/actions/wallet/cancelRedeemRequest.d.ts +14 -0
  76. package/_types/actions/wallet/cancelRedeemRequest.d.ts.map +1 -0
  77. package/_types/actions/wallet/deposit.d.ts +19 -0
  78. package/_types/actions/wallet/deposit.d.ts.map +1 -0
  79. package/_types/actions/wallet/redeem.d.ts +24 -0
  80. package/_types/actions/wallet/redeem.d.ts.map +1 -0
  81. package/_types/actions/wallet/requestRedeem.d.ts +18 -0
  82. package/_types/actions/wallet/requestRedeem.d.ts.map +1 -0
  83. package/_types/gatewayAddresses.d.ts +8 -0
  84. package/_types/gatewayAddresses.d.ts.map +1 -0
  85. package/_types/index.d.ts +42 -0
  86. package/_types/index.d.ts.map +1 -0
  87. package/_types/types.d.ts +53 -0
  88. package/_types/types.d.ts.map +1 -0
  89. package/_types/utils/isAddressValid.d.ts +3 -0
  90. package/_types/utils/isAddressValid.d.ts.map +1 -0
  91. package/package.json +59 -0
  92. package/src/abi/gatewayAbi.ts +184 -0
  93. package/src/actions/index.ts +18 -0
  94. package/src/actions/public/getMaxWithdraw.ts +40 -0
  95. package/src/actions/public/getMintFee.ts +40 -0
  96. package/src/actions/public/getPeggedToken.ts +33 -0
  97. package/src/actions/public/getRedeemFee.ts +40 -0
  98. package/src/actions/public/getRedeemRequest.ts +40 -0
  99. package/src/actions/public/getTreasury.ts +33 -0
  100. package/src/actions/public/getWithdrawalDelay.ts +33 -0
  101. package/src/actions/public/getWithdrawalDelayEnabled.ts +33 -0
  102. package/src/actions/public/index.ts +11 -0
  103. package/src/actions/public/isInstantRedeemWhitelisted.ts +40 -0
  104. package/src/actions/public/previewDeposit.ts +49 -0
  105. package/src/actions/public/previewRedeem.ts +49 -0
  106. package/src/actions/wallet/cancelRedeemRequest.ts +135 -0
  107. package/src/actions/wallet/deposit.ts +277 -0
  108. package/src/actions/wallet/redeem.ts +321 -0
  109. package/src/actions/wallet/requestRedeem.ts +226 -0
  110. package/src/gatewayAddresses.ts +27 -0
  111. package/src/index.ts +79 -0
  112. package/src/types.ts +60 -0
  113. package/src/utils/isAddressValid.ts +4 -0
@@ -0,0 +1,7 @@
1
+ import { type Address, type Client } from "viem";
2
+ export declare function previewRedeem(client: Client, parameters: {
3
+ address: Address;
4
+ tokenOut: Address;
5
+ peggedTokenIn: bigint;
6
+ }): Promise<bigint>;
7
+ //# sourceMappingURL=previewRedeem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"previewRedeem.d.ts","sourceRoot":"","sources":["../../../src/actions/public/previewRedeem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAMjD,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE;IACV,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,mBAoCF"}
@@ -0,0 +1,14 @@
1
+ import { EventEmitter } from "events";
2
+ import { type Address, type WalletClient } from "viem";
3
+ import type { CancelRedeemRequestEvents } from "../../types.js";
4
+ export type CancelRedeemRequestParams = {
5
+ gatewayAddress: Address;
6
+ };
7
+ declare const runCancelRedeemRequest: (walletClient: WalletClient, { gatewayAddress }: CancelRedeemRequestParams) => (emitter: EventEmitter<CancelRedeemRequestEvents>) => Promise<void>;
8
+ export declare const cancelRedeemRequest: (...args: Parameters<typeof runCancelRedeemRequest>) => {
9
+ emitter: EventEmitter<CancelRedeemRequestEvents>;
10
+ promise: Promise<void>;
11
+ };
12
+ export declare const encodeCancelRedeemRequest: () => `0x${string}`;
13
+ export {};
14
+ //# sourceMappingURL=cancelRedeemRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancelRedeemRequest.d.ts","sourceRoot":"","sources":["../../../src/actions/wallet/cancelRedeemRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAC;AAId,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAEhE,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AA+CF,QAAA,MAAM,sBAAsB,GAC1B,cAAc,YAAY,EAC1B,oBAAoB,yBAAyB,MAE7B,SAAS,YAAY,CAAC,yBAAyB,CAAC,kBAuD/D,CAAC;AAEJ,eAAO,MAAM,mBAAmB,GAC9B,GAAG,MAAM,UAAU,CAAC,OAAO,sBAAsB,CAAC;;;CAC2B,CAAC;AAEhF,eAAO,MAAM,yBAAyB,qBAIlC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { EventEmitter } from "events";
2
+ import { type Address, type WalletClient } from "viem";
3
+ import type { DepositEvents } from "../../types.js";
4
+ export type DepositParams = {
5
+ amountIn: bigint;
6
+ approveAmount?: bigint;
7
+ gatewayAddress: Address;
8
+ minPeggedTokenOut: bigint;
9
+ receiver: Address;
10
+ tokenIn: Address;
11
+ };
12
+ declare const runDeposit: (walletClient: WalletClient, { amountIn, approveAmount, gatewayAddress, minPeggedTokenOut, receiver, tokenIn, }: DepositParams) => (emitter: EventEmitter<DepositEvents>) => Promise<void>;
13
+ export declare const deposit: (...args: Parameters<typeof runDeposit>) => {
14
+ emitter: EventEmitter<DepositEvents>;
15
+ promise: Promise<void>;
16
+ };
17
+ export declare const encodeDeposit: ({ amountIn, minPeggedTokenOut, receiver, tokenIn, }: Omit<DepositParams, "gatewayAddress">) => `0x${string}`;
18
+ export {};
19
+ //# sourceMappingURL=deposit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deposit.d.ts","sourceRoot":"","sources":["../../../src/actions/wallet/deposit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AA0HF,QAAA,MAAM,UAAU,GACd,cAAc,YAAY,EAC1B,oFAOG,aAAa,MAEA,SAAS,YAAY,CAAC,aAAa,CAAC,kBAwGnD,CAAC;AAEJ,eAAO,MAAM,OAAO,GAAI,GAAG,MAAM,UAAU,CAAC,OAAO,UAAU,CAAC;;;CACV,CAAC;AAErD,eAAO,MAAM,aAAa,GAAI,qDAK3B,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC,kBAKpC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { EventEmitter } from "events";
2
+ import { type Address, type WalletClient } from "viem";
3
+ import type { RedeemEvents } from "../../types.js";
4
+ export type RedeemParams = {
5
+ approveAmount?: bigint;
6
+ gatewayAddress: Address;
7
+ minAmountOut: bigint;
8
+ peggedTokenIn: bigint;
9
+ receiver: Address;
10
+ tokenOut: Address;
11
+ };
12
+ declare const runRedeem: (walletClient: WalletClient, { approveAmount, gatewayAddress, minAmountOut, peggedTokenIn, receiver, tokenOut, }: RedeemParams) => (emitter: EventEmitter<RedeemEvents>) => Promise<void>;
13
+ export declare const redeem: (...args: Parameters<typeof runRedeem>) => {
14
+ emitter: EventEmitter<RedeemEvents>;
15
+ promise: Promise<void>;
16
+ };
17
+ export declare const encodeRedeem: ({ minAmountOut, peggedTokenIn, receiver, tokenOut, }: {
18
+ minAmountOut: bigint;
19
+ peggedTokenIn: bigint;
20
+ receiver: Address;
21
+ tokenOut: Address;
22
+ }) => `0x${string}`;
23
+ export {};
24
+ //# sourceMappingURL=redeem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redeem.d.ts","sourceRoot":"","sources":["../../../src/actions/wallet/redeem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMnD,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAsIF,QAAA,MAAM,SAAS,GACb,cAAc,YAAY,EAC1B,qFAOG,YAAY,MAEC,SAAS,YAAY,CAAC,YAAY,CAAC,kBA+HlD,CAAC;AAEJ,eAAO,MAAM,MAAM,GAAI,GAAG,MAAM,UAAU,CAAC,OAAO,SAAS,CAAC;;;CACV,CAAC;AAEnD,eAAO,MAAM,YAAY,GAAI,sDAK1B;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB,kBAKG,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { EventEmitter } from "events";
2
+ import { type Address, type WalletClient } from "viem";
3
+ import type { RequestRedeemEvents } from "../../types.js";
4
+ export type RequestRedeemParams = {
5
+ approveAmount?: bigint;
6
+ gatewayAddress: Address;
7
+ peggedTokenAmount: bigint;
8
+ };
9
+ declare const runRequestRedeem: (walletClient: WalletClient, { approveAmount, gatewayAddress, peggedTokenAmount }: RequestRedeemParams) => (emitter: EventEmitter<RequestRedeemEvents>) => Promise<void>;
10
+ export declare const requestRedeem: (...args: Parameters<typeof runRequestRedeem>) => {
11
+ emitter: EventEmitter<RequestRedeemEvents>;
12
+ promise: Promise<void>;
13
+ };
14
+ export declare const encodeRequestRedeem: ({ peggedTokenAmount, }: {
15
+ peggedTokenAmount: bigint;
16
+ }) => `0x${string}`;
17
+ export {};
18
+ //# sourceMappingURL=requestRedeem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestRedeem.d.ts","sourceRoot":"","sources":["../../../src/actions/wallet/requestRedeem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,MAAM,MAAM,mBAAmB,GAAG;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAwEF,QAAA,MAAM,gBAAgB,GACpB,cAAc,YAAY,EAC1B,sDAAsD,mBAAmB,MAEzD,SAAS,YAAY,CAAC,mBAAmB,CAAC,kBAiHzD,CAAC;AAEJ,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,UAAU,CAAC,OAAO,gBAAgB,CAAC;;;CACV,CAAC;AAEjE,eAAO,MAAM,mBAAmB,GAAI,wBAEjC;IACD,iBAAiB,EAAE,MAAM,CAAC;CAC3B,kBAKG,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Address } from "viem";
2
+ export type Gateway = {
3
+ address: Address;
4
+ pegBaseSymbol: string;
5
+ };
6
+ export declare const gateways: Gateway[];
7
+ export declare const gatewayAddresses: Address[];
8
+ //# sourceMappingURL=gatewayAddresses.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gatewayAddresses.d.ts","sourceRoot":"","sources":["../src/gatewayAddresses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,EAAE,OAAO,CAAC;IAGjB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAMF,eAAO,MAAM,QAAQ,EAAE,OAAO,EAW7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,OAAO,EAAmC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { Client, WalletClient } from "viem";
2
+ import { getMaxWithdraw, getMintFee, getPeggedToken, getRedeemFee, getRedeemRequest, getTreasury, getWithdrawalDelay, getWithdrawalDelayEnabled, isInstantRedeemWhitelisted, previewDeposit, previewRedeem } from "./actions/public/index.js";
3
+ import { type CancelRedeemRequestParams } from "./actions/wallet/cancelRedeemRequest.js";
4
+ import { type DepositParams } from "./actions/wallet/deposit.js";
5
+ import { type RedeemParams } from "./actions/wallet/redeem.js";
6
+ import { type RequestRedeemParams } from "./actions/wallet/requestRedeem.js";
7
+ export { gatewayAbi } from "./abi/gatewayAbi.js";
8
+ export { type Gateway, gatewayAddresses, gateways, } from "./gatewayAddresses.js";
9
+ export type { CancelRedeemRequestParams };
10
+ export { type CancelRedeemRequestEvents, type DepositEvents, type RedeemEvents, type RequestRedeemEvents, } from "./types.js";
11
+ export declare const gatewayPublicActions: () => (client: Client) => {
12
+ getMaxWithdraw: (params: Parameters<typeof getMaxWithdraw>[1]) => Promise<bigint>;
13
+ getMintFee: (params: Parameters<typeof getMintFee>[1]) => Promise<bigint>;
14
+ getPeggedToken: (params: Parameters<typeof getPeggedToken>[1]) => Promise<`0x${string}`>;
15
+ getRedeemFee: (params: Parameters<typeof getRedeemFee>[1]) => Promise<bigint>;
16
+ getRedeemRequest: (params: Parameters<typeof getRedeemRequest>[1]) => Promise<readonly [bigint, bigint]>;
17
+ getTreasury: (params: Parameters<typeof getTreasury>[1]) => Promise<`0x${string}`>;
18
+ getWithdrawalDelay: (params: Parameters<typeof getWithdrawalDelay>[1]) => Promise<bigint>;
19
+ getWithdrawalDelayEnabled: (params: Parameters<typeof getWithdrawalDelayEnabled>[1]) => Promise<boolean>;
20
+ isInstantRedeemWhitelisted: (params: Parameters<typeof isInstantRedeemWhitelisted>[1]) => Promise<boolean>;
21
+ previewDeposit: (params: Parameters<typeof previewDeposit>[1]) => Promise<bigint>;
22
+ previewRedeem: (params: Parameters<typeof previewRedeem>[1]) => Promise<bigint>;
23
+ };
24
+ export declare const gatewayWalletActions: () => (client: WalletClient) => {
25
+ cancelRedeemRequest: (params: CancelRedeemRequestParams) => {
26
+ emitter: import("events")<import("./types.js").CancelRedeemRequestEvents>;
27
+ promise: Promise<void>;
28
+ };
29
+ deposit: (params: DepositParams) => {
30
+ emitter: import("events")<import("./types.js").DepositEvents>;
31
+ promise: Promise<void>;
32
+ };
33
+ redeem: (params: RedeemParams) => {
34
+ emitter: import("events")<import("./types.js").RedeemEvents>;
35
+ promise: Promise<void>;
36
+ };
37
+ requestRedeem: (params: RequestRedeemParams) => {
38
+ emitter: import("events")<import("./types.js").RequestRedeemEvents>;
39
+ promise: Promise<void>;
40
+ };
41
+ };
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEjD,OAAO,EACL,cAAc,EACd,UAAU,EACV,c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,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;4BAErC,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC;CAE3D,CAAC;AAEH,eAAO,MAAM,oBAAoB,SAAU,QAAQ,YAAY;kCAC/B,yBAAyB;;;;sBAErC,aAAa;;;;qBACd,YAAY;;;;4BACL,mBAAmB;;;;CAC3C,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { Hash, TransactionReceipt } from "viem";
2
+ type CommonEvents = {
3
+ "unexpected-error": [Error];
4
+ };
5
+ type ApprovalEvents = {
6
+ "approve-transaction-reverted": [TransactionReceipt];
7
+ "approve-transaction-succeeded": [TransactionReceipt];
8
+ "pre-approve": [];
9
+ "user-signed-approval": [Hash];
10
+ "user-signing-approval-error": [Error];
11
+ };
12
+ export type DepositEvents = ApprovalEvents & CommonEvents & {
13
+ "deposit-failed": [Error];
14
+ "deposit-failed-validation": [string];
15
+ "deposit-settled": [];
16
+ "deposit-transaction-reverted": [TransactionReceipt];
17
+ "deposit-transaction-succeeded": [TransactionReceipt];
18
+ "pre-deposit": [];
19
+ "user-signed-deposit": [Hash];
20
+ "user-signing-deposit-error": [Error];
21
+ };
22
+ export type CancelRedeemRequestEvents = CommonEvents & {
23
+ "cancel-redeem-request-failed": [Error];
24
+ "cancel-redeem-request-failed-validation": [string];
25
+ "cancel-redeem-request-settled": [];
26
+ "cancel-redeem-request-transaction-reverted": [TransactionReceipt];
27
+ "cancel-redeem-request-transaction-succeeded": [TransactionReceipt];
28
+ "pre-cancel-redeem-request": [];
29
+ "user-signed-cancel-redeem-request": [Hash];
30
+ "user-signing-cancel-redeem-request-error": [Error];
31
+ };
32
+ export type RedeemEvents = ApprovalEvents & CommonEvents & {
33
+ "pre-redeem": [];
34
+ "redeem-failed": [Error];
35
+ "redeem-failed-validation": [string];
36
+ "redeem-settled": [];
37
+ "redeem-transaction-reverted": [TransactionReceipt];
38
+ "redeem-transaction-succeeded": [TransactionReceipt];
39
+ "user-signed-redeem": [Hash];
40
+ "user-signing-redeem-error": [Error];
41
+ };
42
+ export type RequestRedeemEvents = ApprovalEvents & CommonEvents & {
43
+ "pre-request-redeem": [];
44
+ "request-redeem-failed": [Error];
45
+ "request-redeem-failed-validation": [string];
46
+ "request-redeem-settled": [];
47
+ "request-redeem-transaction-reverted": [TransactionReceipt];
48
+ "request-redeem-transaction-succeeded": [TransactionReceipt];
49
+ "user-signed-request-redeem": [Hash];
50
+ "user-signing-request-redeem-error": [Error];
51
+ };
52
+ export {};
53
+ //# 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,IAAI,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAErD,KAAK,YAAY,GAAG;IAClB,kBAAkB,EAAE,CAAC,KAAK,CAAC,CAAC;CAC7B,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,8BAA8B,EAAE,CAAC,kBAAkB,CAAC,CAAC;IACrD,+BAA+B,EAAE,CAAC,kBAAkB,CAAC,CAAC;IACtD,aAAa,EAAE,EAAE,CAAC;IAClB,sBAAsB,EAAE,CAAC,IAAI,CAAC,CAAC;IAC/B,6BAA6B,EAAE,CAAC,KAAK,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,cAAc,GACxC,YAAY,GAAG;IACb,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,2BAA2B,EAAE,CAAC,MAAM,CAAC,CAAC;IACtC,iBAAiB,EAAE,EAAE,CAAC;IACtB,8BAA8B,EAAE,CAAC,kBAAkB,CAAC,CAAC;IACrD,+BAA+B,EAAE,CAAC,kBAAkB,CAAC,CAAC;IACtD,aAAa,EAAE,EAAE,CAAC;IAClB,qBAAqB,EAAE,CAAC,IAAI,CAAC,CAAC;IAC9B,4BAA4B,EAAE,CAAC,KAAK,CAAC,CAAC;CACvC,CAA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
+ import { type Address } from "viem";
2
+ export declare const isAddressValid: (address: Address | undefined) => boolean;
3
+ //# sourceMappingURL=isAddressValid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isAddressValid.d.ts","sourceRoot":"","sources":["../../src/utils/isAddressValid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAA0C,MAAM,MAAM,CAAC;AAE5E,eAAO,MAAM,cAAc,GAAI,SAAS,OAAO,GAAG,SAAS,YACe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@vetro-protocol/gateway",
3
+ "version": "1.0.0-beta",
4
+ "description": "Vetro Protocol gateway actions for viem.",
5
+ "license": "MIT",
6
+ "files": [
7
+ "LICENSE",
8
+ "README.md",
9
+ "_esm",
10
+ "_types",
11
+ "src"
12
+ ],
13
+ "dependencies": {
14
+ "to-promise-event": "1.0.0",
15
+ "viem-erc20": "2.1.0"
16
+ },
17
+ "devDependencies": {
18
+ "@tsconfig/node24": "24.0.4",
19
+ "@types/node": "24.1.0",
20
+ "@vitest/coverage-v8": "4.0.18",
21
+ "typescript": "5.9.3",
22
+ "viem": "2.44.4",
23
+ "vitest": "4.0.18"
24
+ },
25
+ "peerDependencies": {
26
+ "viem": "^2.x"
27
+ },
28
+ "engines": {
29
+ "node": ">=20"
30
+ },
31
+ "private": false,
32
+ "publishConfig": {
33
+ "access": "public",
34
+ "provenance": false
35
+ },
36
+ "type": "module",
37
+ "exports": {
38
+ ".": {
39
+ "default": "./_esm/index.js",
40
+ "types": "./_types/index.d.ts"
41
+ },
42
+ "./actions": {
43
+ "default": "./_esm/actions/index.js",
44
+ "types": "./_types/actions/index.d.ts"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "sideEffects": false,
49
+ "scripts": {
50
+ "build": "tsc --noEmit",
51
+ "build:esm": "tsc -p tsconfig.build.json --outDir ./_esm --sourceMap",
52
+ "build:types": "tsc -p tsconfig.build.json --declarationDir ./_types --emitDeclarationOnly --declaration --declarationMap",
53
+ "clean": "rm -rf ./_esm ./_types",
54
+ "test": "vitest run",
55
+ "test:coverage": "vitest run --coverage"
56
+ },
57
+ "main": "./_esm/index.js",
58
+ "types": "./_types/index.d.ts"
59
+ }
@@ -0,0 +1,184 @@
1
+ export const gatewayAbi = [
2
+ {
3
+ inputs: [],
4
+ name: "PEGGED_TOKEN",
5
+ outputs: [{ type: "address" }],
6
+ stateMutability: "view",
7
+ type: "function",
8
+ },
9
+ {
10
+ inputs: [{ name: "token_", type: "address" }],
11
+ name: "mintFee",
12
+ outputs: [{ type: "uint256" }],
13
+ stateMutability: "view",
14
+ type: "function",
15
+ },
16
+ {
17
+ inputs: [],
18
+ name: "owner",
19
+ outputs: [{ type: "address" }],
20
+ stateMutability: "view",
21
+ type: "function",
22
+ },
23
+ {
24
+ inputs: [{ name: "token_", type: "address" }],
25
+ name: "redeemFee",
26
+ outputs: [{ type: "uint256" }],
27
+ stateMutability: "view",
28
+ type: "function",
29
+ },
30
+ {
31
+ inputs: [],
32
+ name: "treasury",
33
+ outputs: [{ type: "address" }],
34
+ stateMutability: "view",
35
+ type: "function",
36
+ },
37
+ {
38
+ inputs: [],
39
+ name: "withdrawalDelayEnabled",
40
+ outputs: [{ type: "bool" }],
41
+ stateMutability: "view",
42
+ type: "function",
43
+ },
44
+ {
45
+ inputs: [],
46
+ name: "withdrawalDelay",
47
+ outputs: [{ type: "uint256" }],
48
+ stateMutability: "view",
49
+ type: "function",
50
+ },
51
+ {
52
+ inputs: [{ name: "user_", type: "address" }],
53
+ name: "getRedeemRequest",
54
+ outputs: [
55
+ { name: "amountLocked", type: "uint256" },
56
+ { name: "claimableAt", type: "uint256" },
57
+ ],
58
+ stateMutability: "view",
59
+ type: "function",
60
+ },
61
+ {
62
+ inputs: [{ name: "account_", type: "address" }],
63
+ name: "isInstantRedeemWhitelisted",
64
+ outputs: [{ type: "bool" }],
65
+ stateMutability: "view",
66
+ type: "function",
67
+ },
68
+ {
69
+ inputs: [{ name: "tokenOut_", type: "address" }],
70
+ name: "maxWithdraw",
71
+ outputs: [{ type: "uint256" }],
72
+ stateMutability: "view",
73
+ type: "function",
74
+ },
75
+ {
76
+ inputs: [{ name: "account_", type: "address" }],
77
+ name: "removeFromInstantRedeemWhitelist",
78
+ outputs: [],
79
+ stateMutability: "nonpayable",
80
+ type: "function",
81
+ },
82
+ {
83
+ inputs: [
84
+ { name: "tokenIn_", type: "address" },
85
+ { name: "amountIn_", type: "uint256" },
86
+ ],
87
+ name: "previewDeposit",
88
+ outputs: [{ type: "uint256" }],
89
+ stateMutability: "view",
90
+ type: "function",
91
+ },
92
+ {
93
+ inputs: [
94
+ { name: "tokenOut_", type: "address" },
95
+ { name: "peggedTokenIn_", type: "uint256" },
96
+ ],
97
+ name: "previewRedeem",
98
+ outputs: [{ type: "uint256" }],
99
+ stateMutability: "view",
100
+ type: "function",
101
+ },
102
+ {
103
+ inputs: [],
104
+ name: "cancelRedeemRequest",
105
+ outputs: [],
106
+ stateMutability: "nonpayable",
107
+ type: "function",
108
+ },
109
+ {
110
+ inputs: [
111
+ { name: "tokenIn_", type: "address" },
112
+ { name: "amountIn_", type: "uint256" },
113
+ { name: "minPeggedTokenOut_", type: "uint256" },
114
+ { name: "receiver_", type: "address" },
115
+ ],
116
+ name: "deposit",
117
+ outputs: [{ type: "uint256" }],
118
+ stateMutability: "nonpayable",
119
+ type: "function",
120
+ },
121
+ {
122
+ inputs: [
123
+ { name: "tokenOut_", type: "address" },
124
+ { name: "peggedTokenIn_", type: "uint256" },
125
+ { name: "minAmountOut_", type: "uint256" },
126
+ { name: "receiver_", type: "address" },
127
+ ],
128
+ name: "redeem",
129
+ outputs: [{ type: "uint256" }],
130
+ stateMutability: "nonpayable",
131
+ type: "function",
132
+ },
133
+ {
134
+ inputs: [{ name: "peggedTokenAmount_", type: "uint256" }],
135
+ name: "requestRedeem",
136
+ outputs: [],
137
+ stateMutability: "nonpayable",
138
+ type: "function",
139
+ },
140
+ {
141
+ inputs: [{ name: "enabled_", type: "bool" }],
142
+ name: "setWithdrawalDelayEnabled",
143
+ outputs: [],
144
+ stateMutability: "nonpayable",
145
+ type: "function",
146
+ },
147
+ {
148
+ inputs: [
149
+ { name: "token_", type: "address" },
150
+ { name: "newMintFee_", type: "uint256" },
151
+ ],
152
+ name: "updateMintFee",
153
+ outputs: [],
154
+ stateMutability: "nonpayable",
155
+ type: "function",
156
+ },
157
+ {
158
+ inputs: [
159
+ { name: "token_", type: "address" },
160
+ { name: "newRedeemFee_", type: "uint256" },
161
+ ],
162
+ name: "updateRedeemFee",
163
+ outputs: [],
164
+ stateMutability: "nonpayable",
165
+ type: "function",
166
+ },
167
+ {
168
+ inputs: [{ name: "newDelay_", type: "uint256" }],
169
+ name: "updateWithdrawalDelay",
170
+ outputs: [],
171
+ stateMutability: "nonpayable",
172
+ type: "function",
173
+ },
174
+ {
175
+ anonymous: false,
176
+ inputs: [
177
+ { indexed: true, name: "user", type: "address" },
178
+ { indexed: false, name: "amount", type: "uint256" },
179
+ { indexed: false, name: "claimableAt", type: "uint256" },
180
+ ],
181
+ name: "RedeemRequested",
182
+ type: "event",
183
+ },
184
+ ] as const;
@@ -0,0 +1,18 @@
1
+ // Export all public actions
2
+ export * from "./public/getMaxWithdraw.js";
3
+ export * from "./public/getPeggedToken.js";
4
+ export * from "./public/getMintFee.js";
5
+ export * from "./public/getRedeemFee.js";
6
+ export * from "./public/getRedeemRequest.js";
7
+ export * from "./public/getTreasury.js";
8
+ export * from "./public/getWithdrawalDelayEnabled.js";
9
+ export * from "./public/getWithdrawalDelay.js";
10
+ export * from "./public/isInstantRedeemWhitelisted.js";
11
+ export * from "./public/previewDeposit.js";
12
+ export * from "./public/previewRedeem.js";
13
+
14
+ // Export all wallet actions
15
+ export * from "./wallet/cancelRedeemRequest.js";
16
+ export * from "./wallet/deposit.js";
17
+ export * from "./wallet/redeem.js";
18
+ export * from "./wallet/requestRedeem.js";
@@ -0,0 +1,40 @@
1
+ import { type Address, type Client } from "viem";
2
+ import { readContract } from "viem/actions";
3
+
4
+ import { gatewayAbi } from "../../abi/gatewayAbi.js";
5
+ import { isAddressValid } from "../../utils/isAddressValid.js";
6
+
7
+ export async function getMaxWithdraw(
8
+ client: Client,
9
+ parameters: {
10
+ address: Address;
11
+ tokenOut: Address;
12
+ },
13
+ ) {
14
+ // Validate client
15
+ if (!client) {
16
+ throw new Error("Client is not defined");
17
+ }
18
+
19
+ // Validate parameters exist
20
+ if (!parameters) {
21
+ throw new Error("Parameters are required");
22
+ }
23
+
24
+ // Validate gateway address
25
+ if (!isAddressValid(parameters.address)) {
26
+ throw new Error("Gateway is invalid");
27
+ }
28
+
29
+ // Validate tokenOut address
30
+ if (!isAddressValid(parameters.tokenOut)) {
31
+ throw new Error("Token is invalid");
32
+ }
33
+
34
+ return readContract(client, {
35
+ abi: gatewayAbi,
36
+ address: parameters.address,
37
+ args: [parameters.tokenOut],
38
+ functionName: "maxWithdraw",
39
+ });
40
+ }
@@ -0,0 +1,40 @@
1
+ import { type Address, type Client } from "viem";
2
+ import { readContract } from "viem/actions";
3
+
4
+ import { gatewayAbi } from "../../abi/gatewayAbi.js";
5
+ import { isAddressValid } from "../../utils/isAddressValid.js";
6
+
7
+ export async function getMintFee(
8
+ client: Client,
9
+ parameters: {
10
+ address: Address;
11
+ token: Address;
12
+ },
13
+ ) {
14
+ // Validate client
15
+ if (!client) {
16
+ throw new Error("Client is not defined");
17
+ }
18
+
19
+ // Validate parameters exist
20
+ if (!parameters) {
21
+ throw new Error("Parameters are required");
22
+ }
23
+
24
+ // Validate gateway address
25
+ if (!isAddressValid(parameters.address)) {
26
+ throw new Error("Gateway is invalid");
27
+ }
28
+
29
+ // Validate token address
30
+ if (!isAddressValid(parameters.token)) {
31
+ throw new Error("Token is invalid");
32
+ }
33
+
34
+ return readContract(client, {
35
+ abi: gatewayAbi,
36
+ address: parameters.address,
37
+ args: [parameters.token],
38
+ functionName: "mintFee",
39
+ });
40
+ }
@@ -0,0 +1,33 @@
1
+ import { type Address, type Client } from "viem";
2
+ import { readContract } from "viem/actions";
3
+
4
+ import { gatewayAbi } from "../../abi/gatewayAbi.js";
5
+ import { isAddressValid } from "../../utils/isAddressValid.js";
6
+
7
+ export async function getPeggedToken(
8
+ client: Client,
9
+ parameters: {
10
+ address: Address;
11
+ },
12
+ ) {
13
+ // Validate client
14
+ if (!client) {
15
+ throw new Error("Client is not defined");
16
+ }
17
+
18
+ // Validate parameters exist
19
+ if (!parameters) {
20
+ throw new Error("Parameters are required");
21
+ }
22
+
23
+ // Validate gateway address
24
+ if (!isAddressValid(parameters.address)) {
25
+ throw new Error("Gateway is invalid");
26
+ }
27
+
28
+ return readContract(client, {
29
+ abi: gatewayAbi,
30
+ address: parameters.address,
31
+ functionName: "PEGGED_TOKEN",
32
+ });
33
+ }
@@ -0,0 +1,40 @@
1
+ import { type Address, type Client } from "viem";
2
+ import { readContract } from "viem/actions";
3
+
4
+ import { gatewayAbi } from "../../abi/gatewayAbi.js";
5
+ import { isAddressValid } from "../../utils/isAddressValid.js";
6
+
7
+ export async function getRedeemFee(
8
+ client: Client,
9
+ parameters: {
10
+ address: Address;
11
+ token: Address;
12
+ },
13
+ ) {
14
+ // Validate client
15
+ if (!client) {
16
+ throw new Error("Client is not defined");
17
+ }
18
+
19
+ // Validate parameters exist
20
+ if (!parameters) {
21
+ throw new Error("Parameters are required");
22
+ }
23
+
24
+ // Validate gateway address
25
+ if (!isAddressValid(parameters.address)) {
26
+ throw new Error("Gateway is invalid");
27
+ }
28
+
29
+ // Validate token address
30
+ if (!isAddressValid(parameters.token)) {
31
+ throw new Error("Token is invalid");
32
+ }
33
+
34
+ return readContract(client, {
35
+ abi: gatewayAbi,
36
+ address: parameters.address,
37
+ args: [parameters.token],
38
+ functionName: "redeemFee",
39
+ });
40
+ }