cosmos-sdk/docs/uml/svg/unbond_sequence.svg

110 lines
22 KiB
XML

<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentScriptType="application/ecmascript" contentStyleType="text/css" height="989px" preserveAspectRatio="none" style="width:1429px;height:989px;" version="1.1" viewBox="0 0 1429 989" width="1429px" zoomAndPan="magnify"><defs><filter height="300%" id="f1harfv0wr5n65" width="300%" x="-1" y="-1"><feGaussianBlur result="blurOut" stdDeviation="2.0"/><feColorMatrix in="blurOut" result="blurOut2" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .4 0"/><feOffset dx="4.0" dy="4.0" in="blurOut2" result="blurOut3"/><feBlend in="SourceGraphic" in2="blurOut3" mode="normal"/></filter></defs><g><text fill="#000000" font-family="sans-serif" font-size="18" lengthAdjust="spacing" textLength="105" x="660.25" y="28.708">Undelegate</text><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="190.5156"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="551.3438" style="stroke:#000000;stroke-width:2.0;" width="1405.5" x="10" y="250.7813"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="317.0469"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="377.3125"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="82.6797" style="stroke:#000000;stroke-width:2.0;" width="619" x="304" y="437.5781"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="132.3359" style="stroke:#000000;stroke-width:2.0;" width="455" x="570.5" y="534.2578"/><rect fill="#FFFFFF" height="86.0703" style="stroke:none;stroke-width:1.0;" width="455" x="570.5" y="580.5234"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="56.2656" style="stroke:#000000;stroke-width:2.0;" width="835" x="570.5" y="738.8594"/><rect fill="#FFFFFF" filter="url(#f1harfv0wr5n65)" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="572" x="570.5" y="816.125"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:5.0,5.0;" x1="77" x2="77" y1="102.25" y2="921.5234"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:5.0,5.0;" x1="615.5" x2="615.5" y1="102.25" y2="921.5234"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:5.0,5.0;" x1="993.5" x2="993.5" y1="102.25" y2="921.5234"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:5.0,5.0;" x1="1078.5" x2="1078.5" y1="102.25" y2="921.5234"/><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="91" x="30" y="66.9531"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="77" x="37" y="86.9482">msgServer</text><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="91" x="30" y="920.5234"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="77" x="37" y="940.5186">msgServer</text><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="66" x="580.5" y="66.9531"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="52" x="587.5" y="86.9482">keeper</text><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="66" x="580.5" y="920.5234"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="52" x="587.5" y="940.5186">keeper</text><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="38" x="971.5" y="98.9482">store</text><path d="M975.5,49.9531 C975.5,39.9531 993.5,39.9531 993.5,39.9531 C993.5,39.9531 1011.5,39.9531 1011.5,49.9531 L1011.5,75.9531 C1011.5,85.9531 993.5,85.9531 993.5,85.9531 C993.5,85.9531 975.5,85.9531 975.5,75.9531 L975.5,49.9531 " fill="#FEFECE" filter="url(#f1harfv0wr5n65)" style="stroke:#000000;stroke-width:1.5;"/><path d="M975.5,49.9531 C975.5,59.9531 993.5,59.9531 993.5,59.9531 C993.5,59.9531 1011.5,59.9531 1011.5,49.9531 " fill="none" style="stroke:#000000;stroke-width:1.5;"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="38" x="971.5" y="933.5186">store</text><path d="M975.5,946.8203 C975.5,936.8203 993.5,936.8203 993.5,936.8203 C993.5,936.8203 1011.5,936.8203 1011.5,946.8203 L1011.5,972.8203 C1011.5,982.8203 993.5,982.8203 993.5,982.8203 C993.5,982.8203 975.5,982.8203 975.5,972.8203 L975.5,946.8203 " fill="#FEFECE" filter="url(#f1harfv0wr5n65)" style="stroke:#000000;stroke-width:1.5;"/><path d="M975.5,946.8203 C975.5,956.8203 993.5,956.8203 993.5,956.8203 C993.5,956.8203 1011.5,956.8203 1011.5,946.8203 " fill="none" style="stroke:#000000;stroke-width:1.5;"/><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="103" x="1025.5" y="66.9531"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="89" x="1032.5" y="86.9482">bankKeeper</text><rect fill="#FEFECE" filter="url(#f1harfv0wr5n65)" height="30.2969" style="stroke:#A80036;stroke-width:1.5;" width="103" x="1025.5" y="920.5234"/><text fill="#000000" font-family="sans-serif" font-size="14" lengthAdjust="spacing" textLength="89" x="1032.5" y="940.5186">bankKeeper</text><polygon fill="#A80036" points="603.5,129.3828,613.5,133.3828,603.5,137.3828,607.5,133.3828" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="77.5" x2="609.5" y1="133.3828" y2="133.3828"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="284" x="84.5" y="128.3169">Undelegate(delAddr, valAddr, tokenAmount)</text><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="657.5" y1="162.5156" y2="162.5156"/><line style="stroke:#A80036;stroke-width:1.0;" x1="657.5" x2="657.5" y1="162.5156" y2="175.5156"/><line style="stroke:#A80036;stroke-width:1.0;" x1="616.5" x2="657.5" y1="175.5156" y2="175.5156"/><polygon fill="#A80036" points="626.5,171.5156,616.5,175.5156,626.5,179.5156,622.5,175.5156" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="364" x="622.5" y="157.4497">calculate number of shares the tokenAmount represents</text><path d="M20,190.5156 L86,190.5156 L86,197.5156 L76,207.5156 L20,207.5156 L20,190.5156 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="190.5156"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="35" y="203.5825">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="100" x="101" y="202.7261">[wrong denom]</text><polygon fill="#A80036" points="88.5,224.7813,78.5,228.7813,88.5,232.7813,84.5,228.7813" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="82.5" x2="614.5" y1="228.7813" y2="228.7813"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="31" x="94.5" y="223.7153">error</text><path d="M10,250.7813 L306,250.7813 L306,257.7813 L296,267.7813 L10,267.7813 L10,250.7813 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="551.3438" style="stroke:#000000;stroke-width:2.0;" width="1405.5" x="10" y="250.7813"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="251" x="25" y="263.8481">Unbond(delAddr, valAddr, shares)</text><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="657.5" y1="289.0469" y2="289.0469"/><line style="stroke:#A80036;stroke-width:1.0;" x1="657.5" x2="657.5" y1="289.0469" y2="302.0469"/><line style="stroke:#A80036;stroke-width:1.0;" x1="616.5" x2="657.5" y1="302.0469" y2="302.0469"/><polygon fill="#A80036" points="626.5,298.0469,616.5,302.0469,626.5,306.0469,622.5,302.0469" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="243" x="622.5" y="283.981">BeforeDelegationSharesModified hook</text><path d="M20,317.0469 L86,317.0469 L86,324.0469 L76,334.0469 L20,334.0469 L20,317.0469 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="317.0469"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="35" y="330.1138">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="137" x="101" y="329.2573">[no such delegation]</text><polygon fill="#A80036" points="88.5,351.3125,78.5,355.3125,88.5,359.3125,84.5,355.3125" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="82.5" x2="614.5" y1="355.3125" y2="355.3125"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="31" x="94.5" y="350.2466">error</text><path d="M20,377.3125 L86,377.3125 L86,384.3125 L76,394.3125 L20,394.3125 L20,377.3125 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="640.5" x="20" y="377.3125"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="35" y="390.3794">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="135" x="101" y="389.5229">[not enough shares]</text><polygon fill="#A80036" points="88.5,411.5781,78.5,415.5781,88.5,419.5781,84.5,415.5781" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="82.5" x2="614.5" y1="415.5781" y2="415.5781"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="31" x="94.5" y="410.5122">error</text><path d="M304,437.5781 L370,437.5781 L370,444.5781 L360,454.5781 L304,454.5781 L304,437.5781 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="82.6797" style="stroke:#000000;stroke-width:2.0;" width="619" x="304" y="437.5781"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="319" y="450.645">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="290" x="385" y="449.7886">[delegator is the operator of the validator</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="225" x="385" y="462.5933">and validator is not already jailed</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="418" x="385" y="475.3979">and unbonding would put self-delegation under min threshold]</text><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="657.5" y1="499.2578" y2="499.2578"/><line style="stroke:#A80036;stroke-width:1.0;" x1="657.5" x2="657.5" y1="499.2578" y2="512.2578"/><line style="stroke:#A80036;stroke-width:1.0;" x1="616.5" x2="657.5" y1="512.2578" y2="512.2578"/><polygon fill="#A80036" points="626.5,508.2578,616.5,512.2578,626.5,516.2578,622.5,512.2578" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="289" x="622.5" y="494.1919">jail the validator, but proceed with unbonding</text><path d="M314,484.625 L314,509.625 L606,509.625 L606,494.625 L596,484.625 L314,484.625 " fill="#FBFB77" filter="url(#f1harfv0wr5n65)" style="stroke:#A80036;stroke-width:1.0;"/><path d="M596,484.625 L596,494.625 L606,494.625 L596,484.625 " fill="#FBFB77" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="271" x="320" y="501.6919">Default min delegation threshold : 1 share</text><path d="M570.5,534.2578 L636.5,534.2578 L636.5,541.2578 L626.5,551.2578 L570.5,551.2578 L570.5,534.2578 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="132.3359" style="stroke:#000000;stroke-width:2.0;" width="455" x="570.5" y="534.2578"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="585.5" y="547.3247">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="280" x="651.5" y="546.4683">[complete unbonding, all shares removed]</text><polygon fill="#A80036" points="981.5,568.5234,991.5,572.5234,981.5,576.5234,985.5,572.5234" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="987.5" y1="572.5234" y2="572.5234"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="164" x="622.5" y="567.4575">remove delegation object</text><line style="stroke:#000000;stroke-width:1.0;stroke-dasharray:2.0,2.0;" x1="570.5" x2="1025.5" y1="581.5234" y2="581.5234"/><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="420" x="575.5" y="591.7339">[there are still shares delegated (not a complete undbonding)]</text><polygon fill="#A80036" points="981.5,612.4609,991.5,616.4609,981.5,620.4609,985.5,616.4609" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="987.5" y1="616.4609" y2="616.4609"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="159" x="622.5" y="611.395">update delegation object</text><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="657.5" y1="645.5938" y2="645.5938"/><line style="stroke:#A80036;stroke-width:1.0;" x1="657.5" x2="657.5" y1="645.5938" y2="658.5938"/><line style="stroke:#A80036;stroke-width:1.0;" x1="616.5" x2="657.5" y1="658.5938" y2="658.5938"/><polygon fill="#A80036" points="626.5,654.5938,616.5,658.5938,626.5,662.5938,622.5,658.5938" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="189" x="622.5" y="640.5278">AfterDelegationModified hook</text><polygon fill="#A80036" points="981.5,690.7266,991.5,694.7266,981.5,698.7266,985.5,694.7266" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="987.5" y1="694.7266" y2="694.7266"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="188" x="622.5" y="689.6606">update validator power index</text><polygon fill="#A80036" points="981.5,719.8594,991.5,723.8594,981.5,727.8594,985.5,723.8594" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="987.5" y1="723.8594" y2="723.8594"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="347" x="622.5" y="718.7935">update validator information (including token amount)</text><path d="M570.5,738.8594 L636.5,738.8594 L636.5,745.8594 L626.5,755.8594 L570.5,755.8594 L570.5,738.8594 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="56.2656" style="stroke:#000000;stroke-width:2.0;" width="835" x="570.5" y="738.8594"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="585.5" y="751.9263">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="393" x="651.5" y="751.0698">[validator status is "unbonded" and it has no more tokens]</text><polygon fill="#A80036" points="981.5,778.125,991.5,782.125,981.5,786.125,985.5,782.125" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="987.5" y1="782.125" y2="782.125"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="125" x="622.5" y="777.0591">delete the validator</text><path d="M998,760.9922 L998,785.9922 L1386,785.9922 L1386,770.9922 L1376,760.9922 L998,760.9922 " fill="#FBFB77" filter="url(#f1harfv0wr5n65)" style="stroke:#A80036;stroke-width:1.0;"/><path d="M1376,760.9922 L1376,770.9922 L1386,770.9922 L1376,760.9922 " fill="#FBFB77" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="367" x="1004" y="778.0591">otherwise, do this in EndBlock once validator is unbonded</text><path d="M570.5,816.125 L636.5,816.125 L636.5,823.125 L626.5,833.125 L570.5,833.125 L570.5,816.125 " fill="#EEEEEE" style="stroke:#000000;stroke-width:1.0;"/><rect fill="none" height="46.2656" style="stroke:#000000;stroke-width:2.0;" width="572" x="570.5" y="816.125"/><text fill="#000000" font-family="sans-serif" font-size="13" font-weight="bold" lengthAdjust="spacing" textLength="21" x="585.5" y="829.1919">alt</text><text fill="#000000" font-family="sans-serif" font-size="11" font-weight="bold" lengthAdjust="spacing" textLength="139" x="651.5" y="828.3354">[validator is bonded]</text><polygon fill="#A80036" points="1067,850.3906,1077,854.3906,1067,858.3906,1071,854.3906" style="stroke:#A80036;stroke-width:1.0;"/><line style="stroke:#A80036;stroke-width:1.0;" x1="615.5" x2="1073" y1="854.3906" y2="854.3906"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="321" x="622.5" y="849.3247">send tokens from bonded pool to not bonded pool</text><line style="stroke:#A80036;stroke-width:1.0;" x1="77.5" x2="119.5" y1="890.5234" y2="890.5234"/><line style="stroke:#A80036;stroke-width:1.0;" x1="119.5" x2="119.5" y1="890.5234" y2="903.5234"/><line style="stroke:#A80036;stroke-width:1.0;" x1="78.5" x2="119.5" y1="903.5234" y2="903.5234"/><polygon fill="#A80036" points="88.5,899.5234,78.5,903.5234,88.5,907.5234,84.5,903.5234" style="stroke:#A80036;stroke-width:1.0;"/><text fill="#000000" font-family="sans-serif" font-size="13" lengthAdjust="spacing" textLength="524" x="84.5" y="885.4575">emit event : EventTypeUnbond(delAddr, valAddr, tokenAmount, completion time)</text><!--MD5=[706374f960862dec8381e9708278a90a]
@startuml
'https://plantuml.com/sequence-diagram
title: Undelegate
msgServer -> keeper : Undelegate(delAddr, valAddr, tokenAmount)
keeper -> keeper : calculate number of shares the tokenAmount represents
alt wrong denom
msgServer <- - keeper : error
end
group Unbond(delAddr, valAddr, shares)
keeper -> keeper: BeforeDelegationSharesModified hook
alt no such delegation
keeper - -> msgServer : error
end
alt not enough shares
keeper - -> msgServer : error
end
alt delegator is the operator of the validator\nand validator is not already jailed\nand unbonding would put self-delegation under min threshold
keeper -> keeper : jail the validator, but proceed with unbonding
note left : Default min delegation threshold : 1 share
end
database store
alt complete unbonding, all shares removed
keeper -> store : remove delegation object
else there are still shares delegated (not a complete undbonding)
keeper -> store : update delegation object
keeper -> keeper : AfterDelegationModified hook
end
keeper -> store : update validator power index
keeper -> store : update validator information (including token amount)
alt validator status is "unbonded" and it has no more tokens
keeper -> store : delete the validator
note right : otherwise, do this in EndBlock once validator is unbonded
end
end
alt validator is bonded
keeper -> bankKeeper : send tokens from bonded pool to not bonded pool
end
msgServer -> msgServer : emit event : EventTypeUnbond(delAddr, valAddr, tokenAmount, completion time)
@enduml
@startuml
title: Undelegate
msgServer -> keeper : Undelegate(delAddr, valAddr, tokenAmount)
keeper -> keeper : calculate number of shares the tokenAmount represents
alt wrong denom
msgServer <- - keeper : error
end
group Unbond(delAddr, valAddr, shares)
keeper -> keeper: BeforeDelegationSharesModified hook
alt no such delegation
keeper - -> msgServer : error
end
alt not enough shares
keeper - -> msgServer : error
end
alt delegator is the operator of the validator\nand validator is not already jailed\nand unbonding would put self-delegation under min threshold
keeper -> keeper : jail the validator, but proceed with unbonding
note left : Default min delegation threshold : 1 share
end
database store
alt complete unbonding, all shares removed
keeper -> store : remove delegation object
else there are still shares delegated (not a complete undbonding)
keeper -> store : update delegation object
keeper -> keeper : AfterDelegationModified hook
end
keeper -> store : update validator power index
keeper -> store : update validator information (including token amount)
alt validator status is "unbonded" and it has no more tokens
keeper -> store : delete the validator
note right : otherwise, do this in EndBlock once validator is unbonded
end
end
alt validator is bonded
keeper -> bankKeeper : send tokens from bonded pool to not bonded pool
end
msgServer -> msgServer : emit event : EventTypeUnbond(delAddr, valAddr, tokenAmount, completion time)
@enduml
PlantUML version 1.2021.5beta3(Unknown compile time)
(GPL source distribution)
Java Runtime: Java(TM) SE Runtime Environment
JVM: Java HotSpot(TM) 64-Bit Server VM
Default Encoding: UTF-8
Language: en
Country: US
--></g></svg>