Skip to content

Maker DAO examples stub added to deontic logic experiments #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
21 changes: 20 additions & 1 deletion deontic_logic/ct_dts.metta
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,24 @@
(: and1 Eventuality)
(: and2 Eventuality)

(= (NOT_EXIST_stb $x)
(if (== $x (match &self $x $x)) True False)
)

(= (FILTER_stb $p $set $x)
(match &self
(, ($p $set $x)
($p aint-my-set $x))
$x)
)

(= (CONSTRUCT_stb $x $y)
(add-atom &self (match &self $x $y))
)

;Inference rules at the 1st level (the level of the eventualities)

;“not(en, e)” states that en and e are opposite eventualities; e.g., if e refers
;to the fact that “John leaves”, en may refer to the fact that “John does not
;leave”.

!(match )
64 changes: 64 additions & 0 deletions deontic_logic/functional_examples/infer2.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
(:-- True True)

; a way to stop evaluation of what is wrapped in TV
(: TV (-> Atom Atom))
(= (infer-step (TV $x))
(match &self (:-- $x $y) (TV $y)))
; it could possibly be improved:
; it's enough for one of operands to be False (while the second can be empty)
(= (infer (AND $x $y))
(and (infer $x)
(infer $y))

(= (infer (OR $x $y))
(or (infer $x)
(infer $y))

)
(= (infer (NOT-TRUE $x))
; could it be done without case?
(case (infer $x) ; a way to capture empty (unknown) results
((True False)
($_ True)))
)

(= (infer $x)
(case (infer-step (TV $x)) (
((TV True) True)
((TV False) False)
((TV $y) (infer $y))
)
)
)

(= (infer $x)
(case (infer-step (TV $x)) (
((TV True) True)
((TV False) False)
((TV $y) (infer $y))
)
)
)

;a. PE(p)⊢ ¬OB(¬p), via Modus Ponens.
;b. ¬OB(¬p)⊢ PE(p), via Modus Ponens.
;c. OB(¬p)⊢ ¬PE(p), via Modus Tollens.
;d. ¬PE(p)⊢ OB(¬p), via Modus Tollens.

(:-- (pe &p) (NOT-TRUE (ob (NOT-TRUE &p))))

;it is impermissible that (IM)

(:-- (im &p) (ob (NOT-TRUE &p)))

;it is omissible that (OM)

(:-- (om &p) (NOT-TRUE (ob &p)))

;it is optional that (OP)

:-- (op &p) (AND (om &p) (pe &p)))

;it is non-optional that (NO)

(:-- (no &p) (OR (ob &p) (im &p)))
5 changes: 5 additions & 0 deletions deontic_logic/infer.metta
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
)
)

;(Normally) there must be no fence
;But if you do put a fence, it must be white
;By the sea, you can put a fence
;You decide to put a fence

(:-- (Fence fence-001) True)
(:-- (Fence fence-002) True)

Expand Down
Empty file.
34 changes: 34 additions & 0 deletions deontic_logic/maker_atlas_examples/endgame_mip_amendment.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;https://mips.makerdao.com/mips/details/MIP102#MIP102c1
;MIP102c1: Purpose Description
;Amendments
;MIP Amendments that preserve the MIP number can be performed
;to modify any aspect of an existing MIP, including MIP0.
;There are no restrictions on how an existing MIP can be amended.
;
;Multiple amendments to multiple MIPs are allowed to be submitted
;as a single subproposal.
;
;Removals
;MIP102 also enables the removal of one or multiple MIPs
;that are inactive as a part of the Endgame transition.
;
;Multiple MIPs may be removed in a single MIP Removal subproposal.

(= (exist mip1) True)

(= (inactive mip1) True)

(= (preserve_mip_number amendment1 mip1) True)
(= (preserve_mip_number amendment2 mip1) False)

(= (preserve_mip_number amendment3 mip2) True)
(= (preserve_mip_number amendment4 mip2) False)

(= (permissible (modify $amendment $mip))
(and (== (preserve_mip_number $amendment $mip) True) (== (exist $mip) True)))

(= (permissible (remove $mip))
(== (inactive $mip) True))

!(permissible (modify amendment2 mip1))
!(permissible (remove mip2))
39 changes: 39 additions & 0 deletions deontic_logic/maker_atlas_examples/governance_scope.metta
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;https://mips.makerdao.com/mips/details/MIP101#2-the-governance-scope-gov

;2.6.5.1.2
;If FacilitatorDAOs fail to take action against misaligned AD,
;they must be severely penalized.

;Aligned Delegate (AD)
;Aligned Delegates are Anonymous Alignment Conservers that
;use the Protocol Delegation System
;to enable regular MKR holders to easily
;and safely delegate their MKR voting power
;towards implementing the Aligned Governance Strategy of an AVC,
;while earning Governance Participation Rewards in the process.

;2.6.5.1
;If a FacilitatorDAO finds that an AD has performed a misaligned act
;or breached their requirements, they can derecognize the AD
;and confiscate their AD Buffer.
;The AD Buffer can be used as a whistleblower bounty in case
;an ecosystem actor provided useful data, information or evidence
;that led to the derecognition of the AD.
;GOV6 must specify sufficient safety mechanisms around the payment of
;the whistleblower bounty.

(= (Facilitator DAO) True)
(= (misaligned AD1) False)
(= (misaligned AD2) True)

