@layerzerolabs/layerzero-v2-ton 3.0.19-ton.0 → 3.0.19-ton.1
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/CHANGELOG.md +6 -0
- package/build/AllStorages.compiled.json +1 -1
- package/build/AllStorages.test.compiled.json +1 -1
- package/build/BaseContract.test.compiled.json +1 -1
- package/build/Channel.compiled.json +1 -1
- package/build/Channel.permissions.test.compiled.json +1 -1
- package/build/ChannelBurn.test.compiled.json +1 -1
- package/build/ChannelCommitPacket.test.compiled.json +1 -1
- package/build/ChannelConfig.test.compiled.json +1 -1
- package/build/ChannelInitialize.test.compiled.json +1 -1
- package/build/ChannelMsglibIntegration.test.compiled.json +1 -1
- package/build/ChannelMsglibSendCallback.test.compiled.json +1 -1
- package/build/ChannelNilify.test.compiled.json +1 -1
- package/build/ChannelReceive.test.compiled.json +1 -1
- package/build/ChannelReceiveCallback.test.compiled.json +1 -1
- package/build/ChannelReceiveView.test.compiled.json +1 -1
- package/build/ChannelSend.test.compiled.json +1 -1
- package/build/Classlib.test.compiled.json +1 -1
- package/build/ComputeDataSizeGas.test.compiled.json +1 -1
- package/build/Connection.compiled.json +1 -1
- package/build/Controller.assertions.test.compiled.json +1 -1
- package/build/Controller.compiled.json +1 -1
- package/build/Controller.permissions.test.compiled.json +1 -1
- package/build/Controller.test.compiled.json +1 -1
- package/build/Counter.compiled.json +1 -1
- package/build/Counter.permissions.test.compiled.json +1 -1
- package/build/Counter.setters.test.compiled.json +1 -1
- package/build/Counter.test.compiled.json +1 -1
- package/build/Dvn.compiled.json +1 -1
- package/build/Dvn.test.compiled.json +1 -1
- package/build/DvnFeeLib.compiled.json +1 -1
- package/build/DvnPermissions.test.compiled.json +1 -1
- package/build/Endpoint.compiled.json +1 -1
- package/build/Endpoint.permissions.test.compiled.json +1 -1
- package/build/Endpoint.test.compiled.json +1 -1
- package/build/EndpointSetEpConfigDefaults.test.compiled.json +1 -1
- package/build/Executor.compiled.json +1 -1
- package/build/Executor.test.compiled.json +1 -1
- package/build/ExecutorFeeLib.compiled.json +1 -1
- package/build/ExecutorPermissions.test.compiled.json +1 -1
- package/build/LzClasses.test.compiled.json +1 -1
- package/build/LzUtil.test.compiled.json +1 -1
- package/build/MsgData.test.compiled.json +1 -1
- package/build/MsglibPacketCodec.test.compiled.json +1 -1
- package/build/PipelinedOutOfOrder.test.compiled.json +1 -1
- package/build/PriceFeedCache.compiled.json +1 -1
- package/build/PriceFeedCache.permissions.test.compiled.json +1 -1
- package/build/PriceFeedCache.test.compiled.json +1 -1
- package/build/Proxy.compiled.json +1 -1
- package/build/Proxy.permissions.test.compiled.json +1 -1
- package/build/Proxy.test.compiled.json +1 -1
- package/build/SmlConnection.compiled.json +1 -1
- package/build/SmlConnection.permissions.test.compiled.json +1 -1
- package/build/SmlConnection.test.compiled.json +1 -1
- package/build/SmlManager.compiled.json +1 -1
- package/build/SmlManager.permissions.test.compiled.json +1 -1
- package/build/SmlManager.test.compiled.json +1 -1
- package/build/Uln.compiled.json +1 -1
- package/build/Uln.test.compiled.json +1 -1
- package/build/UlnConnection.compiled.json +1 -1
- package/build/UlnConnection.test.compiled.json +1 -1
- package/build/UlnConnectionPermissions.test.compiled.json +1 -1
- package/build/UlnManagement.test.compiled.json +1 -1
- package/build/UlnManager.compiled.json +1 -1
- package/build/UlnManager.test.compiled.json +1 -1
- package/build/UlnManagerPermissions.test.compiled.json +1 -1
- package/build/UlnManagerUtil.test.compiled.json +1 -1
- package/build/UlnPermissions.test.compiled.json +1 -1
- package/build/UlnReceiveConfig.test.compiled.json +1 -1
- package/build/UlnSend.test.compiled.json +1 -1
- package/build/UlnSendConfig.test.compiled.json +1 -1
- package/build/UlnSendWithDvnFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWithExecFeeLib.test.compiled.json +1 -1
- package/build/UlnSendWorkerFactory.test.compiled.json +1 -1
- package/build/UlnUtil.test.compiled.json +1 -1
- package/build/WorkerCore.test.compiled.json +1 -1
- package/build/badFeeLib1.test.compiled.json +1 -1
- package/build/badFeeLib10.test.compiled.json +1 -1
- package/build/badFeeLib11.test.compiled.json +1 -1
- package/build/badFeeLib12.test.compiled.json +1 -1
- package/build/badFeeLib2.test.compiled.json +1 -1
- package/build/badFeeLib3.test.compiled.json +1 -1
- package/build/badFeeLib4.test.compiled.json +1 -1
- package/build/badFeeLib5.test.compiled.json +1 -1
- package/build/badFeeLib6.test.compiled.json +1 -1
- package/build/badFeeLib7.test.compiled.json +1 -1
- package/build/badFeeLib8.test.compiled.json +1 -1
- package/build/badFeeLib9.test.compiled.json +1 -1
- package/package.json +5 -5
- package/src/classes/msgdata/LzReceiveStatus.fc +0 -1
- package/src/funC++/actions/call.fc +1 -0
- package/src/funC++/actions/deploy.fc +0 -1
- package/src/funC++/actions/destroy.fc +0 -1
- package/src/funC++/actions/dispatch.fc +0 -1
- package/src/funC++/actions/event.fc +0 -1
- package/src/funC++/actions/payment.fc +0 -1
- package/src/funC++/actions/sendJettons.fc +0 -1
- package/src/funC++/actions/utils.fc +0 -2
- package/src/funC++/baseInterface.fc +0 -2
- package/src/funC++/classlib.fc +0 -36
- package/src/funC++/contractMain.fc +2 -8
- package/src/funC++/dataStructures/DeterministicInsertionCircularQueue.fc +0 -1
- package/src/funC++/dataStructures/PipelinedOutOfOrder.fc +0 -1
- package/src/funC++/handlerCore.fc +2 -6
- package/src/funC++/stringlib.fc +0 -2
- package/src/funC++/testutils.fc +0 -1
- package/src/funC++/txnContext.fc +1 -1
- package/src/funC++/utils.fc +35 -0
- package/src/protocol/channel/callbackOpcodes.fc +10 -0
- package/src/protocol/channel/handler.fc +1032 -0
- package/src/protocol/channel/interface.fc +60 -0
- package/src/protocol/channel/main.fc +39 -0
- package/src/protocol/channel/storage.fc +55 -0
- package/src/protocol/controller/handler.fc +347 -0
- package/src/protocol/controller/interface.fc +25 -0
- package/src/protocol/controller/main.fc +29 -0
- package/src/protocol/controller/storage.fc +31 -0
- package/src/protocol/core/abstract/protocolHandler.fc +110 -0
- package/src/protocol/core/abstract/protocolMain.fc +30 -0
- package/src/protocol/core/baseStorage.fc +1 -2
- package/src/protocol/endpoint/handler.fc +426 -0
- package/src/protocol/endpoint/interface.fc +20 -0
- package/src/protocol/endpoint/main.fc +23 -0
- package/src/protocol/interfaces.fc +4 -0
- package/src/protocol/msglibs/BytesDecoder.fc +135 -0
- package/src/protocol/msglibs/BytesEncoder.fc +150 -0
- package/src/protocol/msglibs/interface.fc +16 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/handler.fc +125 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/interface.fc +3 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/main.fc +19 -0
- package/src/protocol/msglibs/simpleMsglib/smlConnection/storage.fc +20 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/handler.fc +281 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/interface.fc +14 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/main.fc +24 -0
- package/src/protocol/msglibs/simpleMsglib/smlManager/storage.fc +38 -0
- package/src/protocol/msglibs/ultralightnode/callbackOpcodes.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/feeLibInterface.fc +10 -0
- package/src/protocol/msglibs/ultralightnode/feeLibUtils.fc +51 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/Attestation.fc +49 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/DvnFeesPaidEvent.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/ExecutorFeePaidEvent.fc +23 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUln.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnConnection.fc +62 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/InitUlnManager.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/RentRefill.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/SetAdminWorkerAddresses.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/TreasuryFeeBps.fc +16 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnEvents.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnReceiveConfig.fc +249 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSend.fc +27 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnSendConfig.fc +170 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnVerification.fc +21 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibBytecode.fc +16 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibEvents.fc +58 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/UlnWorkerFeelibInfo.fc +56 -0
- package/src/protocol/msglibs/ultralightnode/msgdata/VerificationStatus.fc +18 -0
- package/src/protocol/msglibs/ultralightnode/uln/handler.fc +803 -0
- package/src/protocol/msglibs/ultralightnode/uln/interface.fc +63 -0
- package/src/protocol/msglibs/ultralightnode/uln/main.fc +37 -0
- package/src/protocol/msglibs/ultralightnode/uln/storage.fc +43 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/handler.fc +600 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/interface.fc +36 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/main.fc +32 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/storage.fc +49 -0
- package/src/protocol/msglibs/ultralightnode/ulnConnection/utils.fc +141 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/handler.fc +495 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/interface.fc +59 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/main.fc +40 -0
- package/src/protocol/msglibs/ultralightnode/ulnManager/storage.fc +44 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/common.fc +27 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/handler.fc +80 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/main.fc +4 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/dvnFeeLib/storage.fc +26 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/handler.fc +123 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/main.fc +4 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/executorFeeLib/storage.fc +29 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/main.fc +3 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/main.fc +1 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/priceFeedFeeLib/storage.fc +39 -0
- package/src/protocol/msglibs/ultralightnode/workerFeeLibs/ulnSendWorkerV1.fc +363 -0
- package/src/workers/core/abstract/workerHandler.fc +150 -0
- package/src/workers/core/interface.fc +25 -0
- package/src/workers/core/workerCoreStorage.fc +44 -0
- package/src/workers/dvn/handler.fc +332 -0
- package/src/workers/dvn/interface.fc +25 -0
- package/src/workers/dvn/main.fc +36 -0
- package/src/workers/dvn/storage.fc +27 -0
- package/src/workers/executor/handler.fc +110 -0
- package/src/workers/executor/interface.fc +19 -0
- package/src/workers/executor/main.fc +26 -0
- package/src/workers/executor/storage.fc +19 -0
- package/src/workers/msgdata/ExecuteParams.fc +29 -0
- package/src/workers/msgdata/NativeDrop.fc +16 -0
- package/src/workers/msgdata/ProxyMessage.fc +20 -0
- package/src/workers/msgdata/SetDict.fc +20 -0
- package/src/workers/msgdata/SetQuorum.fc +20 -0
- package/src/workers/msgdata/SignedRequest.fc +18 -0
- package/src/workers/priceFeedCache/handler.fc +114 -0
- package/src/workers/priceFeedCache/interface.fc +4 -0
- package/src/workers/priceFeedCache/main.fc +25 -0
- package/src/workers/priceFeedCache/storage.fc +21 -0
- package/src/workers/proxy/handler.fc +81 -0
- package/src/workers/proxy/interface.fc +11 -0
- package/src/workers/proxy/main.fc +17 -0
- package/src/workers/proxy/storage.fc +21 -0
- package/tests/testMain.fc +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#include "storage.fc";
|
|
2
|
+
|
|
3
|
+
;; Deploy a new ULN (eid-shard)
|
|
4
|
+
;; only-owner
|
|
5
|
+
const int UlnManager::OP::DEPLOY_ULN = "UlnManager::OP::DEPLOY_ULN"c;
|
|
6
|
+
;; Deploy a new connection (oApp path shard)
|
|
7
|
+
;; called by OApp, seeded by SENDER
|
|
8
|
+
const int MsglibManager::OP::DEPLOY_CONNECTION = "MsglibManager::OP::DEPLOY_CONNECTION"c;
|
|
9
|
+
;; Set the default ULN config
|
|
10
|
+
;; only-owner
|
|
11
|
+
const int UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG = "UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG"c;
|
|
12
|
+
|
|
13
|
+
const int UlnManager::OP::SET_DEFAULT_ULN_SEND_CONFIG = "UlnManager::OP::SET_DEFAULT_ULN_SEND_CONFIG"c;
|
|
14
|
+
|
|
15
|
+
const int UlnManager::OP::SET_OAPP_ULN_SEND_CONFIG = "UlnManager::OP::SET_OAPP_ULN_SEND_CONFIG"c;
|
|
16
|
+
|
|
17
|
+
;; Set the connection ULN config
|
|
18
|
+
;; called by OApp, seeded by SENDER
|
|
19
|
+
const int UlnManager::OP::SET_OAPP_ULN_RECEIVE_CONFIG = "UlnManager::OP::SET_OAPP_ULN_RECEIVE_CONFIG"c;
|
|
20
|
+
|
|
21
|
+
;; Note: this is called withdraw treasury fees but really it's just withdraw anything you want
|
|
22
|
+
const int UlnManager::OP::CLAIM_TREASURY_FEES = "UlnManager::OP::CLAIM_TREASURY_FEES"c;
|
|
23
|
+
|
|
24
|
+
;; Register a new approved bytecode
|
|
25
|
+
;; only-owner
|
|
26
|
+
const int UlnManager::OP::REGISTER_WORKER_FEELIB_BYTECODE = "UlnManager::OP::REGISTER_WORKER_FEELIB_INFO"c;
|
|
27
|
+
|
|
28
|
+
;; Add a new worker to the ULN
|
|
29
|
+
;; only-owner
|
|
30
|
+
const int UlnManager::OP::ADD_ULN_WORKER = "UlnManager::OP::ADD_ULN_WORKER"c;
|
|
31
|
+
|
|
32
|
+
;; Set/Remove an admin worker
|
|
33
|
+
;; only-owner
|
|
34
|
+
const int UlnManager::OP::SET_ADMIN_WORKERS = "UlnManager::OP::SET_ADMIN_WORKERS"c;
|
|
35
|
+
const int UlnManager::OP::SET_ULN_TREASURY_FEE_BPS = "UlnManager::OP::SET_ULN_TREASURY_FEE_BPS"c;
|
|
36
|
+
|
|
37
|
+
const int UlnManager::OP::TRANSFER_OWNERSHIP = "UlnManager::OP::TRANSFER_OWNERSHIP"c;
|
|
38
|
+
const int UlnManager::OP::CLAIM_OWNERSHIP = "UlnManager::OP::CLAIM_OWNERSHIP"c;
|
|
39
|
+
|
|
40
|
+
const int UlnManager::ERROR::insufficientBalance = 161;
|
|
41
|
+
const int UlnManager::ERROR::invalidEid = 162;
|
|
42
|
+
const int UlnManager::ERROR::invalidWorkerInfo = 163;
|
|
43
|
+
const int UlnManager::ERROR::workerIsNotAdmin = 164;
|
|
44
|
+
const int UlnManager::ERROR::feelibBytecodesExceeded = 166;
|
|
45
|
+
const int UlnManager::ERROR::invalidPath = 167;
|
|
46
|
+
const int UlnManager::ERROR::invalidAdminWorkerList = 168;
|
|
47
|
+
const int UlnManager::ERROR::onlyTentativeOwner = 169;
|
|
48
|
+
const int UlnManager::ERROR::nullTentativeOwner = 170;
|
|
49
|
+
|
|
50
|
+
const int UlnManager::event::ADMIN_WORKERS_SET = "UlnMgr::event::ADMIN_WORKERS_SET"u;
|
|
51
|
+
const int UlnManager::event::OWNER_SET_TENTATIVE = "UlnMgr::event::OWNER_SET_TNTV"u;
|
|
52
|
+
const int UlnManager::event::OWNER_SET = "UlnMgr::event::OWNER_SET"u;
|
|
53
|
+
|
|
54
|
+
;; each additional cell seems to add about 110 gas
|
|
55
|
+
;; so 7000 cells is about 770,000 gas.
|
|
56
|
+
;; Workers based on the existing base worker each cost about 20-30 cells
|
|
57
|
+
;; so 7000 cells is about 350-500 workers
|
|
58
|
+
const int UlnManager::CONST::MAX_CUMULATIVE_BYTECODE_CELLS = 7000;
|
|
59
|
+
const int UlnManager::CONST::MAX_ADMIN_WORKERS = 256;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include "handler.fc";
|
|
2
|
+
#include "interface.fc";
|
|
3
|
+
|
|
4
|
+
#include "../../interface.fc"; ;; msglib interface
|
|
5
|
+
|
|
6
|
+
#include "../../../core/abstract/protocolMain.fc";
|
|
7
|
+
|
|
8
|
+
tuple _executeOpcode(int op, cell $md) impure inline {
|
|
9
|
+
if (op == UlnManager::OP::DEPLOY_ULN) {
|
|
10
|
+
return deployUln($md);
|
|
11
|
+
} elseif (op == MsglibManager::OP::DEPLOY_CONNECTION) {
|
|
12
|
+
return deployUlnConnection($md);
|
|
13
|
+
} elseif (op == MsglibManager::OP::GET_MSGLIB_INFO) {
|
|
14
|
+
return getMsglibInfo($md);
|
|
15
|
+
} elseif (op == UlnManager::OP::SET_DEFAULT_ULN_SEND_CONFIG) {
|
|
16
|
+
return setDefaultUlnSendConfig($md);
|
|
17
|
+
} elseif (op == UlnManager::OP::SET_DEFAULT_ULN_RECEIVE_CONFIG) {
|
|
18
|
+
return setDefaultUlnReceiveConfig($md);
|
|
19
|
+
} elseif (op == UlnManager::OP::SET_OAPP_ULN_RECEIVE_CONFIG) {
|
|
20
|
+
return setOAppUlnReceiveConfig($md);
|
|
21
|
+
} elseif (op == UlnManager::OP::SET_OAPP_ULN_SEND_CONFIG) {
|
|
22
|
+
return setOAppUlnSendConfig($md);
|
|
23
|
+
} elseif (op == UlnManager::OP::CLAIM_TREASURY_FEES) {
|
|
24
|
+
return claimTreasuryFees($md);
|
|
25
|
+
} elseif (op == UlnManager::OP::ADD_ULN_WORKER) {
|
|
26
|
+
return addWorkerFeelibToUln($md);
|
|
27
|
+
} elseif (op == UlnManager::OP::REGISTER_WORKER_FEELIB_BYTECODE) {
|
|
28
|
+
return registerWorkerFeelibBytecode($md);
|
|
29
|
+
} elseif (op == UlnManager::OP::SET_ADMIN_WORKERS) {
|
|
30
|
+
return setAdminWorkers($md);
|
|
31
|
+
} elseif (op == UlnManager::OP::SET_ULN_TREASURY_FEE_BPS) {
|
|
32
|
+
return setUlnTreasuryFeeBps($md);
|
|
33
|
+
} elseif (op == UlnManager::OP::TRANSFER_OWNERSHIP) {
|
|
34
|
+
return transferOwnership($md);
|
|
35
|
+
} elseif (op == UlnManager::OP::CLAIM_OWNERSHIP) {
|
|
36
|
+
return claimOwnership($md);
|
|
37
|
+
}
|
|
38
|
+
throw(BaseInterface::ERROR::invalidOpcode);
|
|
39
|
+
return null();
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "../../../core/baseStorage.fc";
|
|
2
|
+
|
|
3
|
+
;; 3 years
|
|
4
|
+
const int UlnManager::CONST::minRentSeconds = 3600 * 24 * 365 * 3;
|
|
5
|
+
|
|
6
|
+
const int UlnManager::NAME = "ulnMgr"u;
|
|
7
|
+
|
|
8
|
+
const int UlnManager::baseStorage = 0;
|
|
9
|
+
|
|
10
|
+
;; Bytecodes
|
|
11
|
+
const int UlnManager::ulnCode = 1;
|
|
12
|
+
const int UlnManager::ulnConnectionCode = 2;
|
|
13
|
+
const int UlnManager::controllerAddress = 3;
|
|
14
|
+
const int UlnManager::eid = 4;
|
|
15
|
+
const int UlnManager::endpointCode = 5;
|
|
16
|
+
const int UlnManager::channelCode = 6;
|
|
17
|
+
const int UlnManager::workerFeelibBytecodes = 7;
|
|
18
|
+
const int UlnManager::adminWorkers = 8;
|
|
19
|
+
const int UlnManager::tentativeOwner = 9;
|
|
20
|
+
|
|
21
|
+
;; @owner LayerZero admin EOA
|
|
22
|
+
cell UlnManager::New(
|
|
23
|
+
int owner,
|
|
24
|
+
cell ulnCode,
|
|
25
|
+
cell connectionCode,
|
|
26
|
+
int controllerAddress,
|
|
27
|
+
int eid
|
|
28
|
+
) method_id {
|
|
29
|
+
return cl::declare(
|
|
30
|
+
UlnManager::NAME,
|
|
31
|
+
unsafeTuple([
|
|
32
|
+
[cl::t::objRef, BaseStorage::New(owner)], ;; UlnManager::baseStorage
|
|
33
|
+
[cl::t::cellRef, ulnCode], ;; UlnManager::ulnCode
|
|
34
|
+
[cl::t::cellRef, connectionCode], ;; UlnManager::ulnConnectionCode
|
|
35
|
+
[cl::t::address, controllerAddress], ;; UlnManager::controllerAddress
|
|
36
|
+
[cl::t::uint32, eid], ;; UlnManager::eid
|
|
37
|
+
[cl::t::cellRef, empty_cell()], ;; UlnManager::endpointCode
|
|
38
|
+
[cl::t::cellRef, empty_cell()], ;; UlnManager::channelCode
|
|
39
|
+
[cl::t::dict256, cl::dict256::New()], ;; UlnManager::workerBytecodes
|
|
40
|
+
[cl::t::cellRef, empty_cell()], ;; UlnManager::adminWorkers
|
|
41
|
+
[cl::t::address, NULLADDRESS] ;; UlnManager::tentativeOwner
|
|
42
|
+
])
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#include "priceFeedFeeLib/storage.fc";
|
|
2
|
+
|
|
3
|
+
const int TON::NativeDecimalsRate = 1000000000; ;; TONcoin is 9-decimal
|
|
4
|
+
|
|
5
|
+
int _applyPremiumAndFloor(int feeInTON, int multiplierBps, int floorMarginUSD, int nativePriceUSD) impure inline {
|
|
6
|
+
int feeWithMultiplier = (feeInTON * multiplierBps) / 10000;
|
|
7
|
+
|
|
8
|
+
if (max(floorMarginUSD, nativePriceUSD) <= 0) {
|
|
9
|
+
return feeWithMultiplier;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
int feeWithMargin = ((floorMarginUSD * TON::NativeDecimalsRate) / nativePriceUSD) + feeInTON;
|
|
13
|
+
|
|
14
|
+
return max(feeWithMargin, feeWithMultiplier);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
int _remoteToNanoton(int remoteAmount, int priceRatio) impure inline {
|
|
18
|
+
return (remoteAmount * priceRatio) / PRICE_RATIO_DENOMINATOR;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
int _applyPremiumToValue(int valueInTON, int multiplierBps) impure inline {
|
|
22
|
+
if (valueInTON > 0) {
|
|
23
|
+
return (valueInTON * multiplierBps) / 10000;
|
|
24
|
+
}
|
|
25
|
+
return 0;
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#include "../../../../../classes/msgdata/OptionsV1.fc";
|
|
2
|
+
#include "../../../../../classes/msgdata/OptionsV2.fc";
|
|
3
|
+
|
|
4
|
+
#include "../priceFeedFeeLib/storage.fc";
|
|
5
|
+
#include "../../feeLibInterface.fc";
|
|
6
|
+
#include "../../msgdata/UlnWorkerFeelibInfo.fc";
|
|
7
|
+
|
|
8
|
+
#include "../common.fc";
|
|
9
|
+
#include "storage.fc";
|
|
10
|
+
|
|
11
|
+
const int DvnFeelib::EXECUTE_FIXED_BYTES = 260; ;; encoded: funcSigHash + params -> 4 + (32 * 2)
|
|
12
|
+
const int DvnFeelib::SIGNATURE_RAW_BYTES = 65; ;; not encoded
|
|
13
|
+
const int DvnFeelib::VERIFY_BYTES_ULN = 288;
|
|
14
|
+
|
|
15
|
+
;; just validate options
|
|
16
|
+
() _decodeOption(cell $options) impure inline_ref {
|
|
17
|
+
if (
|
|
18
|
+
(cl::typeof($options) == md::OptionsV1::NAME)
|
|
19
|
+
| (cl::typeof($options) == md::OptionsV2::NAME)
|
|
20
|
+
| cl::isNull($options)
|
|
21
|
+
) {
|
|
22
|
+
return ();
|
|
23
|
+
} else {
|
|
24
|
+
throw(UlnWorkerInterface::ERROR::UNKNOWN_OPTIONS);
|
|
25
|
+
}
|
|
26
|
+
return ();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
() _decodeOptions(cell $extraOptions, cell $enforcedOptions) impure inline_ref {
|
|
30
|
+
_decodeOption($extraOptions);
|
|
31
|
+
_decodeOption($enforcedOptions);
|
|
32
|
+
return ();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
int _getCallDataSize(cell $myStorage) impure inline_ref {
|
|
36
|
+
int quorum = $myStorage.cl::get<uint64>(DvnFeelib::quorum);
|
|
37
|
+
|
|
38
|
+
int totalSignatureBytes = DvnFeelib::SIGNATURE_RAW_BYTES * quorum;
|
|
39
|
+
;; align on 32-byte boundary
|
|
40
|
+
if ((totalSignatureBytes % 32) != 0) {
|
|
41
|
+
totalSignatureBytes += (32 - (totalSignatureBytes % 32));
|
|
42
|
+
}
|
|
43
|
+
return DvnFeelib::EXECUTE_FIXED_BYTES + DvnFeelib::VERIFY_BYTES_ULN + totalSignatureBytes + 32;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
tuple ulnWorker::quote(tuple inputs) method_id {
|
|
48
|
+
cell $myStorage = inputs.cell_at(0);
|
|
49
|
+
cell $priceFeedInfo = inputs.cell_at(1);
|
|
50
|
+
cell $priceFeedStorage = $priceFeedInfo.cl::get<objRef>(UlnWorkerFeelibInfo::workerFeelibStorage);
|
|
51
|
+
;; cell $path = inputs.cell_at(2);
|
|
52
|
+
;; int confirmations = inputs.int_at(3);
|
|
53
|
+
;; int packetBytes = inputs.int_at(4);
|
|
54
|
+
cell $extraOptions = inputs.cell_at(5);
|
|
55
|
+
cell $enforcedOptions = inputs.cell_at(6);
|
|
56
|
+
|
|
57
|
+
_decodeOptions($extraOptions, $enforcedOptions);
|
|
58
|
+
|
|
59
|
+
(
|
|
60
|
+
int priceRatio,
|
|
61
|
+
int gasPriceInUnit,
|
|
62
|
+
int gasPerByte,
|
|
63
|
+
int nativePriceUsd
|
|
64
|
+
) = PriceFeedFeelib::utils::deserializeStorage($priceFeedStorage);
|
|
65
|
+
|
|
66
|
+
int totalGas = $myStorage.cl::get<uint64>(DvnFeelib::gas) + (_getCallDataSize($myStorage) * gasPerByte);
|
|
67
|
+
;; the gas fee in units of remote gas token (e.g., WEI for ETH)
|
|
68
|
+
int gasFeeInUnit = totalGas * gasPriceInUnit;
|
|
69
|
+
|
|
70
|
+
int totalGasFee = _applyPremiumAndFloor(
|
|
71
|
+
_remoteToNanoton(gasFeeInUnit, priceRatio),
|
|
72
|
+
$myStorage.cl::get<uint16>(DvnFeelib::multiplierBps),
|
|
73
|
+
$myStorage.cl::get<coins>(DvnFeelib::floorMarginUSD),
|
|
74
|
+
nativePriceUsd
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return unsafeTuple(
|
|
78
|
+
[totalGasFee, null()]
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#include "../../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
const int DvnFeelib::NAME = "UlnDvnFl"u;
|
|
4
|
+
|
|
5
|
+
;; Bytecodes
|
|
6
|
+
const int DvnFeelib::quorum = 0;
|
|
7
|
+
const int DvnFeelib::gas = 1;
|
|
8
|
+
const int DvnFeelib::multiplierBps = 2;
|
|
9
|
+
const int DvnFeelib::floorMarginUSD = 3; ;; uses priceFeed PRICE_RATIO_DENOMINATOR
|
|
10
|
+
|
|
11
|
+
cell DvnFeelib::New(
|
|
12
|
+
int quorum,
|
|
13
|
+
int gas,
|
|
14
|
+
int multiplierBps,
|
|
15
|
+
int floorMarginUSD
|
|
16
|
+
) method_id {
|
|
17
|
+
return cl::declare(
|
|
18
|
+
DvnFeelib::NAME,
|
|
19
|
+
unsafeTuple([
|
|
20
|
+
[cl::t::uint64, quorum], ;; DvnFeelib::quorum
|
|
21
|
+
[cl::t::uint64, gas], ;; DvnFeelib::gas
|
|
22
|
+
[cl::t::uint16, multiplierBps], ;; DvnFeelib::multiplierBps
|
|
23
|
+
[cl::t::coins, floorMarginUSD] ;; DvnFeelib::floorMarginUSD
|
|
24
|
+
])
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#include "../../../../../classes/msgdata/OptionsV1.fc";
|
|
2
|
+
#include "../../../../../classes/msgdata/OptionsV2.fc";
|
|
3
|
+
|
|
4
|
+
#include "../../feeLibInterface.fc";
|
|
5
|
+
#include "../priceFeedFeeLib/storage.fc";
|
|
6
|
+
#include "../../msgdata/UlnWorkerFeelibInfo.fc";
|
|
7
|
+
|
|
8
|
+
#include "../common.fc";
|
|
9
|
+
#include "storage.fc";
|
|
10
|
+
|
|
11
|
+
(int, int) _decodeOption(int lzReceiveBaseGas, int lzComposeBaseGas, cell $options) impure inline {
|
|
12
|
+
int totalGas = 0;
|
|
13
|
+
int totalDstAmount = 0;
|
|
14
|
+
|
|
15
|
+
if (cl::typeof($options) == md::OptionsV1::NAME) {
|
|
16
|
+
totalGas += lzReceiveBaseGas
|
|
17
|
+
+ $options.cl::get<uint256>(md::OptionsV1::lzReceiveGas);
|
|
18
|
+
|
|
19
|
+
totalDstAmount += $options.cl::get<uint256>(md::OptionsV1::lzReceiveValue)
|
|
20
|
+
+ $options.cl::get<uint256>(md::OptionsV1::nativeDropAmount);
|
|
21
|
+
} elseif (cl::typeof($options) == md::OptionsV2::NAME) {
|
|
22
|
+
int lzComposeGas = $options.cl::get<uint256>(md::OptionsV2::lzComposeGas);
|
|
23
|
+
int lzComposeValue = $options.cl::get<uint256>(md::OptionsV2::lzComposeValue);
|
|
24
|
+
|
|
25
|
+
throw_if(
|
|
26
|
+
UlnWorkerInterface::ERROR::ZERO_LZ_COMPOSE_GAS_PROVIDED,
|
|
27
|
+
(lzComposeGas == 0) & (lzComposeValue > 0)
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
totalGas += lzReceiveBaseGas + $options.cl::get<uint256>(md::OptionsV2::lzReceiveGas);
|
|
31
|
+
|
|
32
|
+
totalDstAmount += $options.cl::get<uint256>(md::OptionsV2::lzReceiveValue)
|
|
33
|
+
+ $options.cl::get<uint256>(md::OptionsV2::nativeDropAmount);
|
|
34
|
+
|
|
35
|
+
if (lzComposeGas > 0) {
|
|
36
|
+
totalGas += lzComposeGas + lzComposeBaseGas;
|
|
37
|
+
totalDstAmount += lzComposeValue;
|
|
38
|
+
}
|
|
39
|
+
} elseif (cl::isNull($options)) {
|
|
40
|
+
return (0, 0);
|
|
41
|
+
} else {
|
|
42
|
+
throw(UlnWorkerInterface::ERROR::UNKNOWN_OPTIONS);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (totalGas, totalDstAmount);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
(int, int) _decodeOptions(
|
|
49
|
+
int lzReceiveBaseGas,
|
|
50
|
+
int lzComposeBaseGas,
|
|
51
|
+
cell $extraOptions,
|
|
52
|
+
cell $enforcedOptions
|
|
53
|
+
) impure inline {
|
|
54
|
+
int totalGas = 0;
|
|
55
|
+
int totalDstAmount = 0;
|
|
56
|
+
|
|
57
|
+
ifnot ($extraOptions.cl::isNull()) {
|
|
58
|
+
(int _totalGas, int _totalDstAmount) = _decodeOption(lzReceiveBaseGas, lzComposeBaseGas, $extraOptions);
|
|
59
|
+
totalGas += _totalGas;
|
|
60
|
+
totalDstAmount += _totalDstAmount;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
ifnot ($enforcedOptions.cl::isNull()) {
|
|
64
|
+
(int _totalGas, int _totalDstAmount) = _decodeOption(lzReceiveBaseGas, lzComposeBaseGas, $enforcedOptions);
|
|
65
|
+
totalGas += _totalGas;
|
|
66
|
+
totalDstAmount += _totalDstAmount;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (totalGas, totalDstAmount);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
;; current gas consumed: 16276
|
|
73
|
+
tuple ulnWorker::quote(tuple inputs) impure method_id {
|
|
74
|
+
cell $myStorage = inputs.cell_at(0);
|
|
75
|
+
cell $priceFeedInfo = inputs.cell_at(1);
|
|
76
|
+
cell $priceFeedStorage = $priceFeedInfo.cl::get<objRef>(UlnWorkerFeelibInfo::workerFeelibStorage);
|
|
77
|
+
;; cell $path = inputs.cell_at(2);
|
|
78
|
+
;; int confirmations = inputs.int_at(3);
|
|
79
|
+
int packetBytes = inputs.int_at(4);
|
|
80
|
+
cell $extraOptions = inputs.cell_at(5);
|
|
81
|
+
cell $enforcedOptions = inputs.cell_at(6);
|
|
82
|
+
|
|
83
|
+
int multiplierBps = $myStorage.cl::get<uint16>(ExecutorFeelib::multiplierBps);
|
|
84
|
+
|
|
85
|
+
(
|
|
86
|
+
int totalRemoteGas,
|
|
87
|
+
int totalRemoteValue
|
|
88
|
+
) = _decodeOptions(
|
|
89
|
+
$myStorage.cl::get<uint64>(ExecutorFeelib::lzReceiveBaseGas),
|
|
90
|
+
$myStorage.cl::get<uint64>(ExecutorFeelib::lzComposeBaseGas),
|
|
91
|
+
$extraOptions,
|
|
92
|
+
$enforcedOptions
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
(
|
|
96
|
+
int priceRatio,
|
|
97
|
+
int gasPriceInUnit,
|
|
98
|
+
int gasPerByte,
|
|
99
|
+
int nativePriceUsd
|
|
100
|
+
) = PriceFeedFeelib::utils::deserializeStorage($priceFeedStorage);
|
|
101
|
+
|
|
102
|
+
;; simple calculation of gas per byte
|
|
103
|
+
int gasForCalldata = packetBytes * gasPerByte;
|
|
104
|
+
|
|
105
|
+
int totalGasFeeInUnit = (totalRemoteGas + gasForCalldata) * gasPriceInUnit;
|
|
106
|
+
|
|
107
|
+
int totalGasFeeInNanoton = _applyPremiumAndFloor(
|
|
108
|
+
_remoteToNanoton(totalGasFeeInUnit, priceRatio),
|
|
109
|
+
multiplierBps,
|
|
110
|
+
$myStorage.cl::get<coins>(ExecutorFeelib::floorMarginUSD),
|
|
111
|
+
nativePriceUsd
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
;; match order of operations of EVM at some loss of precision
|
|
115
|
+
int totalValueFeeInNanoton = _applyPremiumToValue(
|
|
116
|
+
_remoteToNanoton(totalRemoteValue, priceRatio),
|
|
117
|
+
multiplierBps
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
return unsafeTuple(
|
|
121
|
+
[totalGasFeeInNanoton + totalValueFeeInNanoton, null()]
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include "../../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
const int ExecutorFeelib::NAME = "UlnExecutr"u;
|
|
4
|
+
|
|
5
|
+
;; Bytecodes
|
|
6
|
+
const int ExecutorFeelib::lzReceiveBaseGas = 0;
|
|
7
|
+
const int ExecutorFeelib::multiplierBps = 1;
|
|
8
|
+
const int ExecutorFeelib::floorMarginUSD = 2; ;; uses priceFeed PRICE_RATIO_DENOMINATOR
|
|
9
|
+
const int ExecutorFeelib::nativeCap = 3;
|
|
10
|
+
const int ExecutorFeelib::lzComposeBaseGas = 4;
|
|
11
|
+
|
|
12
|
+
cell ExecutorFeelib::New(
|
|
13
|
+
int lzReceiveBaseGas,
|
|
14
|
+
int multiplierBps,
|
|
15
|
+
int floorMarginUSD,
|
|
16
|
+
int nativeCap,
|
|
17
|
+
int lzComposeBaseGas
|
|
18
|
+
) method_id {
|
|
19
|
+
return cl::declare(
|
|
20
|
+
ExecutorFeelib::NAME,
|
|
21
|
+
unsafeTuple([
|
|
22
|
+
[cl::t::uint64, lzReceiveBaseGas], ;; ExecutorFeelib::lzReceiveBaseGas
|
|
23
|
+
[cl::t::uint16, multiplierBps], ;; ExecutorFeelib::multiplierBps
|
|
24
|
+
[cl::t::coins, floorMarginUSD], ;; ExecutorFeelib::floorMarginUSD
|
|
25
|
+
[cl::t::coins, nativeCap], ;; ExecutorFeelib::nativeCap
|
|
26
|
+
[cl::t::uint64, lzComposeBaseGas] ;; ExecutorFeelib::lzComposeBaseGas
|
|
27
|
+
])
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
() main() { }
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#include "../../../../../funC++/classlib.fc";
|
|
2
|
+
|
|
3
|
+
const int PriceFeedFeelib::NAME = "PFFeelib"u;
|
|
4
|
+
|
|
5
|
+
const int PRICE_RATIO_DENOMINATOR = 1000 * 1000 * 1000 * 1000 * 1000 * 1000 * 100;
|
|
6
|
+
|
|
7
|
+
;; Bytecodes
|
|
8
|
+
const int PriceFeedFeelib::priceRatio = 0;
|
|
9
|
+
const int PriceFeedFeelib::gasPriceInUnit = 1;
|
|
10
|
+
const int PriceFeedFeelib::gasPerByte = 2;
|
|
11
|
+
const int PriceFeedFeelib::nativePriceUsd = 3;
|
|
12
|
+
|
|
13
|
+
;; @owner LayerZero admin EOA
|
|
14
|
+
cell PriceFeedFeelib::New(
|
|
15
|
+
int priceRatio,
|
|
16
|
+
int gasPriceInUnit,
|
|
17
|
+
int gasPerByte,
|
|
18
|
+
int nativePriceUsd
|
|
19
|
+
) method_id {
|
|
20
|
+
return cl::declare(
|
|
21
|
+
PriceFeedFeelib::NAME,
|
|
22
|
+
unsafeTuple([
|
|
23
|
+
[cl::t::coins, priceRatio], ;; PriceFeedFeelib::priceRatio
|
|
24
|
+
[cl::t::uint64, gasPriceInUnit], ;; PriceFeedFeelib::gasPriceInUnit
|
|
25
|
+
[cl::t::uint32, gasPerByte], ;; PriceFeedFeelib::gasPerByte
|
|
26
|
+
[cl::t::coins, nativePriceUsd] ;; PriceFeedFeelib::nativePriceUsd
|
|
27
|
+
])
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(int, int, int, int) PriceFeedFeelib::utils::deserializeStorage(cell $storage) inline {
|
|
32
|
+
;; todo: optimize
|
|
33
|
+
return (
|
|
34
|
+
$storage.cl::get<coins>(PriceFeedFeelib::priceRatio),
|
|
35
|
+
$storage.cl::get<uint64>(PriceFeedFeelib::gasPriceInUnit),
|
|
36
|
+
$storage.cl::get<uint32>(PriceFeedFeelib::gasPerByte),
|
|
37
|
+
$storage.cl::get<coins>(PriceFeedFeelib::nativePriceUsd)
|
|
38
|
+
);
|
|
39
|
+
}
|