@picon-finance/dlmm-sdk 1.17.3 → 1.18.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.
@@ -1 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/entities/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,aAAa,CAAC;AAMrB,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EACjB,MAAM,UAAU,CAAC;AAWlB,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,gBAAgB,IAAI,oBAAoB,EAC9C,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,QAAQ,EAKT,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAA4B,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,IAAI;;IAQf,OAAO,eAYN;IAED,IAAW,GAAG,+5nBAAwB;IAEtC,IAAW,cAAc,YAAmC;IAC5D,IAAW,OAAO,oBAAoC;IACtD,IAAW,IAAI,mBAAiC;IAChD,IAAW,WAAW,WAAoC;IAE1D,IAAW,UAAU,YAAmC;IACxD,IAAW,UAAU,YAAmC;IAExD,IAAW,cAAc,WAAwC;IACjE,IAAW,cAAc,WAAwC;IAEjE,IAAW,WAAW,YAAoC;IAC1D,IAAW,WAAW,YAAoC;IAE1D,IAAW,aAAa,YAAyC;IACjE,IAAW,aAAa,YAAyC;IAEpD,eAAe,IAAI,OAAO,CAAC;QAAE,YAAY,CAAC,EAAE,WAAW,CAAC;QAAC,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EAAE,OAAO,EAChB,cAAc,EAAE,OAAO,EACvB,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAWf;CACF;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACrF,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,UAAU,CAC9B,EACE,SAAS,EACT,OAAO,EACP,OAAO,EACP,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,aAAa,EACb,aAAa,GACd,EAAE;IACD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;CACxB,EACD,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,WAAW,CAAC,CAkBtB"}
@@ -198,8 +198,11 @@ export class Pool {
198
198
  inputTransferFee: xToY ? transferFeeX : transferFeeY,
199
199
  outputTransferFee: xToY ? transferFeeY : transferFeeX,
200
200
  binArrays,
201
+ // A swap instruction is built against the full requested amount — a partial fill here
202
+ // would silently under-deliver, so keep the strict all-or-nothing contract.
203
+ allowPartialFill: false,
201
204
  });
202
- const binArrayAddresses = this.#binArrayAddressesForQuote(xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBinId);
205
+ const binArrayAddresses = this.#binArrayAddressesForQuote(xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBin.binId);
203
206
  return { quoteOutput, binArrayAddresses };
204
207
  }
205
208
  async #quoteExactOut({ xToY, amountOut, slippageToleranceBps, }) {
@@ -213,8 +216,11 @@ export class Pool {
213
216
  inputTransferFee: xToY ? transferFeeX : transferFeeY,
214
217
  outputTransferFee: xToY ? transferFeeY : transferFeeX,
215
218
  binArrays,
219
+ // A swap instruction is built against the full requested amount — a partial fill here
220
+ // would silently under-deliver, so keep the strict all-or-nothing contract.
221
+ allowPartialFill: false,
216
222
  });
217
- const binArrayAddresses = this.#binArrayAddressesForQuote(xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBinId);
223
+ const binArrayAddresses = this.#binArrayAddressesForQuote(xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBin.binId);
218
224
  return { quoteOutput, binArrayAddresses };
219
225
  }
220
226
  // The bin array window a quote might touch, before the quote itself narrows down how much of
@@ -2,7 +2,7 @@
2
2
  "address": "pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC",
3
3
  "metadata": {
4
4
  "name": "picon_dlmm",
5
- "version": "1.1.1",
5
+ "version": "1.1.2",
6
6
  "spec": "0.1.0",
7
7
  "description": "Created with Anchor"
8
8
  },
@@ -11,6 +11,11 @@ export interface BinArray {
11
11
  bins: Bin[];
12
12
  }
13
13
 
