@mantle-rwa/sdk 0.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/dist/cjs/client.js +198 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants/index.js +211 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/errors/index.js +218 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/index.js +51 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules/compliance.js +202 -0
- package/dist/cjs/modules/compliance.js.map +1 -0
- package/dist/cjs/modules/index.js +18 -0
- package/dist/cjs/modules/index.js.map +1 -0
- package/dist/cjs/modules/kyc.js +278 -0
- package/dist/cjs/modules/kyc.js.map +1 -0
- package/dist/cjs/modules/token.js +365 -0
- package/dist/cjs/modules/token.js.map +1 -0
- package/dist/cjs/modules/yield.js +406 -0
- package/dist/cjs/modules/yield.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/index.js +20 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/index.js +206 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/client.js +194 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants/index.js +208 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/errors/index.js +209 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules/compliance.js +198 -0
- package/dist/esm/modules/compliance.js.map +1 -0
- package/dist/esm/modules/index.js +8 -0
- package/dist/esm/modules/index.js.map +1 -0
- package/dist/esm/modules/kyc.js +273 -0
- package/dist/esm/modules/kyc.js.map +1 -0
- package/dist/esm/modules/token.js +360 -0
- package/dist/esm/modules/token.js.map +1 -0
- package/dist/esm/modules/yield.js +401 -0
- package/dist/esm/modules/yield.js.map +1 -0
- package/dist/esm/types/index.js +17 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/index.js +188 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/client.d.ts +93 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/constants/index.d.ts +83 -0
- package/dist/types/constants/index.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +83 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/modules/compliance.d.ts +29 -0
- package/dist/types/modules/compliance.d.ts.map +1 -0
- package/dist/types/modules/index.d.ts +8 -0
- package/dist/types/modules/index.d.ts.map +1 -0
- package/dist/types/modules/kyc.d.ts +131 -0
- package/dist/types/modules/kyc.d.ts.map +1 -0
- package/dist/types/modules/token.d.ts +145 -0
- package/dist/types/modules/token.d.ts.map +1 -0
- package/dist/types/modules/yield.d.ts +143 -0
- package/dist/types/modules/yield.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +254 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +80 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +52 -0
- package/src/client.ts +258 -0
- package/src/constants/index.ts +226 -0
- package/src/errors/index.ts +291 -0
- package/src/index.ts +42 -0
- package/src/modules/compliance.ts +252 -0
- package/src/modules/index.ts +8 -0
- package/src/modules/kyc.ts +446 -0
- package/src/modules/token.ts +488 -0
- package/src/modules/yield.ts +566 -0
- package/src/types/index.ts +326 -0
- package/src/utils/index.ts +240 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YieldModule - Handles yield distribution management
|
|
3
|
+
*/
|
|
4
|
+
import { ethers } from 'ethers';
|
|
5
|
+
import { YIELD_DISTRIBUTOR_ABI, RWA_TOKEN_ABI, DEFAULTS } from '../constants/index.js';
|
|
6
|
+
import { RWAError, ErrorCode, parseContractError } from '../errors/index.js';
|
|
7
|
+
import { isValidAddress, normalizeAddress, parseAmount, parseEvents, createTransactionResult, retry, estimateGasWithBuffer, timestampToDate, } from '../utils/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Instance of a connected yield distributor
|
|
10
|
+
*/
|
|
11
|
+
export class YieldDistributorInstance {
|
|
12
|
+
_contract;
|
|
13
|
+
_retries;
|
|
14
|
+
_retryDelay;
|
|
15
|
+
/** Distributor contract address */
|
|
16
|
+
address;
|
|
17
|
+
constructor(address, provider, signer, retries, retryDelay) {
|
|
18
|
+
this.address = normalizeAddress(address);
|
|
19
|
+
this._retries = retries;
|
|
20
|
+
this._retryDelay = retryDelay;
|
|
21
|
+
this._contract = new ethers.Contract(this.address, YIELD_DISTRIBUTOR_ABI, signer || provider);
|
|
22
|
+
}
|
|
23
|
+
/*//////////////////////////////////////////////////////////////
|
|
24
|
+
READ FUNCTIONS
|
|
25
|
+
//////////////////////////////////////////////////////////////*/
|
|
26
|
+
/**
|
|
27
|
+
* Get the number of distributions
|
|
28
|
+
*/
|
|
29
|
+
async distributionCount() {
|
|
30
|
+
const count = await this._contract.distributionCount();
|
|
31
|
+
return Number(count);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get distribution information
|
|
35
|
+
*/
|
|
36
|
+
async getDistributionInfo(distributionId) {
|
|
37
|
+
const [paymentToken, totalAmount, snapshotId, claimDeadline, claimedAmount] = await this._contract.getDistributionInfo(distributionId);
|
|
38
|
+
return {
|
|
39
|
+
id: distributionId,
|
|
40
|
+
paymentToken,
|
|
41
|
+
totalAmount,
|
|
42
|
+
snapshotId,
|
|
43
|
+
claimDeadline: timestampToDate(claimDeadline),
|
|
44
|
+
claimedAmount,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get claimable amount for an account
|
|
49
|
+
*/
|
|
50
|
+
async getClaimableAmount(distributionId, account) {
|
|
51
|
+
return this._contract.getClaimableAmount(distributionId, normalizeAddress(account));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if an account has claimed from a distribution
|
|
55
|
+
*/
|
|
56
|
+
async hasClaimed(distributionId, account) {
|
|
57
|
+
return this._contract.hasClaimed(distributionId, normalizeAddress(account));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get all distributions
|
|
61
|
+
*/
|
|
62
|
+
async getDistributionHistory() {
|
|
63
|
+
const count = await this.distributionCount();
|
|
64
|
+
const distributions = [];
|
|
65
|
+
for (let i = 0; i < count; i++) {
|
|
66
|
+
distributions.push(await this.getDistributionInfo(i));
|
|
67
|
+
}
|
|
68
|
+
return distributions;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get pending claims for an account
|
|
72
|
+
*/
|
|
73
|
+
async getPendingClaims(account) {
|
|
74
|
+
const count = await this.distributionCount();
|
|
75
|
+
const pendingClaims = [];
|
|
76
|
+
const now = new Date();
|
|
77
|
+
for (let i = 0; i < count; i++) {
|
|
78
|
+
const hasClaimed = await this.hasClaimed(i, account);
|
|
79
|
+
if (hasClaimed)
|
|
80
|
+
continue;
|
|
81
|
+
const distribution = await this.getDistributionInfo(i);
|
|
82
|
+
if (distribution.claimDeadline < now)
|
|
83
|
+
continue;
|
|
84
|
+
const amount = await this.getClaimableAmount(i, account);
|
|
85
|
+
if (amount === 0n)
|
|
86
|
+
continue;
|
|
87
|
+
pendingClaims.push({
|
|
88
|
+
distributionId: i,
|
|
89
|
+
amount,
|
|
90
|
+
paymentToken: distribution.paymentToken,
|
|
91
|
+
deadline: distribution.claimDeadline,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return pendingClaims;
|
|
95
|
+
}
|
|
96
|
+
/*//////////////////////////////////////////////////////////////
|
|
97
|
+
WRITE FUNCTIONS
|
|
98
|
+
//////////////////////////////////////////////////////////////*/
|
|
99
|
+
/**
|
|
100
|
+
* Create a new distribution
|
|
101
|
+
*/
|
|
102
|
+
async createDistribution(paymentToken, totalAmount, claimWindowDays = DEFAULTS.YIELD_CLAIM_WINDOW_DAYS, options) {
|
|
103
|
+
const tokenAddress = normalizeAddress(paymentToken);
|
|
104
|
+
const amountWei = parseAmount(totalAmount);
|
|
105
|
+
try {
|
|
106
|
+
const tx = await retry(async () => {
|
|
107
|
+
const gasLimit = options?.gasLimit || await estimateGasWithBuffer(() => this._contract.createDistribution.estimateGas(tokenAddress, amountWei, claimWindowDays));
|
|
108
|
+
return this._contract.createDistribution(tokenAddress, amountWei, claimWindowDays, { gasLimit });
|
|
109
|
+
}, { retries: options?.retries ?? this._retries, delay: options?.retryDelay ?? this._retryDelay });
|
|
110
|
+
const receipt = await tx.wait();
|
|
111
|
+
const events = parseEvents(receipt, this._contract.interface);
|
|
112
|
+
const result = createTransactionResult(receipt, events);
|
|
113
|
+
// Extract distribution ID from event
|
|
114
|
+
const createdEvent = events.find((e) => e.name === 'DistributionCreated');
|
|
115
|
+
const distributionId = Number(createdEvent?.args.distributionId || 0);
|
|
116
|
+
return { result, distributionId };
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
throw parseContractError(error, this.address, 'createDistribution');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Claim yield from a distribution
|
|
124
|
+
*/
|
|
125
|
+
async claim(distributionId, options) {
|
|
126
|
+
try {
|
|
127
|
+
const tx = await retry(async () => {
|
|
128
|
+
const gasLimit = options?.gasLimit || await estimateGasWithBuffer(() => this._contract.claim.estimateGas(distributionId));
|
|
129
|
+
return this._contract.claim(distributionId, { gasLimit });
|
|
130
|
+
}, { retries: options?.retries ?? this._retries, delay: options?.retryDelay ?? this._retryDelay });
|
|
131
|
+
const receipt = await tx.wait();
|
|
132
|
+
const events = parseEvents(receipt, this._contract.interface);
|
|
133
|
+
return createTransactionResult(receipt, events);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
throw parseContractError(error, this.address, 'claim');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Claim yield from multiple distributions
|
|
141
|
+
*/
|
|
142
|
+
async claimMultiple(distributionIds, options) {
|
|
143
|
+
try {
|
|
144
|
+
const tx = await retry(async () => {
|
|
145
|
+
const gasLimit = options?.gasLimit || await estimateGasWithBuffer(() => this._contract.claimMultiple.estimateGas(distributionIds));
|
|
146
|
+
return this._contract.claimMultiple(distributionIds, { gasLimit });
|
|
147
|
+
}, { retries: options?.retries ?? this._retries, delay: options?.retryDelay ?? this._retryDelay });
|
|
148
|
+
const receipt = await tx.wait();
|
|
149
|
+
const events = parseEvents(receipt, this._contract.interface);
|
|
150
|
+
return createTransactionResult(receipt, events);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw parseContractError(error, this.address, 'claimMultiple');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Handle unclaimed funds after claim window expires
|
|
158
|
+
*/
|
|
159
|
+
async handleUnclaimedFunds(distributionId, options) {
|
|
160
|
+
try {
|
|
161
|
+
const tx = await retry(async () => {
|
|
162
|
+
const gasLimit = options?.gasLimit || await estimateGasWithBuffer(() => this._contract.handleUnclaimedFunds.estimateGas(distributionId));
|
|
163
|
+
return this._contract.handleUnclaimedFunds(distributionId, { gasLimit });
|
|
164
|
+
}, { retries: options?.retries ?? this._retries, delay: options?.retryDelay ?? this._retryDelay });
|
|
165
|
+
const receipt = await tx.wait();
|
|
166
|
+
const events = parseEvents(receipt, this._contract.interface);
|
|
167
|
+
return createTransactionResult(receipt, events);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw parseContractError(error, this.address, 'handleUnclaimedFunds');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Set the unclaimed funds recipient
|
|
175
|
+
*/
|
|
176
|
+
async setUnclaimedFundsRecipient(recipient, options) {
|
|
177
|
+
const recipientAddress = normalizeAddress(recipient);
|
|
178
|
+
try {
|
|
179
|
+
const tx = await retry(async () => {
|
|
180
|
+
const gasLimit = options?.gasLimit || await estimateGasWithBuffer(() => this._contract.setUnclaimedFundsRecipient.estimateGas(recipientAddress));
|
|
181
|
+
return this._contract.setUnclaimedFundsRecipient(recipientAddress, { gasLimit });
|
|
182
|
+
}, { retries: options?.retries ?? this._retries, delay: options?.retryDelay ?? this._retryDelay });
|
|
183
|
+
const receipt = await tx.wait();
|
|
184
|
+
const events = parseEvents(receipt, this._contract.interface);
|
|
185
|
+
return createTransactionResult(receipt, events);
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
throw parseContractError(error, this.address, 'setUnclaimedFundsRecipient');
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/*//////////////////////////////////////////////////////////////
|
|
192
|
+
EVENT LISTENERS
|
|
193
|
+
//////////////////////////////////////////////////////////////*/
|
|
194
|
+
/**
|
|
195
|
+
* Listen for DistributionCreated events
|
|
196
|
+
*/
|
|
197
|
+
onDistributionCreated(callback) {
|
|
198
|
+
const listener = (distributionId, paymentToken, totalAmount, snapshotId) => {
|
|
199
|
+
callback(distributionId, paymentToken, totalAmount, snapshotId);
|
|
200
|
+
};
|
|
201
|
+
this._contract.on('DistributionCreated', listener);
|
|
202
|
+
return () => this._contract.off('DistributionCreated', listener);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Listen for YieldClaimed events
|
|
206
|
+
*/
|
|
207
|
+
onYieldClaimed(callback) {
|
|
208
|
+
const listener = (distributionId, claimant, amount) => {
|
|
209
|
+
callback(distributionId, claimant, amount);
|
|
210
|
+
};
|
|
211
|
+
this._contract.on('YieldClaimed', listener);
|
|
212
|
+
return () => this._contract.off('YieldClaimed', listener);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Module for yield distribution operations
|
|
217
|
+
*/
|
|
218
|
+
export class YieldModule {
|
|
219
|
+
_provider;
|
|
220
|
+
_signer;
|
|
221
|
+
_retries;
|
|
222
|
+
_retryDelay;
|
|
223
|
+
constructor(provider, signer, retries, retryDelay) {
|
|
224
|
+
this._provider = provider;
|
|
225
|
+
this._signer = signer;
|
|
226
|
+
this._retries = retries;
|
|
227
|
+
this._retryDelay = retryDelay;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Connect to an existing yield distributor
|
|
231
|
+
*/
|
|
232
|
+
connect(address) {
|
|
233
|
+
if (!isValidAddress(address)) {
|
|
234
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid distributor address: ${address}`);
|
|
235
|
+
}
|
|
236
|
+
return new YieldDistributorInstance(address, this._provider, this._signer, this._retries, this._retryDelay);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Create a distribution
|
|
240
|
+
*
|
|
241
|
+
* @param config - Distribution configuration
|
|
242
|
+
* @returns Transaction result with distribution ID
|
|
243
|
+
*/
|
|
244
|
+
async distribute(config) {
|
|
245
|
+
if (!isValidAddress(config.tokenAddress)) {
|
|
246
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid token address: ${config.tokenAddress}`);
|
|
247
|
+
}
|
|
248
|
+
if (!isValidAddress(config.paymentToken)) {
|
|
249
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid payment token address: ${config.paymentToken}`);
|
|
250
|
+
}
|
|
251
|
+
const distributor = this.connect(config.tokenAddress);
|
|
252
|
+
return distributor.createDistribution(config.paymentToken, config.totalAmount, config.claimWindowDays);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Preview a distribution (calculate per-holder amounts)
|
|
256
|
+
*
|
|
257
|
+
* This method calculates what each holder would receive based on their
|
|
258
|
+
* proportional ownership at the snapshot time.
|
|
259
|
+
*
|
|
260
|
+
* @param tokenAddress - The RWA token address
|
|
261
|
+
* @param totalAmount - Total amount to distribute (in token units)
|
|
262
|
+
* @param snapshotId - Optional snapshot ID (uses current balances if not provided)
|
|
263
|
+
* @param holderAddresses - Optional array of holder addresses to calculate for
|
|
264
|
+
* @returns Preview of the distribution with per-holder breakdown
|
|
265
|
+
*/
|
|
266
|
+
async previewDistribution(tokenAddress, totalAmount, snapshotId, holderAddresses) {
|
|
267
|
+
if (!isValidAddress(tokenAddress)) {
|
|
268
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid token address: ${tokenAddress}`);
|
|
269
|
+
}
|
|
270
|
+
const token = new ethers.Contract(tokenAddress, RWA_TOKEN_ABI, this._provider);
|
|
271
|
+
const totalAmountWei = parseAmount(totalAmount);
|
|
272
|
+
// Get total supply at snapshot
|
|
273
|
+
let totalSupply;
|
|
274
|
+
if (snapshotId !== undefined) {
|
|
275
|
+
totalSupply = await token.totalSupplyAt(snapshotId);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
totalSupply = await token.totalSupply();
|
|
279
|
+
}
|
|
280
|
+
if (totalSupply === 0n) {
|
|
281
|
+
return {
|
|
282
|
+
totalHolders: 0,
|
|
283
|
+
totalSupplyAtSnapshot: 0n,
|
|
284
|
+
distributions: [],
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
// If holder addresses are provided, calculate their distributions
|
|
288
|
+
const distributions = [];
|
|
289
|
+
if (holderAddresses && holderAddresses.length > 0) {
|
|
290
|
+
for (const address of holderAddresses) {
|
|
291
|
+
const normalizedAddress = normalizeAddress(address);
|
|
292
|
+
let balance;
|
|
293
|
+
if (snapshotId !== undefined) {
|
|
294
|
+
balance = await token.balanceOfAt(normalizedAddress, snapshotId);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
balance = await token.balanceOf(normalizedAddress);
|
|
298
|
+
}
|
|
299
|
+
if (balance > 0n) {
|
|
300
|
+
// Calculate proportional yield amount
|
|
301
|
+
const yieldAmount = (totalAmountWei * balance) / totalSupply;
|
|
302
|
+
const percentage = Number((balance * 10000n) / totalSupply) / 100;
|
|
303
|
+
distributions.push({
|
|
304
|
+
address: normalizedAddress,
|
|
305
|
+
balance,
|
|
306
|
+
yieldAmount,
|
|
307
|
+
percentage,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
totalHolders: distributions.length,
|
|
314
|
+
totalSupplyAtSnapshot: totalSupply,
|
|
315
|
+
distributions,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Calculate yield amount for a specific holder
|
|
320
|
+
*
|
|
321
|
+
* @param tokenAddress - The RWA token address
|
|
322
|
+
* @param holderAddress - The holder's address
|
|
323
|
+
* @param totalAmount - Total distribution amount
|
|
324
|
+
* @param snapshotId - Optional snapshot ID
|
|
325
|
+
* @returns The calculated yield amount for the holder
|
|
326
|
+
*/
|
|
327
|
+
async calculateHolderYield(tokenAddress, holderAddress, totalAmount, snapshotId) {
|
|
328
|
+
if (!isValidAddress(tokenAddress)) {
|
|
329
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid token address: ${tokenAddress}`);
|
|
330
|
+
}
|
|
331
|
+
if (!isValidAddress(holderAddress)) {
|
|
332
|
+
throw new RWAError(ErrorCode.INVALID_ADDRESS, `Invalid holder address: ${holderAddress}`);
|
|
333
|
+
}
|
|
334
|
+
const token = new ethers.Contract(tokenAddress, RWA_TOKEN_ABI, this._provider);
|
|
335
|
+
const totalAmountWei = parseAmount(totalAmount);
|
|
336
|
+
const normalizedHolder = normalizeAddress(holderAddress);
|
|
337
|
+
// Get total supply and holder balance
|
|
338
|
+
let totalSupply;
|
|
339
|
+
let balance;
|
|
340
|
+
if (snapshotId !== undefined) {
|
|
341
|
+
totalSupply = await token.totalSupplyAt(snapshotId);
|
|
342
|
+
balance = await token.balanceOfAt(normalizedHolder, snapshotId);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
totalSupply = await token.totalSupply();
|
|
346
|
+
balance = await token.balanceOf(normalizedHolder);
|
|
347
|
+
}
|
|
348
|
+
if (totalSupply === 0n || balance === 0n) {
|
|
349
|
+
return { balance: 0n, yieldAmount: 0n, percentage: 0 };
|
|
350
|
+
}
|
|
351
|
+
// Calculate proportional yield amount
|
|
352
|
+
const yieldAmount = (totalAmountWei * balance) / totalSupply;
|
|
353
|
+
const percentage = Number((balance * 10000n) / totalSupply) / 100;
|
|
354
|
+
return { balance, yieldAmount, percentage };
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Claim yield from a distribution
|
|
358
|
+
*/
|
|
359
|
+
async claim(distributorAddress, distributionId) {
|
|
360
|
+
const distributor = this.connect(distributorAddress);
|
|
361
|
+
return distributor.claim(distributionId);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Claim all pending yields
|
|
365
|
+
*/
|
|
366
|
+
async claimAll(distributorAddress) {
|
|
367
|
+
if (!this._signer) {
|
|
368
|
+
throw new RWAError(ErrorCode.SIGNER_REQUIRED, 'A signer is required to claim yields');
|
|
369
|
+
}
|
|
370
|
+
const distributor = this.connect(distributorAddress);
|
|
371
|
+
const signerAddress = await this._signer.getAddress();
|
|
372
|
+
const pendingClaims = await distributor.getPendingClaims(signerAddress);
|
|
373
|
+
if (pendingClaims.length === 0) {
|
|
374
|
+
throw new RWAError(ErrorCode.INVALID_CONFIGURATION, 'No pending claims to process');
|
|
375
|
+
}
|
|
376
|
+
const distributionIds = pendingClaims.map((c) => c.distributionId);
|
|
377
|
+
return distributor.claimMultiple(distributionIds);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Get claimable amount for an account
|
|
381
|
+
*/
|
|
382
|
+
async getClaimableAmount(distributorAddress, distributionId, account) {
|
|
383
|
+
const distributor = this.connect(distributorAddress);
|
|
384
|
+
return distributor.getClaimableAmount(distributionId, account);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get distribution history
|
|
388
|
+
*/
|
|
389
|
+
async getDistributionHistory(distributorAddress) {
|
|
390
|
+
const distributor = this.connect(distributorAddress);
|
|
391
|
+
return distributor.getDistributionHistory();
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Get pending claims for an account
|
|
395
|
+
*/
|
|
396
|
+
async getPendingClaims(distributorAddress, account) {
|
|
397
|
+
const distributor = this.connect(distributorAddress);
|
|
398
|
+
return distributor.getPendingClaims(account);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
//# sourceMappingURL=yield.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yield.js","sourceRoot":"","sources":["../../../src/modules/yield.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAA8B,MAAM,QAAQ,CAAC;AAU5D,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EACH,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,uBAAuB,EACvB,KAAK,EACL,qBAAqB,EACrB,eAAe,GAClB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAChB,SAAS,CAAkB;IAC3B,QAAQ,CAAS;IACjB,WAAW,CAAS;IAErC,mCAAmC;IAC1B,OAAO,CAAS;IAEzB,YACI,OAAe,EACf,QAAkB,EAClB,MAAqB,EACrB,OAAe,EACf,UAAkB;QAElB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,IAAI,CAAC,SAAS,GAAG,IAAI,MAAM,CAAC,QAAQ,CAChC,IAAI,CAAC,OAAO,EACZ,qBAAqB,EACrB,MAAM,IAAI,QAAQ,CACrB,CAAC;IACN,CAAC;IAED;;oEAEgE;IAEhE;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,GAAG,MAAM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,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,kBAAkB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,sBAAsB,CAAC,kBAA0B;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,sBAAsB,EAAE,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,kBAA0B,EAAE,OAAe;QAC9D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;CACJ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for the Mantle RWA SDK
|
|
3
|
+
*/
|
|
4
|
+
/*//////////////////////////////////////////////////////////////
|
|
5
|
+
ACCREDITATION TYPES
|
|
6
|
+
//////////////////////////////////////////////////////////////*/
|
|
7
|
+
/**
|
|
8
|
+
* Accreditation tiers matching the smart contract enum
|
|
9
|
+
*/
|
|
10
|
+
export var AccreditationTier;
|
|
11
|
+
(function (AccreditationTier) {
|
|
12
|
+
AccreditationTier[AccreditationTier["None"] = 0] = "None";
|
|
13
|
+
AccreditationTier[AccreditationTier["Retail"] = 1] = "Retail";
|
|
14
|
+
AccreditationTier[AccreditationTier["Accredited"] = 2] = "Accredited";
|
|
15
|
+
AccreditationTier[AccreditationTier["Institutional"] = 3] = "Institutional";
|
|
16
|
+
})(AccreditationTier || (AccreditationTier = {}));
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAoCH;;gEAEgE;AAEhE;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,yDAAQ,CAAA;IACR,6DAAU,CAAA;IACV,qEAAc,CAAA;IACd,2EAAiB,CAAA;AACnB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for the Mantle RWA SDK
|
|
3
|
+
*/
|
|
4
|
+
import { ethers } from 'ethers';
|
|
5
|
+
import { NetworkError, ErrorCode, parseNetworkError } from '../errors/index.js';
|
|
6
|
+
import { DEFAULTS } from '../constants/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Validate an Ethereum address
|
|
9
|
+
*/
|
|
10
|
+
export function isValidAddress(address) {
|
|
11
|
+
try {
|
|
12
|
+
return ethers.isAddress(address);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate and normalize an Ethereum address
|
|
20
|
+
*/
|
|
21
|
+
export function normalizeAddress(address) {
|
|
22
|
+
if (!isValidAddress(address)) {
|
|
23
|
+
throw new Error(`Invalid address: ${address}`);
|
|
24
|
+
}
|
|
25
|
+
return ethers.getAddress(address);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse a string amount to bigint with decimals
|
|
29
|
+
*/
|
|
30
|
+
export function parseAmount(amount, decimals = 18) {
|
|
31
|
+
return ethers.parseUnits(amount, decimals);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Format a bigint amount to string with decimals
|
|
35
|
+
*/
|
|
36
|
+
export function formatAmount(amount, decimals = 18) {
|
|
37
|
+
return ethers.formatUnits(amount, decimals);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Parse events from a transaction receipt
|
|
41
|
+
*/
|
|
42
|
+
export function parseEvents(receipt, contractInterface) {
|
|
43
|
+
const events = [];
|
|
44
|
+
for (const log of receipt.logs) {
|
|
45
|
+
try {
|
|
46
|
+
const parsed = contractInterface.parseLog({
|
|
47
|
+
topics: log.topics,
|
|
48
|
+
data: log.data,
|
|
49
|
+
});
|
|
50
|
+
if (parsed) {
|
|
51
|
+
const args = {};
|
|
52
|
+
for (const [key, value] of Object.entries(parsed.args)) {
|
|
53
|
+
// Skip numeric indices
|
|
54
|
+
if (!/^\d+$/.test(key)) {
|
|
55
|
+
args[key] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
events.push({
|
|
59
|
+
name: parsed.name,
|
|
60
|
+
args,
|
|
61
|
+
address: log.address,
|
|
62
|
+
blockNumber: log.blockNumber,
|
|
63
|
+
transactionHash: log.transactionHash,
|
|
64
|
+
logIndex: log.index,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Skip logs that don't match the interface
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return events;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Create a transaction result from a receipt
|
|
76
|
+
*/
|
|
77
|
+
export function createTransactionResult(receipt, events) {
|
|
78
|
+
return {
|
|
79
|
+
hash: receipt.hash,
|
|
80
|
+
blockNumber: receipt.blockNumber,
|
|
81
|
+
gasUsed: receipt.gasUsed,
|
|
82
|
+
status: receipt.status === 1 ? 'success' : 'failed',
|
|
83
|
+
events,
|
|
84
|
+
receipt,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Sleep for a specified duration
|
|
89
|
+
*/
|
|
90
|
+
export function sleep(ms) {
|
|
91
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Retry a function with exponential backoff
|
|
95
|
+
*/
|
|
96
|
+
export async function retry(fn, options = {}) {
|
|
97
|
+
const { retries = DEFAULTS.TRANSACTION_RETRIES, delay = DEFAULTS.RETRY_DELAY_MS, onRetry } = options;
|
|
98
|
+
let lastError;
|
|
99
|
+
for (let attempt = 0; attempt <= retries; attempt++) {
|
|
100
|
+
try {
|
|
101
|
+
return await fn();
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
lastError = error;
|
|
105
|
+
// Check if error is retryable
|
|
106
|
+
const networkError = parseNetworkError(error);
|
|
107
|
+
if (!networkError.retryable) {
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
if (attempt < retries) {
|
|
111
|
+
onRetry?.(error, attempt + 1);
|
|
112
|
+
await sleep(delay * Math.pow(2, attempt)); // Exponential backoff
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw lastError;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Estimate gas with buffer
|
|
120
|
+
*/
|
|
121
|
+
export async function estimateGasWithBuffer(estimateFn, bufferPercent = DEFAULTS.GAS_BUFFER_PERCENT) {
|
|
122
|
+
const estimate = await estimateFn();
|
|
123
|
+
const buffer = (estimate * BigInt(bufferPercent)) / 100n;
|
|
124
|
+
return estimate + buffer;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Generate a keccak256 hash of identity data
|
|
128
|
+
*/
|
|
129
|
+
export function hashIdentityData(data) {
|
|
130
|
+
const normalized = JSON.stringify({
|
|
131
|
+
firstName: data.firstName?.toLowerCase().trim(),
|
|
132
|
+
lastName: data.lastName?.toLowerCase().trim(),
|
|
133
|
+
dateOfBirth: data.dateOfBirth,
|
|
134
|
+
documentNumber: data.documentNumber?.toUpperCase().trim(),
|
|
135
|
+
country: data.country?.toUpperCase().trim(),
|
|
136
|
+
});
|
|
137
|
+
return ethers.keccak256(ethers.toUtf8Bytes(normalized));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Convert a timestamp to a Date object
|
|
141
|
+
*/
|
|
142
|
+
export function timestampToDate(timestamp) {
|
|
143
|
+
const ts = typeof timestamp === 'bigint' ? Number(timestamp) : timestamp;
|
|
144
|
+
return new Date(ts * 1000);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Convert a Date to a Unix timestamp
|
|
148
|
+
*/
|
|
149
|
+
export function dateToTimestamp(date) {
|
|
150
|
+
return Math.floor(date.getTime() / 1000);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if a timestamp is expired
|
|
154
|
+
*/
|
|
155
|
+
export function isExpired(timestamp) {
|
|
156
|
+
const now = Math.floor(Date.now() / 1000);
|
|
157
|
+
const ts = typeof timestamp === 'bigint' ? Number(timestamp) : timestamp;
|
|
158
|
+
return ts < now;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Calculate percentage
|
|
162
|
+
*/
|
|
163
|
+
export function calculatePercentage(part, total) {
|
|
164
|
+
if (total === 0n)
|
|
165
|
+
return 0;
|
|
166
|
+
return Number((part * 10000n) / total) / 100;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Chunk an array into smaller arrays
|
|
170
|
+
*/
|
|
171
|
+
export function chunk(array, size) {
|
|
172
|
+
const chunks = [];
|
|
173
|
+
for (let i = 0; i < array.length; i += size) {
|
|
174
|
+
chunks.push(array.slice(i, i + size));
|
|
175
|
+
}
|
|
176
|
+
return chunks;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Wait for a transaction to be mined
|
|
180
|
+
*/
|
|
181
|
+
export async function waitForTransaction(provider, hash, confirmations = 1) {
|
|
182
|
+
const receipt = await provider.waitForTransaction(hash, confirmations);
|
|
183
|
+
if (!receipt) {
|
|
184
|
+
throw new NetworkError(ErrorCode.TIMEOUT, `Transaction ${hash} was not mined`, true);
|
|
185
|
+
}
|
|
186
|
+
return receipt;
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src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