@shapeshiftoss/swapper 15.3.2 → 15.4.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.
|
@@ -11,7 +11,7 @@ const cowService_1 = require("../utils/cowService");
|
|
|
11
11
|
const helpers_1 = require("../utils/helpers/helpers");
|
|
12
12
|
async function cowExecuteTrade({ apiUrl, adapter }, { trade, wallet }) {
|
|
13
13
|
const cowTrade = trade;
|
|
14
|
-
const { sellAsset, buyAsset, feeAmountInSellTokenCryptoBaseUnit: feeAmountInSellToken, sellAmountDeductFeeCryptoBaseUnit: sellAmountWithoutFee, } = cowTrade;
|
|
14
|
+
const { sellAsset, buyAsset, feeAmountInSellTokenCryptoBaseUnit: feeAmountInSellToken, sellAmountDeductFeeCryptoBaseUnit: sellAmountWithoutFee, accountNumber, } = cowTrade;
|
|
15
15
|
const { assetReference: sellAssetErc20Address, assetNamespace: sellAssetNamespace } = (0, caip_1.fromAssetId)(sellAsset.assetId);
|
|
16
16
|
const { assetReference: buyAssetErc20Address, chainId: buyAssetChainId } = (0, caip_1.fromAssetId)(buyAsset.assetId);
|
|
17
17
|
if (sellAssetNamespace !== 'erc20') {
|
|
@@ -46,7 +46,7 @@ async function cowExecuteTrade({ apiUrl, adapter }, { trade, wallet }) {
|
|
|
46
46
|
// Some context about this : https://docs.cow.fi/tutorials/how-to-submit-orders-via-the-api/4.-signing-the-order
|
|
47
47
|
// For more info, check hashOrder method implementation
|
|
48
48
|
const orderDigest = (0, helpers_1.hashOrder)((0, helpers_1.domain)(1, constants_1.COW_SWAP_SETTLEMENT_ADDRESS), orderToSign);
|
|
49
|
-
const bip44Params =
|
|
49
|
+
const bip44Params = adapter.getBIP44Params({ accountNumber });
|
|
50
50
|
const message = {
|
|
51
51
|
messageToSign: {
|
|
52
52
|
addressNList: (0, chain_adapters_1.toAddressNList)(bip44Params),
|
|
@@ -9,8 +9,19 @@ const chain_adapters_1 = require("@shapeshiftoss/chain-adapters");
|
|
|
9
9
|
const axios_1 = __importDefault(require("axios"));
|
|
10
10
|
const lodash_1 = require("lodash");
|
|
11
11
|
const api_1 = require("../../../api");
|
|
12
|
+
const utils_1 = require("../../../utils");
|
|
12
13
|
const bignumber_1 = require("../../utils/bignumber");
|
|
13
14
|
const constants_1 = require("./constants");
|
|
15
|
+
// Create cached axios service for pools endpoint because it gets called a LOT
|
|
16
|
+
const cache = (0, utils_1.createCache)(3000, ['/osmosis/gamm/v1beta1/pools/']);
|
|
17
|
+
const osmoPoolsService = axios_1.default.create({
|
|
18
|
+
timeout: 10000,
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: 'application/json',
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
adapter: cache.adapter,
|
|
24
|
+
});
|
|
14
25
|
exports.symbolDenomMapping = {
|
|
15
26
|
OSMO: 'uosmo',
|
|
16
27
|
ATOM: 'ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2',
|
|
@@ -102,10 +113,12 @@ exports.pollForAtomChannelBalance = pollForAtomChannelBalance;
|
|
|
102
113
|
const findPool = async (sellAssetSymbol, buyAssetSymbol, osmoUrl) => {
|
|
103
114
|
const sellAssetDenom = exports.symbolDenomMapping[sellAssetSymbol];
|
|
104
115
|
const buyAssetDenom = exports.symbolDenomMapping[buyAssetSymbol];
|
|
105
|
-
|
|
116
|
+
// pagination.limit can be small because we only care about the osmo/atom pool right now
|
|
117
|
+
// this will need to increase when adding new pools
|
|
118
|
+
const poolsUrl = osmoUrl + '/osmosis/gamm/v1beta1/pools?pagination.limit=10';
|
|
106
119
|
const poolsResponse = await (async () => {
|
|
107
120
|
try {
|
|
108
|
-
return
|
|
121
|
+
return osmoPoolsService.get(poolsUrl);
|
|
109
122
|
}
|
|
110
123
|
catch (e) {
|
|
111
124
|
throw new api_1.SwapError('failed to get pool', {
|
package/package.json
CHANGED