@avail-project/ca-common 2.0.0 → 2.2.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/evmabi/fibrousrouter.abi.js +41 -0
- package/dist/cjs/evmabi/index.js +1 -0
- package/dist/cjs/proto/definition.js +153 -4
- package/dist/cjs/xcs/autochoice.js +87 -5
- package/dist/cjs/xcs/bebop-agg.js +7 -8
- package/dist/cjs/xcs/fibrous-agg.js +152 -0
- package/dist/cjs/xcs/index.js +1 -0
- package/dist/cjs/xcs/lifi-agg.js +22 -0
- package/dist/esm/evmabi/fibrousrouter.abi.js +38 -0
- package/dist/esm/evmabi/index.js +1 -0
- package/dist/esm/proto/definition.js +151 -3
- package/dist/esm/xcs/autochoice.js +81 -5
- package/dist/esm/xcs/bebop-agg.js +7 -8
- package/dist/esm/xcs/fibrous-agg.js +147 -0
- package/dist/esm/xcs/index.js +1 -0
- package/dist/esm/xcs/lifi-agg.js +22 -0
- package/dist/types/evmabi/fibrousrouter.abi.d.ts +77 -0
- package/dist/types/evmabi/index.d.ts +1 -0
- package/dist/types/proto/definition.d.ts +9 -0
- package/dist/types/xcs/autochoice.d.ts +80 -3
- package/dist/types/xcs/fibrous-agg.d.ts +54 -0
- package/dist/types/xcs/iface.d.ts +1 -0
- package/dist/types/xcs/index.d.ts +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FibrousRouterABI = void 0;
|
|
4
|
+
exports.FibrousRouterABI = [
|
|
5
|
+
{
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
components: [
|
|
9
|
+
{ internalType: "address", name: "token_in", type: "address" },
|
|
10
|
+
{ internalType: "address", name: "token_out", type: "address" },
|
|
11
|
+
{ internalType: "uint256", name: "amount_in", type: "uint256" },
|
|
12
|
+
{ internalType: "uint256", name: "amount_out", type: "uint256" },
|
|
13
|
+
{ internalType: "uint256", name: "min_received", type: "uint256" },
|
|
14
|
+
{ internalType: "address", name: "destination", type: "address" },
|
|
15
|
+
{ internalType: "uint8", name: "swap_type", type: "uint8" },
|
|
16
|
+
],
|
|
17
|
+
internalType: "struct IFibrousRouter.RouteParam",
|
|
18
|
+
name: "route",
|
|
19
|
+
type: "tuple",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
components: [
|
|
23
|
+
{ internalType: "address", name: "token_in", type: "address" },
|
|
24
|
+
{ internalType: "address", name: "token_out", type: "address" },
|
|
25
|
+
{ internalType: "uint32", name: "rate", type: "uint32" },
|
|
26
|
+
{ internalType: "int24", name: "protocol_id", type: "int24" },
|
|
27
|
+
{ internalType: "address", name: "pool_address", type: "address" },
|
|
28
|
+
{ internalType: "uint8", name: "swap_type", type: "uint8" },
|
|
29
|
+
{ internalType: "bytes", name: "extra_data", type: "bytes" },
|
|
30
|
+
],
|
|
31
|
+
internalType: "struct IFibrousRouter.SwapParams[]",
|
|
32
|
+
name: "swap_parameters",
|
|
33
|
+
type: "tuple[]",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
name: "swap",
|
|
37
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
38
|
+
stateMutability: "payable",
|
|
39
|
+
type: "function",
|
|
40
|
+
},
|
|
41
|
+
];
|
package/dist/cjs/evmabi/index.js
CHANGED
|
@@ -4,3 +4,4 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./erc20.abi"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./vault.abi"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./yakaggregator.abi"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./fibrousrouter.abi"), exports);
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
// protoc v6.32.1
|
|
6
6
|
// source: definition.proto
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.
|
|
8
|
+
exports.FillVEPacket = exports.DepositVEPacket = exports.MsgRefundReqResponse = exports.MsgRefundReq = exports.QueryGetPriceOracleDataResponse = exports.QueryGetPriceOracleDataRequest = exports.PriceOracleData = exports.PriceOracleDatum = exports.MsgUpdateProtocolFeesResponse = exports.MsgUpdateProtocolFees = exports.MsgCreateProtocolFeesResponse = exports.MsgCreateProtocolFees = exports.QueryGetProtocolFeesResponse = exports.QueryGetProtocolFeesRequest = exports.ProtocolFees = exports.PerChainFeeBP = exports.AdminFeeRecipient = exports.FixedFeeTuple = exports.QueryRequestForFundsByAddressRequest = exports.QueryAllSettlementResponse = exports.QueryAllSettlementRequest = exports.QueryGetSettlementResponse = exports.QueryGetSettlementRequest = exports.Settlement = exports.MsgUpdateSolverDataResponse = exports.MsgUpdateSolverData = exports.MsgCreateSolverDataResponse = exports.MsgCreateSolverData = exports.QueryAllSolverDataResponse = exports.QueryAllSolverDataRequest = exports.QueryGetSolverDataResponse = exports.QueryGetSolverDataRequest = exports.SolverData = exports.SolverAddress = exports.RouteFee = exports.QueryAllRequestForFundsResponse = exports.QueryAllRequestForFundsRequest = exports.QueryGetRequestForFundsResponse = exports.QueryGetRequestForFundsRequest = exports.MsgCreateRequestForFundsResponse = exports.MsgCreateRequestForFunds = exports.RequestForFunds = exports.RFFDestinationPair = exports.SignatureDatum = exports.RFFSourcePair = exports.PageResponse = exports.PageRequest = exports.Universe = exports.RFFSourceState = exports.protobufPackage = void 0;
|
|
9
|
+
exports.MsgDoubleCheckTx = void 0;
|
|
9
10
|
exports.rFFSourceStateFromJSON = rFFSourceStateFromJSON;
|
|
10
11
|
exports.rFFSourceStateToJSON = rFFSourceStateToJSON;
|
|
11
12
|
exports.universeFromJSON = universeFromJSON;
|
|
@@ -2779,8 +2780,91 @@ exports.AdminFeeRecipient = {
|
|
|
2779
2780
|
return message;
|
|
2780
2781
|
},
|
|
2781
2782
|
};
|
|
2783
|
+
function createBasePerChainFeeBP() {
|
|
2784
|
+
return { universe: 0, chainID: new Uint8Array(0), feeBP: long_1.default.UZERO };
|
|
2785
|
+
}
|
|
2786
|
+
exports.PerChainFeeBP = {
|
|
2787
|
+
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
2788
|
+
if (message.universe !== 0) {
|
|
2789
|
+
writer.uint32(8).int32(message.universe);
|
|
2790
|
+
}
|
|
2791
|
+
if (message.chainID.length !== 0) {
|
|
2792
|
+
writer.uint32(18).bytes(message.chainID);
|
|
2793
|
+
}
|
|
2794
|
+
if (!message.feeBP.equals(long_1.default.UZERO)) {
|
|
2795
|
+
writer.uint32(24).uint64(message.feeBP.toString());
|
|
2796
|
+
}
|
|
2797
|
+
return writer;
|
|
2798
|
+
},
|
|
2799
|
+
decode(input, length) {
|
|
2800
|
+
const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
|
|
2801
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
2802
|
+
const message = createBasePerChainFeeBP();
|
|
2803
|
+
while (reader.pos < end) {
|
|
2804
|
+
const tag = reader.uint32();
|
|
2805
|
+
switch (tag >>> 3) {
|
|
2806
|
+
case 1: {
|
|
2807
|
+
if (tag !== 8) {
|
|
2808
|
+
break;
|
|
2809
|
+
}
|
|
2810
|
+
message.universe = reader.int32();
|
|
2811
|
+
continue;
|
|
2812
|
+
}
|
|
2813
|
+
case 2: {
|
|
2814
|
+
if (tag !== 18) {
|
|
2815
|
+
break;
|
|
2816
|
+
}
|
|
2817
|
+
message.chainID = reader.bytes();
|
|
2818
|
+
continue;
|
|
2819
|
+
}
|
|
2820
|
+
case 3: {
|
|
2821
|
+
if (tag !== 24) {
|
|
2822
|
+
break;
|
|
2823
|
+
}
|
|
2824
|
+
message.feeBP = long_1.default.fromString(reader.uint64().toString(), true);
|
|
2825
|
+
continue;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
2829
|
+
break;
|
|
2830
|
+
}
|
|
2831
|
+
reader.skip(tag & 7);
|
|
2832
|
+
}
|
|
2833
|
+
return message;
|
|
2834
|
+
},
|
|
2835
|
+
fromJSON(object) {
|
|
2836
|
+
return {
|
|
2837
|
+
universe: isSet(object.universe) ? universeFromJSON(object.universe) : 0,
|
|
2838
|
+
chainID: isSet(object.chainID) ? bytesFromBase64(object.chainID) : new Uint8Array(0),
|
|
2839
|
+
feeBP: isSet(object.feeBP) ? long_1.default.fromValue(object.feeBP) : long_1.default.UZERO,
|
|
2840
|
+
};
|
|
2841
|
+
},
|
|
2842
|
+
toJSON(message) {
|
|
2843
|
+
const obj = {};
|
|
2844
|
+
if (message.universe !== 0) {
|
|
2845
|
+
obj.universe = universeToJSON(message.universe);
|
|
2846
|
+
}
|
|
2847
|
+
if (message.chainID.length !== 0) {
|
|
2848
|
+
obj.chainID = base64FromBytes(message.chainID);
|
|
2849
|
+
}
|
|
2850
|
+
if (!message.feeBP.equals(long_1.default.UZERO)) {
|
|
2851
|
+
obj.feeBP = (message.feeBP || long_1.default.UZERO).toString();
|
|
2852
|
+
}
|
|
2853
|
+
return obj;
|
|
2854
|
+
},
|
|
2855
|
+
create(base) {
|
|
2856
|
+
return exports.PerChainFeeBP.fromPartial(base ?? {});
|
|
2857
|
+
},
|
|
2858
|
+
fromPartial(object) {
|
|
2859
|
+
const message = createBasePerChainFeeBP();
|
|
2860
|
+
message.universe = object.universe ?? 0;
|
|
2861
|
+
message.chainID = object.chainID ?? new Uint8Array(0);
|
|
2862
|
+
message.feeBP = (object.feeBP !== undefined && object.feeBP !== null) ? long_1.default.fromValue(object.feeBP) : long_1.default.UZERO;
|
|
2863
|
+
return message;
|
|
2864
|
+
},
|
|
2865
|
+
};
|
|
2782
2866
|
function createBaseProtocolFees() {
|
|
2783
|
-
return { feeBP: long_1.default.UZERO, collectionFees: [], fulfilmentFees: [], admin: "", feeRecipients: [] };
|
|
2867
|
+
return { feeBP: long_1.default.UZERO, collectionFees: [], fulfilmentFees: [], admin: "", feeRecipients: [], perChainFeeBP: [] };
|
|
2784
2868
|
}
|
|
2785
2869
|
exports.ProtocolFees = {
|
|
2786
2870
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
@@ -2799,6 +2883,9 @@ exports.ProtocolFees = {
|
|
|
2799
2883
|
for (const v of message.feeRecipients) {
|
|
2800
2884
|
exports.AdminFeeRecipient.encode(v, writer.uint32(42).fork()).join();
|
|
2801
2885
|
}
|
|
2886
|
+
for (const v of message.perChainFeeBP) {
|
|
2887
|
+
exports.PerChainFeeBP.encode(v, writer.uint32(50).fork()).join();
|
|
2888
|
+
}
|
|
2802
2889
|
return writer;
|
|
2803
2890
|
},
|
|
2804
2891
|
decode(input, length) {
|
|
@@ -2843,6 +2930,13 @@ exports.ProtocolFees = {
|
|
|
2843
2930
|
message.feeRecipients.push(exports.AdminFeeRecipient.decode(reader, reader.uint32()));
|
|
2844
2931
|
continue;
|
|
2845
2932
|
}
|
|
2933
|
+
case 6: {
|
|
2934
|
+
if (tag !== 50) {
|
|
2935
|
+
break;
|
|
2936
|
+
}
|
|
2937
|
+
message.perChainFeeBP.push(exports.PerChainFeeBP.decode(reader, reader.uint32()));
|
|
2938
|
+
continue;
|
|
2939
|
+
}
|
|
2846
2940
|
}
|
|
2847
2941
|
if ((tag & 7) === 4 || tag === 0) {
|
|
2848
2942
|
break;
|
|
@@ -2864,6 +2958,9 @@ exports.ProtocolFees = {
|
|
|
2864
2958
|
feeRecipients: globalThis.Array.isArray(object?.feeRecipients)
|
|
2865
2959
|
? object.feeRecipients.map((e) => exports.AdminFeeRecipient.fromJSON(e))
|
|
2866
2960
|
: [],
|
|
2961
|
+
perChainFeeBP: globalThis.Array.isArray(object?.perChainFeeBP)
|
|
2962
|
+
? object.perChainFeeBP.map((e) => exports.PerChainFeeBP.fromJSON(e))
|
|
2963
|
+
: [],
|
|
2867
2964
|
};
|
|
2868
2965
|
},
|
|
2869
2966
|
toJSON(message) {
|
|
@@ -2883,6 +2980,9 @@ exports.ProtocolFees = {
|
|
|
2883
2980
|
if (message.feeRecipients?.length) {
|
|
2884
2981
|
obj.feeRecipients = message.feeRecipients.map((e) => exports.AdminFeeRecipient.toJSON(e));
|
|
2885
2982
|
}
|
|
2983
|
+
if (message.perChainFeeBP?.length) {
|
|
2984
|
+
obj.perChainFeeBP = message.perChainFeeBP.map((e) => exports.PerChainFeeBP.toJSON(e));
|
|
2985
|
+
}
|
|
2886
2986
|
return obj;
|
|
2887
2987
|
},
|
|
2888
2988
|
create(base) {
|
|
@@ -2895,6 +2995,7 @@ exports.ProtocolFees = {
|
|
|
2895
2995
|
message.fulfilmentFees = object.fulfilmentFees?.map((e) => exports.FixedFeeTuple.fromPartial(e)) || [];
|
|
2896
2996
|
message.admin = object.admin ?? "";
|
|
2897
2997
|
message.feeRecipients = object.feeRecipients?.map((e) => exports.AdminFeeRecipient.fromPartial(e)) || [];
|
|
2998
|
+
message.perChainFeeBP = object.perChainFeeBP?.map((e) => exports.PerChainFeeBP.fromPartial(e)) || [];
|
|
2898
2999
|
return message;
|
|
2899
3000
|
},
|
|
2900
3001
|
};
|
|
@@ -2989,7 +3090,14 @@ exports.QueryGetProtocolFeesResponse = {
|
|
|
2989
3090
|
},
|
|
2990
3091
|
};
|
|
2991
3092
|
function createBaseMsgCreateProtocolFees() {
|
|
2992
|
-
return {
|
|
3093
|
+
return {
|
|
3094
|
+
creator: "",
|
|
3095
|
+
feeBP: long_1.default.UZERO,
|
|
3096
|
+
collectionFees: [],
|
|
3097
|
+
fulfilmentFees: [],
|
|
3098
|
+
feeRecipients: [],
|
|
3099
|
+
perChainFeeBP: [],
|
|
3100
|
+
};
|
|
2993
3101
|
}
|
|
2994
3102
|
exports.MsgCreateProtocolFees = {
|
|
2995
3103
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
@@ -3008,6 +3116,9 @@ exports.MsgCreateProtocolFees = {
|
|
|
3008
3116
|
for (const v of message.feeRecipients) {
|
|
3009
3117
|
exports.AdminFeeRecipient.encode(v, writer.uint32(42).fork()).join();
|
|
3010
3118
|
}
|
|
3119
|
+
for (const v of message.perChainFeeBP) {
|
|
3120
|
+
exports.PerChainFeeBP.encode(v, writer.uint32(50).fork()).join();
|
|
3121
|
+
}
|
|
3011
3122
|
return writer;
|
|
3012
3123
|
},
|
|
3013
3124
|
decode(input, length) {
|
|
@@ -3052,6 +3163,13 @@ exports.MsgCreateProtocolFees = {
|
|
|
3052
3163
|
message.feeRecipients.push(exports.AdminFeeRecipient.decode(reader, reader.uint32()));
|
|
3053
3164
|
continue;
|
|
3054
3165
|
}
|
|
3166
|
+
case 6: {
|
|
3167
|
+
if (tag !== 50) {
|
|
3168
|
+
break;
|
|
3169
|
+
}
|
|
3170
|
+
message.perChainFeeBP.push(exports.PerChainFeeBP.decode(reader, reader.uint32()));
|
|
3171
|
+
continue;
|
|
3172
|
+
}
|
|
3055
3173
|
}
|
|
3056
3174
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3057
3175
|
break;
|
|
@@ -3073,6 +3191,9 @@ exports.MsgCreateProtocolFees = {
|
|
|
3073
3191
|
feeRecipients: globalThis.Array.isArray(object?.feeRecipients)
|
|
3074
3192
|
? object.feeRecipients.map((e) => exports.AdminFeeRecipient.fromJSON(e))
|
|
3075
3193
|
: [],
|
|
3194
|
+
perChainFeeBP: globalThis.Array.isArray(object?.perChainFeeBP)
|
|
3195
|
+
? object.perChainFeeBP.map((e) => exports.PerChainFeeBP.fromJSON(e))
|
|
3196
|
+
: [],
|
|
3076
3197
|
};
|
|
3077
3198
|
},
|
|
3078
3199
|
toJSON(message) {
|
|
@@ -3092,6 +3213,9 @@ exports.MsgCreateProtocolFees = {
|
|
|
3092
3213
|
if (message.feeRecipients?.length) {
|
|
3093
3214
|
obj.feeRecipients = message.feeRecipients.map((e) => exports.AdminFeeRecipient.toJSON(e));
|
|
3094
3215
|
}
|
|
3216
|
+
if (message.perChainFeeBP?.length) {
|
|
3217
|
+
obj.perChainFeeBP = message.perChainFeeBP.map((e) => exports.PerChainFeeBP.toJSON(e));
|
|
3218
|
+
}
|
|
3095
3219
|
return obj;
|
|
3096
3220
|
},
|
|
3097
3221
|
create(base) {
|
|
@@ -3104,6 +3228,7 @@ exports.MsgCreateProtocolFees = {
|
|
|
3104
3228
|
message.collectionFees = object.collectionFees?.map((e) => exports.FixedFeeTuple.fromPartial(e)) || [];
|
|
3105
3229
|
message.fulfilmentFees = object.fulfilmentFees?.map((e) => exports.FixedFeeTuple.fromPartial(e)) || [];
|
|
3106
3230
|
message.feeRecipients = object.feeRecipients?.map((e) => exports.AdminFeeRecipient.fromPartial(e)) || [];
|
|
3231
|
+
message.perChainFeeBP = object.perChainFeeBP?.map((e) => exports.PerChainFeeBP.fromPartial(e)) || [];
|
|
3107
3232
|
return message;
|
|
3108
3233
|
},
|
|
3109
3234
|
};
|
|
@@ -3145,7 +3270,14 @@ exports.MsgCreateProtocolFeesResponse = {
|
|
|
3145
3270
|
},
|
|
3146
3271
|
};
|
|
3147
3272
|
function createBaseMsgUpdateProtocolFees() {
|
|
3148
|
-
return {
|
|
3273
|
+
return {
|
|
3274
|
+
creator: "",
|
|
3275
|
+
feeBP: long_1.default.UZERO,
|
|
3276
|
+
collectionFees: [],
|
|
3277
|
+
fulfilmentFees: [],
|
|
3278
|
+
feeRecipients: [],
|
|
3279
|
+
perChainFeeBP: [],
|
|
3280
|
+
};
|
|
3149
3281
|
}
|
|
3150
3282
|
exports.MsgUpdateProtocolFees = {
|
|
3151
3283
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
@@ -3164,6 +3296,9 @@ exports.MsgUpdateProtocolFees = {
|
|
|
3164
3296
|
for (const v of message.feeRecipients) {
|
|
3165
3297
|
exports.AdminFeeRecipient.encode(v, writer.uint32(42).fork()).join();
|
|
3166
3298
|
}
|
|
3299
|
+
for (const v of message.perChainFeeBP) {
|
|
3300
|
+
exports.PerChainFeeBP.encode(v, writer.uint32(50).fork()).join();
|
|
3301
|
+
}
|
|
3167
3302
|
return writer;
|
|
3168
3303
|
},
|
|
3169
3304
|
decode(input, length) {
|
|
@@ -3208,6 +3343,13 @@ exports.MsgUpdateProtocolFees = {
|
|
|
3208
3343
|
message.feeRecipients.push(exports.AdminFeeRecipient.decode(reader, reader.uint32()));
|
|
3209
3344
|
continue;
|
|
3210
3345
|
}
|
|
3346
|
+
case 6: {
|
|
3347
|
+
if (tag !== 50) {
|
|
3348
|
+
break;
|
|
3349
|
+
}
|
|
3350
|
+
message.perChainFeeBP.push(exports.PerChainFeeBP.decode(reader, reader.uint32()));
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3211
3353
|
}
|
|
3212
3354
|
if ((tag & 7) === 4 || tag === 0) {
|
|
3213
3355
|
break;
|
|
@@ -3229,6 +3371,9 @@ exports.MsgUpdateProtocolFees = {
|
|
|
3229
3371
|
feeRecipients: globalThis.Array.isArray(object?.feeRecipients)
|
|
3230
3372
|
? object.feeRecipients.map((e) => exports.AdminFeeRecipient.fromJSON(e))
|
|
3231
3373
|
: [],
|
|
3374
|
+
perChainFeeBP: globalThis.Array.isArray(object?.perChainFeeBP)
|
|
3375
|
+
? object.perChainFeeBP.map((e) => exports.PerChainFeeBP.fromJSON(e))
|
|
3376
|
+
: [],
|
|
3232
3377
|
};
|
|
3233
3378
|
},
|
|
3234
3379
|
toJSON(message) {
|
|
@@ -3248,6 +3393,9 @@ exports.MsgUpdateProtocolFees = {
|
|
|
3248
3393
|
if (message.feeRecipients?.length) {
|
|
3249
3394
|
obj.feeRecipients = message.feeRecipients.map((e) => exports.AdminFeeRecipient.toJSON(e));
|
|
3250
3395
|
}
|
|
3396
|
+
if (message.perChainFeeBP?.length) {
|
|
3397
|
+
obj.perChainFeeBP = message.perChainFeeBP.map((e) => exports.PerChainFeeBP.toJSON(e));
|
|
3398
|
+
}
|
|
3251
3399
|
return obj;
|
|
3252
3400
|
},
|
|
3253
3401
|
create(base) {
|
|
@@ -3260,6 +3408,7 @@ exports.MsgUpdateProtocolFees = {
|
|
|
3260
3408
|
message.collectionFees = object.collectionFees?.map((e) => exports.FixedFeeTuple.fromPartial(e)) || [];
|
|
3261
3409
|
message.fulfilmentFees = object.fulfilmentFees?.map((e) => exports.FixedFeeTuple.fromPartial(e)) || [];
|
|
3262
3410
|
message.feeRecipients = object.feeRecipients?.map((e) => exports.AdminFeeRecipient.fromPartial(e)) || [];
|
|
3411
|
+
message.perChainFeeBP = object.perChainFeeBP?.map((e) => exports.PerChainFeeBP.fromPartial(e)) || [];
|
|
3263
3412
|
return message;
|
|
3264
3413
|
},
|
|
3265
3414
|
};
|
|
@@ -3,9 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AutoSelectionError = void 0;
|
|
4
4
|
exports.aggregateAggregators = aggregateAggregators;
|
|
5
5
|
exports.autoSelectSourcesV2 = autoSelectSourcesV2;
|
|
6
|
+
exports.autoSelectSourcesV2ByRecipient = autoSelectSourcesV2ByRecipient;
|
|
6
7
|
exports.determineDestinationSwaps = determineDestinationSwaps;
|
|
7
8
|
exports.liquidateInputHoldings = liquidateInputHoldings;
|
|
9
|
+
exports.liquidateInputHoldingsByRecipient = liquidateInputHoldingsByRecipient;
|
|
8
10
|
exports.destinationSwapWithExactIn = destinationSwapWithExactIn;
|
|
11
|
+
exports.getDestinationExactOutSwap = getDestinationExactOutSwap;
|
|
12
|
+
exports.getDestinationExactInSwap = getDestinationExactInSwap;
|
|
13
|
+
exports.liquidateSourceHoldings = liquidateSourceHoldings;
|
|
14
|
+
exports.autoSelectSources = autoSelectSources;
|
|
9
15
|
const tslib_1 = require("tslib");
|
|
10
16
|
const es_toolkit_1 = require("es-toolkit");
|
|
11
17
|
const viem_1 = require("viem");
|
|
@@ -108,7 +114,18 @@ cots = [(1 COT, 1), (1 COT, 4)]
|
|
|
108
114
|
break
|
|
109
115
|
5. return quotes and assets used.
|
|
110
116
|
*/
|
|
117
|
+
/**
|
|
118
|
+
* @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
|
|
119
|
+
* `receiverAddress` on each `HoldingWithSwapAddresses`).
|
|
120
|
+
*/
|
|
111
121
|
async function autoSelectSourcesV2(userAddress, holdings, outputRequired, aggregators, commonCurrencyID = data_1.CurrencyID.USDC) {
|
|
122
|
+
return autoSelectSourcesV2ByRecipient(holdings.map((holding) => ({ ...holding, recipient: userAddress })), outputRequired, aggregators, commonCurrencyID);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use {@link autoSelectSources} (object args; per-holding `takerAddress` and
|
|
126
|
+
* `receiverAddress` on each `HoldingWithSwapAddresses`).
|
|
127
|
+
*/
|
|
128
|
+
async function autoSelectSourcesV2ByRecipient(holdings, outputRequired, aggregators, commonCurrencyID = data_1.CurrencyID.USDC) {
|
|
112
129
|
// Assumption: Holding is already sorted in usage priority
|
|
113
130
|
console.debug("XCS | SSV2:", {
|
|
114
131
|
holdings,
|
|
@@ -142,7 +159,10 @@ async function autoSelectSourcesV2(userAddress, holdings, outputRequired, aggreg
|
|
|
142
159
|
else {
|
|
143
160
|
fullLiquidationQuotes.push({
|
|
144
161
|
req: {
|
|
145
|
-
userAddress,
|
|
162
|
+
userAddress: holding.recipient,
|
|
163
|
+
// New wrappers thread per-holding receiver via this field. Falls back to taker
|
|
164
|
+
// (`recipient`) when absent — preserves legacy positional-call behavior.
|
|
165
|
+
receiverAddress: holding.receiverAddress,
|
|
146
166
|
type: iface_1.QuoteType.EXACT_IN,
|
|
147
167
|
chain: chain.ChainID,
|
|
148
168
|
inputToken: holding.tokenAddress,
|
|
@@ -326,7 +346,11 @@ async function autoSelectSourcesV2(userAddress, holdings, outputRequired, aggreg
|
|
|
326
346
|
console.log("final_quotes", { quotes: final, cots: usedCOTs });
|
|
327
347
|
return { quoteResponses: final, usedCOTs };
|
|
328
348
|
}
|
|
329
|
-
|
|
349
|
+
/**
|
|
350
|
+
* @deprecated Use {@link getDestinationExactOutSwap} (object args; explicit `takerAddress` and
|
|
351
|
+
* `receiverAddress`, both required).
|
|
352
|
+
*/
|
|
353
|
+
async function determineDestinationSwaps(userAddress, requirement, aggregators, commonCurrencyID = data_1.CurrencyID.USDC, receiverAddress) {
|
|
330
354
|
const chaindata = data_1.ChaindataMap.get(requirement.chainID);
|
|
331
355
|
if (chaindata == null) {
|
|
332
356
|
throw new AutoSelectionError("Chain not found");
|
|
@@ -341,6 +365,7 @@ async function determineDestinationSwaps(userAddress, requirement, aggregators,
|
|
|
341
365
|
type: iface_1.QuoteType.EXACT_IN,
|
|
342
366
|
chain: requirement.chainID,
|
|
343
367
|
userAddress,
|
|
368
|
+
receiverAddress,
|
|
344
369
|
inputToken: requirement.tokenAddress,
|
|
345
370
|
outputToken: COT.tokenAddress,
|
|
346
371
|
inputAmount: requirement.amountRaw,
|
|
@@ -364,6 +389,7 @@ async function determineDestinationSwaps(userAddress, requirement, aggregators,
|
|
|
364
389
|
{
|
|
365
390
|
type: iface_1.QuoteType.EXACT_IN,
|
|
366
391
|
userAddress,
|
|
392
|
+
receiverAddress,
|
|
367
393
|
chain: requirement.chainID,
|
|
368
394
|
inputToken: COT.tokenAddress,
|
|
369
395
|
outputToken: requirement.tokenAddress,
|
|
@@ -395,7 +421,18 @@ async function determineDestinationSwaps(userAddress, requirement, aggregators,
|
|
|
395
421
|
}
|
|
396
422
|
}
|
|
397
423
|
}
|
|
398
|
-
|
|
424
|
+
/**
|
|
425
|
+
* @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
|
|
426
|
+
* and `receiverAddress` on each `HoldingWithSwapAddresses`).
|
|
427
|
+
*/
|
|
428
|
+
async function liquidateInputHoldings(userAddress, holdings, aggregators, commonCurrencyID = data_1.CurrencyID.USDC, receiverAddress) {
|
|
429
|
+
return liquidateInputHoldingsByRecipient(holdings.map((holding) => ({ ...holding, recipient: userAddress })), aggregators, commonCurrencyID, receiverAddress);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* @deprecated Use {@link liquidateSourceHoldings} (object args; per-holding `takerAddress`
|
|
433
|
+
* and `receiverAddress` on each `HoldingWithSwapAddresses`).
|
|
434
|
+
*/
|
|
435
|
+
async function liquidateInputHoldingsByRecipient(holdings, aggregators, commonCurrencyID = data_1.CurrencyID.USDC, receiverAddress) {
|
|
399
436
|
console.debug("XCS | LIH | Holdings:", holdings);
|
|
400
437
|
const groupedByChainID = (0, es_toolkit_1.groupBy)(holdings, (h) => (0, viem_1.bytesToHex)(h.chainID.toBytes()));
|
|
401
438
|
const fullLiquidationQuotes = [];
|
|
@@ -419,7 +456,10 @@ async function liquidateInputHoldings(userAddress, holdings, aggregators, common
|
|
|
419
456
|
}
|
|
420
457
|
fullLiquidationQuotes.push({
|
|
421
458
|
req: {
|
|
422
|
-
userAddress,
|
|
459
|
+
userAddress: holding.recipient,
|
|
460
|
+
// Per-holding receiver wins (set by the new wrappers); shared param is the legacy
|
|
461
|
+
// positional-call fallback.
|
|
462
|
+
receiverAddress: holding.receiverAddress ?? receiverAddress,
|
|
423
463
|
type: iface_1.QuoteType.EXACT_IN,
|
|
424
464
|
chain: chain.ChainID,
|
|
425
465
|
inputToken: holding.tokenAddress,
|
|
@@ -448,7 +488,11 @@ async function liquidateInputHoldings(userAddress, holdings, aggregators, common
|
|
|
448
488
|
}
|
|
449
489
|
return quotes;
|
|
450
490
|
}
|
|
451
|
-
|
|
491
|
+
/**
|
|
492
|
+
* @deprecated Use {@link getDestinationExactInSwap} (object args; explicit `takerAddress`
|
|
493
|
+
* and `receiverAddress`, both required).
|
|
494
|
+
*/
|
|
495
|
+
async function destinationSwapWithExactIn(userAddress, omniChainID, inputAmount, outputToken, aggregators, inputCurrency = data_1.CurrencyID.USDC, receiverAddress) {
|
|
452
496
|
const chaindata = data_1.ChaindataMap.get(omniChainID);
|
|
453
497
|
if (chaindata == null) {
|
|
454
498
|
throw new AutoSelectionError("Chain not found");
|
|
@@ -462,6 +506,7 @@ async function destinationSwapWithExactIn(userAddress, omniChainID, inputAmount,
|
|
|
462
506
|
type: iface_1.QuoteType.EXACT_IN,
|
|
463
507
|
chain: omniChainID,
|
|
464
508
|
userAddress,
|
|
509
|
+
receiverAddress,
|
|
465
510
|
inputToken: COT.tokenAddress,
|
|
466
511
|
outputToken: outputToken,
|
|
467
512
|
inputAmount: inputAmount,
|
|
@@ -486,3 +531,40 @@ async function destinationSwapWithExactIn(userAddress, omniChainID, inputAmount,
|
|
|
486
531
|
},
|
|
487
532
|
};
|
|
488
533
|
}
|
|
534
|
+
// =====================================================================================
|
|
535
|
+
// Object-arg wrappers around the legacy positional functions above.
|
|
536
|
+
//
|
|
537
|
+
// Aggregator vocabulary:
|
|
538
|
+
// takerAddress — on-chain executor of the swap (drives aggregator simulation /
|
|
539
|
+
// permit / approval routing). On 7702 chains this is the ephemeral; on
|
|
540
|
+
// non-Pectra chains it's the deployed Safe. Maps to the underlying
|
|
541
|
+
// QuoteRequest's `userAddress`.
|
|
542
|
+
// receiverAddress — recipient of the swap output. Maps to the underlying QuoteRequest's
|
|
543
|
+
// `receiverAddress`. Required on all 4 wrappers — the GS013-class bug we
|
|
544
|
+
// fixed came from forgetting this and silently defaulting to the wrong
|
|
545
|
+
// address. Even on source side (where it equals the taker today), require
|
|
546
|
+
// it explicitly so the type system forces every call site to acknowledge
|
|
547
|
+
// both roles.
|
|
548
|
+
//
|
|
549
|
+
// Wrap-only: each wrapper delegates to the deprecated positional fn. No business logic added.
|
|
550
|
+
// =====================================================================================
|
|
551
|
+
async function getDestinationExactOutSwap(args) {
|
|
552
|
+
return determineDestinationSwaps(args.takerAddress, args.requirement, args.aggregators, args.commonCurrencyID, args.receiverAddress);
|
|
553
|
+
}
|
|
554
|
+
async function getDestinationExactInSwap(args) {
|
|
555
|
+
return destinationSwapWithExactIn(args.takerAddress, args.chain, args.inputAmount, args.outputToken, args.aggregators, args.inputCurrency, args.receiverAddress);
|
|
556
|
+
}
|
|
557
|
+
async function liquidateSourceHoldings(args) {
|
|
558
|
+
return liquidateInputHoldingsByRecipient(args.holdings.map((h) => ({
|
|
559
|
+
...h,
|
|
560
|
+
recipient: h.takerAddress,
|
|
561
|
+
receiverAddress: h.receiverAddress,
|
|
562
|
+
})), args.aggregators, args.commonCurrencyID);
|
|
563
|
+
}
|
|
564
|
+
async function autoSelectSources(args) {
|
|
565
|
+
return autoSelectSourcesV2ByRecipient(args.holdings.map((h) => ({
|
|
566
|
+
...h,
|
|
567
|
+
recipient: h.takerAddress,
|
|
568
|
+
receiverAddress: h.receiverAddress,
|
|
569
|
+
})), args.outputRequired, args.aggregators, args.commonCurrencyID);
|
|
570
|
+
}
|
|
@@ -14,17 +14,11 @@ const ChainNameMapping = new Map(Object.entries({
|
|
|
14
14
|
arbitrum: 42161,
|
|
15
15
|
optimism: 10,
|
|
16
16
|
base: 8453,
|
|
17
|
-
taiko: 167000,
|
|
18
17
|
bsc: 56,
|
|
19
|
-
|
|
20
|
-
megaethtestnet: 6342,
|
|
21
|
-
berachain: 80094,
|
|
18
|
+
avalanche: 43114,
|
|
22
19
|
polygon: 137,
|
|
23
|
-
zksync: 324,
|
|
24
|
-
blast: 81457,
|
|
25
|
-
mode: 34443,
|
|
26
20
|
scroll: 534352,
|
|
27
|
-
|
|
21
|
+
hyperevm: 999,
|
|
28
22
|
}).map(([k, v]) => [(0, viem_1.bytesToHex)((0, data_1.encodeChainID36)(definition_1.Universe.ETHEREUM, v)), k]));
|
|
29
23
|
class BebopAggregator {
|
|
30
24
|
static BASE_URL = "https://api.bebop.xyz/router";
|
|
@@ -56,6 +50,9 @@ class BebopAggregator {
|
|
|
56
50
|
const inputTokenAddr = (0, viem_1.getAddress)((0, viem_1.bytesToHex)(r.inputToken.subarray(12)));
|
|
57
51
|
const outputTokenAddr = (0, viem_1.getAddress)((0, viem_1.bytesToHex)(r.outputToken.subarray(12)));
|
|
58
52
|
const userAddrHex = (0, viem_1.getAddress)((0, viem_1.bytesToHex)(r.userAddress.subarray(12)));
|
|
53
|
+
const receiverAddrHex = r.receiverAddress != null
|
|
54
|
+
? (0, viem_1.getAddress)((0, viem_1.bytesToHex)(r.receiverAddress.subarray(12)))
|
|
55
|
+
: userAddrHex;
|
|
59
56
|
switch (r.type) {
|
|
60
57
|
case iface_1.QuoteType.EXACT_IN: {
|
|
61
58
|
respPromise = this.axios({
|
|
@@ -65,6 +62,7 @@ class BebopAggregator {
|
|
|
65
62
|
sell_tokens: inputTokenAddr,
|
|
66
63
|
buy_tokens: outputTokenAddr,
|
|
67
64
|
taker_address: userAddrHex,
|
|
65
|
+
receiver_address: receiverAddrHex,
|
|
68
66
|
sell_amounts: r.inputAmount.toString(),
|
|
69
67
|
...BebopAggregator.COMMON_OPTIONS,
|
|
70
68
|
},
|
|
@@ -79,6 +77,7 @@ class BebopAggregator {
|
|
|
79
77
|
sell_tokens: inputTokenAddr,
|
|
80
78
|
buy_tokens: outputTokenAddr,
|
|
81
79
|
taker_address: userAddrHex,
|
|
80
|
+
receiver_address: receiverAddrHex,
|
|
82
81
|
buy_amounts: r.outputAmount.toString(),
|
|
83
82
|
...BebopAggregator.COMMON_OPTIONS,
|
|
84
83
|
},
|