@owney/sdk 0.8.0 → 0.8.2
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/index.cjs +53 -10
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +53 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1027,15 +1027,36 @@ function buildAutoSelectUpdate(current, asset, chainId) {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
|
|
1029
1029
|
// src/agents/zyfai/protocol-merge.ts
|
|
1030
|
-
function
|
|
1030
|
+
function isExcludedProtocol(protocol, excluded) {
|
|
1031
|
+
if (excluded.length === 0) return false;
|
|
1032
|
+
const wanted = new Set(excluded.map((entry) => entry.toLowerCase()));
|
|
1033
|
+
return wanted.has(protocol.id.toLowerCase()) || protocol.name !== void 0 && wanted.has(protocol.name.toLowerCase());
|
|
1034
|
+
}
|
|
1035
|
+
function buildProtocolMergeUpdate(available, current, asset, excluded = []) {
|
|
1036
|
+
const excludedIds = /* @__PURE__ */ new Set([
|
|
1037
|
+
...excluded.map((entry) => entry.toLowerCase()),
|
|
1038
|
+
...available.filter((p) => isExcludedProtocol(p, excluded)).map((p) => p.id.toLowerCase())
|
|
1039
|
+
]);
|
|
1040
|
+
const isExcludedId = (id) => excluded.length > 0 && excludedIds.has(id.toLowerCase());
|
|
1031
1041
|
const enabled = current.protocols ?? [];
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1034
|
-
|
|
1042
|
+
const kept = enabled.filter((id) => !isExcludedId(id));
|
|
1043
|
+
const keptSet = new Set(kept);
|
|
1044
|
+
const missing = available.filter(
|
|
1045
|
+
(p) => !keptSet.has(p.id) && !isExcluded(p)
|
|
1046
|
+
);
|
|
1047
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1048
|
+
const removedAny = kept.length !== enabled.length;
|
|
1049
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1050
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1051
|
+
if (protocols.length === 0) return null;
|
|
1035
1052
|
return {
|
|
1036
1053
|
asset,
|
|
1037
|
-
protocols
|
|
1054
|
+
protocols,
|
|
1055
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
1038
1056
|
};
|
|
1057
|
+
function isExcluded(p) {
|
|
1058
|
+
return isExcludedProtocol(p, excluded);
|
|
1059
|
+
}
|
|
1039
1060
|
}
|
|
1040
1061
|
|
|
1041
1062
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1299,8 +1320,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1299
1320
|
earningsSnapshot = null;
|
|
1300
1321
|
earningsGeneration = 0;
|
|
1301
1322
|
sessionStore;
|
|
1302
|
-
|
|
1323
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1324
|
+
excludedProtocols;
|
|
1325
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1303
1326
|
this.sessionStore = sessionStore;
|
|
1327
|
+
this.excludedProtocols = excludedProtocols;
|
|
1304
1328
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1305
1329
|
this.sdk = new import_sdk.ZyfaiSDK({
|
|
1306
1330
|
apiKey,
|
|
@@ -1557,7 +1581,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1557
1581
|
);
|
|
1558
1582
|
return;
|
|
1559
1583
|
}
|
|
1560
|
-
const update = buildProtocolMergeUpdate(
|
|
1584
|
+
const update = buildProtocolMergeUpdate(
|
|
1585
|
+
available,
|
|
1586
|
+
current,
|
|
1587
|
+
asset,
|
|
1588
|
+
this.excludedProtocols
|
|
1589
|
+
);
|
|
1561
1590
|
if (!update) return;
|
|
1562
1591
|
await this.sdk.updateUserProfile(update);
|
|
1563
1592
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1809,9 +1838,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1809
1838
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1810
1839
|
*/
|
|
1811
1840
|
async getPoolCatalog(params) {
|
|
1812
|
-
const { protocols:
|
|
1841
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1813
1842
|
this.supportedChainIds[0]
|
|
1814
1843
|
);
|
|
1844
|
+
const universe = allProtocols.filter(
|
|
1845
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1846
|
+
);
|
|
1815
1847
|
const poolResults = await Promise.all(
|
|
1816
1848
|
universe.map(async (protocol) => {
|
|
1817
1849
|
try {
|
|
@@ -1888,7 +1920,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1888
1920
|
const protocols = [
|
|
1889
1921
|
.../* @__PURE__ */ new Set([...current.protocols ?? [], ...selectedProtocols])
|
|
1890
1922
|
];
|
|
1891
|
-
await this.sdk.updateUserProfile({
|
|
1923
|
+
await this.sdk.updateUserProfile({
|
|
1924
|
+
asset,
|
|
1925
|
+
strategy,
|
|
1926
|
+
protocols,
|
|
1927
|
+
autoSelectProtocols: false
|
|
1928
|
+
});
|
|
1892
1929
|
})
|
|
1893
1930
|
);
|
|
1894
1931
|
} catch (error) {
|
|
@@ -2243,6 +2280,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2243
2280
|
requestedStrategy: "aggressive",
|
|
2244
2281
|
setupResult
|
|
2245
2282
|
});
|
|
2283
|
+
if (this.excludedProtocols.length > 0) {
|
|
2284
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2285
|
+
}
|
|
2246
2286
|
if (isOwneyDebug()) {
|
|
2247
2287
|
try {
|
|
2248
2288
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5109,6 +5149,7 @@ var OwneySDK = class {
|
|
|
5109
5149
|
orgAgentConfigPromise = null;
|
|
5110
5150
|
zyfaiRpcUrls;
|
|
5111
5151
|
userPoolCustomization = false;
|
|
5152
|
+
excludedProtocols = [];
|
|
5112
5153
|
routingApiBaseUrl;
|
|
5113
5154
|
referralSource;
|
|
5114
5155
|
sessionStore;
|
|
@@ -5137,6 +5178,7 @@ var OwneySDK = class {
|
|
|
5137
5178
|
this.referralSource = config.referralSource;
|
|
5138
5179
|
this.sessionStore = config.sessionStore;
|
|
5139
5180
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5181
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5140
5182
|
}
|
|
5141
5183
|
/**
|
|
5142
5184
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5413,7 +5455,8 @@ var OwneySDK = class {
|
|
|
5413
5455
|
key2,
|
|
5414
5456
|
this.zyfaiRpcUrls,
|
|
5415
5457
|
this.referralSource,
|
|
5416
|
-
this.sessionStore
|
|
5458
|
+
this.sessionStore,
|
|
5459
|
+
this.excludedProtocols
|
|
5417
5460
|
);
|
|
5418
5461
|
}
|
|
5419
5462
|
return null;
|
package/dist/index.d.cts
CHANGED
|
@@ -309,6 +309,14 @@ interface OwneySDKConfig {
|
|
|
309
309
|
* pool customization is the source of truth.
|
|
310
310
|
*/
|
|
311
311
|
userPoolCustomization?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Protocols this app never lets users allocate to, by Zyfai protocol id or
|
|
314
|
+
* name (case-insensitive), e.g. `["superform"]`. On every wallet connect the
|
|
315
|
+
* SDK removes them from the user's protocol list and turns Zyfai's protocol
|
|
316
|
+
* auto-select off (auto-select would bypass the list). They are also left
|
|
317
|
+
* out of the pool catalogue and never added back by the protocol sync.
|
|
318
|
+
*/
|
|
319
|
+
excludedProtocols?: string[];
|
|
312
320
|
/**
|
|
313
321
|
* Absolute URL of an ERC-7677 paymaster service. When set, deposits go out as
|
|
314
322
|
* an EIP-5792 `wallet_sendCalls` with `capabilities.paymasterService`, so a
|
|
@@ -1222,6 +1230,7 @@ declare class OwneySDK {
|
|
|
1222
1230
|
private orgAgentConfigPromise;
|
|
1223
1231
|
private zyfaiRpcUrls?;
|
|
1224
1232
|
private userPoolCustomization;
|
|
1233
|
+
private excludedProtocols;
|
|
1225
1234
|
private routingApiBaseUrl?;
|
|
1226
1235
|
private referralSource?;
|
|
1227
1236
|
private sessionStore?;
|
package/dist/index.d.ts
CHANGED
|
@@ -309,6 +309,14 @@ interface OwneySDKConfig {
|
|
|
309
309
|
* pool customization is the source of truth.
|
|
310
310
|
*/
|
|
311
311
|
userPoolCustomization?: boolean;
|
|
312
|
+
/**
|
|
313
|
+
* Protocols this app never lets users allocate to, by Zyfai protocol id or
|
|
314
|
+
* name (case-insensitive), e.g. `["superform"]`. On every wallet connect the
|
|
315
|
+
* SDK removes them from the user's protocol list and turns Zyfai's protocol
|
|
316
|
+
* auto-select off (auto-select would bypass the list). They are also left
|
|
317
|
+
* out of the pool catalogue and never added back by the protocol sync.
|
|
318
|
+
*/
|
|
319
|
+
excludedProtocols?: string[];
|
|
312
320
|
/**
|
|
313
321
|
* Absolute URL of an ERC-7677 paymaster service. When set, deposits go out as
|
|
314
322
|
* an EIP-5792 `wallet_sendCalls` with `capabilities.paymasterService`, so a
|
|
@@ -1222,6 +1230,7 @@ declare class OwneySDK {
|
|
|
1222
1230
|
private orgAgentConfigPromise;
|
|
1223
1231
|
private zyfaiRpcUrls?;
|
|
1224
1232
|
private userPoolCustomization;
|
|
1233
|
+
private excludedProtocols;
|
|
1225
1234
|
private routingApiBaseUrl?;
|
|
1226
1235
|
private referralSource?;
|
|
1227
1236
|
private sessionStore?;
|
package/dist/index.js
CHANGED
|
@@ -986,15 +986,36 @@ function buildAutoSelectUpdate(current, asset, chainId) {
|
|
|
986
986
|
}
|
|
987
987
|
|
|
988
988
|
// src/agents/zyfai/protocol-merge.ts
|
|
989
|
-
function
|
|
989
|
+
function isExcludedProtocol(protocol, excluded) {
|
|
990
|
+
if (excluded.length === 0) return false;
|
|
991
|
+
const wanted = new Set(excluded.map((entry) => entry.toLowerCase()));
|
|
992
|
+
return wanted.has(protocol.id.toLowerCase()) || protocol.name !== void 0 && wanted.has(protocol.name.toLowerCase());
|
|
993
|
+
}
|
|
994
|
+
function buildProtocolMergeUpdate(available, current, asset, excluded = []) {
|
|
995
|
+
const excludedIds = /* @__PURE__ */ new Set([
|
|
996
|
+
...excluded.map((entry) => entry.toLowerCase()),
|
|
997
|
+
...available.filter((p) => isExcludedProtocol(p, excluded)).map((p) => p.id.toLowerCase())
|
|
998
|
+
]);
|
|
999
|
+
const isExcludedId = (id) => excluded.length > 0 && excludedIds.has(id.toLowerCase());
|
|
990
1000
|
const enabled = current.protocols ?? [];
|
|
991
|
-
const
|
|
992
|
-
const
|
|
993
|
-
|
|
1001
|
+
const kept = enabled.filter((id) => !isExcludedId(id));
|
|
1002
|
+
const keptSet = new Set(kept);
|
|
1003
|
+
const missing = available.filter(
|
|
1004
|
+
(p) => !keptSet.has(p.id) && !isExcluded(p)
|
|
1005
|
+
);
|
|
1006
|
+
const fixAutoSelect = excluded.length > 0 && current.autoSelectProtocols !== false;
|
|
1007
|
+
const removedAny = kept.length !== enabled.length;
|
|
1008
|
+
if (missing.length === 0 && !removedAny && !fixAutoSelect) return null;
|
|
1009
|
+
const protocols = [.../* @__PURE__ */ new Set([...kept, ...missing.map((p) => p.id)])];
|
|
1010
|
+
if (protocols.length === 0) return null;
|
|
994
1011
|
return {
|
|
995
1012
|
asset,
|
|
996
|
-
protocols
|
|
1013
|
+
protocols,
|
|
1014
|
+
...excluded.length > 0 ? { autoSelectProtocols: false } : {}
|
|
997
1015
|
};
|
|
1016
|
+
function isExcluded(p) {
|
|
1017
|
+
return isExcludedProtocol(p, excluded);
|
|
1018
|
+
}
|
|
998
1019
|
}
|
|
999
1020
|
|
|
1000
1021
|
// src/agents/zyfai/splitting.ts
|
|
@@ -1258,8 +1279,11 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1258
1279
|
earningsSnapshot = null;
|
|
1259
1280
|
earningsGeneration = 0;
|
|
1260
1281
|
sessionStore;
|
|
1261
|
-
|
|
1282
|
+
/** Protocols this app bars (id or name); see OwneySDKConfig.excludedProtocols. */
|
|
1283
|
+
excludedProtocols;
|
|
1284
|
+
constructor(apiKey, rpcUrls, referralSource, sessionStore = new BrowserSessionStore(), excludedProtocols = []) {
|
|
1262
1285
|
this.sessionStore = sessionStore;
|
|
1286
|
+
this.excludedProtocols = excludedProtocols;
|
|
1263
1287
|
this.rpcUrls = rpcUrls ?? DEFAULT_ZYFAI_RPC_URLS;
|
|
1264
1288
|
this.sdk = new ZyfaiSDK({
|
|
1265
1289
|
apiKey,
|
|
@@ -1516,7 +1540,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1516
1540
|
);
|
|
1517
1541
|
return;
|
|
1518
1542
|
}
|
|
1519
|
-
const update = buildProtocolMergeUpdate(
|
|
1543
|
+
const update = buildProtocolMergeUpdate(
|
|
1544
|
+
available,
|
|
1545
|
+
current,
|
|
1546
|
+
asset,
|
|
1547
|
+
this.excludedProtocols
|
|
1548
|
+
);
|
|
1520
1549
|
if (!update) return;
|
|
1521
1550
|
await this.sdk.updateUserProfile(update);
|
|
1522
1551
|
debugLog("zyfai:protocol-sync", `${asset}: wrote profile update`, update);
|
|
@@ -1768,9 +1797,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1768
1797
|
* lookup fails is skipped rather than failing the whole catalogue.
|
|
1769
1798
|
*/
|
|
1770
1799
|
async getPoolCatalog(params) {
|
|
1771
|
-
const { protocols:
|
|
1800
|
+
const { protocols: allProtocols } = await this.sdk.getAvailableProtocols(
|
|
1772
1801
|
this.supportedChainIds[0]
|
|
1773
1802
|
);
|
|
1803
|
+
const universe = allProtocols.filter(
|
|
1804
|
+
(protocol) => !isExcludedProtocol(protocol, this.excludedProtocols)
|
|
1805
|
+
);
|
|
1774
1806
|
const poolResults = await Promise.all(
|
|
1775
1807
|
universe.map(async (protocol) => {
|
|
1776
1808
|
try {
|
|
@@ -1847,7 +1879,12 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1847
1879
|
const protocols = [
|
|
1848
1880
|
.../* @__PURE__ */ new Set([...current.protocols ?? [], ...selectedProtocols])
|
|
1849
1881
|
];
|
|
1850
|
-
await this.sdk.updateUserProfile({
|
|
1882
|
+
await this.sdk.updateUserProfile({
|
|
1883
|
+
asset,
|
|
1884
|
+
strategy,
|
|
1885
|
+
protocols,
|
|
1886
|
+
autoSelectProtocols: false
|
|
1887
|
+
});
|
|
1851
1888
|
})
|
|
1852
1889
|
);
|
|
1853
1890
|
} catch (error) {
|
|
@@ -2202,6 +2239,9 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
2202
2239
|
requestedStrategy: "aggressive",
|
|
2203
2240
|
setupResult
|
|
2204
2241
|
});
|
|
2242
|
+
if (this.excludedProtocols.length > 0) {
|
|
2243
|
+
await this.ensureProtocolsSynced(validChainId, asset);
|
|
2244
|
+
}
|
|
2205
2245
|
if (isOwneyDebug()) {
|
|
2206
2246
|
try {
|
|
2207
2247
|
const profileAfterSetup = await this.sdk.getUserDetails(
|
|
@@ -5089,6 +5129,7 @@ var OwneySDK = class {
|
|
|
5089
5129
|
orgAgentConfigPromise = null;
|
|
5090
5130
|
zyfaiRpcUrls;
|
|
5091
5131
|
userPoolCustomization = false;
|
|
5132
|
+
excludedProtocols = [];
|
|
5092
5133
|
routingApiBaseUrl;
|
|
5093
5134
|
referralSource;
|
|
5094
5135
|
sessionStore;
|
|
@@ -5117,6 +5158,7 @@ var OwneySDK = class {
|
|
|
5117
5158
|
this.referralSource = config.referralSource;
|
|
5118
5159
|
this.sessionStore = config.sessionStore;
|
|
5119
5160
|
this.userPoolCustomization = config.userPoolCustomization ?? false;
|
|
5161
|
+
this.excludedProtocols = config.excludedProtocols ?? [];
|
|
5120
5162
|
}
|
|
5121
5163
|
/**
|
|
5122
5164
|
* Establish connection state for all subsequent SDK calls.
|
|
@@ -5393,7 +5435,8 @@ var OwneySDK = class {
|
|
|
5393
5435
|
key2,
|
|
5394
5436
|
this.zyfaiRpcUrls,
|
|
5395
5437
|
this.referralSource,
|
|
5396
|
-
this.sessionStore
|
|
5438
|
+
this.sessionStore,
|
|
5439
|
+
this.excludedProtocols
|
|
5397
5440
|
);
|
|
5398
5441
|
}
|
|
5399
5442
|
return null;
|