@thesingularitynetwork/darkswap-sdk 0.1.30 → 0.1.33
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/config/contractConfig.d.ts +0 -1
- package/dist/darkswap-sdk.cjs.development.js +90 -62
- package/dist/darkswap-sdk.cjs.development.js.map +1 -1
- package/dist/darkswap-sdk.cjs.production.min.js +1 -1
- package/dist/darkswap-sdk.cjs.production.min.js.map +1 -1
- package/dist/darkswap-sdk.esm.js +90 -62
- package/dist/darkswap-sdk.esm.js.map +1 -1
- package/dist/services/retail/depositAndCreateOrder.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4718,48 +4718,42 @@ var contractConfig = (_contractConfig = {}, _contractConfig[exports.ChainId.MAIN
|
|
|
4718
4718
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
4719
4719
|
merkleTreeOperator: '0x0',
|
|
4720
4720
|
darkSwapAssetManager: '0x0',
|
|
4721
|
-
darkSwapFeeAssetManager: '0x0'
|
|
4722
|
-
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-subgraph/version/v0.0.1/api'
|
|
4721
|
+
darkSwapFeeAssetManager: '0x0'
|
|
4723
4722
|
}, _contractConfig[exports.ChainId.ARBITRUM_ONE] = {
|
|
4724
4723
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
4725
4724
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
4726
4725
|
nativeWrapper: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
|
|
4727
4726
|
merkleTreeOperator: '0x0',
|
|
4728
4727
|
darkSwapAssetManager: '0x0',
|
|
4729
|
-
darkSwapFeeAssetManager: '0x0'
|
|
4730
|
-
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-arb-subgraph/api'
|
|
4728
|
+
darkSwapFeeAssetManager: '0x0'
|
|
4731
4729
|
}, _contractConfig[exports.ChainId.BASE] = {
|
|
4732
4730
|
priceOracle: '0xf224a25453D76A41c4427DD1C05369BC9f498444',
|
|
4733
4731
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
4734
4732
|
nativeWrapper: '0x4200000000000000000000000000000000000006',
|
|
4735
|
-
merkleTreeOperator: '
|
|
4736
|
-
darkSwapAssetManager: '
|
|
4737
|
-
darkSwapFeeAssetManager: '
|
|
4738
|
-
drakSwapSubgraphUrl: 'https://subgraph.satsuma-prod.com/1c6a44a9ed6e/pgs-team--611591/singularity-base-subgraph/api'
|
|
4733
|
+
merkleTreeOperator: '0x918B4F76CAE5F67A3818D8eD3d0e11D9888684E9',
|
|
4734
|
+
darkSwapAssetManager: '0x6fbA1F1aAb8449b7ba576E41F4617d918391b7cF',
|
|
4735
|
+
darkSwapFeeAssetManager: '0xfde341e63EB2f25A32D353d58C2DAd7f91c8Bd57'
|
|
4739
4736
|
}, _contractConfig[exports.ChainId.SEPOLIA] = {
|
|
4740
4737
|
priceOracle: '0x4Fe44a9aC8Ef059Be2dB97f9e3bcA32Ab698C2f2',
|
|
4741
4738
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
4742
4739
|
nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
4743
4740
|
merkleTreeOperator: '0x0',
|
|
4744
4741
|
darkSwapAssetManager: '0x0',
|
|
4745
|
-
darkSwapFeeAssetManager: '0x0'
|
|
4746
|
-
drakSwapSubgraphUrl: ''
|
|
4742
|
+
darkSwapFeeAssetManager: '0x0'
|
|
4747
4743
|
}, _contractConfig[exports.ChainId.HORIZEN_TESTNET] = {
|
|
4748
4744
|
priceOracle: '0x54c375f28ce4B0c2B986D6256E4Bc75d242A8793',
|
|
4749
4745
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
4750
4746
|
nativeWrapper: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
|
|
4751
4747
|
merkleTreeOperator: '0x8Cd4061C8b3743810B811E1F4A0B597D79225f4E',
|
|
4752
4748
|
darkSwapAssetManager: '0xEBeD6c7C2189bf8ad6687D3A4cf4b83fB4D1a3D2',
|
|
4753
|
-
darkSwapFeeAssetManager: '0x8CF86856Bd7dE95b4ba33DCae4cd5Ec02542Bf5b'
|
|
4754
|
-
drakSwapSubgraphUrl: ''
|
|
4749
|
+
darkSwapFeeAssetManager: '0x8CF86856Bd7dE95b4ba33DCae4cd5Ec02542Bf5b'
|
|
4755
4750
|
}, _contractConfig[exports.ChainId.HARDHAT] = {
|
|
4756
4751
|
priceOracle: '0x0AdDd25a91563696D8567Df78D5A01C9a991F9B8',
|
|
4757
4752
|
ethAddress: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
4758
4753
|
nativeWrapper: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
4759
4754
|
merkleTreeOperator: '0xEd8D7d3A98CB4ea6C91a80dcd2220719c264531f',
|
|
4760
4755
|
darkSwapAssetManager: '0x6D39d71fF4ab56a4873febd34e1a3BDefc01b41e',
|
|
4761
|
-
darkSwapFeeAssetManager: '0xb9b0c96e4E7181926D2A7ed331C9C346dfa59b4D'
|
|
4762
|
-
drakSwapSubgraphUrl: 'https://34.142.142.240:8080/subgraphs/name/singularity/'
|
|
4756
|
+
darkSwapFeeAssetManager: '0xb9b0c96e4E7181926D2A7ed331C9C346dfa59b4D'
|
|
4763
4757
|
}, _contractConfig);
|
|
4764
4758
|
|
|
4765
4759
|
function refineGasLimit(estimatedGas) {
|
|
@@ -9328,9 +9322,9 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9328
9322
|
}
|
|
9329
9323
|
_inheritsLoose(RetailCreateOrderService, _BaseContractService);
|
|
9330
9324
|
var _proto = RetailCreateOrderService.prototype;
|
|
9331
|
-
_proto.
|
|
9332
|
-
var
|
|
9333
|
-
var _yield$generateKeyPai, pubKey,
|
|
9325
|
+
_proto.rebuildContextFromSwapMessage = /*#__PURE__*/function () {
|
|
9326
|
+
var _rebuildContextFromSwapMessage = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(swapMessage, signature) {
|
|
9327
|
+
var _yield$generateKeyPai, pubKey, context;
|
|
9334
9328
|
return _regenerator().w(function (_context) {
|
|
9335
9329
|
while (1) switch (_context.n) {
|
|
9336
9330
|
case 0:
|
|
@@ -9339,12 +9333,46 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9339
9333
|
case 1:
|
|
9340
9334
|
_yield$generateKeyPai = _context.v;
|
|
9341
9335
|
pubKey = _yield$generateKeyPai[0];
|
|
9342
|
-
|
|
9336
|
+
if (validateOrderNoteWithPubKey(swapMessage.orderNote, pubKey)) {
|
|
9337
|
+
_context.n = 2;
|
|
9338
|
+
break;
|
|
9339
|
+
}
|
|
9340
|
+
throw new DarkSwapError('SwapMessage does not belong to this wallet');
|
|
9341
|
+
case 2:
|
|
9342
|
+
context = new RetailCreateOrderContext(signature);
|
|
9343
|
+
context.orderNote = swapMessage.orderNote;
|
|
9344
|
+
context.swapInNote = swapMessage.inNote;
|
|
9345
|
+
context.feeAmount = swapMessage.feeAmount;
|
|
9346
|
+
context.address = swapMessage.address;
|
|
9347
|
+
_context.n = 3;
|
|
9348
|
+
return this.generateProof(context);
|
|
9349
|
+
case 3:
|
|
9350
|
+
return _context.a(2, context);
|
|
9351
|
+
}
|
|
9352
|
+
}, _callee, this);
|
|
9353
|
+
}));
|
|
9354
|
+
function rebuildContextFromSwapMessage(_x, _x2) {
|
|
9355
|
+
return _rebuildContextFromSwapMessage.apply(this, arguments);
|
|
9356
|
+
}
|
|
9357
|
+
return rebuildContextFromSwapMessage;
|
|
9358
|
+
}();
|
|
9359
|
+
_proto.prepare = /*#__PURE__*/function () {
|
|
9360
|
+
var _prepare = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(address, depositAsset, depositAmount, swapInAsset, swapInAmount, signature) {
|
|
9361
|
+
var _yield$generateKeyPai2, pubKey, privKey, feeRatio, orderNote, feeAmount, realSwapInAmount, swapInNote, context, swapMessage, _t, _t2;
|
|
9362
|
+
return _regenerator().w(function (_context2) {
|
|
9363
|
+
while (1) switch (_context2.n) {
|
|
9364
|
+
case 0:
|
|
9365
|
+
_context2.n = 1;
|
|
9366
|
+
return generateKeyPair(signature);
|
|
9367
|
+
case 1:
|
|
9368
|
+
_yield$generateKeyPai2 = _context2.v;
|
|
9369
|
+
pubKey = _yield$generateKeyPai2[0];
|
|
9370
|
+
privKey = _yield$generateKeyPai2[1];
|
|
9343
9371
|
_t = BigInt;
|
|
9344
|
-
|
|
9372
|
+
_context2.n = 2;
|
|
9345
9373
|
return getFeeRatio(address, this._darkSwap);
|
|
9346
9374
|
case 2:
|
|
9347
|
-
_t2 =
|
|
9375
|
+
_t2 = _context2.v;
|
|
9348
9376
|
feeRatio = _t(_t2);
|
|
9349
9377
|
orderNote = createOrderNoteExt(address, depositAsset, depositAmount, feeRatio, pubKey);
|
|
9350
9378
|
feeAmount = calcFeeAmount(swapInAmount, feeRatio);
|
|
@@ -9355,36 +9383,36 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9355
9383
|
context.swapInNote = swapInNote;
|
|
9356
9384
|
context.feeAmount = feeAmount;
|
|
9357
9385
|
context.address = address;
|
|
9358
|
-
|
|
9386
|
+
_context2.n = 3;
|
|
9359
9387
|
return generateRetailSwapMessage(address, orderNote, swapInNote, feeAmount, pubKey, privKey);
|
|
9360
9388
|
case 3:
|
|
9361
|
-
swapMessage =
|
|
9389
|
+
swapMessage = _context2.v;
|
|
9362
9390
|
context.swapMessage = swapMessage;
|
|
9363
|
-
return
|
|
9391
|
+
return _context2.a(2, {
|
|
9364
9392
|
context: context,
|
|
9365
9393
|
swapMessage: swapMessage
|
|
9366
9394
|
});
|
|
9367
9395
|
}
|
|
9368
|
-
},
|
|
9396
|
+
}, _callee2, this);
|
|
9369
9397
|
}));
|
|
9370
|
-
function prepare(
|
|
9398
|
+
function prepare(_x3, _x4, _x5, _x6, _x7, _x8) {
|
|
9371
9399
|
return _prepare.apply(this, arguments);
|
|
9372
9400
|
}
|
|
9373
9401
|
return prepare;
|
|
9374
9402
|
}();
|
|
9375
9403
|
_proto.generateProof = /*#__PURE__*/function () {
|
|
9376
|
-
var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9404
|
+
var _generateProof = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(context) {
|
|
9377
9405
|
var proof;
|
|
9378
|
-
return _regenerator().w(function (
|
|
9379
|
-
while (1) switch (
|
|
9406
|
+
return _regenerator().w(function (_context3) {
|
|
9407
|
+
while (1) switch (_context3.n) {
|
|
9380
9408
|
case 0:
|
|
9381
9409
|
if (!(!context || !context.orderNote || !context.swapInNote || !context.address || !context.feeAmount || !context.signature)) {
|
|
9382
|
-
|
|
9410
|
+
_context3.n = 1;
|
|
9383
9411
|
break;
|
|
9384
9412
|
}
|
|
9385
9413
|
throw new DarkSwapError('Invalid context');
|
|
9386
9414
|
case 1:
|
|
9387
|
-
|
|
9415
|
+
_context3.n = 2;
|
|
9388
9416
|
return generateRetailCreateOrderProof({
|
|
9389
9417
|
depositNote: context.orderNote,
|
|
9390
9418
|
swapInNote: context.swapInNote,
|
|
@@ -9393,26 +9421,26 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9393
9421
|
feeAmount: context.feeAmount
|
|
9394
9422
|
});
|
|
9395
9423
|
case 2:
|
|
9396
|
-
proof =
|
|
9424
|
+
proof = _context3.v;
|
|
9397
9425
|
context.proof = proof;
|
|
9398
9426
|
case 3:
|
|
9399
|
-
return
|
|
9427
|
+
return _context3.a(2);
|
|
9400
9428
|
}
|
|
9401
|
-
},
|
|
9429
|
+
}, _callee3);
|
|
9402
9430
|
}));
|
|
9403
|
-
function generateProof(
|
|
9431
|
+
function generateProof(_x9) {
|
|
9404
9432
|
return _generateProof.apply(this, arguments);
|
|
9405
9433
|
}
|
|
9406
9434
|
return generateProof;
|
|
9407
9435
|
}();
|
|
9408
9436
|
_proto.allowance = /*#__PURE__*/function () {
|
|
9409
|
-
var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9437
|
+
var _allowance = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(context) {
|
|
9410
9438
|
var signer, asset, amount, allowanceContract, allowance, isLegacy, contract, tx;
|
|
9411
|
-
return _regenerator().w(function (
|
|
9412
|
-
while (1) switch (
|
|
9439
|
+
return _regenerator().w(function (_context4) {
|
|
9440
|
+
while (1) switch (_context4.n) {
|
|
9413
9441
|
case 0:
|
|
9414
9442
|
if (!(!context || !context.orderNote || !context.address || !context.signature || !context.proof)) {
|
|
9415
|
-
|
|
9443
|
+
_context4.n = 1;
|
|
9416
9444
|
break;
|
|
9417
9445
|
}
|
|
9418
9446
|
throw new DarkSwapError('Invalid context');
|
|
@@ -9421,43 +9449,43 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9421
9449
|
asset = context.orderNote.asset;
|
|
9422
9450
|
amount = context.orderNote.amount;
|
|
9423
9451
|
allowanceContract = new ethers.ethers.Contract(asset, ERC20Abi.abi, this._darkSwap);
|
|
9424
|
-
|
|
9452
|
+
_context4.n = 2;
|
|
9425
9453
|
return allowanceContract.allowance(signer.getAddress(), this._darkSwap.contracts.darkSwapAssetManager);
|
|
9426
9454
|
case 2:
|
|
9427
|
-
allowance =
|
|
9455
|
+
allowance = _context4.v;
|
|
9428
9456
|
if (!(BigInt(allowance) < amount)) {
|
|
9429
|
-
|
|
9457
|
+
_context4.n = 4;
|
|
9430
9458
|
break;
|
|
9431
9459
|
}
|
|
9432
9460
|
isLegacy = legacyTokenConfig.hasOwnProperty(this._darkSwap.chainId) && legacyTokenConfig[this._darkSwap.chainId].includes(asset.toLowerCase());
|
|
9433
9461
|
contract = new ethers.ethers.Contract(asset, isLegacy ? ERC20_USDT.abi : ERC20Abi.abi, signer);
|
|
9434
|
-
|
|
9462
|
+
_context4.n = 3;
|
|
9435
9463
|
return contract.approve(this._darkSwap.contracts.darkSwapAssetManager, hexlify32(MAX_ALLOWANCE));
|
|
9436
9464
|
case 3:
|
|
9437
|
-
tx =
|
|
9438
|
-
|
|
9439
|
-
return tx.
|
|
9465
|
+
tx = _context4.v;
|
|
9466
|
+
_context4.n = 4;
|
|
9467
|
+
return this._darkSwap.provider.waitForTransaction(tx.hash, 2);
|
|
9440
9468
|
case 4:
|
|
9441
|
-
return
|
|
9469
|
+
return _context4.a(2);
|
|
9442
9470
|
}
|
|
9443
|
-
},
|
|
9471
|
+
}, _callee4, this);
|
|
9444
9472
|
}));
|
|
9445
|
-
function allowance(
|
|
9473
|
+
function allowance(_x0) {
|
|
9446
9474
|
return _allowance.apply(this, arguments);
|
|
9447
9475
|
}
|
|
9448
9476
|
return allowance;
|
|
9449
9477
|
}();
|
|
9450
9478
|
_proto.execute = /*#__PURE__*/function () {
|
|
9451
|
-
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
9479
|
+
var _execute = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(context) {
|
|
9452
9480
|
var contract, ethAmount, tx;
|
|
9453
|
-
return _regenerator().w(function (
|
|
9454
|
-
while (1) switch (
|
|
9481
|
+
return _regenerator().w(function (_context5) {
|
|
9482
|
+
while (1) switch (_context5.n) {
|
|
9455
9483
|
case 0:
|
|
9456
|
-
|
|
9484
|
+
_context5.n = 1;
|
|
9457
9485
|
return this.generateProof(context);
|
|
9458
9486
|
case 1:
|
|
9459
9487
|
if (!(!context || !context.orderNote || !context.swapInNote || !context.proof)) {
|
|
9460
|
-
|
|
9488
|
+
_context5.n = 2;
|
|
9461
9489
|
break;
|
|
9462
9490
|
}
|
|
9463
9491
|
throw new DarkSwapError('Invalid context');
|
|
@@ -9465,30 +9493,30 @@ var RetailCreateOrderService = /*#__PURE__*/function (_BaseContractService) {
|
|
|
9465
9493
|
contract = new ethers.ethers.Contract(this._darkSwap.contracts.darkSwapAssetManager, DarkSwapAssetManagerAbi.abi, this._darkSwap.signer);
|
|
9466
9494
|
ethAmount = 0n;
|
|
9467
9495
|
if (!isNativeAsset(context.orderNote.asset)) {
|
|
9468
|
-
|
|
9496
|
+
_context5.n = 3;
|
|
9469
9497
|
break;
|
|
9470
9498
|
}
|
|
9471
9499
|
ethAmount = context.orderNote.amount;
|
|
9472
|
-
|
|
9500
|
+
_context5.n = 4;
|
|
9473
9501
|
break;
|
|
9474
9502
|
case 3:
|
|
9475
|
-
|
|
9503
|
+
_context5.n = 4;
|
|
9476
9504
|
return this.allowance(context);
|
|
9477
9505
|
case 4:
|
|
9478
|
-
|
|
9506
|
+
_context5.n = 5;
|
|
9479
9507
|
return contract.retailDepositCreateOrder([hexlify32(context.orderNote.note), context.proof.depositFooter, context.orderNote.asset, bn_to_0xhex(context.orderNote.amount), hexlify32(context.swapInNote.note), context.proof.swapInNoteFooter], context.proof.proof, {
|
|
9480
9508
|
value: bn_to_0xhex(ethAmount)
|
|
9481
9509
|
});
|
|
9482
9510
|
case 5:
|
|
9483
|
-
tx =
|
|
9484
|
-
|
|
9511
|
+
tx = _context5.v;
|
|
9512
|
+
_context5.n = 6;
|
|
9485
9513
|
return tx.wait();
|
|
9486
9514
|
case 6:
|
|
9487
|
-
return
|
|
9515
|
+
return _context5.a(2, tx.hash);
|
|
9488
9516
|
}
|
|
9489
|
-
},
|
|
9517
|
+
}, _callee5, this);
|
|
9490
9518
|
}));
|
|
9491
|
-
function execute(
|
|
9519
|
+
function execute(_x1) {
|
|
9492
9520
|
return _execute.apply(this, arguments);
|
|
9493
9521
|
}
|
|
9494
9522
|
return execute;
|