14
+ export interface BinEntry {
15
+ binId: number;
16
+ price: bigint;
17
+ }
18
+
14
19
  export interface DynamicFeeConfig {
15
20
  filterPeriod: number;
16
21
  decayPeriod: number;
@@ -50,17 +55,33 @@ export interface QuoteExactInInput {
50
55
  binArrays: (BinArray | undefined)[];
51
56
  inputTransferFee?: TransferFee;
52
57
  outputTransferFee?: TransferFee;
58
+ /**
59
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
60
+ */
61
+ allowPartialFill: boolean;
53
62
  }
54
63
 
55
64
  export interface QuoteExactInOutput {
56
- preActiveBinId: number;
57
- postActiveBinId: number;
58
- amountIn: bigint;
65
+ preActiveBin: BinEntry;
66
+ postActiveBin: BinEntry;
67
+ /**
68
+ * What this quote was requested for.
69
+ */
70
+ requestedAmountIn: bigint;
71
+ /**
72
+ * What was actually consumed — use this, not `requested_amount_in`, to build a swap
73
+ * instruction. Differs from it only when `not_enough_liquidity` is `true`.
74
+ */
75
+ consumedAmountIn: bigint;
59
76
  amountOut: bigint;
60
77
  minAmountOut: bigint;
61
78
  fee: bigint;
62
79
  feeRateMin: bigint;
63
80
  feeRateMax: bigint;
81
+ /**
82
+ * `true` on a partial fill.
83
+ */
84
+ notEnoughLiquidity: boolean;
64
85
  }
65
86
 
66
87
  export interface QuoteExactOutInput {
@@ -75,17 +96,26 @@ export interface QuoteExactOutInput {
75
96
  binArrays: (BinArray | undefined)[];
76
97
  inputTransferFee?: TransferFee;
77
98
  outputTransferFee?: TransferFee;
99
+ /**
100
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
101
+ */
102
+ allowPartialFill: boolean;
78
103
  }
79
104
 
80
105
  export interface QuoteExactOutOutput {
81
- preActiveBinId: number;
82
- postActiveBinId: number;
106
+ preActiveBin: BinEntry;
107
+ postActiveBin: BinEntry;
83
108
  /**
84
- * Echoes `input.amount_out`, net.
109
+ * What this quote was requested for, net.
85
110
  */
86
- amountOut: bigint;
111
+ requestedAmountOut: bigint;
87
112
  /**
88
- * Gross of DLMM fee and input transfer fee — what the trader pays.
113
+ * What was actually achieved, net — differs from `requested_amount_out` only when
114
+ * `not_enough_liquidity` is `true`; `amount_in` below is its real cost.
115
+ */
116
+ consumedAmountOut: bigint;
117
+ /**
118
+ * Gross of DLMM fee and input transfer fee — what the trader pays for `consumed_amount_out`.
89
119
  */
90
120
  amountIn: bigint;
91
121
  /**
@@ -98,6 +128,10 @@ export interface QuoteExactOutOutput {
98
128
  fee: bigint;
99
129
  feeRateMin: bigint;
100
130
  feeRateMax: bigint;
131
+ /**
132
+ * `true` on a partial fill.
133
+ */
134
+ notEnoughLiquidity: boolean;
101
135
  }
102
136
 
103
137
  export interface TransferFee {
@@ -11,6 +11,11 @@ export interface BinArray {
11
11
  bins: Bin[];
12
12
  }
13
13
 
14
+ export interface BinEntry {
15
+ binId: number;
16
+ price: bigint;
17
+ }
18
+
14
19
  export interface DynamicFeeConfig {
15
20
  filterPeriod: number;
16
21
  decayPeriod: number;
@@ -50,17 +55,33 @@ export interface QuoteExactInInput {
50
55
  binArrays: (BinArray | undefined)[];
51
56
  inputTransferFee?: TransferFee;
52
57
  outputTransferFee?: TransferFee;
58
+ /**
59
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
60
+ */
61
+ allowPartialFill: boolean;
53
62
  }
54
63
 
55
64
  export interface QuoteExactInOutput {
56
- preActiveBinId: number;
57
- postActiveBinId: number;
58
- amountIn: bigint;
65
+ preActiveBin: BinEntry;
66
+ postActiveBin: BinEntry;
67
+ /**
68
+ * What this quote was requested for.
69
+ */
70
+ requestedAmountIn: bigint;
71
+ /**
72
+ * What was actually consumed — use this, not `requested_amount_in`, to build a swap
73
+ * instruction. Differs from it only when `not_enough_liquidity` is `true`.
74
+ */
75
+ consumedAmountIn: bigint;
59
76
  amountOut: bigint;
60
77
  minAmountOut: bigint;
61
78
  fee: bigint;
62
79
  feeRateMin: bigint;
63
80
  feeRateMax: bigint;
81
+ /**
82
+ * `true` on a partial fill.
83
+ */
84
+ notEnoughLiquidity: boolean;
64
85
  }
65
86
 
66
87
  export interface QuoteExactOutInput {
@@ -75,17 +96,26 @@ export interface QuoteExactOutInput {
75
96
  binArrays: (BinArray | undefined)[];
76
97
  inputTransferFee?: TransferFee;
77
98
  outputTransferFee?: TransferFee;
99
+ /**
100
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
101
+ */
102
+ allowPartialFill: boolean;
78
103
  }
79
104
 
80
105
  export interface QuoteExactOutOutput {
81
- preActiveBinId: number;
82
- postActiveBinId: number;
106
+ preActiveBin: BinEntry;
107
+ postActiveBin: BinEntry;
83
108
  /**
84
- * Echoes `input.amount_out`, net.
109
+ * What this quote was requested for, net.
85
110
  */
86
- amountOut: bigint;
111
+ requestedAmountOut: bigint;
87
112
  /**
88
- * Gross of DLMM fee and input transfer fee — what the trader pays.
113
+ * What was actually achieved, net — differs from `requested_amount_out` only when
114
+ * `not_enough_liquidity` is `true`; `amount_in` below is its real cost.
115
+ */
116
+ consumedAmountOut: bigint;
117
+ /**
118
+ * Gross of DLMM fee and input transfer fee — what the trader pays for `consumed_amount_out`.
89
119
  */
90
120
  amountIn: bigint;
91
121
  /**
@@ -98,6 +128,10 @@ export interface QuoteExactOutOutput {
98
128
  fee: bigint;
99
129
  feeRateMin: bigint;
100
130
  feeRateMax: bigint;
131
+ /**
132
+ * `true` on a partial fill.
133
+ */
134
+ notEnoughLiquidity: boolean;
101
135
  }
102
136
 
103
137
  export interface TransferFee {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picon-finance/dlmm-sdk",
3
- "version": "1.17.3",
3
+ "version": "1.18.1",
4
4
  "description": "Typescript SDK for interacting with the Picon DLMM protocol",
5
5
  "author": "Picon Finance",
6
6
  "license": "MIT",
@@ -389,10 +389,13 @@ export class Pool {
389
389
  inputTransferFee: xToY ? transferFeeX : transferFeeY,
390
390
  outputTransferFee: xToY ? transferFeeY : transferFeeX,
391
391
  binArrays,
392
+ // A swap instruction is built against the full requested amount — a partial fill here
393
+ // would silently under-deliver, so keep the strict all-or-nothing contract.
394
+ allowPartialFill: false,
392
395
  });
393
396
 
394
397
  const binArrayAddresses = this.#binArrayAddressesForQuote(
395
- xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBinId,
398
+ xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBin.binId,
396
399
  );
397
400
  return { quoteOutput, binArrayAddresses };
398
401
  }
@@ -420,10 +423,13 @@ export class Pool {
420
423
  inputTransferFee: xToY ? transferFeeX : transferFeeY,
421
424
  outputTransferFee: xToY ? transferFeeY : transferFeeX,
422
425
  binArrays,
426
+ // A swap instruction is built against the full requested amount — a partial fill here
427
+ // would silently under-deliver, so keep the strict all-or-nothing contract.
428
+ allowPartialFill: false,
423
429
  });
424
430
 
425
431
  const binArrayAddresses = this.#binArrayAddressesForQuote(
426
- xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBinId,
432
+ xToY, indices, maxBinArrayAddresses, quoteOutput.postActiveBin.binId,
427
433
  );
428
434
  return { quoteOutput, binArrayAddresses };
429
435
  }
