@pyxisjs/chains 0.2.7 → 0.3.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.
- package/LICENSE +1 -1
- package/dist/index.d.mts +2 -36
- package/dist/index.d.ts +2 -36
- package/dist/index.js +23 -390
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -383
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Aptos, UserTransactionResponse } from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { BaseChainAdapter, MultiChainVaultAPI, Chain, TxParams, TransactionPayload, ViewParams, EventParams, TransactionResult, QueryIndexerParams, GetWithdrawRateInQuoteSafeArgs, GetDepositRateInQuoteSafeArgs, QuoteDepositArgs, QuoteWithdrawArgs, QuoteBridgeArgs, BridgeQuoteResponse, BuildBridgeTxArgs, BuildDepositTxArgs, BuildWithdrawTxArgs, BuildReclaimWithdrawalRequestTxArgs, BuildCancelWithdrawalRequestTxArgs, GetMinimumRequestAgeArgs, GetWithdrawalRequestsOfUserArgs, PyxisWithdrawalRequest,
|
|
2
|
+
import { BaseChainAdapter, MultiChainVaultAPI, Chain, TxParams, TransactionPayload, ViewParams, EventParams, TransactionResult, QueryIndexerParams, GetWithdrawRateInQuoteSafeArgs, GetDepositRateInQuoteSafeArgs, QuoteDepositArgs, QuoteWithdrawArgs, QuoteBridgeArgs, BridgeQuoteResponse, BuildBridgeTxArgs, BuildDepositTxArgs, BuildWithdrawTxArgs, BuildReclaimWithdrawalRequestTxArgs, BuildCancelWithdrawalRequestTxArgs, GetMinimumRequestAgeArgs, GetWithdrawalRequestsOfUserArgs, PyxisWithdrawalRequest, ChainType } from '@pyxisjs/core';
|
|
3
3
|
export { EventParams, TxParams, ViewParams } from '@pyxisjs/core';
|
|
4
4
|
import { Abi, PublicClient } from 'viem';
|
|
5
5
|
export { Abi as EvmABI } from 'viem';
|
|
@@ -115,40 +115,6 @@ declare class AptosChainAdapter extends BaseChainAdapter<Aptos> implements Multi
|
|
|
115
115
|
getUserWithdrawalRequests({ flag, userAddress, vault, matchAll, }: GetWithdrawalRequestsOfUserArgs): Promise<PyxisWithdrawalRequest[]>;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Aptos analytics utility functions
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Maps an IndexerVaultActivity to a VaultActivity with camelCase properties
|
|
124
|
-
*/
|
|
125
|
-
declare function mapIndexerToVaultActivity(indexerActivity: IndexerVaultActivity): VaultActivity;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Aptos analytics client implementation
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Aptos-specific analytics client implementation
|
|
133
|
-
*/
|
|
134
|
-
declare class AptosAnalyticsClient implements BaseAnalyticsClient {
|
|
135
|
-
private chainAdapter;
|
|
136
|
-
private analyticsAdapter;
|
|
137
|
-
constructor(chainAdapter: BaseChainAdapter<Aptos>, analyticsAdapter: BaseChainAdapter<Aptos>);
|
|
138
|
-
/**
|
|
139
|
-
* Get function signature using contract address from adapter
|
|
140
|
-
*/
|
|
141
|
-
private getBaseFunctionSignature;
|
|
142
|
-
getActivities({ vault, user, page, pageSize, }: GetActivitiesArgs): Promise<{
|
|
143
|
-
activities: VaultActivity[];
|
|
144
|
-
total: number;
|
|
145
|
-
}>;
|
|
146
|
-
getTvlInBaseAsset({ vault, asset }: VaultTvlArgs): Promise<string>;
|
|
147
|
-
getUpdateExchangeRateEvents({ vault, startTime, endTime, }: HistoricalApyArgs): Promise<ExchangeRateEvent[]>;
|
|
148
|
-
get30DayApy(vault: string): Promise<string>;
|
|
149
|
-
getHistoricalApy({ vault, startTime, endTime, window, }: HistoricalApyArgs): Promise<ApyDataPoint[]>;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
118
|
declare const AccountantABI: Abi;
|
|
153
119
|
declare const AtomicQueueABI: Abi;
|
|
154
120
|
declare const BoringVaultABI: Abi;
|
|
@@ -246,4 +212,4 @@ declare function getFunctionSignature(type: ChainType, contractName: string, fun
|
|
|
246
212
|
*/
|
|
247
213
|
declare function getContractABI(type: ChainType, contractName: string): AptosABI | Abi;
|
|
248
214
|
|
|
249
|
-
export { AccountantABI, AccountantAptosABI, type AptosABI,
|
|
215
|
+
export { AccountantABI, AccountantAptosABI, type AptosABI, AptosChainAdapter, type AptosFunction, type AptosGenericTypeParam, type AptosStruct, AtomicQueueABI, AtomicQueueAptosABI, BoringVaultABI, CONTRACTS, type ContractConfig, type ContractsConfig, EthereumChainAdapter, MultiChainLayerZeroTellerAptosABI, TellerAptosABI, TellerWithMultiAssetSupportABI, VaultAptosABI, getContractABI, getFunctionSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Aptos, UserTransactionResponse } from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { BaseChainAdapter, MultiChainVaultAPI, Chain, TxParams, TransactionPayload, ViewParams, EventParams, TransactionResult, QueryIndexerParams, GetWithdrawRateInQuoteSafeArgs, GetDepositRateInQuoteSafeArgs, QuoteDepositArgs, QuoteWithdrawArgs, QuoteBridgeArgs, BridgeQuoteResponse, BuildBridgeTxArgs, BuildDepositTxArgs, BuildWithdrawTxArgs, BuildReclaimWithdrawalRequestTxArgs, BuildCancelWithdrawalRequestTxArgs, GetMinimumRequestAgeArgs, GetWithdrawalRequestsOfUserArgs, PyxisWithdrawalRequest,
|
|
2
|
+
import { BaseChainAdapter, MultiChainVaultAPI, Chain, TxParams, TransactionPayload, ViewParams, EventParams, TransactionResult, QueryIndexerParams, GetWithdrawRateInQuoteSafeArgs, GetDepositRateInQuoteSafeArgs, QuoteDepositArgs, QuoteWithdrawArgs, QuoteBridgeArgs, BridgeQuoteResponse, BuildBridgeTxArgs, BuildDepositTxArgs, BuildWithdrawTxArgs, BuildReclaimWithdrawalRequestTxArgs, BuildCancelWithdrawalRequestTxArgs, GetMinimumRequestAgeArgs, GetWithdrawalRequestsOfUserArgs, PyxisWithdrawalRequest, ChainType } from '@pyxisjs/core';
|
|
3
3
|
export { EventParams, TxParams, ViewParams } from '@pyxisjs/core';
|
|
4
4
|
import { Abi, PublicClient } from 'viem';
|
|
5
5
|
export { Abi as EvmABI } from 'viem';
|
|
@@ -115,40 +115,6 @@ declare class AptosChainAdapter extends BaseChainAdapter<Aptos> implements Multi
|
|
|
115
115
|
getUserWithdrawalRequests({ flag, userAddress, vault, matchAll, }: GetWithdrawalRequestsOfUserArgs): Promise<PyxisWithdrawalRequest[]>;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
/**
|
|
119
|
-
* Aptos analytics utility functions
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Maps an IndexerVaultActivity to a VaultActivity with camelCase properties
|
|
124
|
-
*/
|
|
125
|
-
declare function mapIndexerToVaultActivity(indexerActivity: IndexerVaultActivity): VaultActivity;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Aptos analytics client implementation
|
|
129
|
-
*/
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Aptos-specific analytics client implementation
|
|
133
|
-
*/
|
|
134
|
-
declare class AptosAnalyticsClient implements BaseAnalyticsClient {
|
|
135
|
-
private chainAdapter;
|
|
136
|
-
private analyticsAdapter;
|
|
137
|
-
constructor(chainAdapter: BaseChainAdapter<Aptos>, analyticsAdapter: BaseChainAdapter<Aptos>);
|
|
138
|
-
/**
|
|
139
|
-
* Get function signature using contract address from adapter
|
|
140
|
-
*/
|
|
141
|
-
private getBaseFunctionSignature;
|
|
142
|
-
getActivities({ vault, user, page, pageSize, }: GetActivitiesArgs): Promise<{
|
|
143
|
-
activities: VaultActivity[];
|
|
144
|
-
total: number;
|
|
145
|
-
}>;
|
|
146
|
-
getTvlInBaseAsset({ vault, asset }: VaultTvlArgs): Promise<string>;
|
|
147
|
-
getUpdateExchangeRateEvents({ vault, startTime, endTime, }: HistoricalApyArgs): Promise<ExchangeRateEvent[]>;
|
|
148
|
-
get30DayApy(vault: string): Promise<string>;
|
|
149
|
-
getHistoricalApy({ vault, startTime, endTime, window, }: HistoricalApyArgs): Promise<ApyDataPoint[]>;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
118
|
declare const AccountantABI: Abi;
|
|
153
119
|
declare const AtomicQueueABI: Abi;
|
|
154
120
|
declare const BoringVaultABI: Abi;
|
|
@@ -246,4 +212,4 @@ declare function getFunctionSignature(type: ChainType, contractName: string, fun
|
|
|
246
212
|
*/
|
|
247
213
|
declare function getContractABI(type: ChainType, contractName: string): AptosABI | Abi;
|
|
248
214
|
|
|
249
|
-
export { AccountantABI, AccountantAptosABI, type AptosABI,
|
|
215
|
+
export { AccountantABI, AccountantAptosABI, type AptosABI, AptosChainAdapter, type AptosFunction, type AptosGenericTypeParam, type AptosStruct, AtomicQueueABI, AtomicQueueAptosABI, BoringVaultABI, CONTRACTS, type ContractConfig, type ContractsConfig, EthereumChainAdapter, MultiChainLayerZeroTellerAptosABI, TellerAptosABI, TellerWithMultiAssetSupportABI, VaultAptosABI, getContractABI, getFunctionSignature };
|
package/dist/index.js
CHANGED
|
@@ -311,90 +311,11 @@ var require_dayjs_min = __commonJS({
|
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
|
|
314
|
-
// ../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/utc.js
|
|
315
|
-
var require_utc = __commonJS({
|
|
316
|
-
"../../node_modules/.pnpm/dayjs@1.11.19/node_modules/dayjs/plugin/utc.js"(exports2, module2) {
|
|
317
|
-
"use strict";
|
|
318
|
-
!(function(t, i) {
|
|
319
|
-
"object" == typeof exports2 && "undefined" != typeof module2 ? module2.exports = i() : "function" == typeof define && define.amd ? define(i) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs_plugin_utc = i();
|
|
320
|
-
})(exports2, (function() {
|
|
321
|
-
"use strict";
|
|
322
|
-
var t = "minute", i = /[+-]\d\d(?::?\d\d)?/g, e = /([+-]|\d\d)/g;
|
|
323
|
-
return function(s, f, n) {
|
|
324
|
-
var u = f.prototype;
|
|
325
|
-
n.utc = function(t2) {
|
|
326
|
-
var i2 = { date: t2, utc: true, args: arguments };
|
|
327
|
-
return new f(i2);
|
|
328
|
-
}, u.utc = function(i2) {
|
|
329
|
-
var e2 = n(this.toDate(), { locale: this.$L, utc: true });
|
|
330
|
-
return i2 ? e2.add(this.utcOffset(), t) : e2;
|
|
331
|
-
}, u.local = function() {
|
|
332
|
-
return n(this.toDate(), { locale: this.$L, utc: false });
|
|
333
|
-
};
|
|
334
|
-
var r = u.parse;
|
|
335
|
-
u.parse = function(t2) {
|
|
336
|
-
t2.utc && (this.$u = true), this.$utils().u(t2.$offset) || (this.$offset = t2.$offset), r.call(this, t2);
|
|
337
|
-
};
|
|
338
|
-
var o = u.init;
|
|
339
|
-
u.init = function() {
|
|
340
|
-
if (this.$u) {
|
|
341
|
-
var t2 = this.$d;
|
|
342
|
-
this.$y = t2.getUTCFullYear(), this.$M = t2.getUTCMonth(), this.$D = t2.getUTCDate(), this.$W = t2.getUTCDay(), this.$H = t2.getUTCHours(), this.$m = t2.getUTCMinutes(), this.$s = t2.getUTCSeconds(), this.$ms = t2.getUTCMilliseconds();
|
|
343
|
-
} else o.call(this);
|
|
344
|
-
};
|
|
345
|
-
var a = u.utcOffset;
|
|
346
|
-
u.utcOffset = function(s2, f2) {
|
|
347
|
-
var n2 = this.$utils().u;
|
|
348
|
-
if (n2(s2)) return this.$u ? 0 : n2(this.$offset) ? a.call(this) : this.$offset;
|
|
349
|
-
if ("string" == typeof s2 && (s2 = (function(t2) {
|
|
350
|
-
void 0 === t2 && (t2 = "");
|
|
351
|
-
var s3 = t2.match(i);
|
|
352
|
-
if (!s3) return null;
|
|
353
|
-
var f3 = ("" + s3[0]).match(e) || ["-", 0, 0], n3 = f3[0], u3 = 60 * +f3[1] + +f3[2];
|
|
354
|
-
return 0 === u3 ? 0 : "+" === n3 ? u3 : -u3;
|
|
355
|
-
})(s2), null === s2)) return this;
|
|
356
|
-
var u2 = Math.abs(s2) <= 16 ? 60 * s2 : s2;
|
|
357
|
-
if (0 === u2) return this.utc(f2);
|
|
358
|
-
var r2 = this.clone();
|
|
359
|
-
if (f2) return r2.$offset = u2, r2.$u = false, r2;
|
|
360
|
-
var o2 = this.$u ? this.toDate().getTimezoneOffset() : -1 * this.utcOffset();
|
|
361
|
-
return (r2 = this.local().add(u2 + o2, t)).$offset = u2, r2.$x.$localOffset = o2, r2;
|
|
362
|
-
};
|
|
363
|
-
var h = u.format;
|
|
364
|
-
u.format = function(t2) {
|
|
365
|
-
var i2 = t2 || (this.$u ? "YYYY-MM-DDTHH:mm:ss[Z]" : "");
|
|
366
|
-
return h.call(this, i2);
|
|
367
|
-
}, u.valueOf = function() {
|
|
368
|
-
var t2 = this.$utils().u(this.$offset) ? 0 : this.$offset + (this.$x.$localOffset || this.$d.getTimezoneOffset());
|
|
369
|
-
return this.$d.valueOf() - 6e4 * t2;
|
|
370
|
-
}, u.isUTC = function() {
|
|
371
|
-
return !!this.$u;
|
|
372
|
-
}, u.toISOString = function() {
|
|
373
|
-
return this.toDate().toISOString();
|
|
374
|
-
}, u.toString = function() {
|
|
375
|
-
return this.toDate().toUTCString();
|
|
376
|
-
};
|
|
377
|
-
var l = u.toDate;
|
|
378
|
-
u.toDate = function(t2) {
|
|
379
|
-
return "s" === t2 && this.$offset ? n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate() : l.call(this);
|
|
380
|
-
};
|
|
381
|
-
var c = u.diff;
|
|
382
|
-
u.diff = function(t2, i2, e2) {
|
|
383
|
-
if (t2 && this.$u === t2.$u) return c.call(this, t2, i2, e2);
|
|
384
|
-
var s2 = this.local(), f2 = n(t2).local();
|
|
385
|
-
return c.call(s2, f2, i2, e2);
|
|
386
|
-
};
|
|
387
|
-
};
|
|
388
|
-
}));
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
|
|
392
314
|
// src/index.ts
|
|
393
315
|
var index_exports = {};
|
|
394
316
|
__export(index_exports, {
|
|
395
317
|
AccountantABI: () => AccountantABI,
|
|
396
318
|
AccountantAptosABI: () => AccountantAptosABI,
|
|
397
|
-
AptosAnalyticsClient: () => AptosAnalyticsClient,
|
|
398
319
|
AptosChainAdapter: () => AptosChainAdapter,
|
|
399
320
|
AtomicQueueABI: () => AtomicQueueABI,
|
|
400
321
|
AtomicQueueAptosABI: () => AtomicQueueAptosABI,
|
|
@@ -406,8 +327,7 @@ __export(index_exports, {
|
|
|
406
327
|
TellerWithMultiAssetSupportABI: () => TellerWithMultiAssetSupportABI,
|
|
407
328
|
VaultAptosABI: () => VaultAptosABI,
|
|
408
329
|
getContractABI: () => getContractABI,
|
|
409
|
-
getFunctionSignature: () => getFunctionSignature
|
|
410
|
-
mapIndexerToVaultActivity: () => mapIndexerToVaultActivity
|
|
330
|
+
getFunctionSignature: () => getFunctionSignature
|
|
411
331
|
});
|
|
412
332
|
module.exports = __toCommonJS(index_exports);
|
|
413
333
|
|
|
@@ -8757,303 +8677,18 @@ var AptosChainAdapter = class extends import_core2.BaseChainAdapter {
|
|
|
8757
8677
|
}
|
|
8758
8678
|
};
|
|
8759
8679
|
|
|
8760
|
-
// src/aptos/analytics-client.ts
|
|
8761
|
-
var import_core3 = require("@pyxisjs/core");
|
|
8762
|
-
var import_dayjs = __toESM(require_dayjs_min());
|
|
8763
|
-
var import_utc = __toESM(require_utc());
|
|
8764
|
-
|
|
8765
|
-
// src/aptos/analytics-utils.ts
|
|
8766
|
-
var apyWindowDaysMap = {
|
|
8767
|
-
"7d": 7,
|
|
8768
|
-
"30d": 30,
|
|
8769
|
-
alltime: 0
|
|
8770
|
-
};
|
|
8771
|
-
var buildActivitiesQuery = (vault, user, offset, pageSize) => {
|
|
8772
|
-
const variables = {
|
|
8773
|
-
offset,
|
|
8774
|
-
limit: pageSize
|
|
8775
|
-
};
|
|
8776
|
-
const variableDefinitions = ["$offset: Int!", "$limit: Int!"];
|
|
8777
|
-
const whereConditions = [];
|
|
8778
|
-
if (vault) {
|
|
8779
|
-
variables.vault = vault;
|
|
8780
|
-
variableDefinitions.push("$vault: String");
|
|
8781
|
-
whereConditions.push("{vault: { _eq: $vault }}");
|
|
8782
|
-
}
|
|
8783
|
-
if (user) {
|
|
8784
|
-
variables.user = user;
|
|
8785
|
-
variableDefinitions.push("$user: String");
|
|
8786
|
-
whereConditions.push("{user: { _eq: $user }}");
|
|
8787
|
-
}
|
|
8788
|
-
if (whereConditions.length === 0) {
|
|
8789
|
-
throw new Error("At least one of vault or user must be provided");
|
|
8790
|
-
}
|
|
8791
|
-
const whereClause = whereConditions.length > 1 ? `_and: [${whereConditions.join(", ")}]` : whereConditions[0].slice(1, -1);
|
|
8792
|
-
const query = `
|
|
8793
|
-
query ActivityQuery(${variableDefinitions.join(", ")}) {
|
|
8794
|
-
activities(where: {
|
|
8795
|
-
${whereClause}
|
|
8796
|
-
},
|
|
8797
|
-
order_by: {tx_version: desc},
|
|
8798
|
-
offset: $offset,
|
|
8799
|
-
limit: $limit) {
|
|
8800
|
-
deposit_amount
|
|
8801
|
-
deposit_token
|
|
8802
|
-
event_type
|
|
8803
|
-
tx_hash
|
|
8804
|
-
tx_version
|
|
8805
|
-
tx_timestamp
|
|
8806
|
-
user
|
|
8807
|
-
vault
|
|
8808
|
-
withdraw_amount
|
|
8809
|
-
withdraw_token
|
|
8810
|
-
}
|
|
8811
|
-
activities_aggregate(where: {
|
|
8812
|
-
${whereClause}
|
|
8813
|
-
},) {
|
|
8814
|
-
aggregate {
|
|
8815
|
-
count
|
|
8816
|
-
}
|
|
8817
|
-
}
|
|
8818
|
-
}
|
|
8819
|
-
`;
|
|
8820
|
-
return { query, variables };
|
|
8821
|
-
};
|
|
8822
|
-
var buildExchangeRateEventsQuery = (vault, startTime, endTime) => {
|
|
8823
|
-
const query = `
|
|
8824
|
-
query ExchangeRates($vault: String!, $startTime: numeric!, $endTime: numeric!) {
|
|
8825
|
-
exchange_rate_updated_events(where: {current_time: {_lte: $endTime, _gte: $startTime}, vault: {_eq: $vault}}, order_by: {current_time: asc}) {
|
|
8826
|
-
current_time
|
|
8827
|
-
new_deposit_rate
|
|
8828
|
-
new_withdraw_rate
|
|
8829
|
-
old_deposit_rate
|
|
8830
|
-
old_withdraw_rate
|
|
8831
|
-
vault
|
|
8832
|
-
type
|
|
8833
|
-
}
|
|
8834
|
-
}
|
|
8835
|
-
`;
|
|
8836
|
-
return {
|
|
8837
|
-
query,
|
|
8838
|
-
variables: {
|
|
8839
|
-
vault,
|
|
8840
|
-
startTime,
|
|
8841
|
-
endTime
|
|
8842
|
-
}
|
|
8843
|
-
};
|
|
8844
|
-
};
|
|
8845
|
-
function mapIndexerToVaultActivity(indexerActivity) {
|
|
8846
|
-
return {
|
|
8847
|
-
depositAmount: indexerActivity.deposit_amount,
|
|
8848
|
-
depositToken: indexerActivity.deposit_token,
|
|
8849
|
-
eventType: indexerActivity.event_type,
|
|
8850
|
-
txHash: indexerActivity.tx_hash,
|
|
8851
|
-
txVersion: indexerActivity.tx_version,
|
|
8852
|
-
txTimestamp: indexerActivity.tx_timestamp,
|
|
8853
|
-
user: indexerActivity.user,
|
|
8854
|
-
vault: indexerActivity.vault,
|
|
8855
|
-
withdrawAmount: indexerActivity.withdraw_amount,
|
|
8856
|
-
withdrawToken: indexerActivity.withdraw_token
|
|
8857
|
-
};
|
|
8858
|
-
}
|
|
8859
|
-
function getFunctionSignature2(contractName, functionName, contractAddress) {
|
|
8860
|
-
const signatures = {
|
|
8861
|
-
accountant: {
|
|
8862
|
-
calculate_shares_from_assets_safe: "{address}::accountant::calculate_shares_from_assets_safe",
|
|
8863
|
-
calculate_assets_from_shares_safe: "{address}::accountant::calculate_assets_from_shares_safe",
|
|
8864
|
-
get_withdraw_rate_in_quote_safe: "{address}::accountant::get_withdraw_rate_in_quote_safe",
|
|
8865
|
-
get_deposit_rate_in_quote_safe: "{address}::accountant::get_deposit_rate_in_quote_safe"
|
|
8866
|
-
},
|
|
8867
|
-
teller: {
|
|
8868
|
-
deposit: "{address}::teller::deposit"
|
|
8869
|
-
},
|
|
8870
|
-
atomicQueue: {
|
|
8871
|
-
get_minimum_request_age: "{address}::atomic_queue::get_minimum_request_age"
|
|
8872
|
-
}
|
|
8873
|
-
};
|
|
8874
|
-
const contractSignatures = signatures[contractName];
|
|
8875
|
-
if (!contractSignatures) {
|
|
8876
|
-
throw new Error(`Contract ${contractName} not found`);
|
|
8877
|
-
}
|
|
8878
|
-
const signature = contractSignatures[functionName];
|
|
8879
|
-
if (!signature) {
|
|
8880
|
-
throw new Error(
|
|
8881
|
-
`Function ${functionName} not found in contract ${contractName}`
|
|
8882
|
-
);
|
|
8883
|
-
}
|
|
8884
|
-
return signature.replace("{address}", contractAddress);
|
|
8885
|
-
}
|
|
8886
|
-
|
|
8887
|
-
// src/aptos/analytics-client.ts
|
|
8888
|
-
import_dayjs.default.extend(import_utc.default);
|
|
8889
|
-
var MIN_APY_DATA_POINTS = 2;
|
|
8890
|
-
var DEFAULT_PAGE_SIZE = 10;
|
|
8891
|
-
var DEFAULT_APY_WINDOW_DAYS = 7;
|
|
8892
|
-
var THIRTY_DAYS = 30;
|
|
8893
|
-
var AptosAnalyticsClient = class {
|
|
8894
|
-
constructor(chainAdapter, analyticsAdapter) {
|
|
8895
|
-
this.chainAdapter = chainAdapter;
|
|
8896
|
-
this.analyticsAdapter = analyticsAdapter;
|
|
8897
|
-
const config = (0, import_core3.getChainConfig)(chainAdapter.chain.id);
|
|
8898
|
-
invariant(
|
|
8899
|
-
config.type === import_core3.ChainType.MoveVM,
|
|
8900
|
-
"AptosAnalyticsClient requires a MoveVM chain adapter"
|
|
8901
|
-
);
|
|
8902
|
-
}
|
|
8903
|
-
/**
|
|
8904
|
-
* Get function signature using contract address from adapter
|
|
8905
|
-
*/
|
|
8906
|
-
getBaseFunctionSignature(contractName, functionName) {
|
|
8907
|
-
const contractAddress = this.chainAdapter.getContractAddress(contractName);
|
|
8908
|
-
return getFunctionSignature2(contractName, functionName, contractAddress);
|
|
8909
|
-
}
|
|
8910
|
-
async getActivities({
|
|
8911
|
-
vault,
|
|
8912
|
-
user,
|
|
8913
|
-
page = 1,
|
|
8914
|
-
pageSize = DEFAULT_PAGE_SIZE
|
|
8915
|
-
}) {
|
|
8916
|
-
const offset = (page - 1) * pageSize;
|
|
8917
|
-
const { query, variables } = buildActivitiesQuery(
|
|
8918
|
-
vault,
|
|
8919
|
-
user,
|
|
8920
|
-
offset,
|
|
8921
|
-
pageSize
|
|
8922
|
-
);
|
|
8923
|
-
const response = await this.analyticsAdapter.queryIndexer({
|
|
8924
|
-
query,
|
|
8925
|
-
variables
|
|
8926
|
-
});
|
|
8927
|
-
const activities = response.activities.map(mapIndexerToVaultActivity);
|
|
8928
|
-
return {
|
|
8929
|
-
activities,
|
|
8930
|
-
total: response.activities_aggregate.aggregate.count
|
|
8931
|
-
};
|
|
8932
|
-
}
|
|
8933
|
-
async getTvlInBaseAsset({ vault, asset }) {
|
|
8934
|
-
const normalizedVault = import_core3.PyxisUtils.normalizeAddress(vault);
|
|
8935
|
-
const normalizedAsset = import_core3.PyxisUtils.normalizeAddress(asset);
|
|
8936
|
-
const {
|
|
8937
|
-
vec: [balance]
|
|
8938
|
-
} = await this.chainAdapter.viewContract({
|
|
8939
|
-
function: "0x1::fungible_asset::supply",
|
|
8940
|
-
typeArguments: ["0x1::fungible_asset::Metadata"],
|
|
8941
|
-
arguments: [normalizedVault]
|
|
8942
|
-
});
|
|
8943
|
-
const functionSignature = this.getBaseFunctionSignature(
|
|
8944
|
-
"accountant",
|
|
8945
|
-
"calculate_assets_from_shares_safe"
|
|
8946
|
-
);
|
|
8947
|
-
const baseAssetAmount = await this.chainAdapter.viewContract({
|
|
8948
|
-
function: functionSignature,
|
|
8949
|
-
arguments: [normalizedVault, normalizedAsset, balance]
|
|
8950
|
-
});
|
|
8951
|
-
return baseAssetAmount;
|
|
8952
|
-
}
|
|
8953
|
-
async getUpdateExchangeRateEvents({
|
|
8954
|
-
vault,
|
|
8955
|
-
startTime,
|
|
8956
|
-
endTime
|
|
8957
|
-
}) {
|
|
8958
|
-
const { query, variables } = buildExchangeRateEventsQuery(
|
|
8959
|
-
vault,
|
|
8960
|
-
startTime,
|
|
8961
|
-
endTime
|
|
8962
|
-
);
|
|
8963
|
-
const response = await this.analyticsAdapter.queryIndexer({
|
|
8964
|
-
query,
|
|
8965
|
-
variables
|
|
8966
|
-
});
|
|
8967
|
-
return response.exchange_rate_updated_events.map(
|
|
8968
|
-
import_core3.PyxisUtils.mapIndexerToExchangeRateEvent
|
|
8969
|
-
);
|
|
8970
|
-
}
|
|
8971
|
-
async get30DayApy(vault) {
|
|
8972
|
-
const startTime = (0, import_dayjs.default)().utc().subtract(THIRTY_DAYS, "day").startOf("day").unix();
|
|
8973
|
-
const endTime = (0, import_dayjs.default)().utc().endOf("day").unix();
|
|
8974
|
-
const vaultExchangeRateUpdateEvents = await this.getUpdateExchangeRateEvents({
|
|
8975
|
-
vault,
|
|
8976
|
-
startTime,
|
|
8977
|
-
endTime
|
|
8978
|
-
});
|
|
8979
|
-
if (vaultExchangeRateUpdateEvents.length < MIN_APY_DATA_POINTS) {
|
|
8980
|
-
return "0";
|
|
8981
|
-
}
|
|
8982
|
-
vaultExchangeRateUpdateEvents.sort(
|
|
8983
|
-
(a, b) => Number(a.timestamp) - Number(b.timestamp)
|
|
8984
|
-
);
|
|
8985
|
-
return import_core3.PyxisUtils.calculateApy(
|
|
8986
|
-
vaultExchangeRateUpdateEvents[0],
|
|
8987
|
-
vaultExchangeRateUpdateEvents[vaultExchangeRateUpdateEvents.length - 1]
|
|
8988
|
-
);
|
|
8989
|
-
}
|
|
8990
|
-
async getHistoricalApy({
|
|
8991
|
-
vault,
|
|
8992
|
-
startTime,
|
|
8993
|
-
endTime,
|
|
8994
|
-
window = "alltime"
|
|
8995
|
-
}) {
|
|
8996
|
-
const historicalExchangeRateEvents = await this.getUpdateExchangeRateEvents(
|
|
8997
|
-
{
|
|
8998
|
-
vault,
|
|
8999
|
-
startTime,
|
|
9000
|
-
endTime
|
|
9001
|
-
}
|
|
9002
|
-
);
|
|
9003
|
-
if (historicalExchangeRateEvents.length < MIN_APY_DATA_POINTS) {
|
|
9004
|
-
return [];
|
|
9005
|
-
}
|
|
9006
|
-
historicalExchangeRateEvents.sort(
|
|
9007
|
-
(a, b) => Number(a.timestamp) - Number(b.timestamp)
|
|
9008
|
-
);
|
|
9009
|
-
const sampledEvents = import_core3.PyxisUtils.sampleEventsByDay(
|
|
9010
|
-
historicalExchangeRateEvents
|
|
9011
|
-
);
|
|
9012
|
-
if (sampledEvents.length < MIN_APY_DATA_POINTS) {
|
|
9013
|
-
return [];
|
|
9014
|
-
}
|
|
9015
|
-
const historicalApyData = sampledEvents.map((event, i) => {
|
|
9016
|
-
if (i === 0) return null;
|
|
9017
|
-
let baseEventIndex = 0;
|
|
9018
|
-
if (window === "alltime") {
|
|
9019
|
-
baseEventIndex = 0;
|
|
9020
|
-
} else {
|
|
9021
|
-
const daysToSubtract = apyWindowDaysMap[window] ?? DEFAULT_APY_WINDOW_DAYS;
|
|
9022
|
-
const firstEventTime = import_dayjs.default.unix(Number(sampledEvents[0].timestamp));
|
|
9023
|
-
const currentEventTime = import_dayjs.default.unix(Number(event.timestamp));
|
|
9024
|
-
if (currentEventTime.diff(firstEventTime, "day") < daysToSubtract) {
|
|
9025
|
-
return null;
|
|
9026
|
-
}
|
|
9027
|
-
const pastTime = currentEventTime.subtract(daysToSubtract, "day");
|
|
9028
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
9029
|
-
const eventTime = import_dayjs.default.unix(Number(sampledEvents[j].timestamp));
|
|
9030
|
-
if (eventTime.isSame(pastTime, "date")) {
|
|
9031
|
-
baseEventIndex = j;
|
|
9032
|
-
break;
|
|
9033
|
-
}
|
|
9034
|
-
}
|
|
9035
|
-
}
|
|
9036
|
-
return {
|
|
9037
|
-
value: import_core3.PyxisUtils.calculateApy(sampledEvents[baseEventIndex], event),
|
|
9038
|
-
timestamp: event.timestamp
|
|
9039
|
-
};
|
|
9040
|
-
}).filter((item) => item !== null);
|
|
9041
|
-
return historicalApyData;
|
|
9042
|
-
}
|
|
9043
|
-
};
|
|
9044
|
-
|
|
9045
8680
|
// src/evm/adapter.ts
|
|
9046
8681
|
var import_lz_v2_utilities2 = require("@layerzerolabs/lz-v2-utilities");
|
|
9047
|
-
var
|
|
9048
|
-
var
|
|
8682
|
+
var import_core3 = require("@pyxisjs/core");
|
|
8683
|
+
var import_dayjs = __toESM(require_dayjs_min());
|
|
9049
8684
|
var import_viem = require("viem");
|
|
9050
8685
|
var import_chains = require("viem/chains");
|
|
9051
8686
|
var viemChainMap = {
|
|
9052
|
-
[
|
|
9053
|
-
[
|
|
9054
|
-
[
|
|
8687
|
+
[import_core3.ChainId.ETHEREUM_MAINNET]: import_chains.mainnet,
|
|
8688
|
+
[import_core3.ChainId.ETHEREUM_SEPOLIA]: import_chains.sepolia,
|
|
8689
|
+
[import_core3.ChainId.ARBITRUM_ONE]: import_chains.arbitrum
|
|
9055
8690
|
};
|
|
9056
|
-
var EthereumChainAdapter = class extends
|
|
8691
|
+
var EthereumChainAdapter = class extends import_core3.BaseChainAdapter {
|
|
9057
8692
|
constructor(chain) {
|
|
9058
8693
|
super(chain);
|
|
9059
8694
|
this.viemChain = viemChainMap[chain.id];
|
|
@@ -9081,7 +8716,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9081
8716
|
* Build an Ethereum transaction payload
|
|
9082
8717
|
*/
|
|
9083
8718
|
async buildPayload(params) {
|
|
9084
|
-
const config = (0,
|
|
8719
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9085
8720
|
if (!config.chainId) {
|
|
9086
8721
|
throw new Error("Chain ID is required for EVM transactions");
|
|
9087
8722
|
}
|
|
@@ -9207,7 +8842,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9207
8842
|
* Get function signature using the new configuration system
|
|
9208
8843
|
*/
|
|
9209
8844
|
getFunctionSignature(contractName, functionName) {
|
|
9210
|
-
const config = (0,
|
|
8845
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9211
8846
|
const contractAddress = this.getContractAddress(contractName);
|
|
9212
8847
|
return getFunctionSignature(
|
|
9213
8848
|
config.type,
|
|
@@ -9220,7 +8855,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9220
8855
|
* Get contract ABI using the new configuration system
|
|
9221
8856
|
*/
|
|
9222
8857
|
getContractABI(contractName) {
|
|
9223
|
-
const config = (0,
|
|
8858
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9224
8859
|
return getContractABI(config.type, contractName);
|
|
9225
8860
|
}
|
|
9226
8861
|
async getWithdrawRateInQuoteSafe(args) {
|
|
@@ -9291,8 +8926,8 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9291
8926
|
lzTellerAddress,
|
|
9292
8927
|
"multiChainLzTeller contract address not configured."
|
|
9293
8928
|
);
|
|
9294
|
-
const dstEid = (0,
|
|
9295
|
-
const config = (0,
|
|
8929
|
+
const dstEid = (0, import_core3.getLayerZeroEndpointId)(destinationChain);
|
|
8930
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9296
8931
|
const functionSignature = getFunctionSignature(
|
|
9297
8932
|
config.type,
|
|
9298
8933
|
"multiChainLzTeller",
|
|
@@ -9302,7 +8937,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9302
8937
|
const bridgeData = {
|
|
9303
8938
|
chainSelector: dstEid,
|
|
9304
8939
|
destinationChainReceiver: recipient,
|
|
9305
|
-
messageGas: (0,
|
|
8940
|
+
messageGas: (0, import_core3.getLayerZeroGasLimit)(this.chain.id, destinationChain),
|
|
9306
8941
|
bridgeFeeToken: import_viem.ethAddress,
|
|
9307
8942
|
data: "0x"
|
|
9308
8943
|
// Empty extra data
|
|
@@ -9316,10 +8951,10 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9316
8951
|
return {
|
|
9317
8952
|
fee: result.toString(),
|
|
9318
8953
|
feeTokenAddress: import_viem.zeroAddress,
|
|
9319
|
-
method:
|
|
9320
|
-
estimatedTime: (0,
|
|
8954
|
+
method: import_core3.BridgeMethod.LayerZero,
|
|
8955
|
+
estimatedTime: (0, import_core3.getEstimatedBridgeTime)(this.chain.id, destinationChain),
|
|
9321
8956
|
extraOptions: import_lz_v2_utilities2.Options.newOptions().addExecutorLzReceiveOption(
|
|
9322
|
-
(0,
|
|
8957
|
+
(0, import_core3.getLayerZeroGasLimit)(this.chain.id, destinationChain)
|
|
9323
8958
|
).toBytes(),
|
|
9324
8959
|
zroFee: "0"
|
|
9325
8960
|
};
|
|
@@ -9332,18 +8967,18 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9332
8967
|
lzTellerAddress,
|
|
9333
8968
|
"Vault does not support bridging. multiChainLzTeller contract address not configured."
|
|
9334
8969
|
);
|
|
9335
|
-
const config = (0,
|
|
8970
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9336
8971
|
const functionSignature = getFunctionSignature(
|
|
9337
8972
|
config.type,
|
|
9338
8973
|
"multiChainLzTeller",
|
|
9339
8974
|
"bridge",
|
|
9340
8975
|
lzTellerAddress
|
|
9341
8976
|
);
|
|
9342
|
-
const dstEid = (0,
|
|
8977
|
+
const dstEid = (0, import_core3.getLayerZeroEndpointId)(args.destinationChain);
|
|
9343
8978
|
const extraOptionsHex = "0x" + Buffer.from(args.extraOptions).toString("hex");
|
|
9344
8979
|
const bridgeData = {
|
|
9345
8980
|
chainSelector: dstEid,
|
|
9346
|
-
messageGas: (0,
|
|
8981
|
+
messageGas: (0, import_core3.getLayerZeroGasLimit)(this.chain.id, args.destinationChain),
|
|
9347
8982
|
destinationChainReceiver: args.recipient,
|
|
9348
8983
|
bridgeFeeToken: import_viem.ethAddress,
|
|
9349
8984
|
data: extraOptionsHex
|
|
@@ -9402,7 +9037,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9402
9037
|
Number(args.offerAmount),
|
|
9403
9038
|
false,
|
|
9404
9039
|
// inSolve: Default false
|
|
9405
|
-
(0,
|
|
9040
|
+
(0, import_dayjs.default)().unix()
|
|
9406
9041
|
// UpdatedAt: current unix timestamp
|
|
9407
9042
|
]
|
|
9408
9043
|
],
|
|
@@ -9453,7 +9088,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9453
9088
|
flag,
|
|
9454
9089
|
matchAll
|
|
9455
9090
|
}) {
|
|
9456
|
-
const requestFlag =
|
|
9091
|
+
const requestFlag = import_core3.PyxisUtils.buildRequestFlags(flag);
|
|
9457
9092
|
const getAllWithdrawalRequestFn = this.getFunctionSignature(
|
|
9458
9093
|
"atomicQueue",
|
|
9459
9094
|
"get_all_atomic_requests"
|
|
@@ -9480,7 +9115,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9480
9115
|
return {
|
|
9481
9116
|
atomicPrice: request.atomicPrice,
|
|
9482
9117
|
deadline: request.deadline,
|
|
9483
|
-
flags:
|
|
9118
|
+
flags: import_core3.PyxisUtils.parseRequestFlags(solveData.flags),
|
|
9484
9119
|
offerAmount: request.offerAmount,
|
|
9485
9120
|
offerToken: request.offerToken,
|
|
9486
9121
|
userAddress: request.user,
|
|
@@ -9514,7 +9149,6 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9514
9149
|
0 && (module.exports = {
|
|
9515
9150
|
AccountantABI,
|
|
9516
9151
|
AccountantAptosABI,
|
|
9517
|
-
AptosAnalyticsClient,
|
|
9518
9152
|
AptosChainAdapter,
|
|
9519
9153
|
AtomicQueueABI,
|
|
9520
9154
|
AtomicQueueAptosABI,
|
|
@@ -9526,7 +9160,6 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9526
9160
|
TellerWithMultiAssetSupportABI,
|
|
9527
9161
|
VaultAptosABI,
|
|
9528
9162
|
getContractABI,
|
|
9529
|
-
getFunctionSignature
|
|
9530
|
-
mapIndexerToVaultActivity
|
|
9163
|
+
getFunctionSignature
|
|
9531
9164
|
});
|
|
9532
9165
|
//# sourceMappingURL=index.js.map
|