@pyxisjs/chains 0.3.0 → 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 -44
- package/dist/index.d.ts +2 -44
- package/dist/index.js +23 -429
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -421
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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,
|
|
@@ -402,13 +323,11 @@ __export(index_exports, {
|
|
|
402
323
|
CONTRACTS: () => CONTRACTS,
|
|
403
324
|
EthereumChainAdapter: () => EthereumChainAdapter,
|
|
404
325
|
MultiChainLayerZeroTellerAptosABI: () => MultiChainLayerZeroTellerAptosABI,
|
|
405
|
-
PyxisStatsClient: () => PyxisStatsClient,
|
|
406
326
|
TellerAptosABI: () => TellerAptosABI,
|
|
407
327
|
TellerWithMultiAssetSupportABI: () => TellerWithMultiAssetSupportABI,
|
|
408
328
|
VaultAptosABI: () => VaultAptosABI,
|
|
409
329
|
getContractABI: () => getContractABI,
|
|
410
|
-
getFunctionSignature: () => getFunctionSignature
|
|
411
|
-
mapIndexerToVaultActivity: () => mapIndexerToVaultActivity
|
|
330
|
+
getFunctionSignature: () => getFunctionSignature
|
|
412
331
|
});
|
|
413
332
|
module.exports = __toCommonJS(index_exports);
|
|
414
333
|
|
|
@@ -8758,340 +8677,18 @@ var AptosChainAdapter = class extends import_core2.BaseChainAdapter {
|
|
|
8758
8677
|
}
|
|
8759
8678
|
};
|
|
8760
8679
|
|
|
8761
|
-
// src/aptos/analytics-client.ts
|
|
8762
|
-
var import_core3 = require("@pyxisjs/core");
|
|
8763
|
-
var import_dayjs = __toESM(require_dayjs_min());
|
|
8764
|
-
var import_utc = __toESM(require_utc());
|
|
8765
|
-
|
|
8766
|
-
// src/aptos/analytics-utils.ts
|
|
8767
|
-
var apyWindowDaysMap = {
|
|
8768
|
-
"7d": 7,
|
|
8769
|
-
"30d": 30,
|
|
8770
|
-
alltime: 0
|
|
8771
|
-
};
|
|
8772
|
-
var buildActivitiesQuery = (vault, user, offset, pageSize) => {
|
|
8773
|
-
const variables = {
|
|
8774
|
-
offset,
|
|
8775
|
-
limit: pageSize
|
|
8776
|
-
};
|
|
8777
|
-
const variableDefinitions = ["$offset: Int!", "$limit: Int!"];
|
|
8778
|
-
const whereConditions = [];
|
|
8779
|
-
if (vault) {
|
|
8780
|
-
variables.vault = vault;
|
|
8781
|
-
variableDefinitions.push("$vault: String");
|
|
8782
|
-
whereConditions.push("{vault: { _eq: $vault }}");
|
|
8783
|
-
}
|
|
8784
|
-
if (user) {
|
|
8785
|
-
variables.user = user;
|
|
8786
|
-
variableDefinitions.push("$user: String");
|
|
8787
|
-
whereConditions.push("{user: { _eq: $user }}");
|
|
8788
|
-
}
|
|
8789
|
-
if (whereConditions.length === 0) {
|
|
8790
|
-
throw new Error("At least one of vault or user must be provided");
|
|
8791
|
-
}
|
|
8792
|
-
const whereClause = whereConditions.length > 1 ? `_and: [${whereConditions.join(", ")}]` : whereConditions[0].slice(1, -1);
|
|
8793
|
-
const query = `
|
|
8794
|
-
query ActivityQuery(${variableDefinitions.join(", ")}) {
|
|
8795
|
-
activities(where: {
|
|
8796
|
-
${whereClause}
|
|
8797
|
-
},
|
|
8798
|
-
order_by: {tx_version: desc},
|
|
8799
|
-
offset: $offset,
|
|
8800
|
-
limit: $limit) {
|
|
8801
|
-
deposit_amount
|
|
8802
|
-
deposit_token
|
|
8803
|
-
event_type
|
|
8804
|
-
tx_hash
|
|
8805
|
-
tx_version
|
|
8806
|
-
tx_timestamp
|
|
8807
|
-
user
|
|
8808
|
-
vault
|
|
8809
|
-
withdraw_amount
|
|
8810
|
-
withdraw_token
|
|
8811
|
-
}
|
|
8812
|
-
activities_aggregate(where: {
|
|
8813
|
-
${whereClause}
|
|
8814
|
-
},) {
|
|
8815
|
-
aggregate {
|
|
8816
|
-
count
|
|
8817
|
-
}
|
|
8818
|
-
}
|
|
8819
|
-
}
|
|
8820
|
-
`;
|
|
8821
|
-
return { query, variables };
|
|
8822
|
-
};
|
|
8823
|
-
var buildExchangeRateEventsQuery = (vault, startTime, endTime) => {
|
|
8824
|
-
const query = `
|
|
8825
|
-
query ExchangeRates($vault: String!, $startTime: numeric!, $endTime: numeric!) {
|
|
8826
|
-
exchange_rate_updated_events(where: {current_time: {_lte: $endTime, _gte: $startTime}, vault: {_eq: $vault}}, order_by: {current_time: asc}) {
|
|
8827
|
-
current_time
|
|
8828
|
-
new_deposit_rate
|
|
8829
|
-
new_withdraw_rate
|
|
8830
|
-
old_deposit_rate
|
|
8831
|
-
old_withdraw_rate
|
|
8832
|
-
vault
|
|
8833
|
-
type
|
|
8834
|
-
}
|
|
8835
|
-
}
|
|
8836
|
-
`;
|
|
8837
|
-
return {
|
|
8838
|
-
query,
|
|
8839
|
-
variables: {
|
|
8840
|
-
vault,
|
|
8841
|
-
startTime,
|
|
8842
|
-
endTime
|
|
8843
|
-
}
|
|
8844
|
-
};
|
|
8845
|
-
};
|
|
8846
|
-
function mapIndexerToVaultActivity(indexerActivity) {
|
|
8847
|
-
return {
|
|
8848
|
-
depositAmount: indexerActivity.deposit_amount,
|
|
8849
|
-
depositToken: indexerActivity.deposit_token,
|
|
8850
|
-
eventType: indexerActivity.event_type,
|
|
8851
|
-
txHash: indexerActivity.tx_hash,
|
|
8852
|
-
txVersion: indexerActivity.tx_version,
|
|
8853
|
-
txTimestamp: indexerActivity.tx_timestamp,
|
|
8854
|
-
user: indexerActivity.user,
|
|
8855
|
-
vault: indexerActivity.vault,
|
|
8856
|
-
withdrawAmount: indexerActivity.withdraw_amount,
|
|
8857
|
-
withdrawToken: indexerActivity.withdraw_token
|
|
8858
|
-
};
|
|
8859
|
-
}
|
|
8860
|
-
function getFunctionSignature2(contractName, functionName, contractAddress) {
|
|
8861
|
-
const signatures = {
|
|
8862
|
-
accountant: {
|
|
8863
|
-
calculate_shares_from_assets_safe: "{address}::accountant::calculate_shares_from_assets_safe",
|
|
8864
|
-
calculate_assets_from_shares_safe: "{address}::accountant::calculate_assets_from_shares_safe",
|
|
8865
|
-
get_withdraw_rate_in_quote_safe: "{address}::accountant::get_withdraw_rate_in_quote_safe",
|
|
8866
|
-
get_deposit_rate_in_quote_safe: "{address}::accountant::get_deposit_rate_in_quote_safe"
|
|
8867
|
-
},
|
|
8868
|
-
teller: {
|
|
8869
|
-
deposit: "{address}::teller::deposit"
|
|
8870
|
-
},
|
|
8871
|
-
atomicQueue: {
|
|
8872
|
-
get_minimum_request_age: "{address}::atomic_queue::get_minimum_request_age"
|
|
8873
|
-
}
|
|
8874
|
-
};
|
|
8875
|
-
const contractSignatures = signatures[contractName];
|
|
8876
|
-
if (!contractSignatures) {
|
|
8877
|
-
throw new Error(`Contract ${contractName} not found`);
|
|
8878
|
-
}
|
|
8879
|
-
const signature = contractSignatures[functionName];
|
|
8880
|
-
if (!signature) {
|
|
8881
|
-
throw new Error(
|
|
8882
|
-
`Function ${functionName} not found in contract ${contractName}`
|
|
8883
|
-
);
|
|
8884
|
-
}
|
|
8885
|
-
return signature.replace("{address}", contractAddress);
|
|
8886
|
-
}
|
|
8887
|
-
|
|
8888
|
-
// src/common/stats-client.ts
|
|
8889
|
-
var PyxisStatsClient = class {
|
|
8890
|
-
constructor(baseUrl = "https://stats.pyxisfinance.xyz/v1") {
|
|
8891
|
-
this.baseUrl = baseUrl;
|
|
8892
|
-
}
|
|
8893
|
-
async getManageOperations({
|
|
8894
|
-
vaultId,
|
|
8895
|
-
startTime,
|
|
8896
|
-
endTime,
|
|
8897
|
-
limit = 100
|
|
8898
|
-
}) {
|
|
8899
|
-
const params = new URLSearchParams({
|
|
8900
|
-
start_time: startTime.toString(),
|
|
8901
|
-
end_time: endTime.toString(),
|
|
8902
|
-
limit: limit.toString()
|
|
8903
|
-
});
|
|
8904
|
-
const url = `${this.baseUrl}/vaults/${vaultId}/manage-operations?${params}`;
|
|
8905
|
-
const response = await fetch(url);
|
|
8906
|
-
if (!response.ok) {
|
|
8907
|
-
throw new Error(
|
|
8908
|
-
`Failed to fetch manage operations: ${response.status} ${response.statusText}`
|
|
8909
|
-
);
|
|
8910
|
-
}
|
|
8911
|
-
const data = await response.json();
|
|
8912
|
-
if (data.code !== 0) {
|
|
8913
|
-
throw new Error(
|
|
8914
|
-
`Manage operations API error: ${data.message} (code: ${data.code})`
|
|
8915
|
-
);
|
|
8916
|
-
}
|
|
8917
|
-
return data.data.items;
|
|
8918
|
-
}
|
|
8919
|
-
};
|
|
8920
|
-
|
|
8921
|
-
// src/aptos/analytics-client.ts
|
|
8922
|
-
import_dayjs.default.extend(import_utc.default);
|
|
8923
|
-
var MIN_APY_DATA_POINTS = 2;
|
|
8924
|
-
var DEFAULT_PAGE_SIZE = 10;
|
|
8925
|
-
var DEFAULT_APY_WINDOW_DAYS = 7;
|
|
8926
|
-
var THIRTY_DAYS = 30;
|
|
8927
|
-
var AptosAnalyticsClient = class {
|
|
8928
|
-
constructor(chainAdapter, analyticsAdapter) {
|
|
8929
|
-
this.chainAdapter = chainAdapter;
|
|
8930
|
-
this.analyticsAdapter = analyticsAdapter;
|
|
8931
|
-
this.statsClient = new PyxisStatsClient();
|
|
8932
|
-
const config = (0, import_core3.getChainConfig)(chainAdapter.chain.id);
|
|
8933
|
-
invariant(
|
|
8934
|
-
config.type === import_core3.ChainType.MoveVM,
|
|
8935
|
-
"AptosAnalyticsClient requires a MoveVM chain adapter"
|
|
8936
|
-
);
|
|
8937
|
-
}
|
|
8938
|
-
/**
|
|
8939
|
-
* Get function signature using contract address from adapter
|
|
8940
|
-
*/
|
|
8941
|
-
getBaseFunctionSignature(contractName, functionName) {
|
|
8942
|
-
const contractAddress = this.chainAdapter.getContractAddress(contractName);
|
|
8943
|
-
return getFunctionSignature2(contractName, functionName, contractAddress);
|
|
8944
|
-
}
|
|
8945
|
-
async getActivities({
|
|
8946
|
-
vault,
|
|
8947
|
-
user,
|
|
8948
|
-
page = 1,
|
|
8949
|
-
pageSize = DEFAULT_PAGE_SIZE
|
|
8950
|
-
}) {
|
|
8951
|
-
const offset = (page - 1) * pageSize;
|
|
8952
|
-
const { query, variables } = buildActivitiesQuery(
|
|
8953
|
-
vault,
|
|
8954
|
-
user,
|
|
8955
|
-
offset,
|
|
8956
|
-
pageSize
|
|
8957
|
-
);
|
|
8958
|
-
const response = await this.analyticsAdapter.queryIndexer({
|
|
8959
|
-
query,
|
|
8960
|
-
variables
|
|
8961
|
-
});
|
|
8962
|
-
const activities = response.activities.map(mapIndexerToVaultActivity);
|
|
8963
|
-
return {
|
|
8964
|
-
activities,
|
|
8965
|
-
total: response.activities_aggregate.aggregate.count
|
|
8966
|
-
};
|
|
8967
|
-
}
|
|
8968
|
-
async getTvlInBaseAsset({ vault, asset }) {
|
|
8969
|
-
const normalizedVault = import_core3.PyxisUtils.normalizeAddress(vault);
|
|
8970
|
-
const normalizedAsset = import_core3.PyxisUtils.normalizeAddress(asset);
|
|
8971
|
-
const {
|
|
8972
|
-
vec: [balance]
|
|
8973
|
-
} = await this.chainAdapter.viewContract({
|
|
8974
|
-
function: "0x1::fungible_asset::supply",
|
|
8975
|
-
typeArguments: ["0x1::fungible_asset::Metadata"],
|
|
8976
|
-
arguments: [normalizedVault]
|
|
8977
|
-
});
|
|
8978
|
-
const functionSignature = this.getBaseFunctionSignature(
|
|
8979
|
-
"accountant",
|
|
8980
|
-
"calculate_assets_from_shares_safe"
|
|
8981
|
-
);
|
|
8982
|
-
const baseAssetAmount = await this.chainAdapter.viewContract({
|
|
8983
|
-
function: functionSignature,
|
|
8984
|
-
arguments: [normalizedVault, normalizedAsset, balance]
|
|
8985
|
-
});
|
|
8986
|
-
return baseAssetAmount;
|
|
8987
|
-
}
|
|
8988
|
-
async getUpdateExchangeRateEvents({
|
|
8989
|
-
vault,
|
|
8990
|
-
startTime,
|
|
8991
|
-
endTime
|
|
8992
|
-
}) {
|
|
8993
|
-
const { query, variables } = buildExchangeRateEventsQuery(
|
|
8994
|
-
vault,
|
|
8995
|
-
startTime,
|
|
8996
|
-
endTime
|
|
8997
|
-
);
|
|
8998
|
-
const response = await this.analyticsAdapter.queryIndexer({
|
|
8999
|
-
query,
|
|
9000
|
-
variables
|
|
9001
|
-
});
|
|
9002
|
-
return response.exchange_rate_updated_events.map(
|
|
9003
|
-
import_core3.PyxisUtils.mapIndexerToExchangeRateEvent
|
|
9004
|
-
);
|
|
9005
|
-
}
|
|
9006
|
-
async get30DayApy(vault) {
|
|
9007
|
-
const startTime = (0, import_dayjs.default)().utc().subtract(THIRTY_DAYS, "day").startOf("day").unix();
|
|
9008
|
-
const endTime = (0, import_dayjs.default)().utc().endOf("day").unix();
|
|
9009
|
-
const vaultExchangeRateUpdateEvents = await this.getUpdateExchangeRateEvents({
|
|
9010
|
-
vault,
|
|
9011
|
-
startTime,
|
|
9012
|
-
endTime
|
|
9013
|
-
});
|
|
9014
|
-
if (vaultExchangeRateUpdateEvents.length < MIN_APY_DATA_POINTS) {
|
|
9015
|
-
return "0";
|
|
9016
|
-
}
|
|
9017
|
-
vaultExchangeRateUpdateEvents.sort(
|
|
9018
|
-
(a, b) => Number(a.timestamp) - Number(b.timestamp)
|
|
9019
|
-
);
|
|
9020
|
-
return import_core3.PyxisUtils.calculateApy(
|
|
9021
|
-
vaultExchangeRateUpdateEvents[0],
|
|
9022
|
-
vaultExchangeRateUpdateEvents[vaultExchangeRateUpdateEvents.length - 1]
|
|
9023
|
-
);
|
|
9024
|
-
}
|
|
9025
|
-
async getHistoricalApy({
|
|
9026
|
-
vault,
|
|
9027
|
-
startTime,
|
|
9028
|
-
endTime,
|
|
9029
|
-
window = "alltime"
|
|
9030
|
-
}) {
|
|
9031
|
-
const historicalExchangeRateEvents = await this.getUpdateExchangeRateEvents(
|
|
9032
|
-
{
|
|
9033
|
-
vault,
|
|
9034
|
-
startTime,
|
|
9035
|
-
endTime
|
|
9036
|
-
}
|
|
9037
|
-
);
|
|
9038
|
-
if (historicalExchangeRateEvents.length < MIN_APY_DATA_POINTS) {
|
|
9039
|
-
return [];
|
|
9040
|
-
}
|
|
9041
|
-
historicalExchangeRateEvents.sort(
|
|
9042
|
-
(a, b) => Number(a.timestamp) - Number(b.timestamp)
|
|
9043
|
-
);
|
|
9044
|
-
const sampledEvents = import_core3.PyxisUtils.sampleEventsByDay(
|
|
9045
|
-
historicalExchangeRateEvents
|
|
9046
|
-
);
|
|
9047
|
-
if (sampledEvents.length < MIN_APY_DATA_POINTS) {
|
|
9048
|
-
return [];
|
|
9049
|
-
}
|
|
9050
|
-
const historicalApyData = sampledEvents.map((event, i) => {
|
|
9051
|
-
if (i === 0) return null;
|
|
9052
|
-
let baseEventIndex = 0;
|
|
9053
|
-
if (window === "alltime") {
|
|
9054
|
-
baseEventIndex = 0;
|
|
9055
|
-
} else {
|
|
9056
|
-
const daysToSubtract = apyWindowDaysMap[window] ?? DEFAULT_APY_WINDOW_DAYS;
|
|
9057
|
-
const firstEventTime = import_dayjs.default.unix(Number(sampledEvents[0].timestamp));
|
|
9058
|
-
const currentEventTime = import_dayjs.default.unix(Number(event.timestamp));
|
|
9059
|
-
if (currentEventTime.diff(firstEventTime, "day") < daysToSubtract) {
|
|
9060
|
-
return null;
|
|
9061
|
-
}
|
|
9062
|
-
const pastTime = currentEventTime.subtract(daysToSubtract, "day");
|
|
9063
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
9064
|
-
const eventTime = import_dayjs.default.unix(Number(sampledEvents[j].timestamp));
|
|
9065
|
-
if (eventTime.isSame(pastTime, "date")) {
|
|
9066
|
-
baseEventIndex = j;
|
|
9067
|
-
break;
|
|
9068
|
-
}
|
|
9069
|
-
}
|
|
9070
|
-
}
|
|
9071
|
-
return {
|
|
9072
|
-
value: import_core3.PyxisUtils.calculateApy(sampledEvents[baseEventIndex], event),
|
|
9073
|
-
timestamp: event.timestamp
|
|
9074
|
-
};
|
|
9075
|
-
}).filter((item) => item !== null);
|
|
9076
|
-
return historicalApyData;
|
|
9077
|
-
}
|
|
9078
|
-
async getManageOperations(args) {
|
|
9079
|
-
return this.statsClient.getManageOperations(args);
|
|
9080
|
-
}
|
|
9081
|
-
};
|
|
9082
|
-
|
|
9083
8680
|
// src/evm/adapter.ts
|
|
9084
8681
|
var import_lz_v2_utilities2 = require("@layerzerolabs/lz-v2-utilities");
|
|
9085
|
-
var
|
|
9086
|
-
var
|
|
8682
|
+
var import_core3 = require("@pyxisjs/core");
|
|
8683
|
+
var import_dayjs = __toESM(require_dayjs_min());
|
|
9087
8684
|
var import_viem = require("viem");
|
|
9088
8685
|
var import_chains = require("viem/chains");
|
|
9089
8686
|
var viemChainMap = {
|
|
9090
|
-
[
|
|
9091
|
-
[
|
|
9092
|
-
[
|
|
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
|
|
9093
8690
|
};
|
|
9094
|
-
var EthereumChainAdapter = class extends
|
|
8691
|
+
var EthereumChainAdapter = class extends import_core3.BaseChainAdapter {
|
|
9095
8692
|
constructor(chain) {
|
|
9096
8693
|
super(chain);
|
|
9097
8694
|
this.viemChain = viemChainMap[chain.id];
|
|
@@ -9119,7 +8716,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9119
8716
|
* Build an Ethereum transaction payload
|
|
9120
8717
|
*/
|
|
9121
8718
|
async buildPayload(params) {
|
|
9122
|
-
const config = (0,
|
|
8719
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9123
8720
|
if (!config.chainId) {
|
|
9124
8721
|
throw new Error("Chain ID is required for EVM transactions");
|
|
9125
8722
|
}
|
|
@@ -9245,7 +8842,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9245
8842
|
* Get function signature using the new configuration system
|
|
9246
8843
|
*/
|
|
9247
8844
|
getFunctionSignature(contractName, functionName) {
|
|
9248
|
-
const config = (0,
|
|
8845
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9249
8846
|
const contractAddress = this.getContractAddress(contractName);
|
|
9250
8847
|
return getFunctionSignature(
|
|
9251
8848
|
config.type,
|
|
@@ -9258,7 +8855,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9258
8855
|
* Get contract ABI using the new configuration system
|
|
9259
8856
|
*/
|
|
9260
8857
|
getContractABI(contractName) {
|
|
9261
|
-
const config = (0,
|
|
8858
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9262
8859
|
return getContractABI(config.type, contractName);
|
|
9263
8860
|
}
|
|
9264
8861
|
async getWithdrawRateInQuoteSafe(args) {
|
|
@@ -9329,8 +8926,8 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9329
8926
|
lzTellerAddress,
|
|
9330
8927
|
"multiChainLzTeller contract address not configured."
|
|
9331
8928
|
);
|
|
9332
|
-
const dstEid = (0,
|
|
9333
|
-
const config = (0,
|
|
8929
|
+
const dstEid = (0, import_core3.getLayerZeroEndpointId)(destinationChain);
|
|
8930
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9334
8931
|
const functionSignature = getFunctionSignature(
|
|
9335
8932
|
config.type,
|
|
9336
8933
|
"multiChainLzTeller",
|
|
@@ -9340,7 +8937,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9340
8937
|
const bridgeData = {
|
|
9341
8938
|
chainSelector: dstEid,
|
|
9342
8939
|
destinationChainReceiver: recipient,
|
|
9343
|
-
messageGas: (0,
|
|
8940
|
+
messageGas: (0, import_core3.getLayerZeroGasLimit)(this.chain.id, destinationChain),
|
|
9344
8941
|
bridgeFeeToken: import_viem.ethAddress,
|
|
9345
8942
|
data: "0x"
|
|
9346
8943
|
// Empty extra data
|
|
@@ -9354,10 +8951,10 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9354
8951
|
return {
|
|
9355
8952
|
fee: result.toString(),
|
|
9356
8953
|
feeTokenAddress: import_viem.zeroAddress,
|
|
9357
|
-
method:
|
|
9358
|
-
estimatedTime: (0,
|
|
8954
|
+
method: import_core3.BridgeMethod.LayerZero,
|
|
8955
|
+
estimatedTime: (0, import_core3.getEstimatedBridgeTime)(this.chain.id, destinationChain),
|
|
9359
8956
|
extraOptions: import_lz_v2_utilities2.Options.newOptions().addExecutorLzReceiveOption(
|
|
9360
|
-
(0,
|
|
8957
|
+
(0, import_core3.getLayerZeroGasLimit)(this.chain.id, destinationChain)
|
|
9361
8958
|
).toBytes(),
|
|
9362
8959
|
zroFee: "0"
|
|
9363
8960
|
};
|
|
@@ -9370,18 +8967,18 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9370
8967
|
lzTellerAddress,
|
|
9371
8968
|
"Vault does not support bridging. multiChainLzTeller contract address not configured."
|
|
9372
8969
|
);
|
|
9373
|
-
const config = (0,
|
|
8970
|
+
const config = (0, import_core3.getChainConfig)(this.chain.id);
|
|
9374
8971
|
const functionSignature = getFunctionSignature(
|
|
9375
8972
|
config.type,
|
|
9376
8973
|
"multiChainLzTeller",
|
|
9377
8974
|
"bridge",
|
|
9378
8975
|
lzTellerAddress
|
|
9379
8976
|
);
|
|
9380
|
-
const dstEid = (0,
|
|
8977
|
+
const dstEid = (0, import_core3.getLayerZeroEndpointId)(args.destinationChain);
|
|
9381
8978
|
const extraOptionsHex = "0x" + Buffer.from(args.extraOptions).toString("hex");
|
|
9382
8979
|
const bridgeData = {
|
|
9383
8980
|
chainSelector: dstEid,
|
|
9384
|
-
messageGas: (0,
|
|
8981
|
+
messageGas: (0, import_core3.getLayerZeroGasLimit)(this.chain.id, args.destinationChain),
|
|
9385
8982
|
destinationChainReceiver: args.recipient,
|
|
9386
8983
|
bridgeFeeToken: import_viem.ethAddress,
|
|
9387
8984
|
data: extraOptionsHex
|
|
@@ -9440,7 +9037,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9440
9037
|
Number(args.offerAmount),
|
|
9441
9038
|
false,
|
|
9442
9039
|
// inSolve: Default false
|
|
9443
|
-
(0,
|
|
9040
|
+
(0, import_dayjs.default)().unix()
|
|
9444
9041
|
// UpdatedAt: current unix timestamp
|
|
9445
9042
|
]
|
|
9446
9043
|
],
|
|
@@ -9491,7 +9088,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9491
9088
|
flag,
|
|
9492
9089
|
matchAll
|
|
9493
9090
|
}) {
|
|
9494
|
-
const requestFlag =
|
|
9091
|
+
const requestFlag = import_core3.PyxisUtils.buildRequestFlags(flag);
|
|
9495
9092
|
const getAllWithdrawalRequestFn = this.getFunctionSignature(
|
|
9496
9093
|
"atomicQueue",
|
|
9497
9094
|
"get_all_atomic_requests"
|
|
@@ -9518,7 +9115,7 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9518
9115
|
return {
|
|
9519
9116
|
atomicPrice: request.atomicPrice,
|
|
9520
9117
|
deadline: request.deadline,
|
|
9521
|
-
flags:
|
|
9118
|
+
flags: import_core3.PyxisUtils.parseRequestFlags(solveData.flags),
|
|
9522
9119
|
offerAmount: request.offerAmount,
|
|
9523
9120
|
offerToken: request.offerToken,
|
|
9524
9121
|
userAddress: request.user,
|
|
@@ -9552,7 +9149,6 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9552
9149
|
0 && (module.exports = {
|
|
9553
9150
|
AccountantABI,
|
|
9554
9151
|
AccountantAptosABI,
|
|
9555
|
-
AptosAnalyticsClient,
|
|
9556
9152
|
AptosChainAdapter,
|
|
9557
9153
|
AtomicQueueABI,
|
|
9558
9154
|
AtomicQueueAptosABI,
|
|
@@ -9560,12 +9156,10 @@ var EthereumChainAdapter = class extends import_core4.BaseChainAdapter {
|
|
|
9560
9156
|
CONTRACTS,
|
|
9561
9157
|
EthereumChainAdapter,
|
|
9562
9158
|
MultiChainLayerZeroTellerAptosABI,
|
|
9563
|
-
PyxisStatsClient,
|
|
9564
9159
|
TellerAptosABI,
|
|
9565
9160
|
TellerWithMultiAssetSupportABI,
|
|
9566
9161
|
VaultAptosABI,
|
|
9567
9162
|
getContractABI,
|
|
9568
|
-
getFunctionSignature
|
|
9569
|
-
mapIndexerToVaultActivity
|
|
9163
|
+
getFunctionSignature
|
|
9570
9164
|
});
|
|
9571
9165
|
//# sourceMappingURL=index.js.map
|