@chainflip/sdk 1.3.0-beta.6 → 1.4.0-alpha.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/dist/funding.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-TOAMIDO2.mjs';
2
- import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-QNH6727P.mjs';
1
+ import { getFlipBalance, getFundingEnvironment, getStateChainGatewayContractAddress, approve, getTokenContractAddress, checkAllowance, extractOverrides, StateChainGateway__factory } from './chunk-HT34JS2O.mjs';
2
+ import { __name, __publicField, ChainflipNetworks, InternalAssets, assert } from './chunk-Q6JCV35Y.mjs';
3
3
 
4
4
  // ../shared/src/stateChainGateway/utils.ts
5
5
  var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
@@ -28,12 +28,14 @@ var fundStateChainAccount = /* @__PURE__ */ __name(async (accountId, amount, net
28
28
  const { hasSufficientAllowance } = await checkAllowance(amount, await stateChainGateway.getAddress(), flipContractAddress, networkOpts.signer);
29
29
  assert(hasSufficientAllowance, "Insufficient allowance");
30
30
  const transaction = await stateChainGateway.fundStateChainAccount(accountId, amount, extractOverrides(txOpts));
31
- return transaction.wait(txOpts.wait);
31
+ await transaction.wait(txOpts.wait);
32
+ return transaction;
32
33
  }, "fundStateChainAccount");
33
34
  var executeRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts, txOpts) => {
34
35
  const stateChainGateway = getStateChainGateway(networkOpts);
35
36
  const transaction = await stateChainGateway.executeRedemption(accountId, extractOverrides(txOpts));
36
- return transaction.wait(txOpts.wait);
37
+ await transaction.wait(txOpts.wait);
38
+ return transaction;
37
39
  }, "executeRedemption");
