@paxoslabs/amplify-sdk 0.1.0-beta.0 → 0.1.1-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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +2026 -1946
- package/dist/index.d.ts +2026 -1946
- package/dist/index.js +206 -171
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +207 -172
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_SLIPPAGE_BPS } from './chunk-XXHRCCZS.mjs';
|
|
2
2
|
export { YieldType } from './chunk-XXHRCCZS.mjs';
|
|
3
3
|
export { getDepositExchangeRate, getWithdrawExchangeRate, isDepositSpendApproved, isWithdrawalSpendApproved } from './chunk-HI44AMLC.mjs';
|
|
4
|
-
import { getRateInQuoteWithAssetDecimals,
|
|
4
|
+
import { getRateInQuoteWithAssetDecimals, getClient, BoringVaultAbi, getRateInQuoteAndSharesAndWantAssetDecimals, TellerAbi } from './chunk-ZILA73XN.mjs';
|
|
5
5
|
import './chunk-R663BFAZ.mjs';
|
|
6
6
|
import { toChainId } from './chunk-J3662HYT.mjs';
|
|
7
7
|
import { calculateDeadline } from './chunk-REKEQLQA.mjs';
|
|
@@ -68,207 +68,230 @@ async function prepareApproveDepositTokenTxData({
|
|
|
68
68
|
// src/abi/community-code-depositor-abi.ts
|
|
69
69
|
var CommunityCodeDepositorAbi = [
|
|
70
70
|
{
|
|
71
|
-
type: "constructor",
|
|
72
71
|
inputs: [
|
|
73
|
-
{
|
|
74
|
-
|
|
72
|
+
{
|
|
73
|
+
internalType: "contract TellerWithMultiAssetSupport",
|
|
74
|
+
name: "_teller",
|
|
75
|
+
type: "address"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
internalType: "contract INativeWrapper",
|
|
79
|
+
name: "_nativeWrapper",
|
|
80
|
+
type: "address"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
internalType: "contract Authority",
|
|
84
|
+
name: "_rolesAuthority",
|
|
85
|
+
type: "address"
|
|
86
|
+
},
|
|
87
|
+
{ internalType: "bool", name: "_isNativeDepositSupported", type: "bool" },
|
|
88
|
+
{ internalType: "address", name: "_owner", type: "address" }
|
|
75
89
|
],
|
|
76
|
-
stateMutability: "nonpayable"
|
|
90
|
+
stateMutability: "nonpayable",
|
|
91
|
+
type: "constructor"
|
|
77
92
|
},
|
|
93
|
+
{ inputs: [], name: "IncorrectNativeDepositAmount", type: "error" },
|
|
94
|
+
{ inputs: [], name: "NativeDepositNotSupported", type: "error" },
|
|
78
95
|
{
|
|
79
|
-
type: "function",
|
|
80
|
-
name: "authority",
|
|
81
96
|
inputs: [],
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
],
|
|
85
|
-
stateMutability: "view"
|
|
97
|
+
name: "NativeWrapperAccountantDecimalsMismatch",
|
|
98
|
+
type: "error"
|
|
86
99
|
},
|
|
100
|
+
{ inputs: [], name: "PermitFailedAndAllowanceTooLow", type: "error" },
|
|
101
|
+
{ inputs: [], name: "ZeroAddress", type: "error" },
|
|
87
102
|
{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
anonymous: false,
|
|
104
|
+
inputs: [
|
|
105
|
+
{ indexed: true, internalType: "address", name: "user", type: "address" },
|
|
106
|
+
{
|
|
107
|
+
indexed: true,
|
|
108
|
+
internalType: "contract Authority",
|
|
109
|
+
name: "newAuthority",
|
|
110
|
+
type: "address"
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
name: "AuthorityUpdated",
|
|
114
|
+
type: "event"
|
|
93
115
|
},
|
|
94
116
|
{
|
|
95
|
-
|
|
96
|
-
name: "deposit",
|
|
117
|
+
anonymous: false,
|
|
97
118
|
inputs: [
|
|
98
119
|
{
|
|
120
|
+
indexed: true,
|
|
121
|
+
internalType: "address",
|
|
122
|
+
name: "depositor",
|
|
123
|
+
type: "address"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
indexed: true,
|
|
127
|
+
internalType: "contract ERC20",
|
|
99
128
|
name: "depositAsset",
|
|
100
|
-
type: "address"
|
|
101
|
-
internalType: "contract ERC20"
|
|
129
|
+
type: "address"
|
|
102
130
|
},
|
|
103
131
|
{
|
|
132
|
+
indexed: false,
|
|
133
|
+
internalType: "uint256",
|
|
104
134
|
name: "depositAmount",
|
|
105
|
-
type: "uint256"
|
|
106
|
-
internalType: "uint256"
|
|
135
|
+
type: "uint256"
|
|
107
136
|
},
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
{
|
|
138
|
+
indexed: false,
|
|
139
|
+
internalType: "uint256",
|
|
140
|
+
name: "minimumMint",
|
|
141
|
+
type: "uint256"
|
|
142
|
+
},
|
|
143
|
+
{ indexed: false, internalType: "address", name: "to", type: "address" },
|
|
144
|
+
{
|
|
145
|
+
indexed: false,
|
|
146
|
+
internalType: "bytes32",
|
|
147
|
+
name: "depositHash",
|
|
148
|
+
type: "bytes32"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
indexed: true,
|
|
152
|
+
internalType: "bytes",
|
|
153
|
+
name: "distributorCode",
|
|
154
|
+
type: "bytes"
|
|
155
|
+
}
|
|
111
156
|
],
|
|
112
|
-
|
|
113
|
-
|
|
157
|
+
name: "DepositWithDistributorCode",
|
|
158
|
+
type: "event"
|
|
114
159
|
},
|
|
115
160
|
{
|
|
116
|
-
|
|
117
|
-
name: "depositNative",
|
|
161
|
+
anonymous: false,
|
|
118
162
|
inputs: [
|
|
163
|
+
{ indexed: true, internalType: "address", name: "user", type: "address" },
|
|
119
164
|
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{ name: "to", type: "address", internalType: "address" },
|
|
126
|
-
{ name: "communityCode", type: "bytes", internalType: "bytes" }
|
|
165
|
+
indexed: true,
|
|
166
|
+
internalType: "address",
|
|
167
|
+
name: "newOwner",
|
|
168
|
+
type: "address"
|
|
169
|
+
}
|
|
127
170
|
],
|
|
128
|
-
|
|
129
|
-
|
|
171
|
+
name: "OwnershipTransferred",
|
|
172
|
+
type: "event"
|
|
130
173
|
},
|
|
131
174
|
{
|
|
132
|
-
type: "function",
|
|
133
|
-
name: "depositNonce",
|
|
134
175
|
inputs: [],
|
|
135
|
-
|
|
136
|
-
|
|
176
|
+
name: "authority",
|
|
177
|
+
outputs: [
|
|
178
|
+
{ internalType: "contract Authority", name: "", type: "address" }
|
|
179
|
+
],
|
|
180
|
+
stateMutability: "view",
|
|
181
|
+
type: "function"
|
|
137
182
|
},
|
|
138
183
|
{
|
|
139
|
-
type: "function",
|
|
140
|
-
name: "owner",
|
|
141
184
|
inputs: [],
|
|
142
|
-
|
|
143
|
-
|
|
185
|
+
name: "boringVault",
|
|
186
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
187
|
+
stateMutability: "view",
|
|
188
|
+
type: "function"
|
|
144
189
|
},
|
|
145
190
|
{
|
|
146
|
-
type: "function",
|
|
147
|
-
name: "setAuthority",
|
|
148
191
|
inputs: [
|
|
149
|
-
{
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
192
|
+
{ internalType: "contract ERC20", name: "depositAsset", type: "address" },
|
|
193
|
+
{ internalType: "uint256", name: "depositAmount", type: "uint256" },
|
|
194
|
+
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
195
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
196
|
+
{ internalType: "bytes", name: "distributorCode", type: "bytes" }
|
|
154
197
|
],
|
|
155
|
-
|
|
156
|
-
|
|
198
|
+
name: "deposit",
|
|
199
|
+
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
200
|
+
stateMutability: "nonpayable",
|
|
201
|
+
type: "function"
|
|
157
202
|
},
|
|
158
203
|
{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{
|
|
164
|
-
name: "",
|
|
165
|
-
type: "address",
|
|
166
|
-
internalType: "contract TellerWithMultiAssetSupport"
|
|
167
|
-
}
|
|
204
|
+
inputs: [
|
|
205
|
+
{ internalType: "uint256", name: "depositAmount", type: "uint256" },
|
|
206
|
+
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
207
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
208
|
+
{ internalType: "bytes", name: "distributorCode", type: "bytes" }
|
|
168
209
|
],
|
|
169
|
-
|
|
210
|
+
name: "depositNative",
|
|
211
|
+
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
212
|
+
stateMutability: "payable",
|
|
213
|
+
type: "function"
|
|
170
214
|
},
|
|
171
215
|
{
|
|
172
|
-
|
|
173
|
-
name: "
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
inputs: [],
|
|
217
|
+
name: "depositNonce",
|
|
218
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
219
|
+
stateMutability: "view",
|
|
220
|
+
type: "function"
|
|
177
221
|
},
|
|
178
222
|
{
|
|
179
|
-
type: "event",
|
|
180
|
-
name: "AuthorityUpdated",
|
|
181
223
|
inputs: [
|
|
182
|
-
{
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
indexed: true,
|
|
192
|
-
internalType: "contract Authority"
|
|
193
|
-
}
|
|
224
|
+
{ internalType: "contract ERC20", name: "depositAsset", type: "address" },
|
|
225
|
+
{ internalType: "uint256", name: "depositAmount", type: "uint256" },
|
|
226
|
+
{ internalType: "uint256", name: "minimumMint", type: "uint256" },
|
|
227
|
+
{ internalType: "address", name: "to", type: "address" },
|
|
228
|
+
{ internalType: "bytes", name: "distributorCode", type: "bytes" },
|
|
229
|
+
{ internalType: "uint256", name: "deadline", type: "uint256" },
|
|
230
|
+
{ internalType: "uint8", name: "v", type: "uint8" },
|
|
231
|
+
{ internalType: "bytes32", name: "r", type: "bytes32" },
|
|
232
|
+
{ internalType: "bytes32", name: "s", type: "bytes32" }
|
|
194
233
|
],
|
|
195
|
-
|
|
234
|
+
name: "depositWithPermit",
|
|
235
|
+
outputs: [{ internalType: "uint256", name: "shares", type: "uint256" }],
|
|
236
|
+
stateMutability: "nonpayable",
|
|
237
|
+
type: "function"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
inputs: [],
|
|
241
|
+
name: "isNativeDepositSupported",
|
|
242
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
243
|
+
stateMutability: "view",
|
|
244
|
+
type: "function"
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
inputs: [],
|
|
248
|
+
name: "nativeWrapper",
|
|
249
|
+
outputs: [
|
|
250
|
+
{ internalType: "contract INativeWrapper", name: "", type: "address" }
|
|
251
|
+
],
|
|
252
|
+
stateMutability: "view",
|
|
253
|
+
type: "function"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
inputs: [],
|
|
257
|
+
name: "owner",
|
|
258
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
259
|
+
stateMutability: "view",
|
|
260
|
+
type: "function"
|
|
196
261
|
},
|
|
197
262
|
{
|
|
198
|
-
type: "event",
|
|
199
|
-
name: "DepositWithCommunityCode",
|
|
200
263
|
inputs: [
|
|
201
264
|
{
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
internalType: "address"
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
name: "depositAsset",
|
|
209
|
-
type: "address",
|
|
210
|
-
indexed: true,
|
|
211
|
-
internalType: "contract ERC20"
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: "depositAmount",
|
|
215
|
-
type: "uint256",
|
|
216
|
-
indexed: false,
|
|
217
|
-
internalType: "uint256"
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
name: "minimumMint",
|
|
221
|
-
type: "uint256",
|
|
222
|
-
indexed: false,
|
|
223
|
-
internalType: "uint256"
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
name: "to",
|
|
227
|
-
type: "address",
|
|
228
|
-
indexed: true,
|
|
229
|
-
internalType: "address"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
name: "depositHash",
|
|
233
|
-
type: "bytes32",
|
|
234
|
-
indexed: false,
|
|
235
|
-
internalType: "bytes32"
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
name: "communityCode",
|
|
239
|
-
type: "bytes",
|
|
240
|
-
indexed: false,
|
|
241
|
-
internalType: "bytes"
|
|
265
|
+
internalType: "contract Authority",
|
|
266
|
+
name: "newAuthority",
|
|
267
|
+
type: "address"
|
|
242
268
|
}
|
|
243
269
|
],
|
|
244
|
-
|
|
270
|
+
name: "setAuthority",
|
|
271
|
+
outputs: [],
|
|
272
|
+
stateMutability: "nonpayable",
|
|
273
|
+
type: "function"
|
|
245
274
|
},
|
|
246
275
|
{
|
|
247
|
-
|
|
248
|
-
name: "
|
|
249
|
-
|
|
250
|
-
{
|
|
251
|
-
name: "user",
|
|
252
|
-
type: "address",
|
|
253
|
-
indexed: true,
|
|
254
|
-
internalType: "address"
|
|
255
|
-
},
|
|
276
|
+
inputs: [],
|
|
277
|
+
name: "teller",
|
|
278
|
+
outputs: [
|
|
256
279
|
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
internalType: "address"
|
|
280
|
+
internalType: "contract TellerWithMultiAssetSupport",
|
|
281
|
+
name: "",
|
|
282
|
+
type: "address"
|
|
261
283
|
}
|
|
262
284
|
],
|
|
263
|
-
|
|
285
|
+
stateMutability: "view",
|
|
286
|
+
type: "function"
|
|
264
287
|
},
|
|
265
|
-
{ type: "error", name: "IncorrectNativeDepositAmount", inputs: [] },
|
|
266
288
|
{
|
|
267
|
-
type: "
|
|
268
|
-
name: "
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
289
|
+
inputs: [{ internalType: "address", name: "newOwner", type: "address" }],
|
|
290
|
+
name: "transferOwnership",
|
|
291
|
+
outputs: [],
|
|
292
|
+
stateMutability: "nonpayable",
|
|
293
|
+
type: "function"
|
|
294
|
+
}
|
|
272
295
|
];
|
|
273
296
|
|
|
274
297
|
// src/vaults/deposit/utils.ts
|
|
@@ -333,7 +356,6 @@ async function prepareDepositTxData(params) {
|
|
|
333
356
|
}
|
|
334
357
|
);
|
|
335
358
|
}
|
|
336
|
-
const tellerAddress = vault.vault.tellerAddress;
|
|
337
359
|
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
338
360
|
const accountantAddress = vault.vault.accountantAddress;
|
|
339
361
|
const depositAssetAddress = asset.address;
|
|
@@ -379,26 +401,23 @@ async function prepareDepositTxData(params) {
|
|
|
379
401
|
depositAssetDecimalsResult.result,
|
|
380
402
|
slippage
|
|
381
403
|
);
|
|
382
|
-
if (communityCodeDepositorAddress
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
args: [
|
|
388
|
-
depositAssetAddress,
|
|
389
|
-
depositAmountAsBigInt,
|
|
390
|
-
minimumMint,
|
|
391
|
-
recipientAddress,
|
|
392
|
-
toBytes(partnerCode)
|
|
393
|
-
],
|
|
394
|
-
chainId: normalizedChainId
|
|
395
|
-
};
|
|
404
|
+
if (!communityCodeDepositorAddress) {
|
|
405
|
+
throw new APIError(
|
|
406
|
+
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
407
|
+
{ endpoint: "prepareDepositTransactionData" }
|
|
408
|
+
);
|
|
396
409
|
}
|
|
397
410
|
return {
|
|
398
|
-
abi:
|
|
399
|
-
address:
|
|
411
|
+
abi: CommunityCodeDepositorAbi,
|
|
412
|
+
address: communityCodeDepositorAddress,
|
|
400
413
|
functionName: "deposit",
|
|
401
|
-
args: [
|
|
414
|
+
args: [
|
|
415
|
+
depositAssetAddress,
|
|
416
|
+
depositAmountAsBigInt,
|
|
417
|
+
minimumMint,
|
|
418
|
+
recipientAddress,
|
|
419
|
+
toBytes(partnerCode || "")
|
|
420
|
+
],
|
|
402
421
|
chainId: normalizedChainId
|
|
403
422
|
};
|
|
404
423
|
} catch (error) {
|
|
@@ -508,7 +527,13 @@ async function prepareDepositPermitSignature(params) {
|
|
|
508
527
|
}
|
|
509
528
|
);
|
|
510
529
|
}
|
|
511
|
-
const
|
|
530
|
+
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
531
|
+
if (!communityCodeDepositorAddress) {
|
|
532
|
+
throw new APIError(
|
|
533
|
+
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
534
|
+
{ endpoint: "prepareDepositPermitSignature" }
|
|
535
|
+
);
|
|
536
|
+
}
|
|
512
537
|
const client = await getClient(normalizedChainId);
|
|
513
538
|
let tokenName;
|
|
514
539
|
let tokenVersion;
|
|
@@ -587,7 +612,7 @@ async function prepareDepositPermitSignature(params) {
|
|
|
587
612
|
};
|
|
588
613
|
const message = {
|
|
589
614
|
owner: recipientAddress,
|
|
590
|
-
spender:
|
|
615
|
+
spender: communityCodeDepositorAddress,
|
|
591
616
|
value,
|
|
592
617
|
nonce,
|
|
593
618
|
deadline: permitDeadline
|
|
@@ -645,7 +670,9 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
645
670
|
chainId,
|
|
646
671
|
signature,
|
|
647
672
|
deadline,
|
|
648
|
-
slippage = DEFAULT_SLIPPAGE_BPS
|
|
673
|
+
slippage = DEFAULT_SLIPPAGE_BPS,
|
|
674
|
+
recipientAddress,
|
|
675
|
+
partnerCode
|
|
649
676
|
} = params;
|
|
650
677
|
try {
|
|
651
678
|
const { v, r, s } = parsePermitSignature(signature);
|
|
@@ -703,9 +730,15 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
703
730
|
}
|
|
704
731
|
);
|
|
705
732
|
}
|
|
706
|
-
const
|
|
733
|
+
const communityCodeDepositorAddress = vault.vault.communityCodeDepositorAddress;
|
|
707
734
|
const accountantAddress = vault.vault.accountantAddress;
|
|
708
735
|
const depositAssetAddress = asset.address;
|
|
736
|
+
if (!communityCodeDepositorAddress) {
|
|
737
|
+
throw new APIError(
|
|
738
|
+
`CommunityCodeDepositor contract address not found for vault ${vault.id}`,
|
|
739
|
+
{ endpoint: "prepareDepositWithPermitTxData" }
|
|
740
|
+
);
|
|
741
|
+
}
|
|
709
742
|
const [depositAssetDecimalsResult, rateInQuoteResult] = await getRateInQuoteWithAssetDecimals({
|
|
710
743
|
assetAddress: depositAssetAddress,
|
|
711
744
|
accountantAddress,
|
|
@@ -747,19 +780,21 @@ async function prepareDepositWithPermitTxData(params) {
|
|
|
747
780
|
);
|
|
748
781
|
return {
|
|
749
782
|
data: {
|
|
750
|
-
abi:
|
|
783
|
+
abi: CommunityCodeDepositorAbi,
|
|
751
784
|
functionName: "depositWithPermit",
|
|
752
785
|
args: [
|
|
753
786
|
depositAssetAddress,
|
|
754
787
|
depositAmountAsBigInt,
|
|
755
788
|
minimumMint,
|
|
789
|
+
recipientAddress,
|
|
790
|
+
toBytes(partnerCode || ""),
|
|
756
791
|
deadline,
|
|
757
792
|
v,
|
|
758
793
|
r,
|
|
759
794
|
s
|
|
760
795
|
]
|
|
761
796
|
},
|
|
762
|
-
address:
|
|
797
|
+
address: communityCodeDepositorAddress,
|
|
763
798
|
chainId: normalizedChainId
|
|
764
799
|
};
|
|
765
800
|
} catch (error) {
|