Compare commits

...
Author SHA1 Message Date
Matthew Russell bde7a9fbf9 fix(smart-contracts): add increased gas limit estimation (#3371) 2023-04-04 11:41:11 -07:00
dexturr 5fd93ee9c8 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-04 18:09:38 +00:00
botond 9ac07fd98a fix: add missing announcement config url (#3367) 2023-04-04 15:11:48 +00:00
dexturr 9c975ed822 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-04 12:10:23 +00:00
Edd 138bf7da00 build(explorer): update validator testnet be url (#3357) 2023-04-04 10:53:47 +00:00
dexturr 3e7fe517f3 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-04 06:07:34 +00:00
dexturr 4f960d09b3 chore: update tranches
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-04-04 00:15:07 +00:00
12 changed files with 301 additions and 99 deletions
+1 -1
View File
@@ -9,5 +9,5 @@ NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/annou
NX_VEGA_GOVERNANCE_URL=https://validator-testnet.governance.vega.xyz
NX_TENDERMINT_URL=https://tm-be.validators-testnet.vega.rocks
NX_BLOCK_EXPLORER=https://be.validators-testnet.vega.rocks/
NX_BLOCK_EXPLORER=https://be.validators-testnet.vega.rocks/rest
NX_TENDERMINT_WEBSOCKET_URL=wss://be.validators-testnet.vega.xyz/websocket
+1
View File
@@ -8,3 +8,4 @@ NX_ETHEREUM_PROVIDER_URL=https://sepolia.infura.io/v3/4f846e79e13f44d1b51bbd7ed9
NX_ETHERSCAN_URL=https://sepolia.etherscan.io
NX_GITHUB_FEEDBACK_URL=https://github.com/vegaprotocol/feedback/discussions
NX_VEGA_EXPLORER_URL=https://dev.explorer.vega.xyz
NX_ANNOUNCEMENTS_CONFIG_URL=https://raw.githubusercontent.com/vegaprotocol/announcements/fairground/announcements.json
+123 -43
View File
@@ -743,7 +743,7 @@
"tranche_end": "2023-04-06T00:00:00.000Z",
"total_added": "14099",
"total_removed": "165.10784124668",
"locked_amount": "1020.23509744623685628",
"locked_amount": "565.470757541816007166",
"deposits": [
{
"amount": "30",
@@ -3531,7 +3531,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "86666.297",
"total_removed": "0",
"locked_amount": "58231.0206471161547092772",
"locked_amount": "57993.6007228891030790117",
"deposits": [
{
"amount": "86666.297",
@@ -3597,7 +3597,7 @@
"tranche_end": "2023-06-01T00:00:00.000Z",
"total_added": "2500",
"total_removed": "0",
"locked_amount": "800.044356684981575",
"locked_amount": "786.30936482498975",
"deposits": [
{
"amount": "2500",
@@ -3718,7 +3718,7 @@
"tranche_end": "2023-09-01T00:00:00.000Z",
"total_added": "17500",
"total_removed": "0",
"locked_amount": "14289.43755661231775",
"locked_amount": "14194.337667320853",
"deposits": [
{
"amount": "12500",
@@ -3985,7 +3985,7 @@
"tranche_end": "2023-08-01T00:00:00.000Z",
"total_added": "37500",
"total_removed": "11781.2245815",
"locked_amount": "24705.08891574585375",
"locked_amount": "24497.9257788520575",
"deposits": [
{
"amount": "7500",
@@ -4305,7 +4305,7 @@
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "129999.45",
"total_removed": "0",
"locked_amount": "58177.89216768362770314",
"locked_amount": "57940.6888592641162179",
"deposits": [
{
"amount": "129999.45",
@@ -4338,7 +4338,7 @@
"tranche_end": "2024-04-01T00:00:00.000Z",
"total_added": "54144.7663",
"total_removed": "0",
"locked_amount": "53736.93921662980913205788",
"locked_amount": "53589.01639451037519275324",
"deposits": [
{
"amount": "54144.7663",
@@ -4371,7 +4371,7 @@
"tranche_end": "2023-09-03T00:00:00.000Z",
"total_added": "62600",
"total_removed": "0",
"locked_amount": "26110.75656392694224",
"locked_amount": "25939.265594875696096",
"deposits": [
{
"amount": "10000",
@@ -4564,7 +4564,7 @@
"tranche_end": "2023-09-17T00:00:00.000Z",
"total_added": "5000",
"total_removed": "0",
"locked_amount": "2277.30450913242",
"locked_amount": "2263.60714738711335",
"deposits": [
{
"amount": "5000",
@@ -4775,7 +4775,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "97499.58",
"total_removed": "0",
"locked_amount": "289.2943236127702715019",
"locked_amount": "56.619974540901995087628",
"deposits": [
{
"amount": "97499.58",
@@ -4808,7 +4808,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "135173.4239508",
"total_removed": "133818.54965292963650862",
"locked_amount": "395.4153957972609424964042112",
"locked_amount": "77.38973016660167928688450596",
"deposits": [
{
"amount": "135173.4239508",
@@ -4865,7 +4865,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "32499.86",
"total_removed": "0",
"locked_amount": "121.701126098142348042122",
"locked_amount": "23.819045514696515832434",
"deposits": [
{
"amount": "32499.86",
@@ -4898,7 +4898,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "10833.29",
"total_removed": "0",
"locked_amount": "39.612535585171623792263",
"locked_amount": "7.752868180487023081501",
"deposits": [
{
"amount": "10833.29",
@@ -4931,7 +4931,7 @@
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "22749.93",
"total_removed": "4720.860935375",
"locked_amount": "148.080505317408011860722",
"locked_amount": "28.98195283049736585006",
"deposits": [
{
"amount": "6500",
@@ -5083,7 +5083,7 @@
"tranche_end": "2023-05-01T00:00:00.000Z",
"total_added": "22500",
"total_removed": "6357.929999175",
"locked_amount": "3386.5892610497226",
"locked_amount": "3262.2913789134444",
"deposits": [
{
"amount": "7500",
@@ -5523,7 +5523,7 @@
"tranche_end": "2023-06-02T00:00:00.000Z",
"total_added": "1939928.38",
"total_removed": "928642.9598472029154",
"locked_amount": "314870.1961185216721358008",
"locked_amount": "309555.815962352273510404",
"deposits": [
{
"amount": "1852091.69",
@@ -39256,7 +39256,7 @@
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "3732368.4671",
"total_removed": "700133.348465855088393",
"locked_amount": "508347.190004695251441550046",
"locked_amount": "500180.743448598467211370596",
"deposits": [
{
"amount": "1998.95815",
@@ -40637,8 +40637,8 @@
"tranche_start": "2022-06-05T00:00:00.000Z",
"tranche_end": "2023-12-05T00:00:00.000Z",
"total_added": "15870102.715470999700000001",
"total_removed": "814951.95458233668060452",
"locked_amount": "7102254.0823883096815429813321985808150852",
"total_removed": "815414.41205294384422952",
"locked_amount": "7073296.38723637379898712666179481614084885",
"deposits": [
{
"amount": "16249.93",
@@ -41177,6 +41177,11 @@
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tx": "0x625ce40117b67b756a12ad676cfbfd2c59e264b3c86adbc624bf7107c4dbc5d5"
},
{
"amount": "462.457470607163625",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tx": "0xa65322922116e2e0949be9d83e65ef0b1f2d8fe3eb399616a5cbbb7c95593717"
},
{
"amount": "545.4204142199725",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
@@ -43207,6 +43212,12 @@
"tranche_id": 2,
"tx": "0x625ce40117b67b756a12ad676cfbfd2c59e264b3c86adbc624bf7107c4dbc5d5"
},
{
"amount": "462.457470607163625",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
"tranche_id": 2,
"tx": "0xa65322922116e2e0949be9d83e65ef0b1f2d8fe3eb399616a5cbbb7c95593717"
},
{
"amount": "545.4204142199725",
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
@@ -44583,8 +44594,8 @@
}
],
"total_tokens": "259998.8875",
"withdrawn_tokens": "143495.97418057557425",
"remaining_tokens": "116502.91331942442575"
"withdrawn_tokens": "143958.431651182737875",
"remaining_tokens": "116040.455848817262125"
},
{
"address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c",
@@ -46929,8 +46940,8 @@
"tranche_start": "2021-11-05T00:00:00.000Z",
"tranche_end": "2023-05-05T00:00:00.000Z",
"total_added": "14597706.0446472999",
"total_removed": "5806817.570026167688715156",
"locked_amount": "835310.394250092778046317149087858",
"total_removed": "5807463.612246947184450156",
"locked_amount": "808576.834982455928473059742460535",
"deposits": [
{
"amount": "129284.449",
@@ -47204,6 +47215,11 @@
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tx": "0x523cbf99fb25ac9633e40a26cf1aa66ac5442392e577299159bf50e844a860e1"
},
{
"amount": "646.042220779495735",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tx": "0xcd3480c11e987e702a52413185dcc232b399747ef2fd7529aa46bea02c6f4be5"
},
{
"amount": "755.482067130393772",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
@@ -50376,6 +50392,12 @@
"tranche_id": 3,
"tx": "0x523cbf99fb25ac9633e40a26cf1aa66ac5442392e577299159bf50e844a860e1"
},
{
"amount": "646.042220779495735",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
"tranche_id": 3,
"tx": "0xcd3480c11e987e702a52413185dcc232b399747ef2fd7529aa46bea02c6f4be5"
},
{
"amount": "755.482067130393772",
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
@@ -53054,8 +53076,8 @@
}
],
"total_tokens": "359123.469575",
"withdrawn_tokens": "338364.23991060390069175",
"remaining_tokens": "20759.22966439609930825"
"withdrawn_tokens": "339010.28213138339642675",
"remaining_tokens": "20113.18744361660357325"
},
{
"address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB",
@@ -54482,8 +54504,8 @@
"tranche_start": "2021-10-05T00:00:00.000Z",
"tranche_end": "2023-04-05T00:00:00.000Z",
"total_added": "5778205.3912159303",
"total_removed": "3381706.364737906998719578",
"locked_amount": "13132.78514323649783129733831977186",
"total_removed": "3405527.985875969683269578",
"locked_amount": "2570.194193372696618931420745650855",
"deposits": [
{
"amount": "552496.6455",
@@ -54627,6 +54649,16 @@
}
],
"withdrawals": [
{
"amount": "10509.407528939748325",
"user": "0xBc934494675a6ceB639B9EfEe5b9C0f017D35a75",
"tx": "0x621a569bfd19dbc0a6ba78addf836a9f2f1897258a88198d994e5b18c9f4901e"
},
{
"amount": "13312.213609122936225",
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
"tx": "0x8a1d50991be09f4adc9eba704fbbcd271e8022db56498b300f39d3111bf187ea"
},
{
"amount": "8511.948415174862415",
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
@@ -55624,6 +55656,12 @@
}
],
"withdrawals": [
{
"amount": "10509.407528939748325",
"user": "0xBc934494675a6ceB639B9EfEe5b9C0f017D35a75",
"tranche_id": 4,
"tx": "0x621a569bfd19dbc0a6ba78addf836a9f2f1897258a88198d994e5b18c9f4901e"
},
{
"amount": "990.74735267405816",
"user": "0xBc934494675a6ceB639B9EfEe5b9C0f017D35a75",
@@ -55728,8 +55766,8 @@
}
],
"total_tokens": "110499.5291",
"withdrawn_tokens": "99798.20962987885552",
"remaining_tokens": "10701.31947012114448"
"withdrawn_tokens": "110307.617158818603845",
"remaining_tokens": "191.911941181396155"
},
{
"address": "0xdbC5d439F373EB646345e1c67D1d46231ACE7dD3",
@@ -56247,6 +56285,12 @@
}
],
"withdrawals": [
{
"amount": "13312.213609122936225",
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
"tranche_id": 4,
"tx": "0x8a1d50991be09f4adc9eba704fbbcd271e8022db56498b300f39d3111bf187ea"
},
{
"amount": "8511.948415174862415",
"user": "0xafa64cCa337eFEE0AD827F6C2684e69275226e90",
@@ -56507,8 +56551,8 @@
}
],
"total_tokens": "331498.5873",
"withdrawn_tokens": "317966.428170547352487",
"remaining_tokens": "13532.159129452647513"
"withdrawn_tokens": "331278.641779670288712",
"remaining_tokens": "219.945520329711288"
},
{
"address": "0x16da609341ed67750A8BCC5AAa2005471006Cd77",
@@ -56610,8 +56654,8 @@
"tranche_start": "2022-06-05T00:00:00.000Z",
"tranche_end": "2023-06-05T00:00:00.000Z",
"total_added": "472355.6199999996",
"total_removed": "40152.1324861581949",
"locked_amount": "80550.51809266543339246000913244",
"total_removed": "41316.3370079701949",
"locked_amount": "79256.497954453234412822232673788",
"deposits": [
{
"amount": "3000",
@@ -63290,6 +63334,16 @@
"user": "0x28FC83947F02f59Cb36b40f97f2D32BBC5D00585",
"tx": "0x14da65fbf5ae2f3a593036daa58b3353ab88fc22666e5514f9160e252ad2fdf9"
},
{
"amount": "332.441235412",
"user": "0x5c8fadaf56946d60823Dae0526A540EEfE791c99",
"tx": "0x67af8d72b36a27796fbe8f52ac55951d54102ac58582f848f0d21cf8ca427e77"
},
{
"amount": "831.7632864",
"user": "0x9405F540EcC1204801De5C4444D06386BD6693F0",
"tx": "0x0df6ec04cbdda41c8649a5e360ec541d14371e3877d82e1404308180024ede02"
},
{
"amount": "154.812094114",
"user": "0x27e2254A2A8c9c9D1321E5Fe64cAD88e7A4f0ba7",
@@ -68457,10 +68511,17 @@
"tx": "0x1c2c084e3efafb2ffa09c0b259bd229cce0d6da04dd092d911c7e6136a7ac8a9"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "831.7632864",
"user": "0x9405F540EcC1204801De5C4444D06386BD6693F0",
"tranche_id": 5,
"tx": "0x0df6ec04cbdda41c8649a5e360ec541d14371e3877d82e1404308180024ede02"
}
],
"total_tokens": "1000",
"withdrawn_tokens": "0",
"remaining_tokens": "1000"
"withdrawn_tokens": "831.7632864",
"remaining_tokens": "168.2367136"
},
{
"address": "0x99b4635De6c5c8cdbBf728d7AA0d1b9DD8Ee381F",
@@ -84297,10 +84358,17 @@
"tx": "0xb59405747c8088945a412703637a7b422f3639439ec2ee15e180c0a2a0d71ee4"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "332.441235412",
"user": "0x5c8fadaf56946d60823Dae0526A540EEfE791c99",
"tranche_id": 5,
"tx": "0x67af8d72b36a27796fbe8f52ac55951d54102ac58582f848f0d21cf8ca427e77"
}
],
"total_tokens": "400",
"withdrawn_tokens": "0",
"remaining_tokens": "400"
"withdrawn_tokens": "332.441235412",
"remaining_tokens": "67.558764588"
},
{
"address": "0x96715eF2F036069202B1C8065Db14601F40C9554",
@@ -86148,7 +86216,7 @@
"tranche_start": "2021-12-05T00:00:00.000Z",
"tranche_end": "2022-06-05T00:00:00.000Z",
"total_added": "171288.42",
"total_removed": "67553.5995794947989",
"total_removed": "68803.5995794947989",
"locked_amount": "0",
"deposits": [
{
@@ -90373,6 +90441,11 @@
}
],
"withdrawals": [
{
"amount": "1250",
"user": "0x9405F540EcC1204801De5C4444D06386BD6693F0",
"tx": "0x7dbc1e3f31a7aeea4e74f2bf14137bb99045b84afe7582a9ed2bc9d63b5458a4"
},
{
"amount": "250",
"user": "0x2dd204e9cC4D41C68f2bb7Aa3b8Ce49884e482f5",
@@ -95797,10 +95870,17 @@
"tx": "0x1c2c084e3efafb2ffa09c0b259bd229cce0d6da04dd092d911c7e6136a7ac8a9"
}
],
"withdrawals": [],
"withdrawals": [
{
"amount": "1250",
"user": "0x9405F540EcC1204801De5C4444D06386BD6693F0",
"tranche_id": 6,
"tx": "0x7dbc1e3f31a7aeea4e74f2bf14137bb99045b84afe7582a9ed2bc9d63b5458a4"
}
],
"total_tokens": "1250",
"withdrawn_tokens": "0",
"remaining_tokens": "1250"
"withdrawn_tokens": "1250",
"remaining_tokens": "0"
},
{
"address": "0xf36f5369adBE86DF71f5bFfB0264fc1D99fA2935",
+16 -15
View File
@@ -1,6 +1,7 @@
import { ethers } from 'ethers';
import { hexlify } from 'ethers/lib/utils';
import abi from '../abis/claim_abi.json';
import { calcGasBuffer } from '../utils';
export const UNSPENT_CODE = '0x0000000000000000000000000000000000000000';
export const SPENT_CODE = '0x0000000000000000000000000000000000000001';
@@ -42,7 +43,7 @@ export class Claim {
* was performed and mined beforehand
* @return {Promise<boolean>}
*/
public claim({
public async claim({
amount,
tranche,
expiry,
@@ -61,20 +62,20 @@ export class Claim {
r: string;
s: string;
}): Promise<ethers.ContractTransaction> {
return this.contract[
target != null ? 'claim_targeted' : 'claim_untargeted'
](
...[
{ r, s, v },
{
amount,
tranche,
expiry,
},
hexlify(country),
target,
].filter(Boolean)
);
const method = target != null ? 'claim_targeted' : 'claim_untargeted';
const args = [
{ r, s, v },
{
amount,
tranche,
expiry,
},
hexlify(country),
target,
].filter(Boolean);
const res = await this.contract.estimateGas[method](...args);
const gasLimit = calcGasBuffer(res);
return this.contract[method](...args, { gasLimit });
}
/**
@@ -1,6 +1,7 @@
import type { BigNumber } from 'ethers';
import { ethers } from 'ethers';
import abi from '../abis/erc20_bridge_abi.json';
import { calcGasBuffer } from '../utils';
export class CollateralBridge {
public contract: ethers.Contract;
@@ -13,8 +14,20 @@ export class CollateralBridge {
this.contract = new ethers.Contract(address, abi, signerOrProvider);
}
deposit_asset(assetSource: string, amount: string, vegaPublicKey: string) {
return this.contract.deposit_asset(assetSource, amount, vegaPublicKey);
async deposit_asset(
assetSource: string,
amount: string,
vegaPublicKey: string
) {
const res = await this.contract.estimateGas.deposit_asset(
assetSource,
amount,
vegaPublicKey
);
const gasLimit = calcGasBuffer(res);
return this.contract.deposit_asset(assetSource, amount, vegaPublicKey, {
gasLimit,
});
}
get_asset_source(vegaAssetId: string) {
return this.contract.get_asset_source(vegaAssetId);
@@ -37,7 +50,7 @@ export class CollateralBridge {
default_withdraw_delay() {
return this.contract.default_withdraw_delay();
}
list_asset(
async list_asset(
address: string,
vegaAssetId: string,
lifetimeLimit: string,
@@ -45,7 +58,7 @@ export class CollateralBridge {
nonce: string,
signatures: string
) {
return this.contract.list_asset(
const res = await this.contract.estimateGas.list_asset(
address,
vegaAssetId,
lifetimeLimit,
@@ -53,8 +66,20 @@ export class CollateralBridge {
nonce,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.list_asset(
address,
vegaAssetId,
lifetimeLimit,
withdraw_threshold,
nonce,
signatures,
{
gasLimit,
}
);
}
withdraw_asset(
async withdraw_asset(
assetSource: string,
amount: string,
target: string,
@@ -62,7 +87,7 @@ export class CollateralBridge {
nonce: string,
signatures: string
) {
return this.contract.withdraw_asset(
const res = await this.contract.estimateGas.withdraw_asset(
assetSource,
amount,
target,
@@ -70,6 +95,18 @@ export class CollateralBridge {
nonce,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.withdraw_asset(
assetSource,
amount,
target,
creation,
nonce,
signatures,
{
gasLimit,
}
);
}
is_stopped() {
@@ -1,5 +1,6 @@
import { ethers } from 'ethers';
import abi from '../abis/multisig_abi.json';
import { calcGasBuffer } from '../utils';
export class MultisigControl {
public contract: ethers.Contract;
@@ -13,12 +14,20 @@ export class MultisigControl {
this.address = address;
}
add_signer(newSigner: string, nonce: string, signatures: string) {
return this.contract.add_signer(newSigner, nonce, signatures);
async add_signer(newSigner: string, nonce: string, signatures: string) {
const res = await this.contract.estimateGas.add_signer(
newSigner,
nonce,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.add_signer(newSigner, nonce, signatures, { gasLimit });
}
burn_nonce(nonce: string, signatures: string) {
return this.contract.burn_nonce(nonce, signatures);
async burn_nonce(nonce: string, signatures: string) {
const res = await this.contract.estimateGas.burn_nonce(nonce, signatures);
const gasLimit = calcGasBuffer(res);
return this.contract.burn_nonce(nonce, signatures, { gasLimit });
}
get_current_threshold() {
@@ -37,19 +46,43 @@ export class MultisigControl {
return this.contract.is_valid_signer(signerAddress);
}
remove_signer(oldSigner: string, nonce: string, signatures: string) {
return this.contract.remove_signer(oldSigner, nonce, signatures);
async remove_signer(oldSigner: string, nonce: string, signatures: string) {
const res = await this.contract.estimateGas.remove_signer(
oldSigner,
nonce,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.remove_signer(oldSigner, nonce, signatures, {
gasLimit,
});
}
set_threshold(newThreshold: string, nonce: string, signatures: string) {
return this.contract.set_threshold(newThreshold, nonce, signatures);
async set_threshold(newThreshold: string, nonce: string, signatures: string) {
const res = await this.contract.estimateGas.set_threshold(
newThreshold,
nonce,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.set_threshold(newThreshold, nonce, signatures, {
gasLimit,
});
}
signers(address: string) {
return this.contract.signers(address);
}
verify_signatures(nonce: string, message: string, signatures: string) {
return this.contract.verify_signatures(nonce, message, signatures);
async verify_signatures(nonce: string, message: string, signatures: string) {
const res = await this.contract.estimateGas.verify_signatures(
nonce,
message,
signatures
);
const gasLimit = calcGasBuffer(res);
return this.contract.verify_signatures(nonce, message, signatures, {
gasLimit,
});
}
}
@@ -1,6 +1,6 @@
import { ethers } from 'ethers';
import abi from '../abis/staking_abi.json';
import { prepend0x } from '../utils';
import { calcGasBuffer, prepend0x } from '../utils';
export class StakingBridge {
public contract: ethers.Contract;
@@ -13,20 +13,41 @@ export class StakingBridge {
this.contract = new ethers.Contract(address, abi, signerOrProvider);
this.address = address;
}
async stake(amount: string, vegaPublicKey: string) {
const key = prepend0x(vegaPublicKey);
const res = await this.contract.estimateGas.stake(amount, key);
const gasLimit = calcGasBuffer(res);
return this.contract.stake(amount, key, {
gasLimit,
});
}
stake(amount: string, vegaPublicKey: string) {
return this.contract.stake(amount, prepend0x(vegaPublicKey));
async remove_stake(amount: string, vegaPublicKey: string) {
const key = prepend0x(vegaPublicKey);
const res = await this.contract.estimateGas.remove_stake(amount, key);
const gasLimit = calcGasBuffer(res);
return this.contract.remove_stake(amount, key, {
gasLimit,
});
}
remove_stake(amount: string, vegaPublicKey: string) {
return this.contract.remove_stake(amount, prepend0x(vegaPublicKey));
}
transfer_stake(amount: string, newAddress: string, vegaPublicKey: string) {
return this.contract.transfer_stake(
async transfer_stake(
amount: string,
newAddress: string,
vegaPublicKey: string
) {
const key = prepend0x(vegaPublicKey);
const res = await this.contract.estimateGas.transfer_stake(
amount,
newAddress,
prepend0x(vegaPublicKey)
key
);
const gasLimit = calcGasBuffer(res);
return this.contract.transfer_stake(amount, newAddress, key, {
gasLimit,
});
}
staking_token() {
return this.contract.staking_token();
}
@@ -1,6 +1,7 @@
import type { BigNumber } from 'ethers';
import { ethers } from 'ethers';
import erc20AbiFaucetable from '../abis/erc20_abi_faucet.json';
import { calcGasBuffer } from '../utils';
export class TokenFaucetable {
public contract: ethers.Contract;
@@ -27,13 +28,17 @@ export class TokenFaucetable {
allowance(owner: string, spender: string): Promise<BigNumber> {
return this.contract.allowance(owner, spender);
}
approve(spender: string, amount: string) {
return this.contract.approve(spender, amount);
async approve(spender: string, amount: string) {
const res = await this.contract.estimateGas.approve(spender, amount);
const gasLimit = calcGasBuffer(res);
return this.contract.approve(spender, amount, { gasLimit });
}
decimals(): Promise<number> {
return this.contract.decimals();
}
faucet() {
return this.contract.faucet();
async faucet() {
const res = await this.contract.estimateGas.faucet();
const gasLimit = calcGasBuffer(res);
return this.contract.faucet({ gasLimit });
}
}
@@ -1,6 +1,6 @@
import { ethers } from 'ethers';
import abi from '../abis/vesting_abi.json';
import { prepend0x } from '../utils';
import { calcGasBuffer, prepend0x } from '../utils';
export class TokenVesting {
public contract: ethers.Contract;
@@ -13,12 +13,21 @@ export class TokenVesting {
this.contract = new ethers.Contract(address, abi, signerOrProvider);
this.address = address;
}
stake_tokens(amount: string, vegaPublicKey: string) {
return this.contract.stake_tokens(amount, prepend0x(vegaPublicKey));
async stake_tokens(amount: string, vegaPublicKey: string) {
const key = prepend0x(vegaPublicKey);
const res = await this.contract.estimateGas.stake_tokens(amount, key);
const gasLimit = calcGasBuffer(res);
return this.contract.stake_tokens(amount, key, {
gasLimit,
});
}
remove_stake(amount: string, vegaPublicKey: string) {
return this.contract.remove_stake(amount, prepend0x(vegaPublicKey));
async remove_stake(amount: string, vegaPublicKey: string) {
const key = prepend0x(vegaPublicKey);
const res = await this.contract.estimateGas.remove_stake(amount, key);
const gasLimit = calcGasBuffer(res);
return this.contract.remove_stake(amount, key, {
gasLimit,
});
}
stake_balance(address: string, vegaPublicKey: string) {
return this.contract.stake_balance(address, prepend0x(vegaPublicKey));
@@ -38,7 +47,13 @@ export class TokenVesting {
user_total_all_tranches(address: string) {
return this.contract.user_total_all_tranches(address);
}
withdraw_from_tranche(trancheId: number) {
return this.contract.withdraw_from_tranche(trancheId);
async withdraw_from_tranche(trancheId: number) {
const res = await this.contract.estimateGas.withdraw_from_tranche(
trancheId
);
const gasLimit = calcGasBuffer(res);
return this.contract.withdraw_from_tranche(trancheId, {
gasLimit,
});
}
}
+6 -3
View File
@@ -1,6 +1,7 @@
import type { BigNumber } from 'ethers';
import { ethers } from 'ethers';
import erc20Abi from '../abis/erc20_abi.json';
import { calcGasBuffer } from '../utils';
export class Token {
public contract: ethers.Contract;
@@ -23,13 +24,15 @@ export class Token {
allowance(owner: string, spender: string): Promise<BigNumber> {
return this.contract.allowance(owner, spender);
}
approve(spender: string, amount: string) {
return this.contract.approve(spender, amount);
async approve(spender: string, amount: string) {
const res = await this.contract.estimateGas.approve(spender, amount);
const gasLimit = calcGasBuffer(res);
return this.contract.approve(spender, amount, { gasLimit });
}
decimals(): Promise<number> {
return this.contract.decimals();
}
faucet() {
async faucet() {
/* No op */
}
}
@@ -0,0 +1,5 @@
import type { BigNumber as EthersBigNumber } from 'ethers';
export function calcGasBuffer(value: EthersBigNumber): EthersBigNumber {
return value.mul(120).div(100);
}
+1
View File
@@ -1 +1,2 @@
export * from './calc-gas-buffer';
export * from './prepend-0x';