@@ -2,7 +2,7 @@
2
2
  "address": "pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC",
3
3
  "metadata": {
4
4
  "name": "picon_dlmm",
5
- "version": "1.1.1",
5
+ "version": "1.1.2",
6
6
  "spec": "0.1.0",
7
7
  "description": "Created with Anchor"
8
8
  },
@@ -11,6 +11,11 @@ export interface BinArray {
11
11
  bins: Bin[];
12
12
  }
13
13
 
14
+ export interface BinEntry {
15
+ binId: number;
16
+ price: bigint;
17
+ }
18
+
14
19
  export interface DynamicFeeConfig {
15
20
  filterPeriod: number;
16
21
  decayPeriod: number;
@@ -50,17 +55,33 @@ export interface QuoteExactInInput {
50
55
  binArrays: (BinArray | undefined)[];
51
56
  inputTransferFee?: TransferFee;
52
57
  outputTransferFee?: TransferFee;
58
+ /**
59
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
60
+ */
61
+ allowPartialFill: boolean;
53
62
  }
54
63
 
55
64
  export interface QuoteExactInOutput {
56
- preActiveBinId: number;
57
- postActiveBinId: number;
58
- amountIn: bigint;
65
+ preActiveBin: BinEntry;
66
+ postActiveBin: BinEntry;
67
+ /**
68
+ * What this quote was requested for.
69
+ */
70
+ requestedAmountIn: bigint;
71
+ /**
72
+ * What was actually consumed — use this, not `requested_amount_in`, to build a swap
73
+ * instruction. Differs from it only when `not_enough_liquidity` is `true`.
74
+ */
75
+ consumedAmountIn: bigint;
59
76
  amountOut: bigint;
60
77
  minAmountOut: bigint;
61
78
  fee: bigint;
62
79
  feeRateMin: bigint;
63
80
  feeRateMax: bigint;
81
+ /**
82
+ * `true` on a partial fill.
83
+ */
84
+ notEnoughLiquidity: boolean;
64
85
  }
65
86
 
66
87
  export interface QuoteExactOutInput {
@@ -75,17 +96,26 @@ export interface QuoteExactOutInput {
75
96
  binArrays: (BinArray | undefined)[];
76
97
  inputTransferFee?: TransferFee;
77
98
  outputTransferFee?: TransferFee;
99
+ /**
100
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
101
+ */
102
+ allowPartialFill: boolean;
78
103
  }
79
104
 
80
105
  export interface QuoteExactOutOutput {
81
- preActiveBinId: number;
82
- postActiveBinId: number;
106
+ preActiveBin: BinEntry;
107
+ postActiveBin: BinEntry;
83
108
  /**
84
- * Echoes `input.amount_out`, net.
109
+ * What this quote was requested for, net.
85
110
  */
86
- amountOut: bigint;
111
+ requestedAmountOut: bigint;
87
112
  /**
88
- * Gross of DLMM fee and input transfer fee — what the trader pays.
113
+ * What was actually achieved, net — differs from `requested_amount_out` only when
114
+ * `not_enough_liquidity` is `true`; `amount_in` below is its real cost.
115
+ */
116
+ consumedAmountOut: bigint;
117
+ /**
118
+ * Gross of DLMM fee and input transfer fee — what the trader pays for `consumed_amount_out`.
89
119
  */
90
120
  amountIn: bigint;
91
121
  /**
@@ -98,6 +128,10 @@ export interface QuoteExactOutOutput {
98
128
  fee: bigint;
99
129
  feeRateMin: bigint;
100
130
  feeRateMax: bigint;
131
+ /**
132
+ * `true` on a partial fill.
133
+ */
134
+ notEnoughLiquidity: boolean;
101
135
  }
102
136
 
103
137
  export interface TransferFee {
@@ -11,6 +11,11 @@ export interface BinArray {
11
11
  bins: Bin[];
12
12
  }
13
13
 
14
+ export interface BinEntry {
15
+ binId: number;
16
+ price: bigint;
17
+ }
18
+
14
19
  export interface DynamicFeeConfig {
15
20
  filterPeriod: number;
16
21
  decayPeriod: number;
@@ -50,17 +55,33 @@ export interface QuoteExactInInput {
50
55
  binArrays: (BinArray | undefined)[];
51
56
  inputTransferFee?: TransferFee;
52
57
  outputTransferFee?: TransferFee;
58
+ /**
59
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
60
+ */
61
+ allowPartialFill: boolean;
53
62
  }
54
63
 
55
64
  export interface QuoteExactInOutput {
56
- preActiveBinId: number;
57
- postActiveBinId: number;
58
- amountIn: bigint;
65
+ preActiveBin: BinEntry;
66
+ postActiveBin: BinEntry;
67
+ /**
68
+ * What this quote was requested for.
69
+ */
70
+ requestedAmountIn: bigint;
71
+ /**
72
+ * What was actually consumed — use this, not `requested_amount_in`, to build a swap
73
+ * instruction. Differs from it only when `not_enough_liquidity` is `true`.
74
+ */
75
+ consumedAmountIn: bigint;
59
76
  amountOut: bigint;
60
77
  minAmountOut: bigint;
61
78
  fee: bigint;
62
79
  feeRateMin: bigint;
63
80
  feeRateMax: bigint;
81
+ /**
82
+ * `true` on a partial fill.
83
+ */
84
+ notEnoughLiquidity: boolean;
64
85
  }
65
86
 
66
87
  export interface QuoteExactOutInput {
@@ -75,17 +96,26 @@ export interface QuoteExactOutInput {
75
96
  binArrays: (BinArray | undefined)[];
76
97
  inputTransferFee?: TransferFee;
77
98
  outputTransferFee?: TransferFee;
99
+ /**
100
+ * Report a partial fill as `Ok` instead of `Err(InsufficientLiquidity)`.
101
+ */
102
+ allowPartialFill: boolean;
78
103
  }
79
104
 
80
105
  export interface QuoteExactOutOutput {
81
- preActiveBinId: number;
82
- postActiveBinId: number;
106
+ preActiveBin: BinEntry;
107
+ postActiveBin: BinEntry;
83
108
  /**
84
- * Echoes `input.amount_out`, net.
109
+ * What this quote was requested for, net.
85
110
  */
86
- amountOut: bigint;
111
+ requestedAmountOut: bigint;
87
112
  /**
88
- * Gross of DLMM fee and input transfer fee — what the trader pays.
113
+ * What was actually achieved, net — differs from `requested_amount_out` only when
114
+ * `not_enough_liquidity` is `true`; `amount_in` below is its real cost.
115
+ */
116
+ consumedAmountOut: bigint;
117
+ /**
118
+ * Gross of DLMM fee and input transfer fee — what the trader pays for `consumed_amount_out`.
89
119
  */
90
120
  amountIn: bigint;
91
121
  /**
@@ -98,6 +128,10 @@ export interface QuoteExactOutOutput {
98
128
  fee: bigint;
99
129
  feeRateMin: bigint;
100
130
  feeRateMax: bigint;
131
+ /**
132
+ * `true` on a partial fill.
133
+ */
134
+ notEnoughLiquidity: boolean;
101
135
  }
102
136
 
103
137
  export interface TransferFee {