Socket
Socket
Sign inDemoInstall

@swapkit/helpers

Package Overview
Dependencies
3
Maintainers
2
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-rc.101 to 1.0.0-rc.102

src/types/quotes.ts

8

package.json

@@ -5,3 +5,4 @@ {

"dependencies": {
"ky": "1.2.3"
"ky": "1.2.3",
"zod": "3.23.8"
},

@@ -15,3 +16,4 @@ "devDependencies": {

"@swapkit/tokens": "1.0.0-rc.52",
"ky": "1.2.3"
"ky": "1.2.3",
"zod": "3.23.8"
},

@@ -41,3 +43,3 @@ "files": [

"types": "./src/index.ts",
"version": "1.0.0-rc.101"
"version": "1.0.0-rc.102"
}

@@ -24,6 +24,5 @@ import type { KyInstance, Options } from "ky";

const getTypedBaseRequestClient = (kyClient: KyInstance) => ({
get: <T>(url: string | URL | Request, options?: Options) => kyClient.get(url, options).json<T>(),
post: <T>(url: string | URL | Request, options?: Options) =>
kyClient.post(url, options).json<T>(),
const getTypedBaseRequestClient = (ky: KyInstance) => ({
get: <T>(url: string | URL | Request, options?: Options) => ky.get(url, options).json<T>(),
post: <T>(url: string | URL | Request, options?: Options) => ky.post(url, options).json<T>(),
});

@@ -30,0 +29,0 @@

@@ -77,2 +77,7 @@ const errorMessages = {

/**
* SwapKit API
*/
api_v2_invalid_response: 40001,
/**
* Helpers

@@ -79,0 +84,0 @@ */

@@ -11,1 +11,2 @@ export * from "./abis/erc20";

export * from "./sdk";
export * from "./quotes";

@@ -0,11 +1,15 @@

import { z } from "zod";
import type { AssetValue } from "../modules/assetValue";
import type { QuoteResponseRoute } from "./quotes";
export type GenericSwapParams = {
buyAsset: AssetValue;
sellAsset: AssetValue;
recipient: string;
buyAsset?: AssetValue;
sellAsset?: AssetValue;
recipient?: string;
feeOptionKey?: FeeOption;
route: QuoteResponseRoute;
};
export type SwapParams<PluginNames = string, T = GenericSwapParams> = T & {
pluginName: PluginNames;
pluginName?: PluginNames;
};

@@ -45,1 +49,79 @@

}
export const QuoteRequestSchema = z
.object({
sellAsset: z.string({
description: "Asset to sell",
}),
buyAsset: z.string({
description: "Asset to buy",
}),
sellAmount: z
.number({
description: "Amount of asset to sell",
})
.refine((amount) => amount > 0, {
message: "sellAmount must be greater than 0",
path: ["sellAmount"],
}),
providers: z.optional(
z.array(
z.string({
description: "List of providers to use",
}),
),
),
sourceAddress: z.optional(
z.string({
description: "Address to send asset from",
}),
),
destinationAddress: z.optional(
z.string({
description: "Address to send asset to",
}),
),
slippage: z.optional(
z.number({
description: "Slippage tolerance as a percentage. Default is 3%.",
}),
),
affiliate: z.optional(
z.string({
description: "Affiliate thorname",
}),
),
affiliateFee: z.optional(
z
.number({
description: "Affiliate fee in basis points",
})
.refine(
(fee) => {
return fee === Math.floor(fee) && fee >= 0;
},
{ message: "affiliateFee must be a positive integer", path: ["affiliateFee"] },
),
),
allowSmartContractSender: z.optional(
z.boolean({
description: "Allow smart contract as sender",
}),
),
allowSmartContractReceiver: z.optional(
z.boolean({
description: "Allow smart contract as recipient",
}),
),
disableSecurityChecks: z.optional(
z.boolean({
description: "Disable security checks",
}),
),
})
.refine((data) => data.sellAsset !== data.buyAsset, {
message: "Must be different",
path: ["sellAsset", "buyAsset"],
});
export type QuoteRequest = z.infer<typeof QuoteRequestSchema>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc