stable-layer-sdk 2.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 +39 -24
- package/dist/cjs/index.cjs +669 -367
- package/dist/cjs/index.cjs.map +4 -4
- package/dist/esm/index.mjs +654 -369
- 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 +15 -8
package/README.md
CHANGED
|
@@ -13,20 +13,22 @@ 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
|
-
import {
|
|
31
|
+
import { coinWithBalance, Transaction } from "@mysten/sui/transactions";
|
|
30
32
|
|
|
31
33
|
const tx = new Transaction();
|
|
32
34
|
|
|
@@ -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();
|
|
@@ -96,9 +98,7 @@ await client.buildClaimTx({
|
|
|
96
98
|
const totalSupply = await client.getTotalSupply();
|
|
97
99
|
|
|
98
100
|
// Total supply for a specific coin type
|
|
99
|
-
const btcUsdcSupply = await client.getTotalSupplyByCoinType(
|
|
100
|
-
"0x6d9fc...::btc_usdc::BtcUSDC",
|
|
101
|
-
);
|
|
101
|
+
const btcUsdcSupply = await client.getTotalSupplyByCoinType("0x6d9fc...::btc_usdc::BtcUSDC");
|
|
102
102
|
```
|
|
103
103
|
|
|
104
104
|
### Signing and Executing
|
|
@@ -106,14 +106,17 @@ const btcUsdcSupply = await client.getTotalSupplyByCoinType(
|
|
|
106
106
|
All `build*` methods return a `Transaction` that you sign and execute with the Sui SDK:
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
import {
|
|
109
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
110
110
|
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
111
111
|
|
|
112
|
-
const suiClient = new
|
|
112
|
+
const suiClient = new SuiGrpcClient({
|
|
113
|
+
network: "mainnet",
|
|
114
|
+
baseUrl: "https://fullnode.mainnet.sui.io:443",
|
|
115
|
+
});
|
|
113
116
|
const keypair = Ed25519Keypair.fromSecretKey(YOUR_PRIVATE_KEY);
|
|
114
117
|
|
|
115
118
|
const tx = new Transaction();
|
|
116
|
-
await client.buildMintTx({ tx
|
|
119
|
+
await client.buildMintTx({ tx /* ... */ });
|
|
117
120
|
|
|
118
121
|
const result = await suiClient.signAndExecuteTransaction({
|
|
119
122
|
transaction: tx,
|
|
@@ -121,26 +124,38 @@ const result = await suiClient.signAndExecuteTransaction({
|
|
|
121
124
|
});
|
|
122
125
|
```
|
|
123
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
|
+
|
|
124
131
|
## API
|
|
125
132
|
|
|
126
|
-
### `
|
|
133
|
+
### `StableLayerClient.initialize(config)`
|
|
134
|
+
|
|
135
|
+
Creates a client with config fetched from chain (via Bucket Protocol SDK). Returns `Promise<StableLayerClient>`.
|
|
127
136
|
|
|
128
|
-
| Parameter
|
|
129
|
-
|
|
130
|
-
| `config.network` | `"mainnet" \| "testnet"` | Sui network
|
|
131
|
-
| `config.sender`
|
|
137
|
+
| Parameter | Type | Description |
|
|
138
|
+
| ---------------- | ------------------------ | ---------------------- |
|
|
139
|
+
| `config.network` | `"mainnet" \| "testnet"` | Sui network |
|
|
140
|
+
| `config.sender` | `string` | Default sender address |
|
|
132
141
|
|
|
133
|
-
### Transaction
|
|
142
|
+
### Transaction & query methods
|
|
134
143
|
|
|
135
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.
|
|
136
145
|
|
|
137
|
-
| Method
|
|
138
|
-
|
|
139
|
-
| `buildMintTx(params)`
|
|
140
|
-
| `buildBurnTx(params)`
|
|
141
|
-
| `buildClaimTx(params)`
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
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.
|
|
144
159
|
|
|
145
160
|
## License
|
|
146
161
|
|