@pearcurve/sdk 0.1.1 → 0.1.3

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 (2) hide show
  1. package/README.md +17 -18
  2. package/package.json +2 -4
package/README.md CHANGED
@@ -1,29 +1,29 @@
1
1
  # Pearcurve TypeScript SDK (`@pearcurve/sdk`)
2
2
 
3
- **Install this package to write on-chain** — encode calldata and submit transactions via [ethers v6](https://docs.ethers.org/v6/).
3
+ Encode calldata and submit Pearcurve transactions with [ethers v6](https://docs.ethers.org/v6/).
4
4
 
5
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
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.
7
+ ABIs come from the [`@pearcurve/contracts`](https://www.npmjs.com/package/@pearcurve/contracts) dependency. Deployment addresses live in `src/networkConfig.ts`.
8
8
 
9
9
  ## Contents
10
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.
11
+ - **ABIs** — `Main`, `MatchingEngine`, `IntentRegistry` (core), **`IntentRegistryViews`**, `YieldSourceRegistry`, `IYieldSource`, and protocol errors, imported from `@pearcurve/contracts`. Bump that dependency after a contracts release.
12
+ - **Custom errors** — `decodeProtocolError` / `formatProtocolError` map revert selectors (`bytes4(keccak256("FillExceedsCapacity()"))`) to human-readable copy. UI, API, and bots should use this instead of scraping wallet text.
13
13
  - **Preflight** — `assertLenderSubmitLiquidity(provider, …)` mirrors on-chain checks for `committedCapacity + maxPrincipal` vs yield `balanceOf` or wallet `min(balance, allowance)` before `submitLenderIntent`.
14
14
  - **Encoding** — `encodeSubmitLenderIntent`, `encodeMatchBundleOnChain`, etc.
15
15
  - **Clients** — `getMain`, `getMatchingEngine`, `getIntentRegistry` (core), **`getIntentRegistryViews`**, `getYieldSourceRegistry`, `getYieldSource` helpers.
16
16
  - **Loan positions** — `transferLoanPosition`, `listLoanPosition`, `delistLoanPosition`, and `getLoanPositionTokenFromMain` for direct lender position NFT ownership flows.
17
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`).
18
+ - **Network config** — `deployments`, `getDeployment`, `requireDeployment`, and `PearcurveChainId`. Refresh addresses with `npm run sync-deployments -- @pearcurve/contracts@<version> <chainId>`, then `npm run build`.
19
19
 
20
20
  ## Install
21
21
 
22
22
  ```bash
23
- npm install
23
+ npm install @pearcurve/sdk ethers
24
24
  ```
25
25
 
26
- Consumers should depend on **`ethers` ^6.16** (see `peerDependencies`).
26
+ `ethers` is a peer dependency (`^6.16`). Working in this repository: `npm install`.
27
27
 
28
28
  ## API vs SDK
29
29
 
@@ -42,7 +42,7 @@ curl https://api.pearcurve.io/v1/intents/book
42
42
  npm install @pearcurve/sdk ethers
43
43
  ```
44
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.
45
+ The solver bot reads the on-chain intent book via this SDK (IntentRegistryViews + PriceOracle) and submits `matchBundleOnChain`. Other bots and apps may still fetch the public API for state.
46
46
 
47
47
  ### On-chain solver match (integrator / solver bot)
48
48
 
@@ -71,11 +71,11 @@ await getMain(mainAddress, wallet).matchBundleOnChain(sol)
71
71
  npm run build
72
72
  ```
73
73
 
74
- Output: `dist/` (TypeScript declarations included).
74
+ Output: `dist/` (TypeScript declarations included). `prepack` runs this before `npm publish`.
75
75
 
76
76
  ## Publish
77
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.
78
+ `npm run publish:sdk` publishes this package as `@pearcurve/sdk`. It runs the test suite, then `npm publish --access public`. A merge does not publish it.
79
79
 
80
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
81
 
@@ -84,22 +84,21 @@ npm run publish:sdk
84
84
  npm run publish:sdk -- --dry-run
85
85
  ```
86
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).
87
+ ## Tests
90
88
 
91
89
  ```bash
92
- # pearcurve-solidity cloned next to this repo, or set PEARCURVE_CONTRACTS_DIR to it
93
- (cd ../pearcurve-solidity && forge build) && npm test
90
+ npm test
94
91
  ```
95
92
 
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`.
93
+ Integration tests deploy the protocol against a local **Anvil** node (Vitest starts one on port **19545** by default) and load Foundry artifacts from `PEARCURVE_CONTRACTS_DIR`. That variable defaults to `../pearcurve-solidity`, which must already contain `out/` from `forge build`.
94
+
95
+ Override the port with `ANVIL_PORT=19546 npm test`. Use an existing node with `SKIP_ANVIL=1 ANVIL_RPC_URL=http://127.0.0.1:8545 npm test`.
97
96
 
98
97
  ### ethers + Anvil nonces
99
98
 
100
99
  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
100
 
102
- ## Loan Position Helpers
101
+ ## Loan position helpers
103
102
 
104
103
  ```typescript
105
104
  import {
@@ -120,4 +119,4 @@ await delistLoanPosition(main, 42n)
120
119
 
121
120
  ## License
122
121
 
123
- Business Source License — see [`LICENSE`](LICENSE); contracts use `LicenseRef-BUSL` SPDX.
122
+ Business Source License — see [`LICENSE`](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pearcurve/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "TypeScript SDK for Pearcurve protocol (ethers, calldata helpers)",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -27,13 +27,11 @@
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest"
29
29
  },
30
- "dependencies": {
31
- "@pearcurve/contracts": "^0.1.0"
32
- },
33
30
  "peerDependencies": {
34
31
  "ethers": "^6.16.0"
35
32
  },
36
33
  "devDependencies": {
34
+ "@pearcurve/contracts": "^0.1.2",
37
35
  "@types/node": "^22.10.0",
38
36
  "ethers": "^6.16.0",
39
37
  "tsx": "^4.19.0",