Skip to content

Commit

Permalink
Merge pull request #97 from develei/master
Browse files Browse the repository at this point in the history
[update] add withdraw to DLN
  • Loading branch information
vrtnd authored Dec 21, 2023
2 parents 39fd90e + 5670ace commit f411c6f
Showing 1 changed file with 33 additions and 11 deletions.
44 changes: 33 additions & 11 deletions src/adapters/debridgedln/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,49 @@ const depositPrarms: PartialContractEventParams = {
isDeposit: true,
};

// since doesn't support solana, need set withdraw = deposit
// after support solana, change to original withdraw
const withdrawParams: PartialContractEventParams = {
target: evmContracts.dlnDestination,
target: evmContracts.dlnSource,
topic:
"FulfilledOrder((uint64,bytes,uint256,bytes,uint256,uint256,bytes,uint256,bytes,bytes,bytes,bytes,bytes,bytes),bytes32,address,address)",
"CreatedOrder((uint64,bytes,uint256,bytes,uint256,uint256,bytes,uint256,bytes,bytes,bytes,bytes,bytes,bytes),bytes32,bytes,uint256,uint256,uint32,bytes)",
abi: [
"event FulfilledOrder((uint64 makerOrderNonce, bytes makerSrc, uint256 giveChainId, bytes giveTokenAddress, uint256 giveAmount, uint256 takeChainId, bytes takeTokenAddress, uint256 takeAmount, bytes receiverDst, bytes givePatchAuthoritySrc, bytes orderAuthorityAddressDst, bytes allowedTakerDst, bytes allowedCancelBeneficiarySrc, bytes externalCall) order, bytes32 orderId, address sender, address unlockAuthority)",
"event CreatedOrder((uint64 makerOrderNonce, bytes makerSrc, uint256 giveChainId, bytes giveTokenAddress, uint256 giveAmount, uint256 takeChainId, bytes takeTokenAddress, uint256 takeAmount, bytes receiverDst, bytes givePatchAuthoritySrc, bytes orderAuthorityAddressDst, bytes allowedTakerDst, bytes allowedCancelBeneficiarySrc, bytes externalCall) order, bytes32 orderId, bytes affiliateFee, uint256 nativeFixFee, uint256 percentFee, uint32 referralCode, bytes metadata)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
amount: "order.takeAmount",
token: "order.takeTokenAddress",
amount: "order.giveAmount",
to: "order.receiverDst",
from: "order.makerSrc",
token: "order.giveTokenAddress",
},
mapTokens: {},
isDeposit: false,
};

// const withdrawParams: PartialContractEventParams = {
// target: evmContracts.dlnDestination,
// topic:
// "FulfilledOrder((uint64,bytes,uint256,bytes,uint256,uint256,bytes,uint256,bytes,bytes,bytes,bytes,bytes,bytes),bytes32,address,address)",
// abi: [
// "event FulfilledOrder((uint64 makerOrderNonce, bytes makerSrc, uint256 giveChainId, bytes giveTokenAddress, uint256 giveAmount, uint256 takeChainId, bytes takeTokenAddress, uint256 takeAmount, bytes receiverDst, bytes givePatchAuthoritySrc, bytes orderAuthorityAddressDst, bytes allowedTakerDst, bytes allowedCancelBeneficiarySrc, bytes externalCall) order, bytes32 orderId, address sender, address unlockAuthority)",
// ],
// logKeys: {
// blockNumber: "blockNumber",
// txHash: "transactionHash",
// },
// argKeys: {
// amount: "order.takeAmount",
// token: "order.takeTokenAddress",
// to: "order.receiverDst",
// from: "order.makerSrc",
// },
// mapTokens: {},
// isDeposit: false,
// };

const constructParams = (chain: SupportedChains) => {
const eventParams: PartialContractEventParams[] = [];

Expand All @@ -80,12 +102,12 @@ const constructParams = (chain: SupportedChains) => {
mapTokens: { "0x0000000000000000000000000000000000000000": token },
};

// const finalWithdrawParams = {
// ...withdrawParams,
// mapTokens: { "0x0000000000000000000000000000000000000000": token },
// };
const finalWithdrawParams = {
...withdrawParams,
mapTokens: { "0x0000000000000000000000000000000000000000": token },
};

eventParams.push(finalDepositParams);
eventParams.push(finalDepositParams, finalWithdrawParams);

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("debridgedln", chain, fromBlock, toBlock, eventParams);
Expand Down

0 comments on commit f411c6f

Please sign in to comment.