Skip to content

Commit

Permalink
TON v3: add claim method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyAdoniev committed Nov 30, 2023
1 parent 2d3bcdd commit dfef94b
Show file tree
Hide file tree
Showing 11 changed files with 6,243 additions and 1,023 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"near-api-js": "1.0.0",
"secretjs": "=1.4.7",
"socket.io-client": "^4.1.3",
"ton-core": "^0.53.0",
"ton-x": "^2.0.0",
"tonweb": "^0.0.57",
"tonweb-mnemonic": "^1.0.1",
Expand Down
1 change: 0 additions & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ export enum ChainType {
}

export const CHAIN_INFO: ChainInfo = new Map();
console.log(elrondHelperFactory, "elrondHelperFactory");

CHAIN_INFO.set(Chain.HECO, {
name: "HECO",
Expand Down
20 changes: 14 additions & 6 deletions src/factory/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const signatureSvc_prod = signatureService(signature_service_uri_prod);

export namespace ChainFactoryConfigs {
export const TestNet: () => Promise<Partial<ChainParams>> = async () => {
const feeMargin = { min: 1, max: 5 };
const feeMargin = { min: 0.5, max: 5 };
const testnet_oracle = signatureService(
"https://tools.xp.network/testnet-oracle/"
);
Expand Down Expand Up @@ -93,11 +93,13 @@ export namespace ChainFactoryConfigs {
"abe8c1222f19b0891a9a35889d112dc88562093467db8dda39961eeacd50f9b1",
})
),
nonce: Chain.TON,
bridgeAddr: "kQBwUu-b4O6qDYq3iDRvsYUnTD6l3WCxLXkv0aH6ywAaPs3c",
burnerAddr: "kQCbH9gGgqJzXuusUVajW_40brrl2fxTYqMkk6HUhJnIgOQA",
xpnftAddr: "EQDji0YH-SNT-qi6o5dQQBLeWL0Xmm46fnqj34EYhOL34WDc",
v3_bridge: "EQDI6P9gheuWLh1euThjFE2muUpa9tp2y49TD6Zz5oOF5gWL",
feeMargin,

extraFees: new Map().set(Chain.ETHEREUM, "1"),
notifier,
},
Expand Down Expand Up @@ -461,9 +463,10 @@ export namespace ChainFactoryConfigs {
evmProvider: new ethers.providers.JsonRpcProvider(
TestNetRpcUri.HEDERA_RELAY
),
feeMargin,
feeMargin: { min: 1.5, max: 5 },
nonce: Chain.HEDERA,
noWhitelist: false,
extraFees: "10",
htcToken: "0xc4348F9b1B04Faa58DD94202B97bc89F62771B1E",
erc721_addr: "0x1aE75f1e6cdf374604F041805280927f38493dAc",
erc1155_addr: "0x1aE75f1e6cdf374604F041805280927f38493dAc",
Expand Down Expand Up @@ -547,7 +550,7 @@ export namespace ChainFactoryConfigs {
};

export const Staging: () => Promise<Partial<ChainParams>> = async () => {
const feeMargin: FeeMargins = { min: 1, max: 5 };
const feeMargin: FeeMargins = { min: 0.5, max: 5 };
const notifier = evNotifier("https://tools.xp.network/notifier");
const signatureSvc_staging = signatureService(
"https://tools.xp.network/fee-oracle"
Expand All @@ -559,6 +562,7 @@ export namespace ChainFactoryConfigs {
bridgeAddr: "kQAhrkiW7pA5eE_7vtz7_AQhHznfqR0VFyTGs4mgyaVLPgfG",
burnerAddr: "kQBo5aNuDXghpZ2u9yMdfaR9oVQEuRddNLCoNg8YgI_k2MOE",
notifier,
nonce: Chain.TON,
tonweb: new TonWeb(
new TonWeb.HttpProvider("https://toncenter.com/api/v2/jsonRPC", {
apiKey:
Expand Down Expand Up @@ -622,8 +626,9 @@ export namespace ChainFactoryConfigs {
),
provider: new ethers.providers.JsonRpcProvider(MainNetRpcUri.HEDERA),
evmProvider: new ethers.providers.JsonRpcProvider(MainNetRpcUri.HEDERA),
feeMargin,
feeMargin: { min: 1.5, max: 5 },
nonce: Chain.HEDERA,
extraFees: "10",
noWhitelist: true,
htcToken: "0x04CEb24a3228aF70765dc28ffBF64dadc011679f",
erc721_addr: "0x9Bf86174B058a45565EC73c15712A9a19321B862",
Expand Down Expand Up @@ -849,7 +854,7 @@ export namespace ChainFactoryConfigs {
};

export const MainNet: () => Promise<Partial<ChainParams>> = async () => {
const feeMargin = { min: 1, max: 5 };
const feeMargin = { min: 0.5, max: 5 };
const notifier = evNotifier(middleware_uri);

// VeChain related:
Expand All @@ -872,6 +877,7 @@ export namespace ChainFactoryConfigs {
"05645d6b549f33bf80cee8822bd63df720c6781bd00020646deb7b2b2cd53b73",
})
),
nonce: Chain.TON,
v3_bridge: "",
xpnftAddr: "EQABqbZubs5e3QQF3lxVZMvdaxlaIdNQWq8W1rn8rvVvWHys",
extraFees: new Map().set(Chain.ETHEREUM, "1"),
Expand Down Expand Up @@ -1270,14 +1276,16 @@ export namespace ChainFactoryConfigs {
helperUrl: "https://helper.mainnet.near.org",
signatureSvc: signatureSvc_prod,
},
//extraFees(departure side) in native currency (15 means 15 HBAR), feeMargin(dest side) in usd
hederaParams: {
notifier,
provider: new ethers.providers.JsonRpcProvider(MainNetRpcUri.HEDERA),
evmProvider: new ethers.providers.JsonRpcProvider(MainNetRpcUri.HEDERA),
hederaApi: hederaService(
"https://mainnet-public.mirrornode.hedera.com/api/v1"
),
feeMargin,
feeMargin: { min: 1.5, max: 5 },
extraFees: "15",
nonce: Chain.HEDERA,
noWhitelist: false,
Xpnfthtsclaims: "0x00000000000000000000000000000000002db2d8",
Expand Down
3 changes: 2 additions & 1 deletion src/factory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,12 @@ export function ChainFactory(
Math.max(toChainFee.min, feeR.times(toExRate * 0.1).toNumber()),
toChainFee.max
);

const feeProfit = usdFee / fromExRate;

return feeR
.times(toExRate / fromExRate)
.plus(feeProfit * 0.5)
.plus(feeProfit)
.times(CHAIN_INFO.get(fromChain)!.decimals)
.integerValue(BigNumber.ROUND_CEIL);
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/evm/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export interface Web3Params {
erc1155Minter: string;
nonce: ChainNonce;
feeMargin: FeeMargins;
extraFees?: string;
noWhitelist?: boolean;
v3_bridge?: string;
}
Expand Down
Loading

0 comments on commit dfef94b

Please sign in to comment.