@iris-credit/core-sdk 0.0.0
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/LICENSE +21 -0
- package/lib/cjs/abis/blm.d.ts +192 -0
- package/lib/cjs/abis/blm.js +251 -0
- package/lib/cjs/abis/errors.d.ts +441 -0
- package/lib/cjs/abis/errors.js +558 -0
- package/lib/cjs/abis/index.d.ts +4 -0
- package/lib/cjs/abis/index.js +20 -0
- package/lib/cjs/abis/iris.d.ts +1448 -0
- package/lib/cjs/abis/iris.js +1850 -0
- package/lib/cjs/abis/whitelist-blm.d.ts +235 -0
- package/lib/cjs/abis/whitelist-blm.js +307 -0
- package/lib/cjs/addresses.d.ts +12 -0
- package/lib/cjs/addresses.js +17 -0
- package/lib/cjs/chain.d.ts +35 -0
- package/lib/cjs/chain.js +40 -0
- package/lib/cjs/constants.d.ts +14 -0
- package/lib/cjs/constants.js +18 -0
- package/lib/cjs/index.d.ts +7 -0
- package/lib/cjs/index.js +23 -0
- package/lib/cjs/math/MathLib.d.ts +26 -0
- package/lib/cjs/math/MathLib.js +88 -0
- package/lib/cjs/math/index.d.ts +1 -0
- package/lib/cjs/math/index.js +17 -0
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/signatures/authorization.d.ts +20 -0
- package/lib/cjs/signatures/authorization.js +25 -0
- package/lib/cjs/signatures/erc2612.d.ts +34 -0
- package/lib/cjs/signatures/erc2612.js +26 -0
- package/lib/cjs/signatures/index.d.ts +4 -0
- package/lib/cjs/signatures/index.js +20 -0
- package/lib/cjs/signatures/permit2.d.ts +33 -0
- package/lib/cjs/signatures/permit2.js +41 -0
- package/lib/cjs/signatures/quote.d.ts +34 -0
- package/lib/cjs/signatures/quote.js +40 -0
- package/lib/cjs/types.d.ts +9 -0
- package/lib/cjs/types.js +7 -0
- package/lib/esm/abis/blm.d.ts +192 -0
- package/lib/esm/abis/blm.js +248 -0
- package/lib/esm/abis/errors.d.ts +441 -0
- package/lib/esm/abis/errors.js +555 -0
- package/lib/esm/abis/index.d.ts +4 -0
- package/lib/esm/abis/index.js +4 -0
- package/lib/esm/abis/iris.d.ts +1448 -0
- package/lib/esm/abis/iris.js +1847 -0
- package/lib/esm/abis/whitelist-blm.d.ts +235 -0
- package/lib/esm/abis/whitelist-blm.js +304 -0
- package/lib/esm/addresses.d.ts +12 -0
- package/lib/esm/addresses.js +13 -0
- package/lib/esm/chain.d.ts +35 -0
- package/lib/esm/chain.js +38 -0
- package/lib/esm/constants.d.ts +14 -0
- package/lib/esm/constants.js +15 -0
- package/lib/esm/index.d.ts +7 -0
- package/lib/esm/index.js +7 -0
- package/lib/esm/math/MathLib.d.ts +26 -0
- package/lib/esm/math/MathLib.js +86 -0
- package/lib/esm/math/index.d.ts +1 -0
- package/lib/esm/math/index.js +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/signatures/authorization.d.ts +20 -0
- package/lib/esm/signatures/authorization.js +21 -0
- package/lib/esm/signatures/erc2612.d.ts +34 -0
- package/lib/esm/signatures/erc2612.js +22 -0
- package/lib/esm/signatures/index.d.ts +4 -0
- package/lib/esm/signatures/index.js +4 -0
- package/lib/esm/signatures/permit2.d.ts +33 -0
- package/lib/esm/signatures/permit2.js +37 -0
- package/lib/esm/signatures/quote.d.ts +34 -0
- package/lib/esm/signatures/quote.js +36 -0
- package/lib/esm/types.d.ts +9 -0
- package/lib/esm/types.js +3 -0
- package/package.json +39 -0
- package/src/index.ts +7 -0
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.js"), exports);
|
|
18
|
+
__exportStar(require("./chain.js"), exports);
|
|
19
|
+
__exportStar(require("./constants.js"), exports);
|
|
20
|
+
__exportStar(require("./addresses.js"), exports);
|
|
21
|
+
__exportStar(require("./signatures/index.js"), exports);
|
|
22
|
+
__exportStar(require("./math/index.js"), exports);
|
|
23
|
+
__exportStar(require("./abis/index.js"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BigIntish } from "../types.js";
|
|
2
|
+
/** Rounding direction for share↔asset conversions. */
|
|
3
|
+
export type RoundingDirection = "Down" | "Up";
|
|
4
|
+
export declare namespace MathLib {
|
|
5
|
+
const WAD = 1000000000000000000n;
|
|
6
|
+
const RAY = 1000000000000000000000000000n;
|
|
7
|
+
const MAX_UINT_256: bigint;
|
|
8
|
+
const MAX_UINT_160: bigint;
|
|
9
|
+
const MAX_UINT_128: bigint;
|
|
10
|
+
const MAX_UINT_48: bigint;
|
|
11
|
+
function maxUint(nBits: number): bigint;
|
|
12
|
+
function abs(a: BigIntish): bigint;
|
|
13
|
+
function min(...xs: BigIntish[]): bigint;
|
|
14
|
+
function max(...xs: BigIntish[]): bigint;
|
|
15
|
+
function zeroFloorSub(x: BigIntish, y: BigIntish): bigint;
|
|
16
|
+
function wMulDown(x: BigIntish, y: BigIntish): bigint;
|
|
17
|
+
function wMulUp(x: BigIntish, y: BigIntish): bigint;
|
|
18
|
+
function wMul(x: BigIntish, y: BigIntish, rounding: RoundingDirection): bigint;
|
|
19
|
+
function wDivDown(x: BigIntish, y: BigIntish): bigint;
|
|
20
|
+
function wDivUp(x: BigIntish, y: BigIntish): bigint;
|
|
21
|
+
function wDiv(x: BigIntish, y: BigIntish, rounding: RoundingDirection): bigint;
|
|
22
|
+
function mulDivDown(x: BigIntish, y: BigIntish, denominator: BigIntish): bigint;
|
|
23
|
+
function mulDivUp(x: BigIntish, y: BigIntish, denominator: BigIntish): bigint;
|
|
24
|
+
function mulDiv(x: BigIntish, y: BigIntish, denominator: BigIntish, rounding: RoundingDirection): bigint;
|
|
25
|
+
function wToRay(x: BigIntish): bigint;
|
|
26
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MathLib = void 0;
|
|
4
|
+
var MathLib;
|
|
5
|
+
(function (MathLib) {
|
|
6
|
+
MathLib.WAD = 1000000000000000000n;
|
|
7
|
+
MathLib.RAY = 1000000000000000000000000000n;
|
|
8
|
+
MathLib.MAX_UINT_256 = maxUint(256);
|
|
9
|
+
MathLib.MAX_UINT_160 = maxUint(160);
|
|
10
|
+
MathLib.MAX_UINT_128 = maxUint(128);
|
|
11
|
+
MathLib.MAX_UINT_48 = maxUint(48);
|
|
12
|
+
function maxUint(nBits) {
|
|
13
|
+
if (nBits % 4 !== 0)
|
|
14
|
+
throw new Error(`Invalid number of bits: ${nBits}`);
|
|
15
|
+
return BigInt(`0x${"f".repeat(nBits / 4)}`);
|
|
16
|
+
}
|
|
17
|
+
MathLib.maxUint = maxUint;
|
|
18
|
+
function abs(a) {
|
|
19
|
+
a = BigInt(a);
|
|
20
|
+
return a >= 0 ? a : -a;
|
|
21
|
+
}
|
|
22
|
+
MathLib.abs = abs;
|
|
23
|
+
function min(...xs) {
|
|
24
|
+
return xs.map(BigInt).reduce((x, y) => (x <= y ? x : y));
|
|
25
|
+
}
|
|
26
|
+
MathLib.min = min;
|
|
27
|
+
function max(...xs) {
|
|
28
|
+
return xs.map(BigInt).reduce((x, y) => (x <= y ? y : x));
|
|
29
|
+
}
|
|
30
|
+
MathLib.max = max;
|
|
31
|
+
function zeroFloorSub(x, y) {
|
|
32
|
+
x = BigInt(x);
|
|
33
|
+
y = BigInt(y);
|
|
34
|
+
return x <= y ? 0n : x - y;
|
|
35
|
+
}
|
|
36
|
+
MathLib.zeroFloorSub = zeroFloorSub;
|
|
37
|
+
function wMulDown(x, y) {
|
|
38
|
+
return MathLib.wMul(x, y, "Down");
|
|
39
|
+
}
|
|
40
|
+
MathLib.wMulDown = wMulDown;
|
|
41
|
+
function wMulUp(x, y) {
|
|
42
|
+
return MathLib.wMul(x, y, "Up");
|
|
43
|
+
}
|
|
44
|
+
MathLib.wMulUp = wMulUp;
|
|
45
|
+
function wMul(x, y, rounding) {
|
|
46
|
+
return MathLib.mulDiv(x, y, MathLib.WAD, rounding);
|
|
47
|
+
}
|
|
48
|
+
MathLib.wMul = wMul;
|
|
49
|
+
function wDivDown(x, y) {
|
|
50
|
+
return MathLib.wDiv(x, y, "Down");
|
|
51
|
+
}
|
|
52
|
+
MathLib.wDivDown = wDivDown;
|
|
53
|
+
function wDivUp(x, y) {
|
|
54
|
+
return MathLib.wDiv(x, y, "Up");
|
|
55
|
+
}
|
|
56
|
+
MathLib.wDivUp = wDivUp;
|
|
57
|
+
function wDiv(x, y, rounding) {
|
|
58
|
+
return MathLib.mulDiv(x, MathLib.WAD, y, rounding);
|
|
59
|
+
}
|
|
60
|
+
MathLib.wDiv = wDiv;
|
|
61
|
+
function mulDivDown(x, y, denominator) {
|
|
62
|
+
x = BigInt(x);
|
|
63
|
+
y = BigInt(y);
|
|
64
|
+
denominator = BigInt(denominator);
|
|
65
|
+
if (denominator === 0n)
|
|
66
|
+
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
67
|
+
return (x * y) / denominator;
|
|
68
|
+
}
|
|
69
|
+
MathLib.mulDivDown = mulDivDown;
|
|
70
|
+
function mulDivUp(x, y, denominator) {
|
|
71
|
+
x = BigInt(x);
|
|
72
|
+
y = BigInt(y);
|
|
73
|
+
denominator = BigInt(denominator);
|
|
74
|
+
if (denominator === 0n)
|
|
75
|
+
throw Error("MathLib: DIVISION_BY_ZERO");
|
|
76
|
+
const roundup = (x * y) % denominator > 0 ? 1n : 0n;
|
|
77
|
+
return (x * y) / denominator + roundup;
|
|
78
|
+
}
|
|
79
|
+
MathLib.mulDivUp = mulDivUp;
|
|
80
|
+
function mulDiv(x, y, denominator, rounding) {
|
|
81
|
+
return MathLib[`mulDiv${rounding}`](x, y, denominator);
|
|
82
|
+
}
|
|
83
|
+
MathLib.mulDiv = mulDiv;
|
|
84
|
+
function wToRay(x) {
|
|
85
|
+
return BigInt(x) * 1000000000n;
|
|
86
|
+
}
|
|
87
|
+
MathLib.wToRay = wToRay;
|
|
88
|
+
})(MathLib || (exports.MathLib = MathLib = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./MathLib.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./MathLib.js"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
export type Authorization = {
|
|
3
|
+
authorizer: Address;
|
|
4
|
+
authorized: Address;
|
|
5
|
+
isAuthorized: boolean;
|
|
6
|
+
nonce: bigint;
|
|
7
|
+
deadline: bigint;
|
|
8
|
+
};
|
|
9
|
+
export declare const getAuthorizationTypedData: (chainId: 1, authorization: Authorization) => import("viem").MessageDefinition<{
|
|
10
|
+
Authorization: {
|
|
11
|
+
name: string;
|
|
12
|
+
type: string;
|
|
13
|
+
}[];
|
|
14
|
+
}, "Authorization", "message", "Authorization", {
|
|
15
|
+
Authorization: {
|
|
16
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
17
|
+
};
|
|
18
|
+
}, {
|
|
19
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuthorizationTypedData = void 0;
|
|
4
|
+
const addresses_js_1 = require("../addresses.js");
|
|
5
|
+
const authorizationTypes = {
|
|
6
|
+
Authorization: [
|
|
7
|
+
{ name: "authorizer", type: "address" },
|
|
8
|
+
{ name: "authorized", type: "address" },
|
|
9
|
+
{ name: "isAuthorized", type: "bool" },
|
|
10
|
+
{ name: "nonce", type: "uint256" },
|
|
11
|
+
{ name: "deadline", type: "uint256" },
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
const getAuthorizationTypedData = (chainId, authorization) => {
|
|
15
|
+
return {
|
|
16
|
+
domain: {
|
|
17
|
+
chainId,
|
|
18
|
+
verifyingContract: (0, addresses_js_1.getChainAddresses)(chainId).iris,
|
|
19
|
+
},
|
|
20
|
+
types: authorizationTypes,
|
|
21
|
+
message: authorization,
|
|
22
|
+
primaryType: "Authorization",
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.getAuthorizationTypedData = getAuthorizationTypedData;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { ChainId } from "../chain.js";
|
|
3
|
+
/**
|
|
4
|
+
* The EIP-712 domain of an ERC-20 token that implements EIP-2612.
|
|
5
|
+
*
|
|
6
|
+
* Unlike the iris-signed types, the `verifyingContract` here is the token itself,
|
|
7
|
+
* and `name`/`version` are token-specific — they must be read from the token
|
|
8
|
+
* (e.g. via `name()` / `eip712Domain()`), not assumed.
|
|
9
|
+
*/
|
|
10
|
+
export type Erc2612Domain = {
|
|
11
|
+
token: Address;
|
|
12
|
+
chainId: ChainId;
|
|
13
|
+
name: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
};
|
|
16
|
+
export type Erc2612Permit = {
|
|
17
|
+
owner: Address;
|
|
18
|
+
spender: Address;
|
|
19
|
+
value: bigint;
|
|
20
|
+
nonce: bigint;
|
|
21
|
+
deadline: bigint;
|
|
22
|
+
};
|
|
23
|
+
export declare const getErc2612PermitTypedData: (domain: Erc2612Domain, permit: Erc2612Permit) => import("viem").MessageDefinition<{
|
|
24
|
+
Permit: {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
}, "Permit", "message", "Permit", {
|
|
29
|
+
Permit: {
|
|
30
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getErc2612PermitTypedData = void 0;
|
|
4
|
+
const permitTypes = {
|
|
5
|
+
Permit: [
|
|
6
|
+
{ name: "owner", type: "address" },
|
|
7
|
+
{ name: "spender", type: "address" },
|
|
8
|
+
{ name: "value", type: "uint256" },
|
|
9
|
+
{ name: "nonce", type: "uint256" },
|
|
10
|
+
{ name: "deadline", type: "uint256" },
|
|
11
|
+
],
|
|
12
|
+
};
|
|
13
|
+
const getErc2612PermitTypedData = (domain, permit) => {
|
|
14
|
+
return {
|
|
15
|
+
domain: {
|
|
16
|
+
name: domain.name,
|
|
17
|
+
version: domain.version,
|
|
18
|
+
chainId: domain.chainId,
|
|
19
|
+
verifyingContract: domain.token,
|
|
20
|
+
},
|
|
21
|
+
types: permitTypes,
|
|
22
|
+
message: permit,
|
|
23
|
+
primaryType: "Permit",
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.getErc2612PermitTypedData = getErc2612PermitTypedData;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./authorization.js"), exports);
|
|
18
|
+
__exportStar(require("./erc2612.js"), exports);
|
|
19
|
+
__exportStar(require("./permit2.js"), exports);
|
|
20
|
+
__exportStar(require("./quote.js"), exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
/** The permit data for a token. */
|
|
3
|
+
export type PermitDetails = {
|
|
4
|
+
token: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
expiration: number;
|
|
7
|
+
nonce: number;
|
|
8
|
+
};
|
|
9
|
+
/** The permit message signed for a single token allowance. */
|
|
10
|
+
export type PermitSingle = {
|
|
11
|
+
details: PermitDetails;
|
|
12
|
+
spender: Address;
|
|
13
|
+
sigDeadline: bigint;
|
|
14
|
+
};
|
|
15
|
+
export declare const getPermit2PermitTypedData: (chainId: 1, permitSingle: PermitSingle) => import("viem").MessageDefinition<{
|
|
16
|
+
PermitSingle: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}[];
|
|
20
|
+
PermitDetails: {
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
}[];
|
|
24
|
+
}, "PermitSingle", "message", "PermitDetails" | "PermitSingle", {
|
|
25
|
+
PermitSingle: {
|
|
26
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
27
|
+
};
|
|
28
|
+
PermitDetails: {
|
|
29
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
30
|
+
};
|
|
31
|
+
}, {
|
|
32
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
33
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPermit2PermitTypedData = void 0;
|
|
4
|
+
const addresses_js_1 = require("../addresses.js");
|
|
5
|
+
const index_js_1 = require("../math/index.js");
|
|
6
|
+
const permit2PermitTypes = {
|
|
7
|
+
PermitSingle: [
|
|
8
|
+
{ name: "details", type: "PermitDetails" },
|
|
9
|
+
{ name: "spender", type: "address" },
|
|
10
|
+
{ name: "sigDeadline", type: "uint256" },
|
|
11
|
+
],
|
|
12
|
+
PermitDetails: [
|
|
13
|
+
{ name: "token", type: "address" },
|
|
14
|
+
{ name: "amount", type: "uint160" },
|
|
15
|
+
{ name: "expiration", type: "uint48" },
|
|
16
|
+
{ name: "nonce", type: "uint48" },
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
const getPermit2PermitTypedData = (chainId, permitSingle) => {
|
|
20
|
+
const { details, spender, sigDeadline } = permitSingle;
|
|
21
|
+
return {
|
|
22
|
+
domain: {
|
|
23
|
+
name: "Permit2",
|
|
24
|
+
chainId,
|
|
25
|
+
verifyingContract: (0, addresses_js_1.getChainAddresses)(chainId).permit2,
|
|
26
|
+
},
|
|
27
|
+
types: permit2PermitTypes,
|
|
28
|
+
message: {
|
|
29
|
+
details: {
|
|
30
|
+
token: details.token,
|
|
31
|
+
amount: index_js_1.MathLib.min(details.amount, index_js_1.MathLib.MAX_UINT_160),
|
|
32
|
+
expiration: index_js_1.MathLib.min(details.expiration, index_js_1.MathLib.MAX_UINT_48),
|
|
33
|
+
nonce: details.nonce,
|
|
34
|
+
},
|
|
35
|
+
spender,
|
|
36
|
+
sigDeadline,
|
|
37
|
+
},
|
|
38
|
+
primaryType: "PermitSingle",
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.getPermit2PermitTypedData = getPermit2PermitTypedData;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
export type Quote = {
|
|
3
|
+
borrower: Address;
|
|
4
|
+
solver: Address;
|
|
5
|
+
receiver: Address;
|
|
6
|
+
blm: Address;
|
|
7
|
+
collateralToken: Address;
|
|
8
|
+
debtToken: Address;
|
|
9
|
+
collateral: bigint;
|
|
10
|
+
debt: bigint;
|
|
11
|
+
fixedRate: bigint;
|
|
12
|
+
duration: bigint;
|
|
13
|
+
overdueRate: bigint;
|
|
14
|
+
overduePeriod: bigint;
|
|
15
|
+
bond: bigint;
|
|
16
|
+
bondLltv: bigint;
|
|
17
|
+
venueBitmap: bigint;
|
|
18
|
+
venueId: bigint;
|
|
19
|
+
deadline: bigint;
|
|
20
|
+
nonce: bigint;
|
|
21
|
+
data: Hex;
|
|
22
|
+
};
|
|
23
|
+
export declare const getQuoteTypedData: (chainId: 1, quote: Quote) => import("viem").MessageDefinition<{
|
|
24
|
+
Quote: {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
}[];
|
|
28
|
+
}, "Quote", "message", "Quote", {
|
|
29
|
+
Quote: {
|
|
30
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
31
|
+
};
|
|
32
|
+
}, {
|
|
33
|
+
[x: string]: [`Error: Cannot convert unknown type '${string}' to primitive type.`];
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getQuoteTypedData = void 0;
|
|
4
|
+
const addresses_js_1 = require("../addresses.js");
|
|
5
|
+
// Field order must match the contract's QUOTE_TYPEHASH; EIP-712 struct hashing is order-sensitive.
|
|
6
|
+
const quoteTypes = {
|
|
7
|
+
Quote: [
|
|
8
|
+
{ name: "borrower", type: "address" },
|
|
9
|
+
{ name: "solver", type: "address" },
|
|
10
|
+
{ name: "receiver", type: "address" },
|
|
11
|
+
{ name: "blm", type: "address" },
|
|
12
|
+
{ name: "collateralToken", type: "address" },
|
|
13
|
+
{ name: "debtToken", type: "address" },
|
|
14
|
+
{ name: "collateral", type: "uint256" },
|
|
15
|
+
{ name: "debt", type: "uint256" },
|
|
16
|
+
{ name: "fixedRate", type: "uint256" },
|
|
17
|
+
{ name: "duration", type: "uint256" },
|
|
18
|
+
{ name: "overdueRate", type: "uint256" },
|
|
19
|
+
{ name: "overduePeriod", type: "uint256" },
|
|
20
|
+
{ name: "bond", type: "uint256" },
|
|
21
|
+
{ name: "bondLltv", type: "uint256" },
|
|
22
|
+
{ name: "venueBitmap", type: "uint256" },
|
|
23
|
+
{ name: "venueId", type: "uint256" },
|
|
24
|
+
{ name: "deadline", type: "uint256" },
|
|
25
|
+
{ name: "nonce", type: "uint256" },
|
|
26
|
+
{ name: "data", type: "bytes" },
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
const getQuoteTypedData = (chainId, quote) => {
|
|
30
|
+
return {
|
|
31
|
+
domain: {
|
|
32
|
+
chainId,
|
|
33
|
+
verifyingContract: (0, addresses_js_1.getChainAddresses)(chainId).iris,
|
|
34
|
+
},
|
|
35
|
+
types: quoteTypes,
|
|
36
|
+
message: quote,
|
|
37
|
+
primaryType: "Quote",
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
exports.getQuoteTypedData = getQuoteTypedData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The id of a market used on the core contract */
|
|
2
|
+
export type MarketId = `0x${string}` & {
|
|
3
|
+
readonly __TYPE__: "marketId";
|
|
4
|
+
};
|
|
5
|
+
export type BigIntish = bigint | string | number | boolean;
|
|
6
|
+
export type Loadable<T> = T | undefined;
|
|
7
|
+
export type Failable<T> = T | null;
|
|
8
|
+
export type Fetchable<T> = Failable<Loadable<T>>;
|
|
9
|
+
export declare const isMarketId: (value: unknown) => value is MarketId;
|
package/lib/cjs/types.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
export declare const blmAbi: readonly [{
|
|
2
|
+
readonly type: "constructor";
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly name: "iris";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
readonly internalType: "address";
|
|
7
|
+
}];
|
|
8
|
+
readonly stateMutability: "nonpayable";
|
|
9
|
+
}, {
|
|
10
|
+
readonly type: "function";
|
|
11
|
+
readonly name: "IRIS";
|
|
12
|
+
readonly inputs: readonly [];
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly name: "";
|
|
15
|
+
readonly type: "address";
|
|
16
|
+
readonly internalType: "contract IIris";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "view";
|
|
19
|
+
}, {
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
readonly name: "bondRequirement";
|
|
22
|
+
readonly inputs: readonly [{
|
|
23
|
+
readonly name: "quote";
|
|
24
|
+
readonly type: "tuple";
|
|
25
|
+
readonly internalType: "struct Quote";
|
|
26
|
+
readonly components: readonly [{
|
|
27
|
+
readonly name: "borrower";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
readonly internalType: "address";
|
|
30
|
+
}, {
|
|
31
|
+
readonly name: "solver";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
readonly internalType: "address";
|
|
34
|
+
}, {
|
|
35
|
+
readonly name: "receiver";
|
|
36
|
+
readonly type: "address";
|
|
37
|
+
readonly internalType: "address";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "blm";
|
|
40
|
+
readonly type: "address";
|
|
41
|
+
readonly internalType: "address";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "collateralToken";
|
|
44
|
+
readonly type: "address";
|
|
45
|
+
readonly internalType: "address";
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "debtToken";
|
|
48
|
+
readonly type: "address";
|
|
49
|
+
readonly internalType: "address";
|
|
50
|
+
}, {
|
|
51
|
+
readonly name: "collateral";
|
|
52
|
+
readonly type: "uint256";
|
|
53
|
+
readonly internalType: "uint256";
|
|
54
|
+
}, {
|
|
55
|
+
readonly name: "debt";
|
|
56
|
+
readonly type: "uint256";
|
|
57
|
+
readonly internalType: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "fixedRate";
|
|
60
|
+
readonly type: "uint256";
|
|
61
|
+
readonly internalType: "uint256";
|
|
62
|
+
}, {
|
|
63
|
+
readonly name: "duration";
|
|
64
|
+
readonly type: "uint256";
|
|
65
|
+
readonly internalType: "uint256";
|
|
66
|
+
}, {
|
|
67
|
+
readonly name: "overdueRate";
|
|
68
|
+
readonly type: "uint256";
|
|
69
|
+
readonly internalType: "uint256";
|
|
70
|
+
}, {
|
|
71
|
+
readonly name: "overduePeriod";
|
|
72
|
+
readonly type: "uint256";
|
|
73
|
+
readonly internalType: "uint256";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "bond";
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
readonly internalType: "uint256";
|
|
78
|
+
}, {
|
|
79
|
+
readonly name: "bondLltv";
|
|
80
|
+
readonly type: "uint256";
|
|
81
|
+
readonly internalType: "uint256";
|
|
82
|
+
}, {
|
|
83
|
+
readonly name: "venueBitmap";
|
|
84
|
+
readonly type: "uint256";
|
|
85
|
+
readonly internalType: "uint256";
|
|
86
|
+
}, {
|
|
87
|
+
readonly name: "venueId";
|
|
88
|
+
readonly type: "uint256";
|
|
89
|
+
readonly internalType: "uint256";
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "deadline";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
readonly internalType: "uint256";
|
|
94
|
+
}, {
|
|
95
|
+
readonly name: "nonce";
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
readonly internalType: "uint256";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "data";
|
|
100
|
+
readonly type: "bytes";
|
|
101
|
+
readonly internalType: "bytes";
|
|
102
|
+
}];
|
|
103
|
+
}];
|
|
104
|
+
readonly outputs: readonly [{
|
|
105
|
+
readonly name: "";
|
|
106
|
+
readonly type: "uint256";
|
|
107
|
+
readonly internalType: "uint256";
|
|
108
|
+
}];
|
|
109
|
+
readonly stateMutability: "view";
|
|
110
|
+
}, {
|
|
111
|
+
readonly type: "function";
|
|
112
|
+
readonly name: "intercept";
|
|
113
|
+
readonly inputs: readonly [{
|
|
114
|
+
readonly name: "token";
|
|
115
|
+
readonly type: "address";
|
|
116
|
+
readonly internalType: "address";
|
|
117
|
+
}];
|
|
118
|
+
readonly outputs: readonly [{
|
|
119
|
+
readonly name: "";
|
|
120
|
+
readonly type: "uint256";
|
|
121
|
+
readonly internalType: "uint256";
|
|
122
|
+
}];
|
|
123
|
+
readonly stateMutability: "view";
|
|
124
|
+
}, {
|
|
125
|
+
readonly type: "function";
|
|
126
|
+
readonly name: "setParams";
|
|
127
|
+
readonly inputs: readonly [{
|
|
128
|
+
readonly name: "token";
|
|
129
|
+
readonly type: "address";
|
|
130
|
+
readonly internalType: "address";
|
|
131
|
+
}, {
|
|
132
|
+
readonly name: "newSlope";
|
|
133
|
+
readonly type: "uint256";
|
|
134
|
+
readonly internalType: "uint256";
|
|
135
|
+
}, {
|
|
136
|
+
readonly name: "newIntercept";
|
|
137
|
+
readonly type: "uint256";
|
|
138
|
+
readonly internalType: "uint256";
|
|
139
|
+
}];
|
|
140
|
+
readonly outputs: readonly [];
|
|
141
|
+
readonly stateMutability: "nonpayable";
|
|
142
|
+
}, {
|
|
143
|
+
readonly type: "function";
|
|
144
|
+
readonly name: "slope";
|
|
145
|
+
readonly inputs: readonly [{
|
|
146
|
+
readonly name: "token";
|
|
147
|
+
readonly type: "address";
|
|
148
|
+
readonly internalType: "address";
|
|
149
|
+
}];
|
|
150
|
+
readonly outputs: readonly [{
|
|
151
|
+
readonly name: "";
|
|
152
|
+
readonly type: "uint256";
|
|
153
|
+
readonly internalType: "uint256";
|
|
154
|
+
}];
|
|
155
|
+
readonly stateMutability: "view";
|
|
156
|
+
}, {
|
|
157
|
+
readonly type: "event";
|
|
158
|
+
readonly name: "SetParams";
|
|
159
|
+
readonly inputs: readonly [{
|
|
160
|
+
readonly name: "token";
|
|
161
|
+
readonly type: "address";
|
|
162
|
+
readonly indexed: false;
|
|
163
|
+
readonly internalType: "address";
|
|
164
|
+
}, {
|
|
165
|
+
readonly name: "newSlope";
|
|
166
|
+
readonly type: "uint256";
|
|
167
|
+
readonly indexed: false;
|
|
168
|
+
readonly internalType: "uint256";
|
|
169
|
+
}, {
|
|
170
|
+
readonly name: "newIntercept";
|
|
171
|
+
readonly type: "uint256";
|
|
172
|
+
readonly indexed: false;
|
|
173
|
+
readonly internalType: "uint256";
|
|
174
|
+
}];
|
|
175
|
+
readonly anonymous: false;
|
|
176
|
+
}, {
|
|
177
|
+
readonly type: "error";
|
|
178
|
+
readonly name: "ParamsTooHigh";
|
|
179
|
+
readonly inputs: readonly [];
|
|
180
|
+
}, {
|
|
181
|
+
readonly type: "error";
|
|
182
|
+
readonly name: "Unauthorized";
|
|
183
|
+
readonly inputs: readonly [];
|
|
184
|
+
}, {
|
|
185
|
+
readonly type: "error";
|
|
186
|
+
readonly name: "ZeroAddress";
|
|
187
|
+
readonly inputs: readonly [];
|
|
188
|
+
}, {
|
|
189
|
+
readonly type: "error";
|
|
190
|
+
readonly name: "ZeroAmount";
|
|
191
|
+
readonly inputs: readonly [];
|
|
192
|
+
}];
|