@zofai/zo-sdk 0.1.94 → 0.1.96
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 +4 -3
- package/dist/consts/deployments-usdz-mainnet.json +1 -53
- package/dist/implementations/SLPAPI.cjs +34 -0
- package/dist/implementations/SLPAPI.cjs.map +1 -1
- package/dist/implementations/SLPAPI.d.cts +6 -0
- package/dist/implementations/SLPAPI.d.cts.map +1 -1
- package/dist/implementations/SLPAPI.d.mts +6 -0
- package/dist/implementations/SLPAPI.d.mts.map +1 -1
- package/dist/implementations/SLPAPI.mjs +34 -0
- package/dist/implementations/SLPAPI.mjs.map +1 -1
- package/dist/implementations/USDZAPI.cjs +32 -0
- package/dist/implementations/USDZAPI.cjs.map +1 -1
- package/dist/implementations/USDZAPI.d.cts +6 -0
- package/dist/implementations/USDZAPI.d.cts.map +1 -1
- package/dist/implementations/USDZAPI.d.mts +6 -0
- package/dist/implementations/USDZAPI.d.mts.map +1 -1
- package/dist/implementations/USDZAPI.mjs +32 -0
- package/dist/implementations/USDZAPI.mjs.map +1 -1
- package/dist/implementations/ZLPAPI.cjs +34 -0
- package/dist/implementations/ZLPAPI.cjs.map +1 -1
- package/dist/implementations/ZLPAPI.d.cts +6 -0
- package/dist/implementations/ZLPAPI.d.cts.map +1 -1
- package/dist/implementations/ZLPAPI.d.mts +6 -0
- package/dist/implementations/ZLPAPI.d.mts.map +1 -1
- package/dist/implementations/ZLPAPI.mjs +34 -0
- package/dist/implementations/ZLPAPI.mjs.map +1 -1
- package/dist/interfaces/slp.d.cts +5 -0
- package/dist/interfaces/slp.d.cts.map +1 -1
- package/dist/interfaces/slp.d.mts +5 -0
- package/dist/interfaces/slp.d.mts.map +1 -1
- package/dist/interfaces/usdz.d.cts +5 -0
- package/dist/interfaces/usdz.d.cts.map +1 -1
- package/dist/interfaces/usdz.d.mts +5 -0
- package/dist/interfaces/usdz.d.mts.map +1 -1
- package/dist/interfaces/zlp.d.cts +5 -0
- package/dist/interfaces/zlp.d.cts.map +1 -1
- package/dist/interfaces/zlp.d.mts +5 -0
- package/dist/interfaces/zlp.d.mts.map +1 -1
- package/docs/SUMMARY.md +1 -0
- package/docs/getting-started.md +4 -4
- package/docs/introduction.md +3 -3
- package/docs/swap-integration.md +183 -0
- package/docs/type-safety.md +1 -1
- package/package.json +1 -1
- package/src/consts/deployments-usdz-mainnet.json +1 -53
- package/src/implementations/SLPAPI.ts +46 -0
- package/src/implementations/USDZAPI.ts +41 -0
- package/src/implementations/ZLPAPI.ts +43 -0
- package/src/interfaces/slp.ts +13 -0
- package/src/interfaces/usdz.ts +13 -0
- package/src/interfaces/zlp.ts +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zlp.d.mts","sourceRoot":"","sources":["../../src/interfaces/zlp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,yBAAyB,EAAE,iCAAgC;AAEtF,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,cAAc,EACd,iBAAiB,EAClB,mBAAc;AAGf,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,oFAAoF;IACpF,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc;CAAI;AAEzD,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;CAAI;AAEzE,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;CAAI;AAErE,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;CAAI;AAEnE,MAAM,WAAW,cAAe,SAAQ,eAAe;CAAI;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E,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EAAE,EACzB,YAAY,CAAC,EAAE,MAAM,EACrB,EAAE,CAAC,EAAE,WAAW,KACb,OAAO,CAAC,yBAAyB,CAAC,CAAA;CACxC"}
|
package/docs/SUMMARY.md
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* [Architecture](architecture.md)
|
|
5
5
|
* [Getting Started](getting-started.md)
|
|
6
6
|
* [Common Operations](common-operations.md)
|
|
7
|
+
* [Swap Integration](swap-integration.md)
|
|
7
8
|
* [Trading Examples](lp-specific-features.md)
|
|
8
9
|
* [Type Safety](type-safety.md)
|
|
9
10
|
* [Error Handling](error-handling.md)
|
package/docs/getting-started.md
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## 1. Create an API or DataAPI instance
|
|
4
4
|
|
|
5
|
-
Use the **SDK** factory (exported as `SDK` from
|
|
5
|
+
Use the **SDK** factory (exported as `SDK` from `@zofai/zo-sdk`) to create LP-specific instances. You need a Sui client, network, API endpoint, and connection URL.
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
|
-
import { SDK, LPToken, Network } from 'zo-sdk'
|
|
8
|
+
import { SDK, LPToken, Network } from '@zofai/zo-sdk'
|
|
9
9
|
import { SuiClient } from '@mysten/sui/client'
|
|
10
10
|
|
|
11
11
|
const provider = new SuiClient({ url: 'https://fullnode.mainnet.sui.io' })
|
|
12
12
|
const network = Network.MAINNET
|
|
13
|
-
const apiEndpoint = 'https://api.
|
|
14
|
-
const connectionURL = '
|
|
13
|
+
const apiEndpoint = 'https://api.zofinance.io'
|
|
14
|
+
const connectionURL = 'https://hermes.zofinance.io'
|
|
15
15
|
|
|
16
16
|
// Create API instances (transactions + data)
|
|
17
17
|
const zlpAPI = SDK.createZLPAPI(network, provider, apiEndpoint, connectionURL)
|
package/docs/introduction.md
CHANGED
|
@@ -5,11 +5,11 @@ ZO SDK is a TypeScript SDK for interacting with multiple LP tokens on Sui Networ
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install zo-sdk
|
|
8
|
+
npm install @zofai/zo-sdk
|
|
9
9
|
# or
|
|
10
|
-
yarn add zo-sdk
|
|
10
|
+
yarn add @zofai/zo-sdk
|
|
11
11
|
# or
|
|
12
|
-
pnpm add zo-sdk
|
|
12
|
+
pnpm add @zofai/zo-sdk
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
For the full guide, see [Getting Started](getting-started.md).
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# Swap Integration
|
|
2
|
+
|
|
3
|
+
This guide covers how to integrate swaps using the ZO SDK. Swaps are supported on **ZLP**, **SLP**, and **USDZ** via `api.swap()`, `api.swapV2Ptb()`, and fee estimation via `dataAPI.calculateSwapFeeBreakdown()`.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
A swap flow typically involves:
|
|
8
|
+
|
|
9
|
+
1. **Estimate fees** – Get the expected fee breakdown for the swap.
|
|
10
|
+
2. **Set slippage protection** – Compute `minAmountOut` based on expected output and slippage tolerance.
|
|
11
|
+
3. **Build transaction** – Call `api.swap()` to construct the transaction.
|
|
12
|
+
4. **Sign and send** – Sign with the wallet and submit to the network.
|
|
13
|
+
|
|
14
|
+
## Amounts and units
|
|
15
|
+
|
|
16
|
+
- `fromAmount` is in **atomic units** (raw token units), e.g. `1_000_000` for 1 USDC (6 decimals).
|
|
17
|
+
- `minAmountOut` is in **atomic units** of the destination token.
|
|
18
|
+
- `calculateSwapFeeBreakdown(fromAmount)` expects atomic units for the source token.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
// Example: swap 100 USDC (6 decimals) for SUI
|
|
22
|
+
const fromAmount = BigInt(100 * 1e6) // 100_000_000 atomic units
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Estimate swap fees
|
|
26
|
+
|
|
27
|
+
Before building the swap transaction, you can estimate the fee breakdown to display to the user or compute a safe `minAmountOut`.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { SDK, LPToken, Network } from '@zofai/zo-sdk'
|
|
31
|
+
import { SuiClient } from '@mysten/sui/client'
|
|
32
|
+
|
|
33
|
+
const provider = new SuiClient({ url: 'https://fullnode.mainnet.sui.io' })
|
|
34
|
+
const network = Network.MAINNET
|
|
35
|
+
const apiEndpoint = 'https://api.zofinance.io'
|
|
36
|
+
const connectionURL = 'https://hermes.zofinance.io'
|
|
37
|
+
|
|
38
|
+
const slpDataAPI = SDK.createSLPDataAPI(network, provider, apiEndpoint, connectionURL)
|
|
39
|
+
|
|
40
|
+
// fromAmount in atomic units (e.g. 100 USDC = 100 * 1e6)
|
|
41
|
+
const fromToken = 'usdc'
|
|
42
|
+
const toToken = 'sui'
|
|
43
|
+
const fromAmount = 100 * 1e6
|
|
44
|
+
|
|
45
|
+
const feeBreakdown = await slpDataAPI.calculateSwapFeeBreakdown(fromToken, toToken, fromAmount)
|
|
46
|
+
|
|
47
|
+
// feeBreakdown contains:
|
|
48
|
+
// - swapValue: notional in USD
|
|
49
|
+
// - totalVaultsValue: total vault value in USD
|
|
50
|
+
// - rebaseFeeInRate, rebaseFeeOutRate: rates for swap-in and swap-out
|
|
51
|
+
// - rebaseFeeInValue, rebaseFeeOutValue: rebase fee amounts in USD
|
|
52
|
+
// - swapImpactFeeValue: swap impact fee in USD
|
|
53
|
+
// - emaVolatilityFeeValue: EMA volatility fee in USD
|
|
54
|
+
// - totalFeeValue: sum of all fee components
|
|
55
|
+
// - totalFeeRate: totalFeeValue / swapValue
|
|
56
|
+
|
|
57
|
+
console.log(`Total fee: ${feeBreakdown.totalFeeValue.toFixed(4)} USD`)
|
|
58
|
+
console.log(`Fee rate: ${(feeBreakdown.totalFeeRate * 100).toFixed(2)}%`)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Build and submit swap transaction
|
|
62
|
+
|
|
63
|
+
Use the **API** instance to build the swap transaction. You need:
|
|
64
|
+
|
|
65
|
+
- `fromToken`, `toToken` – token identifiers (e.g. `'usdc'`, `'sui'`).
|
|
66
|
+
- `fromAmount` – amount in atomic units (bigint).
|
|
67
|
+
- `fromCoinObjects` – owned coin object IDs for the source token.
|
|
68
|
+
- `minAmountOut` – optional; minimum output amount in atomic units (slippage protection).
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
const slpAPI = SDK.createSLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
72
|
+
|
|
73
|
+
const fromAmount = BigInt(100 * 1e6) // 100 USDC
|
|
74
|
+
const fromCoinObjects = ['0x...'] // user's USDC coin IDs
|
|
75
|
+
|
|
76
|
+
// Optional: set minAmountOut to protect against slippage
|
|
77
|
+
// e.g. 1% slippage: minAmountOut = expectedOut * 0.99
|
|
78
|
+
const minAmountOut = 0 // or compute from oracle + slippage
|
|
79
|
+
|
|
80
|
+
const tx = await slpAPI.swap(
|
|
81
|
+
'usdc',
|
|
82
|
+
'sui',
|
|
83
|
+
fromAmount,
|
|
84
|
+
fromCoinObjects,
|
|
85
|
+
minAmountOut
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
// Sign with wallet and execute
|
|
89
|
+
// const signed = await signAndExecuteTransaction({ transaction: tx })
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Swap and return coin to user (swapV2Ptb)
|
|
93
|
+
|
|
94
|
+
Use `swapV2Ptb()` when you need the output coin returned as a `TransactionObjectArgument`—for example, to pass into another move call or to transfer it within the same transaction. Unlike `swap()`, which consumes the output internally, `swapV2Ptb()` returns the output coin so you can compose it into larger transactions.
|
|
95
|
+
|
|
96
|
+
Pass an optional `tx` to compose into an existing transaction; otherwise a new transaction is created (you must sign and execute it via your wallet).
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
const slpAPI = SDK.createSLPAPI(network, provider, apiEndpoint, connectionURL)
|
|
100
|
+
|
|
101
|
+
// Option 1: Standalone swap (tx created internally)
|
|
102
|
+
const tx = new Transaction()
|
|
103
|
+
const outputCoin = await slpAPI.swapV2Ptb(
|
|
104
|
+
'usdc',
|
|
105
|
+
'sui',
|
|
106
|
+
BigInt(100 * 1e6),
|
|
107
|
+
fromCoinObjects,
|
|
108
|
+
minAmountOut,
|
|
109
|
+
tx
|
|
110
|
+
)
|
|
111
|
+
// tx is modified in place; sign and execute tx
|
|
112
|
+
|
|
113
|
+
// Option 2: Compose with other move calls
|
|
114
|
+
const composedTx = new Transaction()
|
|
115
|
+
const swapCoin = await slpAPI.swapV2Ptb('usdc', 'sui', BigInt(100 * 1e6), fromCoinObjects, minAmountOut, composedTx)
|
|
116
|
+
composedTx.transferObjects([swapCoin], composedTx.pure.address(recipientAddress))
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Complete integration example
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { SDK, LPToken, Network } from '@zofai/zo-sdk'
|
|
123
|
+
import { SuiClient } from '@mysten/sui/client'
|
|
124
|
+
|
|
125
|
+
async function swapWithFeeEstimate(
|
|
126
|
+
fromToken: string,
|
|
127
|
+
toToken: string,
|
|
128
|
+
fromAmountAtomic: number,
|
|
129
|
+
fromCoinObjects: string[],
|
|
130
|
+
slippageBps: number = 50, // 0.5%
|
|
131
|
+
) {
|
|
132
|
+
const provider = new SuiClient({ url: 'https://fullnode.mainnet.sui.io' })
|
|
133
|
+
const api = SDK.createSLPAPI(
|
|
134
|
+
Network.MAINNET,
|
|
135
|
+
provider,
|
|
136
|
+
'https://api.zofinance.io',
|
|
137
|
+
'https://hermes.zofinance.io'
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
// 1. Estimate fees
|
|
141
|
+
const feeBreakdown = await api.dataAPI.calculateSwapFeeBreakdown(
|
|
142
|
+
fromToken,
|
|
143
|
+
toToken,
|
|
144
|
+
fromAmountAtomic
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
// 2. Compute minAmountOut from fee breakdown (net value after fees) and slippage
|
|
148
|
+
const toPrice = (await api.getOraclePrice(toToken)).getPriceUnchecked().getPriceAsNumberUnchecked()
|
|
149
|
+
const toDecimals = 9 // use deployment consts or lookup
|
|
150
|
+
const netValueUsd = feeBreakdown.swapValue - feeBreakdown.totalFeeValue
|
|
151
|
+
const expectedOutAtomic = (netValueUsd * (10 ** toDecimals)) / toPrice
|
|
152
|
+
const minAmountOut = Math.floor(expectedOutAtomic * (1 - slippageBps / 10000))
|
|
153
|
+
|
|
154
|
+
// 3. Build transaction
|
|
155
|
+
const tx = await api.swap(
|
|
156
|
+
fromToken,
|
|
157
|
+
toToken,
|
|
158
|
+
BigInt(fromAmountAtomic),
|
|
159
|
+
fromCoinObjects,
|
|
160
|
+
minAmountOut
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
transaction: tx,
|
|
165
|
+
feeBreakdown,
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Fee components
|
|
171
|
+
|
|
172
|
+
| Component | Description |
|
|
173
|
+
|-----------|-------------|
|
|
174
|
+
| **Rebase fee (in)** | Fee on the source token when swapping in; depends on vault utilization. |
|
|
175
|
+
| **Rebase fee (out)** | Fee on the destination token when swapping out. |
|
|
176
|
+
| **Swap impact fee** | Fee from `SwapImpactConfig`; scales with `swapValue / totalVaultsValue`. |
|
|
177
|
+
| **EMA volatility fee** | Fee from `EmaVolatilityFeeConfig`; scales with price divergence from EMA. |
|
|
178
|
+
|
|
179
|
+
Use `calculateSwapFeeBreakdown` to get the USD value of each component and the total fee before executing the swap.
|
|
180
|
+
|
|
181
|
+
## Token identifiers
|
|
182
|
+
|
|
183
|
+
Tokens are identified by their symbol in the deployment config, e.g. `'sui'`, `'usdc'`, `'usdt'`, `'eth'`, `'btc'`. Ensure the `fromToken` and `toToken` values match those in the LP’s supported tokens.
|
package/docs/type-safety.md
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
IBaseSymbolInfo,
|
|
17
17
|
IBasePositionInfo,
|
|
18
18
|
IBaseOrderInfo
|
|
19
|
-
} from 'zo-sdk'
|
|
19
|
+
} from '@zofai/zo-sdk'
|
|
20
20
|
|
|
21
21
|
// All APIs implement their respective interfaces
|
|
22
22
|
const zlpAPI: IZLPAPI = SDK.createZLPAPI(network, provider, apiEndpoint, connectionURL)
|
package/package.json
CHANGED
|
@@ -143,56 +143,6 @@
|
|
|
143
143
|
"funding_fee_model": "0xc1c25c0402b1cee0af7c724aedee71fe64436bdee285a37f5a6dcca3004c6eba",
|
|
144
144
|
"position_config": "0x4786e2d0688cfca6329952689f364a6c2ff928ab98262c6beb7aedb1186bc37d"
|
|
145
145
|
},
|
|
146
|
-
"long_spy": {
|
|
147
|
-
"supported_collaterals": ["nusdc"],
|
|
148
|
-
"funding_fee_model": "0x9f39668bc0893250e13d4592dabbf030b4ddd58b38b64c027a0b2858a489dac5",
|
|
149
|
-
"position_config": "0x802ef0a8ced165f79029323c1077e9e6e313b9da7b5522bd70f1690c9ac34f13"
|
|
150
|
-
},
|
|
151
|
-
"short_spy": {
|
|
152
|
-
"supported_collaterals": ["nusdc"],
|
|
153
|
-
"funding_fee_model": "0x92f774684fd05c0bd20e2a690237f856795df7a2464d789306e2789de67c73ab",
|
|
154
|
-
"position_config": "0x9ad859654c3f981e710953a25f4ee6a31470d95b02c6c666cee69878819c439d"
|
|
155
|
-
},
|
|
156
|
-
"long_nlr": {
|
|
157
|
-
"supported_collaterals": ["nusdc"],
|
|
158
|
-
"funding_fee_model": "0x2a47b62ee1a4def0588451cc945e98c1764ecbba9d4b31ce57c5cfc84725cd72",
|
|
159
|
-
"position_config": "0x8696123eba339bc0f4502b331a04ddc85b319bb08b50ba203481873d57df2094"
|
|
160
|
-
},
|
|
161
|
-
"short_nlr": {
|
|
162
|
-
"supported_collaterals": ["nusdc"],
|
|
163
|
-
"funding_fee_model": "0x7ec7a3539d6d7dbbab77e740c27ce0ca2f3f0654664b700f8ad94cfd79c105ed",
|
|
164
|
-
"position_config": "0xc9d655679f822d32c290764cf3797b70ef75a1566590ecfbbbddda2f2a40551a"
|
|
165
|
-
},
|
|
166
|
-
"long_qqq": {
|
|
167
|
-
"supported_collaterals": ["nusdc"],
|
|
168
|
-
"funding_fee_model": "0xbf7fbc99f0951c7cdb8fa1f2d37dc4571abc26c56f163b2e8a6b5130fd4920f4",
|
|
169
|
-
"position_config": "0x095d89be4c5dd3f461764e8a48d9a3f6a8bb62096dc5de84ef9f406770aea771"
|
|
170
|
-
},
|
|
171
|
-
"short_qqq": {
|
|
172
|
-
"supported_collaterals": ["nusdc"],
|
|
173
|
-
"funding_fee_model": "0xd934bfbc094c62cb200bb06eedf884c3a5c19497c92851788f7951a761c34b8f",
|
|
174
|
-
"position_config": "0x6069084d0479949512ccbb7bb7b0caccb7adf93e41dd8664bc5145ed7d1a62de"
|
|
175
|
-
},
|
|
176
|
-
"long_mu": {
|
|
177
|
-
"supported_collaterals": ["nusdc"],
|
|
178
|
-
"funding_fee_model": "0x6d9ca08af29c10928f6e57b6b083a47d45084f4000c39547e7c914d2a713c9e3",
|
|
179
|
-
"position_config": "0x41df6ebcfc8341b3f867d9cdf2b02e55d65862ad34030426c96f85ee54ba3449"
|
|
180
|
-
},
|
|
181
|
-
"short_mu": {
|
|
182
|
-
"supported_collaterals": ["nusdc"],
|
|
183
|
-
"funding_fee_model": "0x0071f4b04835ebea7780d8987eff310e942eca887b92f1017e4d8157d68fc308",
|
|
184
|
-
"position_config": "0x3706ead42207539e92fa8db05face103cf6c23ec9735f9a6b4525d4eb5881375"
|
|
185
|
-
},
|
|
186
|
-
"long_googl": {
|
|
187
|
-
"supported_collaterals": ["nusdc"],
|
|
188
|
-
"funding_fee_model": "0x8bc23ee0a7ee544703e3da151b980e89ffa957668a3f306a0d562a1dec35ea4d",
|
|
189
|
-
"position_config": "0x203f6e25a01c8725df531c76bf09bca630a55bce832920d9c8b748bbc815ca0d"
|
|
190
|
-
},
|
|
191
|
-
"short_googl": {
|
|
192
|
-
"supported_collaterals": ["nusdc"],
|
|
193
|
-
"funding_fee_model": "0x2a060d17867c08e0c5937c97d7a8ad7bca8642a9060f20f5f10cf88cd09301f2",
|
|
194
|
-
"position_config": "0xd7ce0bdcc8ede8ce1eeb137e8da3dd0b327ff54b346e765eed2bd8caf1db322c"
|
|
195
|
-
},
|
|
196
146
|
"long_wti": {
|
|
197
147
|
"supported_collaterals": ["nusdc"],
|
|
198
148
|
"funding_fee_model": "0xe04cce47722ad061de705e1f9c6527976d07879a5c08a3e35101ce70453f55ec",
|
|
@@ -483,9 +433,7 @@
|
|
|
483
433
|
}
|
|
484
434
|
},
|
|
485
435
|
"zo_staking": {
|
|
486
|
-
"pools": [
|
|
487
|
-
"0x283291d471764236db56b692f4f890c4d244a2891c478ee16c7e5076b6ad0fa7"
|
|
488
|
-
],
|
|
436
|
+
"pools": ["0x283291d471764236db56b692f4f890c4d244a2891c478ee16c7e5076b6ad0fa7"],
|
|
489
437
|
"upgrade_cap": "0x0b2ebbdedd751039cf033c1b24f61069b26cb2f99523789e150b5db59f13ccfd",
|
|
490
438
|
"package": "0x87c13bb9157c3d51d61c7802704539d9d4782e838aadc41df0d6f0cc117298ba",
|
|
491
439
|
"admin_cap": "0xe339faca7f7558bdf8256e7174d0543e5db99befcd0e5b9bef9c421cecabc195",
|
|
@@ -441,6 +441,52 @@ export class SLPAPI extends BaseAPI implements ISLPAPI {
|
|
|
441
441
|
return tx
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
+
/**
|
|
445
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
446
|
+
* Same as swap() but returns the output coin as TransactionObjectArgument for use in composed transactions.
|
|
447
|
+
* Pass optional tx to compose with other move calls; otherwise a new transaction is created.
|
|
448
|
+
*/
|
|
449
|
+
public async swapV2Ptb(
|
|
450
|
+
fromToken: string,
|
|
451
|
+
toToken: string,
|
|
452
|
+
fromAmount: bigint,
|
|
453
|
+
fromCoinObjects: string[],
|
|
454
|
+
minAmountOut?: number,
|
|
455
|
+
tx?: Transaction,
|
|
456
|
+
): Promise<TransactionObjectArgument> {
|
|
457
|
+
if (!tx) {
|
|
458
|
+
tx = new Transaction()
|
|
459
|
+
}
|
|
460
|
+
tx = await this.initOracleTxb(
|
|
461
|
+
Object.keys(this.consts.sudoCore.vaults),
|
|
462
|
+
tx,
|
|
463
|
+
)
|
|
464
|
+
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
465
|
+
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
466
|
+
tx.pure.u64(fromAmount),
|
|
467
|
+
])
|
|
468
|
+
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
469
|
+
|
|
470
|
+
const [outputCoin] = tx.moveCall({
|
|
471
|
+
target: `${this.consts.sudoCore.upgradedPackage}::market::swap_v2_ptb`,
|
|
472
|
+
typeArguments: [
|
|
473
|
+
`${this.consts.sudoCore.package}::slp::SLP`,
|
|
474
|
+
this.consts.coins[fromToken].module,
|
|
475
|
+
this.consts.coins[toToken].module,
|
|
476
|
+
],
|
|
477
|
+
arguments: [
|
|
478
|
+
tx.object(this.consts.sudoCore.market),
|
|
479
|
+
tx.object(this.consts.sudoCore.rebaseFeeModel),
|
|
480
|
+
fromDepositObject,
|
|
481
|
+
tx.pure.u64(minAmountOut || 0),
|
|
482
|
+
vaultsValuation,
|
|
483
|
+
tx.object(this.consts.pythFeeder.feeder[fromToken]),
|
|
484
|
+
tx.object(this.consts.pythFeeder.feeder[toToken]),
|
|
485
|
+
],
|
|
486
|
+
})
|
|
487
|
+
return outputCoin
|
|
488
|
+
}
|
|
489
|
+
|
|
444
490
|
/**
|
|
445
491
|
* Stakes SLP tokens in ZO staking pools
|
|
446
492
|
*/
|
|
@@ -1473,6 +1473,47 @@ export class USDZAPI extends BaseAPI implements IUSDZAPI {
|
|
|
1473
1473
|
return tx
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
+
/**
|
|
1477
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
1478
|
+
* Same as swap() but returns the output coin as TransactionObjectArgument for use in composed transactions.
|
|
1479
|
+
* Pass optional tx to compose into an existing transaction.
|
|
1480
|
+
*/
|
|
1481
|
+
public async swapV2Ptb(
|
|
1482
|
+
fromToken: string,
|
|
1483
|
+
toToken: string,
|
|
1484
|
+
fromAmount: bigint,
|
|
1485
|
+
fromCoinObjects: string[],
|
|
1486
|
+
minAmountOut?: number,
|
|
1487
|
+
tx?: Transaction,
|
|
1488
|
+
): Promise<TransactionObjectArgument> {
|
|
1489
|
+
if (!tx) {
|
|
1490
|
+
tx = new Transaction()
|
|
1491
|
+
}
|
|
1492
|
+
tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx)
|
|
1493
|
+
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
1494
|
+
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
1495
|
+
tx.pure.u64(fromAmount),
|
|
1496
|
+
])
|
|
1497
|
+
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
1498
|
+
|
|
1499
|
+
const [outputCoin] = tx.moveCall({
|
|
1500
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::swap_v2_ptb`,
|
|
1501
|
+
typeArguments: [
|
|
1502
|
+
`${this.consts.zoCore.package}::usdz::USDZ`,
|
|
1503
|
+
this.consts.coins[fromToken].module,
|
|
1504
|
+
this.consts.coins[toToken].module,
|
|
1505
|
+
],
|
|
1506
|
+
arguments: [
|
|
1507
|
+
tx.object(this.consts.zoCore.market),
|
|
1508
|
+
tx.object(this.consts.zoCore.rebaseFeeModel),
|
|
1509
|
+
fromDepositObject,
|
|
1510
|
+
tx.pure.u64(minAmountOut || 0),
|
|
1511
|
+
vaultsValuation,
|
|
1512
|
+
],
|
|
1513
|
+
})
|
|
1514
|
+
return outputCoin
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1476
1517
|
/**
|
|
1477
1518
|
* Opens a new position in USDZ
|
|
1478
1519
|
*/
|
|
@@ -624,6 +624,49 @@ export class ZLPAPI extends BaseAPI implements IZLPAPI {
|
|
|
624
624
|
return tx
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
+
/**
|
|
628
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
629
|
+
* Same as swap() but returns the output coin as TransactionObjectArgument for use in composed transactions.
|
|
630
|
+
* Pass optional tx to compose with other move calls; otherwise a new transaction is created.
|
|
631
|
+
*/
|
|
632
|
+
public async swapV2Ptb(
|
|
633
|
+
fromToken: string,
|
|
634
|
+
toToken: string,
|
|
635
|
+
fromAmount: bigint,
|
|
636
|
+
fromCoinObjects: string[],
|
|
637
|
+
minAmountOut?: number,
|
|
638
|
+
tx?: Transaction,
|
|
639
|
+
): Promise<TransactionObjectArgument> {
|
|
640
|
+
if (!tx) {
|
|
641
|
+
tx = new Transaction()
|
|
642
|
+
}
|
|
643
|
+
tx = await this.initOracleTxb(Object.keys(this.consts.zoCore.vaults), tx)
|
|
644
|
+
const fromCoinObject = this.processCoins(tx, fromToken, fromCoinObjects)
|
|
645
|
+
const [fromDepositObject] = tx.splitCoins(fromCoinObject, [
|
|
646
|
+
tx.pure.u64(fromAmount),
|
|
647
|
+
])
|
|
648
|
+
const vaultsValuation = this.dataAPI.valuateVaults(tx)
|
|
649
|
+
|
|
650
|
+
const [outputCoin] = tx.moveCall({
|
|
651
|
+
target: `${this.consts.zoCore.upgradedPackage}::market::swap_v2_ptb`,
|
|
652
|
+
typeArguments: [
|
|
653
|
+
`${this.consts.zoCore.package}::zlp::ZLP`,
|
|
654
|
+
this.consts.coins[fromToken].module,
|
|
655
|
+
this.consts.coins[toToken].module,
|
|
656
|
+
],
|
|
657
|
+
arguments: [
|
|
658
|
+
tx.object(this.consts.zoCore.market),
|
|
659
|
+
tx.object(this.consts.zoCore.rebaseFeeModel),
|
|
660
|
+
fromDepositObject,
|
|
661
|
+
tx.pure.u64(minAmountOut || 0),
|
|
662
|
+
vaultsValuation,
|
|
663
|
+
tx.object(this.consts.pythFeeder.feeder[fromToken]),
|
|
664
|
+
tx.object(this.consts.pythFeeder.feeder[toToken]),
|
|
665
|
+
],
|
|
666
|
+
})
|
|
667
|
+
return outputCoin
|
|
668
|
+
}
|
|
669
|
+
|
|
627
670
|
/**
|
|
628
671
|
* Opens a new position in ZLP
|
|
629
672
|
*/
|
package/src/interfaces/slp.ts
CHANGED
|
@@ -274,4 +274,17 @@ export interface ISLPAPI extends IBaseAPI {
|
|
|
274
274
|
pool: string,
|
|
275
275
|
tx: Transaction,
|
|
276
276
|
) => TransactionObjectArgument[]
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
280
|
+
* Same as swap() but returns the output coin for use in composed transactions.
|
|
281
|
+
*/
|
|
282
|
+
swapV2Ptb: (
|
|
283
|
+
fromToken: string,
|
|
284
|
+
toToken: string,
|
|
285
|
+
fromAmount: bigint,
|
|
286
|
+
fromCoinObjects: string[],
|
|
287
|
+
minAmountOut?: number,
|
|
288
|
+
tx?: Transaction,
|
|
289
|
+
) => Promise<TransactionObjectArgument>
|
|
277
290
|
}
|
package/src/interfaces/usdz.ts
CHANGED
|
@@ -187,4 +187,17 @@ export interface IUSDZAPI extends IBaseAPI {
|
|
|
187
187
|
pool: string,
|
|
188
188
|
tx: Transaction,
|
|
189
189
|
) => TransactionObjectArgument[]
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
193
|
+
* Same as swap() but returns the output coin for use in composed transactions.
|
|
194
|
+
*/
|
|
195
|
+
swapV2Ptb: (
|
|
196
|
+
fromToken: string,
|
|
197
|
+
toToken: string,
|
|
198
|
+
fromAmount: bigint,
|
|
199
|
+
fromCoinObjects: string[],
|
|
200
|
+
minAmountOut?: number,
|
|
201
|
+
tx?: Transaction,
|
|
202
|
+
) => Promise<TransactionObjectArgument>
|
|
190
203
|
}
|
package/src/interfaces/zlp.ts
CHANGED
|
@@ -250,4 +250,17 @@ export interface IZLPAPI extends IBaseAPI {
|
|
|
250
250
|
pool: string,
|
|
251
251
|
tx: Transaction,
|
|
252
252
|
) => TransactionObjectArgument[]
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Swaps tokens and returns the output coin to the user (PTB).
|
|
256
|
+
* Same as swap() but returns the output coin for use in composed transactions.
|
|
257
|
+
*/
|
|
258
|
+
swapV2Ptb: (
|
|
259
|
+
fromToken: string,
|
|
260
|
+
toToken: string,
|
|
261
|
+
fromAmount: bigint,
|
|
262
|
+
fromCoinObjects: string[],
|
|
263
|
+
minAmountOut?: number,
|
|
264
|
+
tx?: Transaction,
|
|
265
|
+
) => Promise<TransactionObjectArgument>
|
|
253
266
|
}
|