(take-action DAO AD1)

(= (obliged (take-action $dao $ad))
(and (== (Facilitator $dao) True) (== (misaligned $ad) True)))

(= (obliged (be-penalized $dao $ad))
(and (and (== (Facilitator $dao) True) (== (misaligned $ad) True))
(not (== (match &self (take-action $dao $ad) $ad) $ad))))

!(obliged (take-action DAO AD1))
!(obliged (be-penalized DAO AD1))
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;https://mips.makerdao.com/mips/details/MIP101#2-3-scope-bounded-mutable-alignment-artifacts-gov3


;Scope Artifacts are continuously updated.
;Their updates must always be aligned with the specifications of the Atlas.

(= (update scope_artifacts) True)

(= (obliged (align_with_specs $artifacts))
((== (update $artifacts) True) ))
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
;ASC rules
;
;The ASC rules ensure that Stars all participate in
;maintaining the stability and peg of USDS.
;
;# Actively stabilizing collateral (ASC):
;
;ASC is collateral that is actively market making against USDS,
;supporting its peg and bidding at a price of at least 0.999 USD per USDS
;(10bps downside spread).
;
;ASC can be USDC and USDT in the PSM, curve, other stablecoins,
;or crypto assets, as long as it is enforced that they enable
;real time redemption of USDS at at least 0.999 USD per USDS.
;
;ASC can also be offchain as RWA loans to market makers,
;as long as there is clear public real time information about the exposure,
;proving that it is at all times used to provide buy support of at least
;0.999 USD per USDS
;
;If a Star doesn’t maintain at least 20% of its collateral portfolio in ASC,
;it will continuously be penalized at a rate of 200% APY on the missing ASC.
;This penalty is settled monthly at the settlement cycle, and retroactively
;calculated per second.
;
;# Demand Absorption Buffer
;
;Demand Absorption Buffer is a type of ASC consisting of USDS that is
;for sale for at most 1.001 USD per USDS. Every Star must maintain a DAB
;equivalent to 25% of their standard ASC requirement. USDS held by a Star is
;not considered a part of its collateral portfolio for the purposes of
;calculating ASC requirements. DAB requirements can also be fulfilled by
;autonomous systems that generate USDS dynamically through the allocation as
;needed.
;
;# Peg Defense Event
;
;A Peg Defense Event is a situation where the volume weighted average price
;of USDS on SkyLink enabled blockchains falls below 0.999 USD per USDS.
;
;In this situation, all Stars must immediately begin to buy USDS at
;a rate of at least 6.25% of their ASC requirement every 6 hours.
;
;If they fail to fulfill this requirement, a penalty of 20 bps on
;all missing buy volume is applied, calculated in finished blocks of
;6 hours from the Peg Defense Event begins, and settled retroactively at
;the monthly settlement cycle.
;
;Peg Defense can be performed both by selling other types of collateral for
;USDS, or by using USDS, or generating new USDS via the allocation system,
;that is then used as collateral on e.g. aave to borrow USDC or USDT and
;buy USDS with it.
;
;# ALM obligation transfer
;
;The ASC and Peg Defense obligation can be transfered against payment to
;a different Star, through the ALM obligation transfer system.
;Both ASC and Peg Defense responsibilities are transferred together,
;as they are tied together.

(= (asset usdt) 100)
(= (asset usds) 200)
(= (asset usdc) 300)

(= (apy-rate r1) 2)

(= (penalize $asset $rate)
(let $res (/ $asset $rate)
$res)
)

(= (stabilizing_collateral $asset $threshold $rate)
(if(>= $asset $threshold)
(penalize $asset $rate)
False
)
)

(= (volume_weighted_average_price usdt) 1000)

;(bind! acc1 (usdt 100))
;(bind! acc2 (usdt 200))
;(bind! acc3 (usdt 300))
;
;(= (asset s1) (usdt 100))
;(= (asset s2) (usdt 200))
;(= (asset s3) (usdc 100))

(= (star_agent a1) s1)

!(bind! &acc1 (new-state (usdt 100)))

(= (asset s1) &acc1)

!(change-state! &acc1 (usdt 200))

(= (increase_by_quant $num $quant)
(+ $num $quant)
)

(= (buy $agent $quant)
(asset $agent)
)

(= (peg_defense_event $vwap $threshold $agent_list)
(if(>= $vwap $threshold)
(buy $asset )
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
;This account counts as controlling 100% of the circulating token supply for
;governance purposes,
;enabling editing of the spark artifact before creation of the Spark token

(= (preserve_mip_number amendment1 mip1) True)
(= (preserve_mip_number amendment2 mip1) False)

(= (preserve_mip_number amendment3 mip2) True)
(= (preserve_mip_number amendment4 mip2) False)

(= (permissible (modify $amendment $mip))
(and (== (preserve_mip_number $amendment $mip) True) (== (exist $mip) True)))

(= (permissible (remove $mip))
(== (inactive $mip) True))


(bind! &master_acc (new-state (supply percent 100)))

(bind! &enable_editing (new-state (token_emission True)))

(= (obliged (enable_editing $artifacts))
((== (proposal_alignment $artifacts) True) ))
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
!(import! &self spark_artifact_edits)
;!(import! &self token_distribution_obligation)
;!(import! &self token_emissions)

!(import! &self infer2)


! (infer (ob (align_with_atlas prop2)))
Loading