@pearcurve/sdk 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +64 -0
- package/README.md +122 -2
- package/dist/abis.d.ts +21 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/abis.js +39 -0
- package/dist/abis.js.map +1 -0
- package/dist/borrowerSubmitPreflight.d.ts +14 -0
- package/dist/borrowerSubmitPreflight.d.ts.map +1 -0
- package/dist/borrowerSubmitPreflight.js +28 -0
- package/dist/borrowerSubmitPreflight.js.map +1 -0
- package/dist/bps.d.ts +11 -0
- package/dist/bps.d.ts.map +1 -0
- package/dist/bps.js +25 -0
- package/dist/bps.js.map +1 -0
- package/dist/clients.d.ts +23 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +59 -0
- package/dist/clients.js.map +1 -0
- package/dist/decodeError.d.ts +24 -0
- package/dist/decodeError.d.ts.map +1 -0
- package/dist/decodeError.js +358 -0
- package/dist/decodeError.js.map +1 -0
- package/dist/encoding.d.ts +18 -0
- package/dist/encoding.d.ts.map +1 -0
- package/dist/encoding.js +94 -0
- package/dist/encoding.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/lenderSubmitPreflight.d.ts +20 -0
- package/dist/lenderSubmitPreflight.d.ts.map +1 -0
- package/dist/lenderSubmitPreflight.js +42 -0
- package/dist/lenderSubmitPreflight.js.map +1 -0
- package/dist/loanPositions.d.ts +23 -0
- package/dist/loanPositions.d.ts.map +1 -0
- package/dist/loanPositions.js +37 -0
- package/dist/loanPositions.js.map +1 -0
- package/dist/marketStats.d.ts +70 -0
- package/dist/marketStats.d.ts.map +1 -0
- package/dist/marketStats.js +117 -0
- package/dist/marketStats.js.map +1 -0
- package/dist/networkConfig.d.ts +48 -0
- package/dist/networkConfig.d.ts.map +1 -0
- package/dist/networkConfig.js +48 -0
- package/dist/networkConfig.js.map +1 -0
- package/dist/pause.d.ts +20 -0
- package/dist/pause.d.ts.map +1 -0
- package/dist/pause.js +40 -0
- package/dist/pause.js.map +1 -0
- package/dist/reads.d.ts +187 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +353 -0
- package/dist/reads.js.map +1 -0
- package/dist/strategies.d.ts +14 -0
- package/dist/strategies.d.ts.map +1 -0
- package/dist/strategies.js +49 -0
- package/dist/strategies.js.map +1 -0
- package/dist/txGas.d.ts +19 -0
- package/dist/txGas.d.ts.map +1 -0
- package/dist/txGas.js +37 -0
- package/dist/txGas.js.map +1 -0
- package/dist/types.d.ts +69 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/dist/yieldMigrationPreflight.d.ts +29 -0
- package/dist/yieldMigrationPreflight.d.ts.map +1 -0
- package/dist/yieldMigrationPreflight.js +61 -0
- package/dist/yieldMigrationPreflight.js.map +1 -0
- package/dist/yieldSources.d.ts +33 -0
- package/dist/yieldSources.d.ts.map +1 -0
- package/dist/yieldSources.js +106 -0
- package/dist/yieldSources.js.map +1 -0
- package/package.json +47 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Business Source License
|
|
2
|
+
|
|
3
|
+
Licensor: Pearcurve Labs
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Definitions**
|
|
8
|
+
|
|
9
|
+
For purposes of this License:
|
|
10
|
+
|
|
11
|
+
**"Competitive Product or Service"** means any product or service providing lending, borrowing, liquidity, or closely substitutable functionality that is materially similar in purpose or function to those provided by the Pearcurve Protocol.
|
|
12
|
+
|
|
13
|
+
**"Derivative"** means any work that modifies, incorporates, is based upon, or would otherwise be considered a derivative work of, the Licensed Work, including under applicable copyright law.
|
|
14
|
+
|
|
15
|
+
**"Production Environment"** means an environment in which users interact with the Licensed Work using "live", real, economically meaningful or value-bearing digital assets.
|
|
16
|
+
|
|
17
|
+
**"Test Environment"** means an environment in which users interact with the Licensed Work using non-live test, simulated, or synthetic data.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
**Terms**
|
|
22
|
+
|
|
23
|
+
1. **Scope**
|
|
24
|
+
|
|
25
|
+
All copies of the original or modified Licensed Work, and any Derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work, and the Change Date may vary for each version. You must conspicuously reproduce this License in each copy of the Licensed Work or Derivative work.
|
|
26
|
+
|
|
27
|
+
2. **Grant of Rights**
|
|
28
|
+
|
|
29
|
+
Licensor hereby grants you a non-exclusive, non-transferable, non-sublicensable right to copy, modify, create Derivative works, redistribute, and use the Licensed Work solely in a Test Environment, subject to the conditions set forth in this License.
|
|
30
|
+
|
|
31
|
+
3. **No Competitive Production Deployment**
|
|
32
|
+
|
|
33
|
+
Any use of the Licensed Work, or any Derivative thereof, in a Production Environment is strictly prohibited. Licensor may grant waivers or commercial licenses for specific parties or use cases, at the direction of Pearcurve Protocol governance. If you are uncertain whether your intended use complies with this License, you must obtain a separate commercial license from Licensor before proceeding.
|
|
34
|
+
|
|
35
|
+
4. **No Prior Competitive Fork Operators**
|
|
36
|
+
|
|
37
|
+
You represent that you are not currently, and have not been within the four years prior to your first use of the Licensed Work, a Materially Involved Contributor to any project that has deployed or is seeking to deploy a Competitive Product or Service. This License automatically terminates at such time that this representation is no longer accurate. "Materially Involved Contributor" means direct participation in protocol design, smart contract development, deployment execution, or governance or operational decision-making relating to a Competitive Product or Service.
|
|
38
|
+
|
|
39
|
+
5. **No Material Misrepresentation of Affiliation**
|
|
40
|
+
|
|
41
|
+
You may not materially misrepresent affiliation with, or endorsement by, the Pearcurve Protocol or the Pearcurve brand even when using the Licensed Work.
|
|
42
|
+
|
|
43
|
+
6. **Change Date**
|
|
44
|
+
|
|
45
|
+
The Change Date is the earlier of:
|
|
46
|
+
|
|
47
|
+
- 5 years after the deployment date of the Pearcurve Protocol on Ethereum Mainnet
|
|
48
|
+
- If specified, a date designated by Pearcurve Protocol governance and recorded in the "changedate" text record at [designated address]
|
|
49
|
+
|
|
50
|
+
A Change Date set through governance takes precedence over the stated date above.
|
|
51
|
+
|
|
52
|
+
7. **Change License**
|
|
53
|
+
|
|
54
|
+
The Change License shall be the MIT License.
|
|
55
|
+
|
|
56
|
+
8. **General**
|
|
57
|
+
|
|
58
|
+
If your use of the Licensed Work does not comply with the requirements of this License, your rights under this License automatically terminate and you must either refrain from using the Licensed Work or obtain a separate commercial license from Licensor or its authorized delegates.
|
|
59
|
+
|
|
60
|
+
If any condition of this License is held unenforceable as applied, such condition shall be severed to the minimum extent necessary, and the remaining conditions shall remain in full force and effect.
|
|
61
|
+
|
|
62
|
+
This License does not grant you any right in any trademark or logo of Pearcurve, except as required for accurate attribution.
|
|
63
|
+
|
|
64
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,123 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pearcurve TypeScript SDK (`@pearcurve/sdk`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Install this package to write on-chain** — encode calldata and submit transactions via [ethers v6](https://docs.ethers.org/v6/).
|
|
4
|
+
|
|
5
|
+
For **reading** protocol state (intent book, loans, health), use the **public read API** — no install. See the [pearcurve-api](https://github.com/pearcurve/pearcurve-api) README.
|
|
6
|
+
|
|
7
|
+
> **Repo note:** The SDK moved here from the `pearcurve-solidity` monorepo and publishes as `@pearcurve/sdk` on npm. Its ABIs and addresses come from `@pearcurve/contracts`, published by pearcurve-solidity.
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- **ABIs** — `Main`, `MatchingEngine`, `IntentRegistry` (core), **`IntentRegistryViews`**, `YieldSourceRegistry`, `IYieldSource`, and **`Errors.sol`**, imported from `@pearcurve/contracts`. Bump that dependency after a contracts release.
|
|
12
|
+
- **Custom errors** — `decodeProtocolError` / `formatProtocolError` map revert selectors (`bytes4(keccak256("FillExceedsCapacity()"))`) from `Errors.sol` to human-readable copy. UI, API, and bots should use this instead of scraping wallet text.
|
|
13
|
+
- **Preflight** — `assertLenderSubmitLiquidity(provider, …)` mirrors on-chain checks for `committedCapacity + maxPrincipal` vs yield `balanceOf` or wallet `min(balance, allowance)` before `submitLenderIntent`.
|
|
14
|
+
- **Encoding** — `encodeSubmitLenderIntent`, `encodeMatchBundleOnChain`, etc.
|
|
15
|
+
- **Clients** — `getMain`, `getMatchingEngine`, `getIntentRegistry` (core), **`getIntentRegistryViews`**, `getYieldSourceRegistry`, `getYieldSource` helpers.
|
|
16
|
+
- **Loan positions** — `transferLoanPosition`, `listLoanPosition`, `delistLoanPosition`, and `getLoanPositionTokenFromMain` for direct lender position NFT ownership flows.
|
|
17
|
+
- **Yield sources** — `listApprovedYieldSourceAddresses`, `fetchSupportedYieldSourceApys`, `fetchSupportedYieldSourceApysFromMain` (wraps registry + `IYieldSource.currentApy` / `name`).
|
|
18
|
+
- **Network config** — `src/networkConfig.ts`: `deployments`, `getDeployment`, `requireDeployment`, and `PearcurveChainId` (regenerate after a deployment with `npm run sync-deployments -- @pearcurve/contracts@<version> <chainId>`, then `npm run build`).
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Consumers should depend on **`ethers` ^6.16** (see `peerDependencies`).
|
|
27
|
+
|
|
28
|
+
## API vs SDK
|
|
29
|
+
|
|
30
|
+
| | Read API | SDK (this package) |
|
|
31
|
+
|--|----------|---------------------|
|
|
32
|
+
| **Install** | **None** — public URL | `npm install @pearcurve/sdk` |
|
|
33
|
+
| **Access** | `GET https://api.pearcurve.io/v1/...` | Import + wallet / signer |
|
|
34
|
+
| **Use for** | Dashboards, analytics, bot polling | Submit intents, matches, liquidations |
|
|
35
|
+
| **Location** | Hosted service (pearcurve-api) | This repository |
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Reading — no install
|
|
39
|
+
curl https://api.pearcurve.io/v1/intents/book
|
|
40
|
+
|
|
41
|
+
# Writing — install SDK
|
|
42
|
+
npm install @pearcurve/sdk ethers
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The solver bot reads the on-chain intent book via this SDK (IntentRegistryViews + PriceOracle) and submits `matchBundleOnChain`. Other bots/apps may still fetch the public API for state.
|
|
46
|
+
|
|
47
|
+
### On-chain solver match (integrator / solver bot)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { Wallet } from 'ethers'
|
|
51
|
+
import { getMain, type SolverSolution } from '@pearcurve/sdk'
|
|
52
|
+
|
|
53
|
+
const wallet = new Wallet(privateKey, provider)
|
|
54
|
+
|
|
55
|
+
const sol: SolverSolution = {
|
|
56
|
+
lenderIntentIds: [lenderIntentId],
|
|
57
|
+
borrowerIntentIds: [borrowerIntentId],
|
|
58
|
+
agreedRates: [agreedRateBps],
|
|
59
|
+
fillAmounts: [fillAmount],
|
|
60
|
+
solverTip: 0n,
|
|
61
|
+
solver: wallet.address,
|
|
62
|
+
deadline,
|
|
63
|
+
signature,
|
|
64
|
+
}
|
|
65
|
+
await getMain(mainAddress, wallet).matchBundleOnChain(sol)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Build
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npm run build
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Output: `dist/` (TypeScript declarations included).
|
|
75
|
+
|
|
76
|
+
## Publish
|
|
77
|
+
|
|
78
|
+
`npm run publish:sdk` publishes this package as `@pearcurve/sdk`. It runs the test suite, then `npm publish --access public`. ABIs are loaded from the `@pearcurve/contracts` dependency. A merge does not publish it.
|
|
79
|
+
|
|
80
|
+
Bump `version` in `package.json` first. npm rejects a second publish of the same version. You need to be logged in as a member of the `pearcurve` npm org.
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm run publish:sdk
|
|
84
|
+
npm run publish:sdk -- --dry-run
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Integration tests
|
|
88
|
+
|
|
89
|
+
Tests deploy the same mock stack as `test/TestBase.sol` in pearcurve-solidity against a local **Anvil** instance (spawned by Vitest on port **19545** by default).
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# pearcurve-solidity cloned next to this repo, or set PEARCURVE_CONTRACTS_DIR to it
|
|
93
|
+
(cd ../pearcurve-solidity && forge build) && npm test
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Override port: `ANVIL_PORT=19546 npm test`. Use an existing node: `SKIP_ANVIL=1 ANVIL_RPC_URL=http://127.0.0.1:8545 npm test`.
|
|
97
|
+
|
|
98
|
+
### ethers + Anvil nonces
|
|
99
|
+
|
|
100
|
+
ethers v6’s `Wallet` can cache the account nonce incorrectly across rapid `ContractFactory.deploy` / contract calls. The test helpers use an explicit nonce counter for the deployer during setup, and per-actor counters in integration tests. In your app, prefer `provider.getTransactionCount(address, 'latest')` (or a `NonceManager`-style pattern) when automating many txs from the same key.
|
|
101
|
+
|
|
102
|
+
## Loan Position Helpers
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import {
|
|
106
|
+
getMain,
|
|
107
|
+
getLoanPositionTokenFromMain,
|
|
108
|
+
transferLoanPosition,
|
|
109
|
+
listLoanPosition,
|
|
110
|
+
delistLoanPosition,
|
|
111
|
+
} from '@pearcurve/sdk'
|
|
112
|
+
|
|
113
|
+
const main = getMain(mainAddress, signer)
|
|
114
|
+
const loanPositionToken = await getLoanPositionTokenFromMain(main)
|
|
115
|
+
|
|
116
|
+
await transferLoanPosition(loanPositionToken, signer.address, recipient, 42n)
|
|
117
|
+
await listLoanPosition(main, 42n, 1_050_000000n, usdcAddress, BigInt(Math.floor(Date.now() / 1000) + 7 * 86400))
|
|
118
|
+
await delistLoanPosition(main, 42n)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
Business Source License — see [`LICENSE`](LICENSE); contracts use `LicenseRef-BUSL` SPDX.
|
package/dist/abis.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InterfaceAbi } from 'ethers';
|
|
2
|
+
export declare const protocolErrorsAbi: InterfaceAbi;
|
|
3
|
+
export declare const mainAbi: InterfaceAbi;
|
|
4
|
+
export declare const matchingEngineAbi: InterfaceAbi;
|
|
5
|
+
export declare const intentRegistryAbi: InterfaceAbi;
|
|
6
|
+
export declare const intentRegistryViewsAbi: InterfaceAbi;
|
|
7
|
+
export declare const loanManagerAbi: InterfaceAbi;
|
|
8
|
+
export declare const loanPositionTokenAbi: InterfaceAbi;
|
|
9
|
+
export declare const loanHealthViewerAbi: InterfaceAbi;
|
|
10
|
+
export declare const protocolViewerAbi: InterfaceAbi;
|
|
11
|
+
export declare const loanMarketCapsAbi: InterfaceAbi;
|
|
12
|
+
export declare const yieldSourceAbi: InterfaceAbi;
|
|
13
|
+
export declare const yieldSourceRegistryAbi: InterfaceAbi;
|
|
14
|
+
export declare const feeManagerAbi: InterfaceAbi;
|
|
15
|
+
export declare const secondaryMarketAbi: InterfaceAbi;
|
|
16
|
+
export declare const loanAssetRegistryAbi: InterfaceAbi;
|
|
17
|
+
export declare const collateralTokenRegistryAbi: InterfaceAbi;
|
|
18
|
+
export declare const strategyRegistryAbi: InterfaceAbi;
|
|
19
|
+
export declare const priceOracleAbi: InterfaceAbi;
|
|
20
|
+
export declare const termCurveOracleAbi: InterfaceAbi;
|
|
21
|
+
//# sourceMappingURL=abis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abis.d.ts","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAsB1C,eAAO,MAAM,iBAAiB,EAAiB,YAAY,CAAA;AAC3D,eAAO,MAAM,OAAO,EAAe,YAAY,CAAA;AAC/C,eAAO,MAAM,iBAAiB,EAAyB,YAAY,CAAA;AACnE,eAAO,MAAM,iBAAiB,EAAyB,YAAY,CAAA;AACnE,eAAO,MAAM,sBAAsB,EAA8B,YAAY,CAAA;AAC7E,eAAO,MAAM,cAAc,EAAsB,YAAY,CAAA;AAC7D,eAAO,MAAM,oBAAoB,EAA4B,YAAY,CAAA;AACzE,eAAO,MAAM,mBAAmB,EAA2B,YAAY,CAAA;AACvE,eAAO,MAAM,iBAAiB,EAAyB,YAAY,CAAA;AACnE,eAAO,MAAM,iBAAiB,EAAyB,YAAY,CAAA;AACnE,eAAO,MAAM,cAAc,EAAsB,YAAY,CAAA;AAC7D,eAAO,MAAM,sBAAsB,EAA8B,YAAY,CAAA;AAC7E,eAAO,MAAM,aAAa,EAAqB,YAAY,CAAA;AAC3D,eAAO,MAAM,kBAAkB,EAA0B,YAAY,CAAA;AACrE,eAAO,MAAM,oBAAoB,EAA4B,YAAY,CAAA;AACzE,eAAO,MAAM,0BAA0B,EAAkC,YAAY,CAAA;AACrF,eAAO,MAAM,mBAAmB,EAA2B,YAAY,CAAA;AACvE,eAAO,MAAM,cAAc,EAAsB,YAAY,CAAA;AAC7D,eAAO,MAAM,kBAAkB,EAA0B,YAAY,CAAA"}
|
package/dist/abis.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import collateralTokenRegistryJson from '@pearcurve/contracts/collateralTokenRegistry' with { type: 'json' };
|
|
2
|
+
import errorsJson from '@pearcurve/contracts/errors' with { type: 'json' };
|
|
3
|
+
import feeManagerJson from '@pearcurve/contracts/feeManager' with { type: 'json' };
|
|
4
|
+
import intentRegistryJson from '@pearcurve/contracts/intentRegistry' with { type: 'json' };
|
|
5
|
+
import intentRegistryViewsJson from '@pearcurve/contracts/intentRegistryViews' with { type: 'json' };
|
|
6
|
+
import loanAssetRegistryJson from '@pearcurve/contracts/loanAssetRegistry' with { type: 'json' };
|
|
7
|
+
import loanHealthViewerJson from '@pearcurve/contracts/loanHealthViewer' with { type: 'json' };
|
|
8
|
+
import protocolViewerJson from '@pearcurve/contracts/protocolViewer' with { type: 'json' };
|
|
9
|
+
import loanManagerJson from '@pearcurve/contracts/loanManager' with { type: 'json' };
|
|
10
|
+
import loanMarketCapsJson from '@pearcurve/contracts/loanMarketCaps' with { type: 'json' };
|
|
11
|
+
import loanPositionTokenJson from '@pearcurve/contracts/loanPositionToken' with { type: 'json' };
|
|
12
|
+
import mainJson from '@pearcurve/contracts/main' with { type: 'json' };
|
|
13
|
+
import matchingEngineJson from '@pearcurve/contracts/matchingEngine' with { type: 'json' };
|
|
14
|
+
import priceOracleJson from '@pearcurve/contracts/priceOracle' with { type: 'json' };
|
|
15
|
+
import secondaryMarketJson from '@pearcurve/contracts/secondaryMarket' with { type: 'json' };
|
|
16
|
+
import strategyRegistryJson from '@pearcurve/contracts/strategyRegistry' with { type: 'json' };
|
|
17
|
+
import termCurveOracleJson from '@pearcurve/contracts/termCurveOracle' with { type: 'json' };
|
|
18
|
+
import yieldSourceJson from '@pearcurve/contracts/yieldSource' with { type: 'json' };
|
|
19
|
+
import yieldSourceRegistryJson from '@pearcurve/contracts/yieldSourceRegistry' with { type: 'json' };
|
|
20
|
+
export const protocolErrorsAbi = errorsJson;
|
|
21
|
+
export const mainAbi = mainJson;
|
|
22
|
+
export const matchingEngineAbi = matchingEngineJson;
|
|
23
|
+
export const intentRegistryAbi = intentRegistryJson;
|
|
24
|
+
export const intentRegistryViewsAbi = intentRegistryViewsJson;
|
|
25
|
+
export const loanManagerAbi = loanManagerJson;
|
|
26
|
+
export const loanPositionTokenAbi = loanPositionTokenJson;
|
|
27
|
+
export const loanHealthViewerAbi = loanHealthViewerJson;
|
|
28
|
+
export const protocolViewerAbi = protocolViewerJson;
|
|
29
|
+
export const loanMarketCapsAbi = loanMarketCapsJson;
|
|
30
|
+
export const yieldSourceAbi = yieldSourceJson;
|
|
31
|
+
export const yieldSourceRegistryAbi = yieldSourceRegistryJson;
|
|
32
|
+
export const feeManagerAbi = feeManagerJson;
|
|
33
|
+
export const secondaryMarketAbi = secondaryMarketJson;
|
|
34
|
+
export const loanAssetRegistryAbi = loanAssetRegistryJson;
|
|
35
|
+
export const collateralTokenRegistryAbi = collateralTokenRegistryJson;
|
|
36
|
+
export const strategyRegistryAbi = strategyRegistryJson;
|
|
37
|
+
export const priceOracleAbi = priceOracleJson;
|
|
38
|
+
export const termCurveOracleAbi = termCurveOracleJson;
|
|
39
|
+
//# sourceMappingURL=abis.js.map
|
package/dist/abis.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abis.js","sourceRoot":"","sources":["../src/abis.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,MAAM,8CAA8C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC5G,OAAO,UAAU,MAAM,6BAA6B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC1E,OAAO,cAAc,MAAM,iCAAiC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAClF,OAAO,kBAAkB,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC1F,OAAO,uBAAuB,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AACpG,OAAO,qBAAqB,MAAM,wCAAwC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAChG,OAAO,oBAAoB,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC9F,OAAO,kBAAkB,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAA;AAC1F,OAAO,eAAe,MAAM,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oC,CAAA;AACvE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,eAA+B,CAAA;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,uBAAuC,CAAA;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,cAA8B,CAAA;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmC,CAAA;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqC,CAAA;AACzE,MAAM,CAAC,MAAM,0BAA0B,GAAG,2BAA2C,CAAA;AACrF,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoC,CAAA;AACvE,MAAM,CAAC,MAAM,cAAc,GAAG,eAA+B,CAAA;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Provider } from 'ethers';
|
|
2
|
+
export type AssertBorrowerSubmitCollateralParams = {
|
|
3
|
+
intentRegistry: string;
|
|
4
|
+
loanManager: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
collateral: string;
|
|
7
|
+
maxCollateralAmount: bigint;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Client-side guard mirroring `IntentValidation.validateBorrowerParams` collateral booking:
|
|
11
|
+
* `min(balance, allowance) >= committedCollateral(owner, collateral) + maxCollateralAmount`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function assertBorrowerSubmitCollateral(provider: Provider, p: AssertBorrowerSubmitCollateralParams): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=borrowerSubmitPreflight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borrowerSubmitPreflight.d.ts","sourceRoot":"","sources":["../src/borrowerSubmitPreflight.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAQtC,MAAM,MAAM,oCAAoC,GAAG;IACjD,cAAc,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,mBAAmB,EAAE,MAAM,CAAA;CAC5B,CAAA;AAED;;;GAGG;AACH,wBAAsB,8BAA8B,CAClD,QAAQ,EAAE,QAAQ,EAClB,CAAC,EAAE,oCAAoC,GACtC,OAAO,CAAC,IAAI,CAAC,CAmBf"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Contract, getAddress } from 'ethers';
|
|
2
|
+
import { intentRegistryAbi } from './abis.js';
|
|
3
|
+
const ERC20_MIN_ABI = [
|
|
4
|
+
'function balanceOf(address) view returns (uint256)',
|
|
5
|
+
'function allowance(address,address) view returns (uint256)',
|
|
6
|
+
];
|
|
7
|
+
/**
|
|
8
|
+
* Client-side guard mirroring `IntentValidation.validateBorrowerParams` collateral booking:
|
|
9
|
+
* `min(balance, allowance) >= committedCollateral(owner, collateral) + maxCollateralAmount`.
|
|
10
|
+
*/
|
|
11
|
+
export async function assertBorrowerSubmitCollateral(provider, p) {
|
|
12
|
+
const reg = new Contract(getAddress(p.intentRegistry), intentRegistryAbi, provider);
|
|
13
|
+
const owner = getAddress(p.owner);
|
|
14
|
+
const collateral = getAddress(p.collateral);
|
|
15
|
+
const lm = getAddress(p.loanManager);
|
|
16
|
+
const token = new Contract(collateral, ERC20_MIN_ABI, provider);
|
|
17
|
+
const [committed, bal, alw] = await Promise.all([
|
|
18
|
+
reg.committedCollateral(owner, collateral),
|
|
19
|
+
token.balanceOf(owner),
|
|
20
|
+
token.allowance(owner, lm),
|
|
21
|
+
]);
|
|
22
|
+
const needed = committed + p.maxCollateralAmount;
|
|
23
|
+
const headroom = bal < alw ? bal : alw;
|
|
24
|
+
if (headroom < needed) {
|
|
25
|
+
throw new Error(`Insufficient collateral headroom: need ${needed.toString()} base units (already booked ${committed.toString()} + new cap ${p.maxCollateralAmount.toString()}), min(balance, LoanManager allowance) is ${headroom.toString()}. Approve LoanManager, reduce collateral cap, or cancel other intents.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=borrowerSubmitPreflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borrowerSubmitPreflight.js","sourceRoot":"","sources":["../src/borrowerSubmitPreflight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,aAAa,GAAG;IACpB,oDAAoD;IACpD,4DAA4D;CACpD,CAAA;AAUV;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,QAAkB,EAClB,CAAuC;IAEvC,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,iBAAiB,EAAE,QAAQ,CAAC,CAAA;IACnF,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;IACjC,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IAC3C,MAAM,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAA;IAEpC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,UAAU,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;IAC/D,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC9C,GAAG,CAAC,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAoB;QAC7D,KAAK,CAAC,SAAS,CAAC,KAAK,CAAoB;QACzC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,CAAoB;KAC9C,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,SAAS,GAAG,CAAC,CAAC,mBAAmB,CAAA;IAChD,MAAM,QAAQ,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAA;IACtC,IAAI,QAAQ,GAAG,MAAM,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,0CAA0C,MAAM,CAAC,QAAQ,EAAE,+BAA+B,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,6CAA6C,QAAQ,CAAC,QAAQ,EAAE,wEAAwE,CACrS,CAAA;IACH,CAAC;AACH,CAAC"}
|
package/dist/bps.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CollateralConfig } from './types.js';
|
|
2
|
+
/** On-chain `CollateralConfig`: `uint16` bps; governance uses max 100% = 10_000 bps. */
|
|
3
|
+
export declare const MAX_COLLATERAL_BPS = 10000n;
|
|
4
|
+
/**
|
|
5
|
+
* Reverts if values violate `IntentValidation._validateCollateralConfigBps` rules
|
|
6
|
+
* (`ltv` 1..10000, `lltv` 1..10000, and `ltv <= lltv`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function assertCollateralConfigBps(c: CollateralConfig): void;
|
|
9
|
+
/** Ensures each value fits `uint16` ABI encoding (0..65535); still run `assertCollateralConfigBps` for protocol rules. */
|
|
10
|
+
export declare function assertFitsUint16(name: string, v: bigint): void;
|
|
11
|
+
//# sourceMappingURL=bps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bps.d.ts","sourceRoot":"","sources":["../src/bps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,SAAU,CAAA;AAEzC;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAWnE;AAED,0HAA0H;AAC1H,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAI9D"}
|
package/dist/bps.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** On-chain `CollateralConfig`: `uint16` bps; governance uses max 100% = 10_000 bps. */
|
|
2
|
+
export const MAX_COLLATERAL_BPS = 10000n;
|
|
3
|
+
/**
|
|
4
|
+
* Reverts if values violate `IntentValidation._validateCollateralConfigBps` rules
|
|
5
|
+
* (`ltv` 1..10000, `lltv` 1..10000, and `ltv <= lltv`).
|
|
6
|
+
*/
|
|
7
|
+
export function assertCollateralConfigBps(c) {
|
|
8
|
+
const { ltv, lltv } = c;
|
|
9
|
+
if (ltv <= 0n || ltv > MAX_COLLATERAL_BPS) {
|
|
10
|
+
throw new Error(`CollateralConfig.ltv must be 1–${MAX_COLLATERAL_BPS} (basis points, uint16 on-chain)`);
|
|
11
|
+
}
|
|
12
|
+
if (lltv <= 0n || lltv > MAX_COLLATERAL_BPS) {
|
|
13
|
+
throw new Error(`CollateralConfig.lltv must be 1–${MAX_COLLATERAL_BPS} (basis points, uint16 on-chain)`);
|
|
14
|
+
}
|
|
15
|
+
if (ltv > lltv) {
|
|
16
|
+
throw new Error('CollateralConfig: ltv must be <= lltv');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Ensures each value fits `uint16` ABI encoding (0..65535); still run `assertCollateralConfigBps` for protocol rules. */
|
|
20
|
+
export function assertFitsUint16(name, v) {
|
|
21
|
+
if (v < 0n || v > 65535n) {
|
|
22
|
+
throw new Error(`${name} must fit uint16 (0–65535)`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=bps.js.map
|
package/dist/bps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bps.js","sourceRoot":"","sources":["../src/bps.ts"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAO,CAAA;AAEzC;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,CAAmB;IAC3D,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IACvB,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,GAAG,kBAAkB,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,kCAAkC,kBAAkB,kCAAkC,CAAC,CAAA;IACzG,CAAC;IACD,IAAI,IAAI,IAAI,EAAE,IAAI,IAAI,GAAG,kBAAkB,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,mCAAmC,kBAAkB,kCAAkC,CAAC,CAAA;IAC1G,CAAC;IACD,IAAI,GAAG,GAAG,IAAI,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAC1D,CAAC;AACH,CAAC;AAED,0HAA0H;AAC1H,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,CAAS;IACtD,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,4BAA4B,CAAC,CAAA;IACtD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Contract, type ContractRunner, type InterfaceAbi } from 'ethers';
|
|
2
|
+
import type { Address } from './types.js';
|
|
3
|
+
export declare function getMain(address: Address, runner: ContractRunner): Contract;
|
|
4
|
+
export declare function getMatchingEngine(address: Address, runner: ContractRunner): Contract;
|
|
5
|
+
export declare function getIntentRegistry(address: Address, runner: ContractRunner): Contract;
|
|
6
|
+
/** Read-only facade (`IntentRegistryViews`) — intent tuples, `getPricedCollateralTokensForLoanAsset`, etc. */
|
|
7
|
+
export declare function getIntentRegistryViews(address: Address, runner: ContractRunner): Contract;
|
|
8
|
+
export declare function getLoanManager(address: Address, runner: ContractRunner): Contract;
|
|
9
|
+
export declare function getLoanHealthViewer(address: Address, runner: ContractRunner): Contract;
|
|
10
|
+
export declare function getProtocolViewer(address: Address, runner: ContractRunner): Contract;
|
|
11
|
+
export declare function getLoanMarketCaps(address: Address, runner: ContractRunner): Contract;
|
|
12
|
+
export declare function getYieldSourceRegistry(address: Address, runner: ContractRunner): Contract;
|
|
13
|
+
export declare function getYieldSource(address: Address, runner: ContractRunner): Contract;
|
|
14
|
+
export declare function getFeeManager(address: Address, runner: ContractRunner): Contract;
|
|
15
|
+
export declare function getSecondaryMarket(address: Address, runner: ContractRunner): Contract;
|
|
16
|
+
export declare function getLoanAssetRegistry(address: Address, runner: ContractRunner): Contract;
|
|
17
|
+
export declare function getCollateralTokenRegistry(address: Address, runner: ContractRunner): Contract;
|
|
18
|
+
export declare function getStrategyRegistry(address: Address, runner: ContractRunner): Contract;
|
|
19
|
+
export declare function getPriceOracle(address: Address, runner: ContractRunner): Contract;
|
|
20
|
+
export declare function getTermCurveOracle(address: Address, runner: ContractRunner): Contract;
|
|
21
|
+
/** Use deployed artifact ABI when interacting with a custom facade or mock. */
|
|
22
|
+
export declare function getContract(address: Address, abi: InterfaceAbi, runner: ContractRunner): Contract;
|
|
23
|
+
//# sourceMappingURL=clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,QAAQ,CAAA;AAqBzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,YAE/D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,YAEzE;AAED,wBAAgB,iBAAiB,CAAC,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cAAc,YAEtF"}
|
package/dist/clients.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Contract } from 'ethers';
|
|
2
|
+
import { collateralTokenRegistryAbi, feeManagerAbi, intentRegistryAbi, intentRegistryViewsAbi, loanAssetRegistryAbi, loanHealthViewerAbi, protocolViewerAbi, loanManagerAbi, loanMarketCapsAbi, mainAbi, matchingEngineAbi, priceOracleAbi, secondaryMarketAbi, strategyRegistryAbi, termCurveOracleAbi, yieldSourceAbi, yieldSourceRegistryAbi, } from './abis.js';
|
|
3
|
+
export function getMain(address, runner) {
|
|
4
|
+
return new Contract(address, mainAbi, runner);
|
|
5
|
+
}
|
|
6
|
+
export function getMatchingEngine(address, runner) {
|
|
7
|
+
return new Contract(address, matchingEngineAbi, runner);
|
|
8
|
+
}
|
|
9
|
+
export function getIntentRegistry(address, runner) {
|
|
10
|
+
return new Contract(address, intentRegistryAbi, runner);
|
|
11
|
+
}
|
|
12
|
+
/** Read-only facade (`IntentRegistryViews`) — intent tuples, `getPricedCollateralTokensForLoanAsset`, etc. */
|
|
13
|
+
export function getIntentRegistryViews(address, runner) {
|
|
14
|
+
return new Contract(address, intentRegistryViewsAbi, runner);
|
|
15
|
+
}
|
|
16
|
+
export function getLoanManager(address, runner) {
|
|
17
|
+
return new Contract(address, loanManagerAbi, runner);
|
|
18
|
+
}
|
|
19
|
+
export function getLoanHealthViewer(address, runner) {
|
|
20
|
+
return new Contract(address, loanHealthViewerAbi, runner);
|
|
21
|
+
}
|
|
22
|
+
export function getProtocolViewer(address, runner) {
|
|
23
|
+
return new Contract(address, protocolViewerAbi, runner);
|
|
24
|
+
}
|
|
25
|
+
export function getLoanMarketCaps(address, runner) {
|
|
26
|
+
return new Contract(address, loanMarketCapsAbi, runner);
|
|
27
|
+
}
|
|
28
|
+
export function getYieldSourceRegistry(address, runner) {
|
|
29
|
+
return new Contract(address, yieldSourceRegistryAbi, runner);
|
|
30
|
+
}
|
|
31
|
+
export function getYieldSource(address, runner) {
|
|
32
|
+
return new Contract(address, yieldSourceAbi, runner);
|
|
33
|
+
}
|
|
34
|
+
export function getFeeManager(address, runner) {
|
|
35
|
+
return new Contract(address, feeManagerAbi, runner);
|
|
36
|
+
}
|
|
37
|
+
export function getSecondaryMarket(address, runner) {
|
|
38
|
+
return new Contract(address, secondaryMarketAbi, runner);
|
|
39
|
+
}
|
|
40
|
+
export function getLoanAssetRegistry(address, runner) {
|
|
41
|
+
return new Contract(address, loanAssetRegistryAbi, runner);
|
|
42
|
+
}
|
|
43
|
+
export function getCollateralTokenRegistry(address, runner) {
|
|
44
|
+
return new Contract(address, collateralTokenRegistryAbi, runner);
|
|
45
|
+
}
|
|
46
|
+
export function getStrategyRegistry(address, runner) {
|
|
47
|
+
return new Contract(address, strategyRegistryAbi, runner);
|
|
48
|
+
}
|
|
49
|
+
export function getPriceOracle(address, runner) {
|
|
50
|
+
return new Contract(address, priceOracleAbi, runner);
|
|
51
|
+
}
|
|
52
|
+
export function getTermCurveOracle(address, runner) {
|
|
53
|
+
return new Contract(address, termCurveOracleAbi, runner);
|
|
54
|
+
}
|
|
55
|
+
/** Use deployed artifact ABI when interacting with a custom facade or mock. */
|
|
56
|
+
export function getContract(address, abi, runner) {
|
|
57
|
+
return new Contract(address, abi, runner);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../src/clients.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA0C,MAAM,QAAQ,CAAA;AAEzE,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,sBAAsB,GACvB,MAA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AAE,MAAsB;IACrF,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const MARKET_FEATURE_LABELS: readonly ["Deposit", "Withdraw", "Borrow", "Repay", "Liquidate", "Refinance", "Match", "Secondary"];
|
|
2
|
+
export type DecodedProtocolError = {
|
|
3
|
+
name: string;
|
|
4
|
+
selector: string;
|
|
5
|
+
signature: string;
|
|
6
|
+
args: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
declare const ERROR_STRING_SELECTOR = "0x08c379a0";
|
|
9
|
+
declare const PANIC_SELECTOR = "0x4e487b71";
|
|
10
|
+
/**
|
|
11
|
+
* Pull revert calldata (`0x` + selector [+ args]) from a thrown wallet/RPC error.
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractRevertData(error: unknown): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Decode a Pearcurve / OZ custom error from revert hex or a nested wallet/RPC error.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodeProtocolError(errorOrData: unknown): DecodedProtocolError | null;
|
|
18
|
+
/**
|
|
19
|
+
* Human-readable copy for a decoded protocol error, revert hex, or thrown wallet/RPC error.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatProtocolError(errorOrData: unknown): string | null;
|
|
22
|
+
export declare function protocolErrorSelector(nameOrSignature: string): string | null;
|
|
23
|
+
export { ERROR_STRING_SELECTOR, PANIC_SELECTOR, MARKET_FEATURE_LABELS };
|
|
24
|
+
//# sourceMappingURL=decodeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeError.d.ts","sourceRoot":"","sources":["../src/decodeError.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,qBAAqB,qGASjB,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA;AAED,QAAA,MAAM,qBAAqB,eAAe,CAAA;AAC1C,QAAA,MAAM,cAAc,eAAe,CAAA;AA8JnC;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CA0C/D;AA0DD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CAwBrF;AAuBD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CASvE;AAED,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO5E;AAED,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAA"}
|