stable-layer-sdk 3.0.0 → 3.1.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/README.md +27 -13
- package/dist/cjs/index.cjs +404 -99
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.mjs +389 -99
- package/dist/esm/index.mjs.map +4 -4
- package/dist/types/index.d.ts +16 -2
- package/dist/types/interface.d.ts +29 -1
- package/dist/types/libs/constants.d.ts +31 -12
- package/dist/types/libs/constants.mainnet.d.ts +20 -0
- package/dist/types/libs/constants.testnet.d.ts +22 -0
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -13,17 +13,19 @@ npm install stable-layer-sdk @mysten/sui @mysten/bcs
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { StableLayerClient } from "stable-layer-sdk";
|
|
15
15
|
|
|
16
|
-
const client =
|
|
17
|
-
network: "mainnet",
|
|
16
|
+
const client = await StableLayerClient.initialize({
|
|
17
|
+
network: "mainnet", // or "testnet" (mint/burn/claim use mock_farm; see src/libs/constants.testnet.ts)
|
|
18
18
|
sender: "0xYOUR_ADDRESS",
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
Testnet republish overrides: optional `mockFarmRegistryId`, `mockFarmPackageId`, `mockUsdbCoinType` on `initialize`.
|
|
23
|
+
|
|
22
24
|
## Examples
|
|
23
25
|
|
|
24
26
|
### Mint Stablecoins
|
|
25
27
|
|
|
26
|
-
Deposit USDC to mint stablecoins. The SDK builds a transaction that mints via Stable Layer and deposits into the vault farm.
|
|
28
|
+
Deposit USDC to mint stablecoins. The SDK builds a transaction that mints via Stable Layer and deposits into the vault farm (mainnet); on testnet, flow uses `mock_farm::receive` after mint.
|
|
27
29
|
|
|
28
30
|
```typescript
|
|
29
31
|
import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
|
|
@@ -78,7 +80,7 @@ await client.buildBurnTx({
|
|
|
78
80
|
|
|
79
81
|
### Claim Rewards
|
|
80
82
|
|
|
81
|
-
Claim
|
|
83
|
+
Claim yield (mainnet: vault farm; testnet: `mock_farm::claim`).
|
|
82
84
|
|
|
83
85
|
```typescript
|
|
84
86
|
const tx = new Transaction();
|
|
@@ -122,26 +124,38 @@ const result = await suiClient.signAndExecuteTransaction({
|
|
|
122
124
|
});
|
|
123
125
|
```
|
|
124
126
|
|
|
127
|
+
## Testing
|
|
128
|
+
|
|
129
|
+
`pnpm exec vitest run` hits mainnet RPC from `test/e2e/`. Use `QUERY_OUTPUT=1` or `pnpm query-output` for extra simulation logs. Optional `E2E_ASSERT_POSITIVE=1` asserts a positive USDB preview in the manager `getClaimRewardUsdbAmount` e2e (default only checks type and non-negative amount so CI does not depend on live accrued rewards). Opt-in live testnet mint/burn: `pnpm test:e2e:testnet` (env vars in `test/e2e/testnet-mint-burn.e2e.ts`).
|
|
130
|
+
|
|
125
131
|
## API
|
|
126
132
|
|
|
127
|
-
### `
|
|
133
|
+
### `StableLayerClient.initialize(config)`
|
|
134
|
+
|
|
135
|
+
Creates a client with config fetched from chain (via Bucket Protocol SDK). Returns `Promise<StableLayerClient>`.
|
|
128
136
|
|
|
129
137
|
| Parameter | Type | Description |
|
|
130
138
|
| ---------------- | ------------------------ | ---------------------- |
|
|
131
139
|
| `config.network` | `"mainnet" \| "testnet"` | Sui network |
|
|
132
140
|
| `config.sender` | `string` | Default sender address |
|
|
133
141
|
|
|
134
|
-
### Transaction
|
|
142
|
+
### Transaction & query methods
|
|
135
143
|
|
|
136
144
|
All methods accept a `tx` (Transaction) and optional `sender` to override the default. Set `autoTransfer: false` to get the resulting coin back instead of auto-transferring.
|
|
137
145
|
|
|
138
|
-
| Method
|
|
139
|
-
|
|
|
140
|
-
| `buildMintTx(params)`
|
|
141
|
-
| `buildBurnTx(params)`
|
|
142
|
-
| `buildClaimTx(params)`
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
146
|
+
| Method | Description |
|
|
147
|
+
| ---------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
148
|
+
| `buildMintTx(params)` | Mint from USDC (testnet: + `mock_farm::receive`) |
|
|
149
|
+
| `buildBurnTx(params)` | Burn to USDC (testnet: `mock_farm::pay`) |
|
|
150
|
+
| `buildClaimTx(params)` | Claim rewards (testnet: `mock_farm::claim`) |
|
|
151
|
+
| `buildSetMaxSupplyTx(params)` | Update max supply |
|
|
152
|
+
| `getClaimRewardUsdbAmount(params)` | Simulate `buildClaimTx`; sum USDB credit (testnet: mock USDB type) — throws if dry-run fails |
|
|
153
|
+
| `getTotalSupply()` | Total supply from registry |
|
|
154
|
+
| `getTotalSupplyByCoinType(type)` | Supply for one coin type |
|
|
155
|
+
|
|
156
|
+
### `getConstants(network)` / `StableLayerClient.getConstants`
|
|
157
|
+
|
|
158
|
+
Returns protocol object IDs and type strings for `mainnet` or `testnet` without building a client.
|
|
145
159
|
|
|
146
160
|
## License
|
|
147
161
|
|