38
40
  var getMinimumFunding = /* @__PURE__ */ __name((networkOpts) => {
39
41
  const stateChainGateway = getStateChainGateway(networkOpts);
@@ -98,8 +100,8 @@ var _FundingSDK = class _FundingSDK {
98
100
  * @returns the transaction hash or null if no approval was required
99
101
  */
100
102
  async approveStateChainGateway(amount, txOpts = {}) {
101
- const receipt = await approveStateChainGateway(amount, this.options, txOpts);
102
- return receipt ? receipt.hash : null;
103
+ const tx = await approveStateChainGateway(amount, this.options, txOpts);
104
+ return tx ? tx.hash : null;
103
105
  }
104
106
  async getRedemptionTax() {
105
107
  this.redemptionTax ?? (this.redemptionTax = (await getFundingEnvironment(this.rpcConfig)).redemptionTax);
package/dist/swap.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as Chain, A as Asset, I as InternalAsset, a as AssetOfChain, b as ChainflipNetwork, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-b0BB7B5m.mjs';
3
- export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-b0BB7B5m.mjs';
2
+ import { C as Chain, A as Asset, I as InternalAsset, a as AssetOfChain, b as ChainflipNetwork, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-ZLesmWHT.mjs';
3
+ export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-ZLesmWHT.mjs';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const ccmMetadataSchema: z.ZodObject<{
@@ -14,19 +14,42 @@ declare const ccmMetadataSchema: z.ZodObject<{
14
14
  gasBudget: string;
15
15
  }>;
16
16
  type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
17
+ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
18
+ account: z.ZodEffects<z.ZodString, string, string>;
19
+ commissionBps: z.ZodNumber;
20
+ }, "strip", z.ZodTypeAny, {
21
+ account: string;
22
+ commissionBps: number;
23
+ }, {
24
+ account: string;
25
+ commissionBps: number;
26
+ }>, {
27
+ account: string;
28
+ bps: number;
29
+ }, {
30
+ account: string;
31
+ commissionBps: number;
32
+ }>;
33
+ type AffiliateBroker = z.input<typeof affiliateBroker>;
17
34
  type SwapFee = {
18
35
  type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST';
19
36
  chain: Chain;
20
37
  asset: Asset;
21
38
  amount: string;
22
39
  };
23
- type QuoteQueryResponse = {
40
+ type QuoteDetails = {
24
41
  intermediateAmount?: string;
25
42
  egressAmount: string;
26
43
  includedFees: SwapFee[];
27
44
  lowLiquidityWarning: boolean | undefined;
28
45
  estimatedDurationSeconds: number;
29
46
  };
47
+ type BoostedQuoteDetails = QuoteDetails & {
48
+ estimatedBoostFeeBps: number;
49
+ };
50
+ type QuoteQueryResponse = QuoteDetails & {
51
+ boostQuote?: BoostedQuoteDetails;
52
+ };
30
53
 
31
54
  interface ExecuteSwapParams {
32
55
  srcChain: Chain;
@@ -68,19 +91,22 @@ interface ChainsAndAssets {
68
91
  }
69
92
  interface QuoteRequest extends ChainsAndAssets {
70
93
  amount: string;
71
- boostFeeBps?: number;
94
+ brokerCommissionBps?: number;
95
+ affiliateBrokers?: AffiliateBroker[];
72
96
  }
73
- interface QuoteResponse extends Omit<QuoteRequest, 'boostFeeBps'> {
97
+ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
74
98
  quote: QuoteQueryResponse;
75
99
  }
76
100
  interface DepositAddressRequest extends QuoteRequest {
77
101
  destAddress: string;
78
102
  ccmMetadata?: CcmMetadata;
103
+ maxBoostFeeBps?: number;
79
104
  }
80
105
  interface DepositAddressResponse extends DepositAddressRequest {
81
106
  depositChannelId: string;
82
107
  depositAddress: string;
83
108
  brokerCommissionBps: number;
109
+ affiliateBrokers: AffiliateBroker[];
84
110
  depositChannelExpiryBlock: bigint;
85
111
  estimatedDepositChannelExpiryTime: number | undefined;
86
112
  channelOpeningFee: bigint;
@@ -91,10 +117,7 @@ interface SwapStatusRequest {
91
117
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
92
118
  destAddress: string;
93
119
  ccmDepositReceivedBlockIndex: string | undefined;
94
- ccmMetadata: {
95
- gasBudget: string;
96
- message: `0x${string}`;
97
- } | undefined;
120
+ ccmMetadata: CcmMetadata | undefined;
98
121
  feesPaid: SwapFee[];
99
122
  }
100
123
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
@@ -106,7 +129,25 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
106
129
  estimatedDepositChannelExpiryTime: number;
107
130
  isDepositChannelExpired: boolean;
108
131
  depositChannelOpenedThroughBackend: boolean;
132
+ depositChannelAffiliateBrokers?: {
133
+ account: string;
134
+ commissionBps: number;
135
+ }[];
109
136
  }
137
+ type BroadcastRequested = {
138
+ swapId: string;
139
+ depositAmount: string;
140
+ depositReceivedAt: number;
141
+ depositReceivedBlockIndex: string;
142
+ intermediateAmount: string | undefined;
143
+ swapExecutedAt: number;
144
+ swapExecutedBlockIndex: string;
145
+ egressAmount: string;
146
+ egressScheduledAt: number;
147
+ egressScheduledBlockIndex: string;
148
+ broadcastRequestedAt: number;
149
+ broadcastRequestedBlockIndex: string;
150
+ };
110
151
  type CopyFields<T, U> = {
111
152
  [K in Exclude<keyof T, keyof U>]: undefined;
112
153
  } & U;
@@ -160,54 +201,21 @@ type SwapState = {
160
201
  egressAmount: string;
161
202
  egressScheduledAt: number;
162
203
  egressScheduledBlockIndex: string;
163
- } | {
164
- state: 'BROADCAST_REQUESTED' | 'BROADCASTED';
165
- swapId: string;
166
- depositAmount: string;
167
- depositReceivedAt: number;
168
- depositReceivedBlockIndex: string;
169
- intermediateAmount: string | undefined;
170
- swapExecutedAt: number;
171
- swapExecutedBlockIndex: string;
172
- egressAmount: string;
173
- egressScheduledAt: number;
174
- egressScheduledBlockIndex: string;
175
- broadcastRequestedAt: number;
176
- broadcastRequestedBlockIndex: string;
177
- } | {
204
+ } | ({
205
+ state: 'BROADCAST_REQUESTED';
206
+ } & BroadcastRequested) | ({
207
+ state: 'BROADCASTED';
208
+ broadcastTransactionRef: string;
209
+ } & BroadcastRequested) | ({
178
210
  state: 'BROADCAST_ABORTED';
179
- swapId: string;
180
- depositAmount: string;
181
- depositReceivedAt: number;
182
- depositReceivedBlockIndex: string;
183
- intermediateAmount: string | undefined;
184
- swapExecutedAt: number;
185
- swapExecutedBlockIndex: string;
186
- egressAmount: string;
187
- egressScheduledAt: number;
188
- egressScheduledBlockIndex: string;
189
- broadcastRequestedAt: number;
190
- broadcastRequestedBlockIndex: string;
191
211
  broadcastAbortedAt: number;
192
212
  broadcastAbortedBlockIndex: string;
193
- } | {
213
+ } & BroadcastRequested) | ({
194
214
  state: 'COMPLETE';
195
- swapId: string;
196
- depositAmount: string;
197
- depositReceivedAt: number;
198
- depositReceivedBlockIndex: string;
199
- intermediateAmount: string | undefined;
200
- swapExecutedAt: number;
201
- swapExecutedBlockIndex: string;
202
- egressAmount: string;
203
- egressScheduledAt: number;
204
- egressScheduledBlockIndex: string;
205
- broadcastRequestedAt: number;
206
- broadcastRequestedBlockIndex: string;
207
215
  broadcastSucceededAt: number;
208
216
  broadcastSucceededBlockIndex: string;
209
217
  broadcastTransactionRef: string;
210
- } | {
218
+ } & BroadcastRequested) | {
211
219
  state: 'FAILED';
212
220
  failure: 'INGRESS_IGNORED';
213
221
  error: {
package/dist/swap.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Signer } from 'ethers';
2
- import { C as Chain, A as Asset, I as InternalAsset, a as AssetOfChain, b as ChainflipNetwork, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-b0BB7B5m.js';
3
- export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-b0BB7B5m.js';
2
+ import { C as Chain, A as Asset, I as InternalAsset, a as AssetOfChain, b as ChainflipNetwork, T as TransactionOptions, c as ChainAssetMap, d as ChainMap } from './contracts-ZLesmWHT.js';
3
+ export { f as Assets, g as ChainflipIds, h as ChainflipNetworks, e as Chains, i as getChainflipId } from './contracts-ZLesmWHT.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const ccmMetadataSchema: z.ZodObject<{
@@ -14,19 +14,42 @@ declare const ccmMetadataSchema: z.ZodObject<{
14
14
  gasBudget: string;
15
15
  }>;
16
16
  type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
17
+ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
18
+ account: z.ZodEffects<z.ZodString, string, string>;
19
+ commissionBps: z.ZodNumber;
20
+ }, "strip", z.ZodTypeAny, {
21
+ account: string;
22
+ commissionBps: number;
23
+ }, {
24
+ account: string;
25
+ commissionBps: number;
26
+ }>, {
27
+ account: string;
28
+ bps: number;
29
+ }, {
30
+ account: string;
31
+ commissionBps: number;
32
+ }>;
33
+ type AffiliateBroker = z.input<typeof affiliateBroker>;
17
34
  type SwapFee = {
18
35
  type: 'LIQUIDITY' | 'NETWORK' | 'INGRESS' | 'EGRESS' | 'BROKER' | 'BOOST';
19
36
  chain: Chain;
20
37
  asset: Asset;
21
38
  amount: string;
22
39
  };
23
- type QuoteQueryResponse = {
40
+ type QuoteDetails = {
24
41
  intermediateAmount?: string;
25
42
  egressAmount: string;
26
43
  includedFees: SwapFee[];
27
44
  lowLiquidityWarning: boolean | undefined;
28
45
  estimatedDurationSeconds: number;
29
46
  };
47
+ type BoostedQuoteDetails = QuoteDetails & {
48
+ estimatedBoostFeeBps: number;
49
+ };
50
+ type QuoteQueryResponse = QuoteDetails & {
51
+ boostQuote?: BoostedQuoteDetails;
52
+ };
30
53
 
31
54
  interface ExecuteSwapParams {
32
55
  srcChain: Chain;
@@ -68,19 +91,22 @@ interface ChainsAndAssets {
68
91
  }
69
92
  interface QuoteRequest extends ChainsAndAssets {
70
93
  amount: string;
71
- boostFeeBps?: number;
94
+ brokerCommissionBps?: number;
95
+ affiliateBrokers?: AffiliateBroker[];
72
96
  }
73
- interface QuoteResponse extends Omit<QuoteRequest, 'boostFeeBps'> {
97
+ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affiliateBrokers'> {
74
98
  quote: QuoteQueryResponse;
75
99
  }
76
100
  interface DepositAddressRequest extends QuoteRequest {
77
101
  destAddress: string;
78
102
  ccmMetadata?: CcmMetadata;
103
+ maxBoostFeeBps?: number;
79
104
  }
80
105
  interface DepositAddressResponse extends DepositAddressRequest {
81
106
  depositChannelId: string;
82
107
  depositAddress: string;
83
108
  brokerCommissionBps: number;
109
+ affiliateBrokers: AffiliateBroker[];
84
110
  depositChannelExpiryBlock: bigint;
85
111
  estimatedDepositChannelExpiryTime: number | undefined;
86
112
  channelOpeningFee: bigint;
@@ -91,10 +117,7 @@ interface SwapStatusRequest {
91
117
  interface SwapStatusResponseCommonFields extends ChainsAndAssets {
92
118
  destAddress: string;
93
119
  ccmDepositReceivedBlockIndex: string | undefined;
94
- ccmMetadata: {
95
- gasBudget: string;
96
- message: `0x${string}`;
97
- } | undefined;
120
+ ccmMetadata: CcmMetadata | undefined;
98
121
  feesPaid: SwapFee[];
99
122
  }
100
123
  interface DepositAddressFields extends SwapStatusResponseCommonFields {
@@ -106,7 +129,25 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
106
129
  estimatedDepositChannelExpiryTime: number;
107
130
  isDepositChannelExpired: boolean;
108
131
  depositChannelOpenedThroughBackend: boolean;
132
+ depositChannelAffiliateBrokers?: {
133
+ account: string;
134
+ commissionBps: number;
135
+ }[];
109
136
  }
137
+ type BroadcastRequested = {
138
+ swapId: string;
139
+ depositAmount: string;
140
+ depositReceivedAt: number;
141
+ depositReceivedBlockIndex: string;
142
+ intermediateAmount: string | undefined;
143
+ swapExecutedAt: number;
144
+ swapExecutedBlockIndex: string;
145
+ egressAmount: string;
146
+ egressScheduledAt: number;
147
+ egressScheduledBlockIndex: string;
148
+ broadcastRequestedAt: number;
149
+ broadcastRequestedBlockIndex: string;
150
+ };
110
151
  type CopyFields<T, U> = {
111
152
  [K in Exclude<keyof T, keyof U>]: undefined;
112
153
  } & U;
@@ -160,54 +201,21 @@ type SwapState = {
160
201
  egressAmount: string;
161
202
  egressScheduledAt: number;
162
203
  egressScheduledBlockIndex: string;
163
- } | {
164
- state: 'BROADCAST_REQUESTED' | 'BROADCASTED';
165
- swapId: string;
166
- depositAmount: string;
167
- depositReceivedAt: number;
168
- depositReceivedBlockIndex: string;
169
- intermediateAmount: string | undefined;
170
- swapExecutedAt: number;
171
- swapExecutedBlockIndex: string;
172
- egressAmount: string;
173
- egressScheduledAt: number;
174
- egressScheduledBlockIndex: string;
175
- broadcastRequestedAt: number;
176
- broadcastRequestedBlockIndex: string;
177
- } | {
204
+ } | ({
205
+ state: 'BROADCAST_REQUESTED';
206
+ } & BroadcastRequested) | ({
207
+ state: 'BROADCASTED';
208
+ broadcastTransactionRef: string;
209
+ } & BroadcastRequested) | ({
178
210
  state: 'BROADCAST_ABORTED';
179
- swapId: string;
180
- depositAmount: string;
181
- depositReceivedAt: number;
182
- depositReceivedBlockIndex: string;
183
- intermediateAmount: string | undefined;
184
- swapExecutedAt: number;
185
- swapExecutedBlockIndex: string;
186
- egressAmount: string;
187
- egressScheduledAt: number;
188
- egressScheduledBlockIndex: string;
189
- broadcastRequestedAt: number;
190
- broadcastRequestedBlockIndex: string;
191
211
  broadcastAbortedAt: number;
192
212
  broadcastAbortedBlockIndex: string;
193
- } | {
213
+ } & BroadcastRequested) | ({
194
214
  state: 'COMPLETE';
195
- swapId: string;
196
- depositAmount: string;
197
- depositReceivedAt: number;
198
- depositReceivedBlockIndex: string;
199
- intermediateAmount: string | undefined;
200
- swapExecutedAt: number;
201
- swapExecutedBlockIndex: string;
202
- egressAmount: string;
203
- egressScheduledAt: number;
204
- egressScheduledBlockIndex: string;
205
- broadcastRequestedAt: number;
206
- broadcastRequestedBlockIndex: string;
207
215
  broadcastSucceededAt: number;
208
216
  broadcastSucceededBlockIndex: string;
209
217
  broadcastTransactionRef: string;
210
- } | {
218
+ } & BroadcastRequested) | {
211
219
  state: 'FAILED';
212
220
  failure: 'INGRESS_IGNORED';
213
221
  error: {