@7kprotocol/sdk-ts 3.5.2-beta.0 → 3.5.2-beta.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/lib/cjs/features/metaAg/index.js +16 -21
- package/lib/cjs/features/metaAg/providers/astro.js +1 -0
- package/lib/cjs/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/cjs/types/features/metaAg/providers/astro.d.ts.map +1 -1
- package/lib/esm/features/metaAg/index.js +16 -21
- package/lib/esm/features/metaAg/providers/astro.js +1 -0
- package/lib/esm/types/features/metaAg/index.d.ts.map +1 -1
- package/lib/esm/types/features/metaAg/providers/astro.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -122,7 +122,7 @@ class MetaAg {
|
|
|
122
122
|
console.warn(error, { provider: provider.kind, quote: quote.id });
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
async _quote(provider, options
|
|
125
|
+
async _quote(provider, options) {
|
|
126
126
|
const quote = await (0, common_1.timeout)(async () => {
|
|
127
127
|
const quote = await provider.quote(options);
|
|
128
128
|
if (!quote)
|
|
@@ -131,24 +131,6 @@ class MetaAg {
|
|
|
131
131
|
quote.amountOut = expectedAmount;
|
|
132
132
|
return quote;
|
|
133
133
|
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinTypeIn} to ${options.coinTypeOut}`);
|
|
134
|
-
if (quote && simulation) {
|
|
135
|
-
if (simulation.onSimulated) {
|
|
136
|
-
this._simulate(provider, quote, simulation).then((payload) => {
|
|
137
|
-
if (payload) {
|
|
138
|
-
setTimeout(() => {
|
|
139
|
-
quote.simulatedAmountOut = payload.simulatedAmountOut;
|
|
140
|
-
quote.gasUsed = payload.gasUsed;
|
|
141
|
-
simulation.onSimulated?.({ ...quote });
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const updated = await this._simulate(provider, quote, simulation);
|
|
148
|
-
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
149
|
-
quote.gasUsed = updated?.gasUsed;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
134
|
return quote;
|
|
153
135
|
}
|
|
154
136
|
async _fastSwap({ quote, signer, useGasCoin, signTransaction }, getTransactionBlockParams) {
|
|
@@ -190,13 +172,26 @@ class MetaAg {
|
|
|
190
172
|
.filter(([_k, v]) => !v.disabled)
|
|
191
173
|
.map(async ([provider]) => {
|
|
192
174
|
const p = await this._getProvider(provider);
|
|
193
|
-
return this._quote(p, opts
|
|
175
|
+
return this._quote(p, opts);
|
|
194
176
|
}));
|
|
195
|
-
|
|
177
|
+
const result = quotes
|
|
196
178
|
.map((quote) => quote.status === "fulfilled"
|
|
197
179
|
? quote.value
|
|
198
180
|
: (console.log(quote.reason), null))
|
|
199
181
|
.filter((quote) => quote !== null);
|
|
182
|
+
if (simulation) {
|
|
183
|
+
const requests = result.map(async (quote) => {
|
|
184
|
+
const provider = await this._getProvider(quote.provider);
|
|
185
|
+
const updated = await this._simulate(provider, quote, simulation);
|
|
186
|
+
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
187
|
+
quote.gasUsed = updated?.gasUsed;
|
|
188
|
+
simulation?.onSimulated?.({ ...quote });
|
|
189
|
+
});
|
|
190
|
+
if (!simulation.onSimulated) {
|
|
191
|
+
await Promise.all(requests);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return result;
|
|
200
195
|
}
|
|
201
196
|
/**
|
|
202
197
|
* Build transaction from quote
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,SAAS,EACT,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EASL,aAAa,EACb,mBAAmB,E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AC,GACpE,OAAO,CAAC,2BAA2B,CAAC;IAcvC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa;CA4B3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/astro.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,aAAa,EAAE,kBAAkB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,QAAQ,CAAC,IAAI,mBAAmB;gBACH,OAAO,EAAE,oBAAoB;IAEpD,KAAK,CAAC,EACV,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/astro.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,aAAa,EAAE,kBAAkB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,QAAQ,CAAC,IAAI,mBAAmB;gBACH,OAAO,EAAE,oBAAoB;IAEpD,KAAK,CAAC,EACV,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA8BzC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,eAAe;CAW1D"}
|
|
@@ -89,7 +89,7 @@ export class MetaAg {
|
|
|
89
89
|
console.warn(error, { provider: provider.kind, quote: quote.id });
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
async _quote(provider, options
|
|
92
|
+
async _quote(provider, options) {
|
|
93
93
|
const quote = await timeout(async () => {
|
|
94
94
|
const quote = await provider.quote(options);
|
|
95
95
|
if (!quote)
|
|
@@ -98,24 +98,6 @@ export class MetaAg {
|
|
|
98
98
|
quote.amountOut = expectedAmount;
|
|
99
99
|
return quote;
|
|
100
100
|
}, options.timeout ?? 2000, `quote for ${provider.kind} provider from ${options.coinTypeIn} to ${options.coinTypeOut}`);
|
|
101
|
-
if (quote && simulation) {
|
|
102
|
-
if (simulation.onSimulated) {
|
|
103
|
-
this._simulate(provider, quote, simulation).then((payload) => {
|
|
104
|
-
if (payload) {
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
quote.simulatedAmountOut = payload.simulatedAmountOut;
|
|
107
|
-
quote.gasUsed = payload.gasUsed;
|
|
108
|
-
simulation.onSimulated?.({ ...quote });
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
const updated = await this._simulate(provider, quote, simulation);
|
|
115
|
-
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
116
|
-
quote.gasUsed = updated?.gasUsed;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
101
|
return quote;
|
|
120
102
|
}
|
|
121
103
|
async _fastSwap({ quote, signer, useGasCoin, signTransaction }, getTransactionBlockParams) {
|
|
@@ -157,13 +139,26 @@ export class MetaAg {
|
|
|
157
139
|
.filter(([_k, v]) => !v.disabled)
|
|
158
140
|
.map(async ([provider]) => {
|
|
159
141
|
const p = await this._getProvider(provider);
|
|
160
|
-
return this._quote(p, opts
|
|
142
|
+
return this._quote(p, opts);
|
|
161
143
|
}));
|
|
162
|
-
|
|
144
|
+
const result = quotes
|
|
163
145
|
.map((quote) => quote.status === "fulfilled"
|
|
164
146
|
? quote.value
|
|
165
147
|
: (console.log(quote.reason), null))
|
|
166
148
|
.filter((quote) => quote !== null);
|
|
149
|
+
if (simulation) {
|
|
150
|
+
const requests = result.map(async (quote) => {
|
|
151
|
+
const provider = await this._getProvider(quote.provider);
|
|
152
|
+
const updated = await this._simulate(provider, quote, simulation);
|
|
153
|
+
quote.simulatedAmountOut = updated?.simulatedAmountOut;
|
|
154
|
+
quote.gasUsed = updated?.gasUsed;
|
|
155
|
+
simulation?.onSimulated?.({ ...quote });
|
|
156
|
+
});
|
|
157
|
+
if (!simulation.onSimulated) {
|
|
158
|
+
await Promise.all(requests);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return result;
|
|
167
162
|
}
|
|
168
163
|
/**
|
|
169
164
|
* Build transaction from quote
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,SAAS,EACT,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EASL,aAAa,EACb,mBAAmB,EACnB,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,eAAe,EAGhB,MAAM,oBAAoB,CAAC;AAwB5B,qBAAa,MAAM;IACjB,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,SAAS,CAAiD;IAClE,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,OAAO,CAA0B;gBAC7B,OAAO,CAAC,EAAE,aAAa;YAkBrB,YAAY;YA2DZ,SAAS;YAkCT,MAAM;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/metaAg/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EACzB,SAAS,EACT,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,yBAAyB,EAC1B,MAAM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ACV,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../../../../../src/features/metaAg/providers/astro.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,aAAa,EACd,MAAM,uBAAuB,CAAC;AAG/B,qBAAa,aAAc,YAAW,aAAa,EAAE,kBAAkB;IAEzD,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpC,QAAQ,CAAC,IAAI,mBAAmB;gBACH,OAAO,EAAE,oBAAoB;IAEpD,KAAK,CAAC,EACV,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IA8BzC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,eAAe;CAW1D"}
|